[R] Mixed model with multinomial distribution

2012-11-01 Thread Liz Deakin
I would like to run a GLMM on categorical data. In this case the response data are abundance of insects of 4 trophic groups. I am unsure whether I need to cbind the categories and run with the model with family=multinomial4 or family=gaussian. Also I'm unsure whether I should use lme4 package or

Re: [R] If loops?

2012-11-01 Thread David Winsemius
On Nov 1, 2012, at 7:18 PM, kebrab67 wrote: > Yes thanks guys the pmin did the trick. Primitif maybe but effective. > > is.primitive(pmin) [1] FALSE David Winsemius, MD Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mail

Re: [R] If loops?

2012-11-01 Thread kebrab67
Yes thanks guys the pmin did the trick. Primitif maybe but effective. On Fri, Nov 2, 2012 at 3:12 AM, David Winsemius [via R] < ml-node+s789695n4648205...@n4.nabble.com> wrote: > > On Nov 1, 2012, at 6:38 PM, arun wrote: > > > Hi, > > > > You can try this also : > > set.seed(132) > > > > dat1<-

Re: [R] If loops?

2012-11-01 Thread David Winsemius
On Nov 1, 2012, at 6:38 PM, arun wrote: > Hi, > > You can try this also : > set.seed(132) > > dat1<-data.frame(Company=rep(LETTERS[1:4],c(3,4,5,6)),Last_year=sample(2005:2012,18,replace=TRUE)) > dat2<-dat1[order(dat1$Company,dat1$Last_year),] > dat2$Last<-ave(dat2$Last_year,dat2$Company,FUN=fu

Re: [R] If loops?

2012-11-01 Thread arun
Hi, You can try this also : set.seed(132)  dat1<-data.frame(Company=rep(LETTERS[1:4],c(3,4,5,6)),Last_year=sample(2005:2012,18,replace=TRUE)) dat2<-dat1[order(dat1$Company,dat1$Last_year),] dat2$Last<-ave(dat2$Last_year,dat2$Company,FUN=function(x) ifelse(x>=2009,2009,x)) head(dat2) #  Company

[R] calculating a gradient in optim without calling a separate function

2012-11-01 Thread dschoenf...@partners.org
It is much more efficient to calculate the value of the log-likelihood and it's gradient at the same time rather than calculating both by separate functions. Is there a way to use optim so that there is one call to a function that calculates both. -- View this message in context: http://r.

Re: [R] If loops?

2012-11-01 Thread David Winsemius
On Nov 1, 2012, at 5:41 PM, kebrab67 wrote: > I have a set of data with 205 988 observation sand 10 variables , three of > which are Legal_status, Date_of_incorporation and . I set my time > horizon from 1989 to 2009. Now I want to know when a company is dead. If > Last_year is bigger or equal t

[R] If loops?

2012-11-01 Thread kebrab67
I have a set of data with 205 988 observation sand 10 variables , three of which are Legal_status, Date_of_incorporation and Last_year. I set my time horizon from 1989 to 2009. Now I want to know when a company is dead. If Last_year is bigger or equal to 2009 then I say that a new "variable" last

Re: [R] Name assignment in for loop

2012-11-01 Thread Bert Gunter
... or let R do all the setup: lmModels <- lapply(seq_len(nrow(dat2)) , FUN = etc. ## the last result is returned as the list component I never declare lists and use for() loops to fill them any more. -- Bert On Thu, Nov 1, 2012 at 2:51 PM, Peter Alspach wrote: > Tena koe Toby > > Try creating

Re: [R] Problem with lm

2012-11-01 Thread William Dunlap
Did you ever show us the call to your function that made it fail on one machine and succeed on two others? In addition, seeing the output of traceback() after the failure and the output of sessionInfo() and conflicts() would help track down the problem. Bill Dunlap Spotfire, TIBCO Software wdun

Re: [R] GraphNEL object retrieve edgenumber from acc() or is it list of lists?

2012-11-01 Thread Martin Morgan
On 11/01/2012 01:23 PM, risclab wrote: Hello everyone, Im working with graphNEL object and want to extract all the nodes which have adjacent nodes with at least 20 nodes in between them. acc(graph, graphnodes) obviously provides a list for the accessable nodes of every node from a node and a nu

Re: [R] Problem with lm

2012-11-01 Thread Eva Prieto Castro
Thanks, Mick and Greg.   Greg, I  have one doubt: taking into account that scope is the cause and that I need to pass a data.frame in the data of the lm, why does it run in some machines?. That point is the one I do not understand.   In any case, I made the change (data.frame) and it will be tes

Re: [R] Select the last rows of when specific conditions are met.

2012-11-01 Thread arun
HI, Instead of splitting, you could also do this: dat1<-read.table(text=" Subj Trial  tt  1  1  1    1  1  2    1  1  3    1  1  4 1  1  5 1  2  1 1  2  2 1  2  3 1 

[R] constrained optimization help please!

2012-11-01 Thread hayduke
Hi All, I am having some real difficulty in trying to carry out constrained optimization. I have had no problems with the Optim() function but when I try to constrain the problem I am getting all sorts of error messages. The model is a simple 2 area, 2 fleet, 1 stock model of a fishery. The code i

Re: [R] What does uniroot return when an error occurs

2012-11-01 Thread William Dunlap
?tryCatch As in: > tryCatch(uniroot( function(x) x^2+1, lower=1, upper=2 )$root, > error=function(e){warning(conditionMessage(e)); NA}) Warning in value[[3L]](cond) : f() values at end points not of opposite sign [1] NA > tryCatch(uniroot( function(x) x^2-1.5, lower=1, upper=2 )$root, > error=

Re: [R] rJava Out of Memory Error

2012-11-01 Thread Martin Studer
Hi Matthew, The problem is that the underlying JVM is running with a fixed maximum heap size. When you load a workbook in XLConnect, an in-memory representation of that workbook is created (in Java by Apache POI). Reading and writing data additionally requires memory due to "communication" of your

[R] What does uniroot return when an error occurs

2012-11-01 Thread asafwe
Hi, I'm using the uniroot function, and would like to detect an error which occurs, for instance, when the values at endpoints are not of opposite signs. For example: uniroot( function(x) x^2+1, lower=1, upper=2 ). I want to say something like: if "error in uniroot(...)" return NA else return u

Re: [R] Reduce(paste, x) question

2012-11-01 Thread arun
HI, Try this: I am not sure about the use of paste() here. To get the output from x:    sapply(x,function(x) x) [,1] [,2] [1,] "A"  "K" [2,] "B"  "L" [3,] "C"  "M" [4,] "D"  "N" [5,] "E"  "O" If you want to get the result from:  res<-Reduce(paste, x)  do.call(rbind,strsplit(res," ")) # 

Re: [R] Select the last rows of when specific conditions are met.

2012-11-01 Thread mardijk
I am so sorry for the lack of clarity. I have a few subjects, every subject has done a number of trials and per trial there is a measurement per millisecond (represented in the variable tt), so every unique trial is represented in around 2500 rows. An example of data would be: Subj | Trial | t

Re: [R] Select the last rows of when specific conditions are met.

2012-11-01 Thread arun
HI, Saw your response in Nabble. Try this: dat1<-read.table(text=" Subj Trial  tt  1  1  1    1  1  2    1  1  3    1  1  4 1  1  5 1  2  1 1  2  2 1  2  3 1  3

Re: [R] Reduce(paste, x) question

2012-11-01 Thread mdvaan
I should have been more specific: y <- list() a <- c("A", "K") b <- c("B", "L") c <- c("C", "M") d <- c("D", "N") e <- c("E", "O") y[[1]] <- a y[[2]] <- b y[[3]] <- c y[[4]] <- d y[[5]] <- e y [[1]] [1] "A" "K" [[2]] [1] "B" "L" [[3]] [1] "C" "M" [[4]] [1] "D" "N" [[5]] [1] "E" "O" How do I

Re: [R] Reduce(paste, x) question

2012-11-01 Thread arun
Hi, This is still a combination.  split(Reduce(cbind,x),1:nrow(Reduce(cbind,x))) #$`1` #[1] "A" "K" # #$`2` #[1] "B" "L" # #$`3` #[1] "C" "M" # #$`4` #[1] "D" "N" # #$`5` #[1] "E" "O" A.K. From: Mathijs de Vaan To: arun Cc: R help Sent: Thursday, Novembe

Re: [R] subset a defined row plus the aforegoing

2012-11-01 Thread arun
HI, May be this also helps:res<- subset(df,type=="Expresssion"|type=="DNase HS") res$indx<-c(0,cumsum(abs(diff(as.integer(res$type=="Expresssion") res1<-with(res,aggregate(dpeak,by=list(indx=indx),tail,1,type=="DNase HS")) res1<-res1[!is.na(res1[,2]),] res2<-res[res$type=="Expresssion"|res[,7]%

Re: [R] Name assignment in for loop

2012-11-01 Thread Peter Alspach
Tena koe Toby Try creating a list and storing each model as an element of the list. For example, lmModels <- vector('list', nrow(dat2)) for (i in 1:nrow(dat2)) { lmModels[[i]] <- etc } Generally, I add a line after creating the list to name the elements and then address the list using these

Re: [R] fitting weibull curve to data using nls

2012-11-01 Thread John.Morrongiello
Thanks very much for identifying this error Michael- of course I don't want to exponentiate an exponential! I had copied the provided formula a little too literally and hadn't done my QA/QCs John -Original Message- From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com] Sent: Thu

Re: [R] How to nicely display R code with the LaTeX package 'listings'?

2012-11-01 Thread Yihui Xie
Hi Marius, I'm not sure if this helps: 1. knitr::spin() can convert a roxygen script to a report, although it has no support to any roxygen @tags, e.g. https://github.com/yihui/knitr/blob/master/inst/examples/knitr-spin.R In your case, you can spin('code.R', format = 'Rnw') 2. knitr does have co

Re: [R] Name assignment in for loop

2012-11-01 Thread David Winsemius
On Nov 1, 2012, at 2:16 PM, nrm2010 wrote: > > > Dear helpeRs- > > I'm using a for loop to create a series of models. > I'm trying to assign a name to each model created, > using the loop index. The loop gets stuck at the name > of the model, giving the error "target of assignment > expan

[R] Name assignment in for loop

2012-11-01 Thread nrm2010
Dear helpeRs- I'm using a for loop to create a series of models. I'm trying to assign a name to each model created, using the loop index. The loop gets stuck at the name of the model, giving the error "target of assignment expands to non-language object". The linear model runs without er

[R] GraphNEL object retrieve edgenumber from acc() or is it list of lists?

2012-11-01 Thread risclab
Hello everyone, Im working with graphNEL object and want to extract all the nodes which have adjacent nodes with at least 20 nodes in between them. acc(graph, graphnodes) obviously provides a list for the accessable nodes of every node from a node and a number of the edges between them. Like th

Re: [R] help with for loop: new column giving count of observation for each SITEID

2012-11-01 Thread Meredith, Christy S -FS
Thanks to you all for your help with this code Basically, the purpose of this was to create a column detailing whether it is the 1st, 2nd, 3rd, etc time that the site was sampled. I need this for creating a graph which shows this new variable on the x axis versus a variable of interest. The var

Re: [R] finding global variables in a function containing formulae

2012-11-01 Thread Bert Gunter
Does ?all.vars ##as in > all.vars(y~x) [1] "y" "x" help? -- Bert On Thu, Nov 1, 2012 at 11:04 AM, Hafen, Ryan P wrote: > I need to find all global variables being used in a function and > findGlobals() in the codetools package works quite nicely. However, I am not > able to find variables t

Re: [R] How to nicely display R code with the LaTeX package 'listings'?

2012-11-01 Thread Roy Mendelssohn
On Nov 1, 2012, at 12:57 PM, Marius Hofert wrote: > So for putting in some lines of code in a > paper, this is quite restrictive (that's why I was hoping for a latex-related > solution -- still asking on r-help since I'd expect R users to have > encountered > this issue before). > > Cheers, >

Re: [R] How to nicely display R code with the LaTeX package 'listings'?

2012-11-01 Thread Marius Hofert
Dear Yihui, Dear Frank, Thanks for helping. I am aware of Sweave and knitr and this is an incredible development. Still, this "machinery" is too heavy for my needs. I typically use pure R scripts for my work (well documented with Roxygen). I can then easily debug and are not disturbed by addition

Re: [R] Reduce(paste, x) question

2012-11-01 Thread Greg Snow
It is not clear exactly what you want. Do you want the final object to be a matrix with 2 columns (or the number of columns equal to the number of items in the list? If so you could just use do.call(cbind, x) and you would not need reduce or paste (paste is the wrong tool unless you want a single

Re: [R] Problem with lm

2012-11-01 Thread Nordlund, Dan (DSHS/RDA)
See comments inline > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Mick Cooney > Sent: Thursday, November 01, 2012 9:23 AM > To: Greg Snow > Cc: r-help@r-project.org; Eva Prieto Castro > Subject: Re: [R] Problem with lm > >

Re: [R] Reduce(paste, x) question

2012-11-01 Thread R. Michael Weylandt
On Thu, Nov 1, 2012 at 6:47 PM, mdvaan wrote: > I have a question about the Reduce function: > > x <- list() > x[[1]] <- LETTERS[1:5] > x[[2]] <- LETTERS[11:15] > Reduce(paste, x) > [1] "A K" "B L" "C M" "D N" "E O" > > How do I get this?: > [1] "A" "K" > [2] "B" "L" > [3] "C" "M" > [4] "D" "N" >

Re: [R] Reduce(paste, x) question

2012-11-01 Thread Sarah Goslee
What is "this"? A matrix with two columns? A data frame? You did an excellent job of providing data to reproduce your attempt so far; thank you. But I'm not sure what you want as result. But maybe one of these two things? > data.frame(x, stringsAsFactors=FALSE) c..ABCDE.. c..K...

Re: [R] Return Vector Component

2012-11-01 Thread arun
HI, By splitting that code into smaller components: res1<-strsplit(v2,"_") # will split the elements into substrings wherever  it matches substring "_".  Result will be a list  head(res1) #[[1]] #[1] "sex" "1"  #[[2]] #[1] "sex" "2"  # [[3]] #[1] "sex" "3"  # #[[4]] #[1] "age"    "height" "

[R] finding global variables in a function containing formulae

2012-11-01 Thread Hafen, Ryan P
I need to find all global variables being used in a function and findGlobals() in the codetools package works quite nicely. However, I am not able to find variables that are used in formulae. Simply avoiding formulae in functions is not an option because I do not have control over what functio

Re: [R] Return Vector Component

2012-11-01 Thread arun
HI, May be this is a bit closer:  res1<-unlist(lapply(strsplit(v2,"_"),function(x) paste(x[1],x[3],x[2],x[4],sep="_")))  v1[1] #[1] "age_1" v2[grep(v1[1],res1)] #[1] "age_height_1_1" "age_height_1_7"  v1[8] #[1] "height_2" v2[grep(v1[8],res1)] #[1] "age_height_2_2" A.K. - Original Messa

[R] Looking for mingw32-make.exe (make.exe not working) in RTools

2012-11-01 Thread Florian Burkart
Hi, I am using premake4 generated make files to compile my projects, which works fine if I am using mingw32-make.exe from the MinGW 32 bit distribution, but doesn't work with the make.exe supplied by the latest RTools 2.16. That make.exe first complains it can't create directories and then that i

[R] Categorical variables using mle2 and slope comparisions

2012-11-01 Thread andmag
I am using the mle2 function to run a simple linear model with a normal distribution. I have one continuous variable (X) and one factor (treatment) with 6 levels. I have seen ANCOVA examples similar to this, but my goal is to compare the differences in the slope parameters (the interaction term) am

[R] Reduce(paste, x) question

2012-11-01 Thread mdvaan
I have a question about the Reduce function: x <- list() x[[1]] <- LETTERS[1:5] x[[2]] <- LETTERS[11:15] Reduce(paste, x) [1] "A K" "B L" "C M" "D N" "E O" How do I get this?: [1] "A" "K" [2] "B" "L" [3] "C" "M" [4] "D" "N" [5] "E" "O" Thanks for your help! -- View this message in context

Re: [R] Problem with lm

2012-11-01 Thread Mick Cooney
But the 'y' is a parameter to the function, so does this mean that the error is occurring when the function is invoked without that parameter? On 1 November 2012 16:02, Greg Snow <538...@gmail.com> wrote: > Yes, it is most likely due to scoping. It is safest to create a data > frame with all the

Re: [R] Java Exception error while reading large data in R from DB using RJDBC.

2012-11-01 Thread Hasan Diwan
On 1 November 2012 11:47, Hasan Diwan wrote: > Sir, > > On 30 October 2012 04:32, aajit75 wrote: >> >> Please suggest where am i going wrong or alternate option to solve such >> issues while reading large DB table. >> > > You might consider setting the fetch size. I haven't used RJDBC in a few

Re: [R] Java Exception error while reading large data in R from DB using RJDBC.

2012-11-01 Thread Hasan Diwan
Sir, On 30 October 2012 04:32, aajit75 wrote: > > Please suggest where am i going wrong or alternate option to solve such > issues while reading large DB table. > You might consider setting the fetch size. I haven't used RJDBC in a few months, but hopefully, the hints on http://www.rforge.net/

Re: [R] How to nicely display R code with the LaTeX package 'listings'?

2012-11-01 Thread Yihui Xie
Or see https://github.com/yihui/knitr-examples/blob/master/015-listings.Rnw for a minimal example. Regards, Yihui -- Yihui Xie Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Thu, Nov 1, 2012 at 1:23 PM, Frank Harrell w

Re: [R] How to nicely display R code with the LaTeX package 'listings'?

2012-11-01 Thread Frank Harrell
The knitr package makes this relatively easy to do. See for example http://biostat.mc.vanderbilt.edu/KnitrHowto Frank Marius Hofert-3 wrote > Dear expeRts, > > What's a 'good' (nice-looking, easy-to-read) setup for the LaTeX package > 'listings' to display R code? > > The two versions below a

Re: [R] SEM validation: Cross-Validation vs. Bootstrapping

2012-11-01 Thread Joshua Wiley
Hi Paul, So you have described bootstrapping in SEM, but that does not address the cross-validation. See inline. On Thu, Nov 1, 2012 at 10:24 AM, Paul Miller wrote: > Hello All, > > Recently, I was asked to help out with an SEM cross-validation analysis. > Initially, the project was based on "

Re: [R] subset a defined row plus the aforegoing

2012-11-01 Thread arun
Hello, A bit confusing: " I would like to extract all rows (so called* defined row*s) with type==Expression - subset (df, type==Expression) - and the aforegoing type==DNase HS (which is not necessarly row n-1 - assumung that the defined row is n" In the dataset, there is "Expresssion" for column

Re: [R] Java Exception error while reading large data in R from DB using RJDBC.

2012-11-01 Thread Jessica Streicher
Actually forget that loop, that was old code. Now remember i had to actually split the one query down into several queries to get everything. On 01.11.2012, at 18:38, Jessica Streicher wrote: > I didn't have the same exception yet, but please make sure you have a stable > connection (avoid wlan

Re: [R] subset a defined row plus the aforegoing

2012-11-01 Thread Peter Langfelder
On Thu, Nov 1, 2012 at 10:28 AM, Hermann Norpois wrote: > Hello, > > my data is sorted by start.ens (see below). And now I would like to extract > all rows (so called* defined row*s) with type==Expression - subset (df, > type==Expression) - and the aforegoing type==DNase HS (which is not > necessa

Re: [R] Java Exception error while reading large data in R from DB using RJDBC.

2012-11-01 Thread Jessica Streicher
I didn't have the same exception yet, but please make sure you have a stable connection (avoid wlan). I personally ran out of memory very often and had to make several queries, combining the results in R instead. This is probably not the best thing to do, but worked for me to fetch large amount

[R] subset a defined row plus the aforegoing

2012-11-01 Thread Hermann Norpois
Hello, my data is sorted by start.ens (see below). And now I would like to extract all rows (so called* defined row*s) with type==Expression - subset (df, type==Expression) - and the aforegoing type==DNase HS (which is not necessarly row n-1 - assumung that the defined row is n). I dont know how t

[R] SEM validation: Cross-Validation vs. Bootstrapping

2012-11-01 Thread Paul Miller
Hello All, Recently, I was asked to help out with an SEM cross-validation analysis. Initially, the project was based on "sample-splitting" where half of cases were randomly assigned to a training sample and half to a testing sample. Attempts to replicate a model developed in the training sample

Re: [R] Select the last rows of when specific conditions are met.

2012-11-01 Thread Jessica Streicher
I really don't understand what you want to achieve and how your data presents itself. You have several combinations of trial/subject which are unique? There is a variable for each such combination that you want to test against (tt)? In addition you have data on each such combination (several set

Re: [R] Problem with lm

2012-11-01 Thread Greg Snow
This error can still occur even if something is passed as the y parameter to the function. There are several things that can complicate the process (and I don't remember exactly which one causes the problem in this case). Here are a couple: In the original function, y is a parameter, but it is n

[R] (no subject)

2012-11-01 Thread Dan Murphy
Dear Claudia: Your question has many layers. Technically speaking, when I do "2011-05-01 CEST" -"2011-04-01 CEST" I get: > "2011-05-01 CEST" -"2011-04-01 CEST" Error in "2011-05-01 CEST" - "2011-04-01 CEST" : non-numeric argument to binary operator As previous posters suggest, storing the dat

Re: [R] Problem with lm

2012-11-01 Thread Greg Snow
Yes, it is most likely due to scoping. It is safest to create a data frame with all the data in it, then pass that to the data argument of lm. On Thu, Nov 1, 2012 at 2:25 AM, Eva Prieto Castro wrote: > Hi, > > I have a problem in relation with a packahe I made. It runs on my machine > (Windows,

[R] Select the last rows of when specific conditions are met.

2012-11-01 Thread mardijk
Hello, As I am new with R I am completely stuck in resolving a, no doubt, easy problem. I have a dataset with an enormous amount of rows and 17 columns. I need to know per trial and subject number if another variable (tt) exceeds a maximum. If this is true than the last 5000 rows of that specific

Re: [R] Data set BregFix in package flexmix

2012-11-01 Thread Uwe Ligges
On 30.10.2012 15:59, tudor wrote: Dear list: I would like to recreate how the artificial data set BregFix was generated in package flexmix (thanks Bettina and Friedrich). The data set is thoroughly described in Grun and Leisch's Computational Statistics & Data Analysis 51(11) :5247-5252 but r

Re: [R] Loop over several variables

2012-11-01 Thread bchr
Oh hey Jan, sorry, I just saw I did not read correctly and mistook your quote of Don's mail as a signature. So thank's to you for the second posting Bernhard -- View this message in context: http://r.789695.n4.nabble.com/Loop-over-several-variables-tp4648112p4648132.html Sent from the R help

Re: [R] Loop over several variables

2012-11-01 Thread bchr
Hey Don, I just saw your second post ... that's even better! Thanks again Bernhard -- View this message in context: http://r.789695.n4.nabble.com/Loop-over-several-variables-tp4648112p4648131.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] Loop over several variables

2012-11-01 Thread bchr
Hey Don, many thanks, I tried that and it works just fine. I have two questions though: 1. In Addition to generating the t1-t5 (I have five iterations, in fact), the code will generate an additional ti(without subscript), which seems to be a copy of ti5. Is that what it should do ( and if yes, wh

Re: [R] Loop over several variables

2012-11-01 Thread Jan van der Laan
Or ti <- aggregate(dataframename[paste0("y", 1:3)], by=dataframename["aggregationvar"], sum,na.rm=TRUE) which gives you all results in one data.frame. Jan "MacQueen, Don" schreef: Many ways. Here is one: ### supposing you have y1, y2, and y3 in your data frame for (i in

Re: [R] Return Vector Component

2012-11-01 Thread frespider
Hi A.K. Thank you so much for replying this could work but the problem you recreate the newv1, to match v2 but I don't want to do that. I just want to check if v2 has that component from v1 THanks Date: Thu, 1 Nov 2012 06:32:03 -0700 From: ml-node+s789695n4648123...@n4.nabble.com To: frespi

Re: [R] help - extract data using column names

2012-11-01 Thread alex_123
Thanks a lot!!! -- View this message in context: http://r.789695.n4.nabble.com/help-extract-data-using-column-names-tp4647869p4648125.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz

Re: [R] Return Vector Component

2012-11-01 Thread arun
Hi, Not sure whether I understand it correctly. v1 <- c("age_1","age_2","age_3","age_4","age_5","age_6","height_1","height_2","height_3","height_4","height_5","height_6","height_7","height_8") v2 <- c("sex_1","sex_2","sex_3","age_height_1_1","age_height_2_2","age_height_3_3","age_height_4_4"

Re: [R] Loop over several variables

2012-11-01 Thread MacQueen, Don
Many ways. Here is one: ### supposing you have y1, y2, and y3 in your data frame for (i in 1:3) { yi <- paste('y',i,sep='') ti <- aggregate(dataframename[[yi]], by=data.frame(dataframename$aggregationvar), sum,na.rm=TRUE) assign( paste('ti',i,sep='') , ti, '.GlobalE

[R] Return Vector Component

2012-11-01 Thread frespider
Hi, I am new R user and I am still learn this fabulous software. I am stuck on this part. I need to check 2 character vectors v1 <- c("age_1","age_2","age_3","age_4","age_5","age_6","height_1","height_2","height_3","height_4","height_5","height_6","height_7","height_8") and v2 <- c("sex_1","s

Re: [R] boxplots of various levels

2012-11-01 Thread John Kane
Ah nice. I clearly misunderstood and thought that facet_wrap() made sense. John Kane Kingston ON Canada > -Original Message- > From: ruipbarra...@sapo.pt > Sent: Wed, 31 Oct 2012 19:45:33 + > To: dysonspher...@gmail.com > Subject: Re: [R] boxplots of various levels > > Hello, >

Re: [R] Subsetting year range

2012-11-01 Thread arun
HI, Without an example dataset, it is a bit difficult to test.  Just a comment about your code: " TableAP <- cbind(zoo(TableAP), Lagpolity4AP1, Lagpolity4AP2, Lagpolity4AP3, Lagpolity4AP4, Lagpolity4AP5, LaglrgdpchAP1, LaglrgdpchAP2, LaglrgdpchAP3, LaglrgdpchAP4, LaglrgdpchAP5) TableAP <- data

[R] Loop over several variables

2012-11-01 Thread bchr
Hey everybody, I am looking for a way to loop commands over several variables in a dataframe. Basically I want to do something like this: ti1<-aggregate(dataframename$y1, by=data.frame(dataframename$aggregationvar), sum,na.rm=TRUE) This works fine as it is but i wan

Re: [R] Subsetting year range

2012-11-01 Thread John Kane
TableAPS1 <- subset(TableAP, year >= 1959) ?? John Kane Kingston ON Canada > -Original Message- > From: iamsta...@gmail.com > Sent: Wed, 31 Oct 2012 20:19:46 -0700 (PDT) > To: r-help@r-project.org > Subject: [R] Subsetting year range > > Hi, > > I have a panel data set that I am tryin

Re: [R] convert list without same component length to matrix

2012-11-01 Thread arun
Hi, Just to add: Infact, there is a small difference in both the approaches. For e.g when tested with your data sapply(l,`[`,1:4) # [,1] [,2] [,3] [,4] [,5] #[1,]  1.0    3    4    2    3 #[2,]  2.0    4    2    4    5 #[3,]  3.7    5    5    6    7 #[4,]   NA    6    7    3    2  sapply(l,hea

Re: [R] convert list without same component length to matrix

2012-11-01 Thread arun
Hi, You can also use: sapply(l,`[`,1:4) # [,1] [,2] [,3] [,4] [,5] #[1,]    1    3    4    2    3 #[2,]    2    4    2    4    5 #[3,]    3    5    5    6    7 #[4,]    7    6    7    3    2 A.K. - Original Message - From: D. Rizopoulos To: Al Ehan Cc: "r-help@r-project.org" Sen

[R] oblique.tree : the predict function asserts the dependent variable to be included in "newdata"

2012-11-01 Thread Yuliya Matveyeva
Dear R community, I have recently discovered the package oblique.tree and I must admit that it was a nice surprise for me, since I have actually made my own version of a kind of a classifier which uses the idea of oblique splits (splits by means of hyperplanes). So I am now interested in comparing

Re: [R] How to parse xml with same key name ?

2012-11-01 Thread Mikko Korpela
On 01.11.2012 06:29, Manish Gupta wrote: > HI, > > I need to parse an xml where key name are same but values are different. > > > > Some dummy text > > one > two > three > > > When i use xmlGetAttr() function i always get one as value. How can i g

[R] How to nicely display R code with the LaTeX package 'listings'?

2012-11-01 Thread Marius Hofert
Dear expeRts, What's a 'good' (nice-looking, easy-to-read) setup for the LaTeX package 'listings' to display R code? The two versions below are partly inspired by the settings of the package SweaveListingUtils and http://r.789695.n4.nabble.com/R-How-to-format-R-code-in-LaTex-documents-td816055.ht

Re: [R] Problem with lm

2012-11-01 Thread Jorge I Velez
Eva, What do you get when you type ls() on the machine that the code does not run? It could be that "y" is not in that particular workspace. HTH, Jorge.- On Thu, Nov 1, 2012 at 7:25 PM, Eva Prieto Castro <> wrote: > Hi, > > I have a problem in relation with a packahe I made. It runs on my machi

Re: [R] Cannot rescale a constant/zero column error.

2012-11-01 Thread Jim Lemon
On 10/31/2012 11:47 PM, fillay89 wrote: I am trying to run the R Script below, I have actually simplified it to just this part that is causing issues. When I run this script I continue to get an error that says "cannot rescale a constant/zero column to a unit variance". I cannot figure out what

Re: [R] convert list without same component length to matrix

2012-11-01 Thread Al Ehan
Thanks a lot! best On Thu, Nov 1, 2012 at 8:19 AM, D. Rizopoulos wrote: > try this: > > l <- list(c(1,2,3,7), c(3,4,5,6,3), c(4,2,5,7), c(2,4,6,3,2), c(3,5,7,2)) > > sapply(l, head, 4) > > > I hope it helps. > > Best, > Dimitris > > > On 11/1/2012 9:11 AM, Al Ehan wrote: > > Hi, > > > > I have t

[R] Problem with lm

2012-11-01 Thread Eva Prieto Castro
Hi, I have a problem in relation with a packahe I made. It runs on my machine (Windows, where I made the package), and it runs in a Mac machine, but it does not run in another Mac machine with the same R version. The part of the code is giving problems: singleCosinor <- function(t, y, period=2

Re: [R] convert list without same component length to matrix

2012-11-01 Thread D. Rizopoulos
try this: l <- list(c(1,2,3,7), c(3,4,5,6,3), c(4,2,5,7), c(2,4,6,3,2), c(3,5,7,2)) sapply(l, head, 4) I hope it helps. Best, Dimitris On 11/1/2012 9:11 AM, Al Ehan wrote: > Hi, > > I have this lame question. I want to convert a list (each with varies in > length) to matrix with same row len

[R] Start R from bash/bat file and end in interactive mode

2012-11-01 Thread Jan van der Laan
I have a r-script (rook.R) that starts a Rook server. To present users from having to start R and type in source("rook.R"), I want to create a bash script and bat file that starts R and sources the script. However, to keep the Rook server running R should not close after running the scrip

[R] convert list without same component length to matrix

2012-11-01 Thread Al Ehan
Hi, I have this lame question. I want to convert a list (each with varies in length) to matrix with same row length by eliminating vectors outside the needed range. For example: l<-list(NULL) l[[1]]=1,2,3.7 l[[2]]=3,4,5,6,3 l[[3]]=4,2,5,7 l[[4]]=2,4,6,3,2 l[[5]]=3,5,7,2 #so say I want to only h

Re: [R] Strange compiling behaviour

2012-11-01 Thread R. Michael Weylandt
On Wed, Oct 31, 2012 at 9:14 PM, Worik R wrote: > Compiling this little function gets me some strange behaviour > > .initDataDir <- function(){ > if(file.exists(LOCATION)) { > if(as.logical(file.info(LOCATION)["isdir"]))return > stop(LOCATION, " exists but is not a directory") > } >

Re: [R] fitting weibull curve to data using nls

2012-11-01 Thread R. Michael Weylandt
On Thu, Nov 1, 2012 at 2:44 AM, wrote: > Hi > I'd like to fit an asymmetrical curve function to some physiological data. > I've been told a weibull curve is a good place to start, but I'm having > trouble specifying and fitting the function with nls and was wondering if > someone could help. >