Re: [R] duplicate rows in a matrix
... but you may not want the rows re-ordered. Here is a possible modification that uses a similar idea: m <- matrix(1:(2*nrow(A)), ncol = 2, byrow = TRUE) AA <- rbind(A, A)[order(m), ] Bill Venables -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Juan Manuel Barreneche Sent: Saturday, 3 November 2007 2:34 AM To: Silvia Lipski; r-help list Subject: Re: [R] duplicate rows in a matrix My sugestion (for an alphabetically ordered output) AA <- rbind(A,A) AA <- AA[order(AA[,1]), ] ## so your matrix gets alphabetically ordered JM On Fri, 2007-11-02 at 09:04 -0700, Silvia Lipski wrote: > Hi! > > Is there a fast way to duplicate rows in a matrix? > I would like to do the following: > > change a matrix A like: > [,1] [,2] > [1,] Kevin 1 > [2,] Alf 2 > > into : > [,1] [,2] > [1,] Kevin 1 > [2,] Kevin 1 > [3,] Alf 2 > [4,] Alf 2 > > i.e. double all rows. The only way I could think off > was: rbind(A[1,],A[1,],A[2,],A[2,]) - which is really > impractible, of course. > > Can anyone help, please? > Thank you, > Silvia > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] GLS with nlme
Janmaat, John wrote: > > Hello All, > > This is my third time attempting to post this message. I don't see it > in the archive, so I'm guessing it is not getting through. If I am > wrong, my apologies. > > I am trying to do a GLS regression, (X'V^-1X)^-1X'V^-1y, using the gls() > function from the nlme package. I have the covariance matrix V. I have > been searching for a way to specify the correlation structure using V, > and have had little luck. I have found a few other messages from people > who have had the same problem. Is there a way to do this? If it > requires building my own corStruct, where can I look for information to > do this? > > Thanks, > > John. > > -- > Don't know if it came through or not before, and not sure of the answer, but just to give you _an_ answer -- if the answer isn't in Pinheiro and Bates (2000), then you'll probably have to dig through the code (which is scary). Ben Bolker -- View this message in context: http://www.nabble.com/GLS-with-nlme-tf4737987.html#a13558299 Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [OT] vista question
Try runas /? On Nov 2, 2007 4:05 PM, Edna Bell <[EMAIL PROTECTED]> wrote: > This is way off topic, but I'll try: > > On a windows vista machine, how can you run commands from the command > prompt as administrator, please? > > tia > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to see source code of nnet package
It is one of the packages in the "VR" bundle. You will find the sources in the source version of the bundle. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dajie Luo Sent: Saturday, 3 November 2007 12:16 AM To: [EMAIL PROTECTED] Subject: [R] How to see source code of nnet package Hi, I am working on a project which needs a multinomial logit regression. So I want to reference the code of multinom in nnet package. I found nnet package is no longer in the CRAN list. But I cannot find the source code in R Core source code package either. Anyone knows how to see the source code of nnet? Luo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] writing a categorical var. with condition
On 02-Nov-07 21:02:57, sigalit mangut-leiba wrote: > Hello, > I want to create a new variable which includes 4 age categories > in this way: > if (age>=12 && age<32) age1==1 > if (age>=32 && age<52) age1==2 > if (age>=52 && age<72) age1==3 > if (age>=72 && age<100) age1==4 > > but I get the results only for the first observation. > > how can I apply this condition to all observations? If A is a vector of ages, one way to do it would be age1 <- 1*(A>=12)&(A<32) + 2*(A>=32)&(A<52) + 3*(A>=52)&(A<72) + 4*(A>=72)&(A<100) Best wishes, Ted. E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 02-Nov-07 Time: 22:33:48 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R timeDate does not allow seconds?
This is what your example had in it. You can format the data in any format that you want. This is nothing special about ':'. On 11/2/07, B. Bogart <[EMAIL PROTECTED]> wrote: > Hi Jim, > > Yes that works!!! > > Why the heck do I need to put "%H.%M.%S" when the input format is > "%H:%M:%S" ? ("." in place of ":". > > I see in the help(timeDate) examples where the format is properly > written as "%Y-%m-%d %H:%M:%S" > > So why does this not work: > > > date = timeDate(as.character(inputdate),format="%Y-%m-%d_%H:%M:%S") > Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : >missing value where TRUE/FALSE needed > > Thanks so much, I don't see how I could have known I would have to put > "." in place of ":" in the format string. > > B. Bogart > Simon Fraser University > > jim holtman wrote: > > Seems to work fine with this call: > > > > > >> inputdate = "2007-10-31_16.20.22" > >> timeDate(as.character(inputdate),format="%Y-%m-%d_%H.%M.%S") > >> > > GMT > > [1] [2007-10-31 16:20:22] > > > > > > > > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R timeDate does not allow seconds?
Hi Jim, Yes that works!!! Why the heck do I need to put "%H.%M.%S" when the input format is "%H:%M:%S" ? ("." in place of ":". I see in the help(timeDate) examples where the format is properly written as "%Y-%m-%d %H:%M:%S" So why does this not work: > date = timeDate(as.character(inputdate),format="%Y-%m-%d_%H:%M:%S") Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : missing value where TRUE/FALSE needed Thanks so much, I don't see how I could have known I would have to put "." in place of ":" in the format string. B. Bogart Simon Fraser University jim holtman wrote: > Seems to work fine with this call: > > >> inputdate = "2007-10-31_16.20.22" >> timeDate(as.character(inputdate),format="%Y-%m-%d_%H.%M.%S") >> > GMT > [1] [2007-10-31 16:20:22] > > > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] when deleting a row from a matrix gives a vector
On Fri, 2 Nov 2007, Gabriel Valiente wrote: > Is there any way to force the result to remain a matrix, even if it > has only one row or column, or even only one entry? Thanks, > Yes. See the FAQ entry or the help page. -thomas Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R timeDate does not allow seconds?
Seems to work fine with this call: > inputdate = "2007-10-31_16.20.22" > timeDate(as.character(inputdate),format="%Y-%m-%d_%H.%M.%S") GMT [1] [2007-10-31 16:20:22] > On 11/2/07, B. Bogart <[EMAIL PROTECTED]> wrote: > Hello all, Sorry if anyone gets this message twice, as my mailserver may > not be working. > > Thanks for your response. Your idea makes a lot of sense to me, but I've > been unable to get seconds to work. > > I ended up with this format finally: > > "2007-10-31_16:20:22" > > Problem is I am unable to get it recognized as a date using timeDate(): > > R> > timeDate(as.character(inputdate),format="%Y-%02m-%02d_%02H.%02M.%02S") > Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : >missing value where TRUE/FALSE needed > > The R-help archives said something about non-standard formats casuing a > problem, but I believe (short of the underscore) that its the seconds, > not the delimiter that is causing the trouble. > > I've also been playing with zoo and its functions without much success > either. The timeDate approach seems simplest. > > With so many date classes/methods in R, what is considered the standard > way of dealing with it? I need to timezone or daylight saving stuff > really, but seconds are imperative! (actually I've ended up with > multiple events per second, which could cause future troubles, so msec > may even be needed. > > Thanks, > B. Bogart > > Following are all my attempts to get R to read seconds (with timeDate): > > > > data[1,1] -> inputdate > > inputdate > [1] "2007-10-31_16:20:22" > > inputdate = "2007-10-31_16.20.22" > > timeDate(as.character(inputdate),format="%Y-%02m-%02d_%02H.%02M.%02S") > Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : >missing value where TRUE/FALSE needed > > inputdate = "2007-10-31_16-20-22" > > timeDate(as.character(inputdate),format="%Y-%02m-%02d_%02H-%02M-%02S") > Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : >missing value where TRUE/FALSE needed > > inputdate = "16:20:22_2007-10-31" > > timeDate(as.character(inputdate),format="%02H:%02M:%02S_%Y-%02m-%02d") > Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : >missing value where TRUE/FALSE needed > > inputdate = "16-20-22_2007-10-31" > > timeDate(as.character(inputdate),format="%02H-%02M-%02S_%Y-%02m-%02d") > Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : >missing value where TRUE/FALSE needed > > inputdate = "16.20.22_2007-10-31" > > timeDate(as.character(inputdate),format="%02H.%02M.%02S_%Y-%02m-%02d") > Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : >missing value where TRUE/FALSE needed > > inputdate = "16/20/22 2007/10/31" > > timeDate(as.character(inputdate),format="%02H/%02M/%02S %Y/%02m/%02d") > Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : >missing value where TRUE/FALSE needed > > inputdate = "16.20.22 2007-10-31" > > timeDate(as.character(inputdate),format="%02H.%02M.%02S %Y-%02m-%02d") > Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : >missing value where TRUE/FALSE needed > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] writing a categorical var. with condition
Thank you! Sigalit. On 11/2/07, Marc Schwartz <[EMAIL PROTECTED]> wrote: > > On Fri, 2007-11-02 at 22:02 +0200, sigalit mangut-leiba wrote: > > Hello, > > I want to create a new variable which includes 4 age categories in this > way: > > > > if (age>=12 && age<32) age1==1 > > > > if (age>=32 && age<52) age1==2 > > > > if (age>=52 && age<72) age1==3 > > > > if (age>=72 && age<100) age1==4 > > > > but I get the results only for the first observation. > > > > how can I apply this condition to all observations? > > > > Thanks in advance, > > > > Sigalit. > > The if() function can only return a single result, so you would have to > create something along the lines of an if...else construct. > > Alternatively, you can use cut(): > > age <- 12:99 > > > cut(age, breaks = c(12, 32, 52, 72, 100), labels = 1:4, include.lowest = > TRUE) > [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 > [35] 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 > [69] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 > Levels: 1 2 3 4 > > > Note that this returns a factor. If you want an actual integer value, > you would have to coerce the result. > > See ?cut for more information. > > HTH, > > Marc Schwartz > > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Permutation test, grouped data
Brian S Cade wrote: > Tom: Paul Mielke, emeritus professor at Colorado State University, > probably has some of the most efficient Fortran programs for enumerating > all possible permutations of small sample sizes for grouped comparisons > and Monte Carlo random sampling of the possible permutations for larger > group sizes. The Fortran source code is available off his CSU Statistics > Department web page. The code is for Mielke's multiresponse permutation > procedures (MRPP), which includes permutation versions of ANOVA or t-tests > as a special case. But where do I find documentation for the programs? Is that in the Spinger book? Tom ++ | Tom Backer Johnsen, Psychometrics Unit, Faculty of Psychology | | University of Bergen, Christies gt. 12, N-5015 Bergen, NORWAY | | Tel : +47-5558-9185Fax : +47-5558-9879 | | Email : [EMAIL PROTECTED]URL : http://www.galton.uib.no/ | ++ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Permutation test, grouped data
Brian S Cade wrote: > Tom: Paul Mielke, emeritus professor at Colorado State University, > probably has some of the most efficient Fortran programs for enumerating > all possible permutations of small sample sizes for grouped comparisons > and Monte Carlo random sampling of the possible permutations for larger > group sizes. The Fortran source code is available off his CSU Statistics > Department web page. The code is for Mielke's multiresponse permutation > procedures (MRPP), which includes permutation versions of ANOVA or t-tests > as a special case. Thank you very much, it may be just what I need. I have just downloaded the source and started looking at them. I'll have to look for a Fortran compiler as well. Alternatively, we've implemented Mielke's code into > our Blossom statistical package, which provides a more user friendly front > end and output than Mielke's programs. This is available at > http://www.fort.usgs.gov/Products/Software/blossom/ The main point is that I would like to include the algorithm into my own somewhat dedicated code, currently written in Object Pascal, (Delphi), but I plan to port the code to some open source variant. > My experience with implementing similar permutation tests in software like > R or S-Plus that are optimal for vector computations is that they will > never be as fast as the looping structures that are implemented in the > Fortran programs. And when you are talking about enumerating all > possible permutations, speed becomes a very limiting factor. Mielke's > code will easily do complete enumeration of 2 groups of n=12 ( 2,704,156 > possible combination) in 10 seconds or so (on Windows XP with 2GB memory) > and 2 groups of n =13 (10,400,600 possible combinations) should still be > not unreasonable. That is really impressive! Tom > > Brian > > Brian S. Cade > > U. S. Geological Survey > Fort Collins Science Center > 2150 Centre Ave., Bldg. C > Fort Collins, CO 80526-8818 > > email: [EMAIL PROTECTED] > tel: 970 226-9326 > > > > Tom Backer Johnsen <[EMAIL PROTECTED]> > Sent by: [EMAIL PROTECTED] > 11/02/2007 08:16 AM > > To > [EMAIL PROTECTED] > cc > > Subject > [R] Permutation test, grouped data > > > > > > > I am perfectly aware that this question is not an R question, at least > not yet, but I have not succeeded in finding what I want in other > ways, so ... > > What I am looking for are two algorithms, preferabley in Pascal, but > other languages may do. For (a) systematic (complete) permutations > for grouped data with unequal group sizes, and (b) random permutations > for the same kind of data. I know of one source: E. S. Edgington > (1980): Randomization Tests (program 4.1 and program 4.3), but those > are written in Fortran with a lot of GO TO's which probably would not > be very efficient even if I managed to manually these programs and do > a correct translation. There must be some more modern ones around, > but where? > > I need the algorithms for a program I have written for exploring > structural balance in sociometric group structures. > > Tom > > ++ > | Tom Backer Johnsen, Psychometrics Unit, Faculty of Psychology | > | University of Bergen, Christies gt. 12, N-5015 Bergen, NORWAY | > | Tel : +47-5558-9185Fax : +47-5558-9879 | > | Email : [EMAIL PROTECTED]URL : http://www.galton.uib.no/ | > ++ > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > -- ++ | Tom Backer Johnsen, Psychometrics Unit, Faculty of Psychology | | University of Bergen, Christies gt. 12, N-5015 Bergen, NORWAY | | Tel : +47-5558-9185Fax : +47-5558-9879 | | Email : [EMAIL PROTECTED]URL : http://www.galton.uib.no/ | ++ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] subsetting problem with multiple criteria: Works in some but not all cases.
You can use apropos to find then and then list out their help pages: > apropos("%") [1] "%%" "%*%" "%/%" "%in%" "%o%" "%x%" On 11/2/07, John Kane <[EMAIL PROTECTED]> wrote: > Thank you Jim. That seems to work perfectly. > > I had looked at %in% and apparently misunderstood what > it would do. Is there any place where I can read on > the various %XX% functions? > > --- jim holtman <[EMAIL PROTECTED]> wrote: > > > I think the problem is with your use of "==" instead > > of "%in%"; try > > > > matching <- subset(mydata[,c(j+1,j+7)], mydata[,j+1] > > %in% lone.word) > > > > > > > > On 11/1/07, John Kane <[EMAIL PROTECTED]> wrote: > > > I am trying to compare some word lists which have > > an > > > associate set of numbers. I want to compare word > > list > > > aa with bb and find only those words which are > > > unique to bb, then compare bb with cc, etc. > > > > > > I thought that I should be able to do this by > > using > > > setdiff to get the unique words and then subset > > the > > > data frame to get the unique names and > > corresponding > > > numbers but I am misunderstanding something. > > > > > > When I run the code below a) I get lots of warning > > and > > > b) I get the correct results for 4 of the 5 > > > comparisons. However the comparison of three with > > > four (cc,dd) gives me an empty subset. > > > > > > Can anyone point out my error or suggest a better > > way > > > to do this? > > > Thanks > > > > > > > > > > > > > > > mydata = data.frame(aa = Cs(cat, dog, horse, > > cow), > > > bb = c("mouse", "dog", "cow", "pigeon"), > > > cc =c("emu", "rat", "crow", "cow"), > > > dd = c("cow", "camel", "manatee", "parrot") , > > > ee = c( "coat", "hat", "dog", "camel") , > > > ff = c("knife","dog", "cow", "pigeon"), > > > ann = c(1,2,3,4), > > > bnn = c(5,6,7,8), > > > cnn = c(9,10,11,12), > > > dnn = c(13,14,15,16), > > > enn = c(17,18,19,20), > > > fnn = c(21,22,23,24)) > > > > > > wordnames <- c("word", "number") > > > word.list <- rep(vector("list", 1), 5) > > > > > > for(j in 1:5) { > > > lone.word <- setdiff(mydata[,j+1],mydata[,j]); > > > lone.word > > > matching <- subset(mydata[,c(j+1,j+7)], > > > mydata[,j+1]==lone.word); matching > > > word.list[[j]] <- matching; > > names(word.list[[j]])<- > > > wordnames > > > } > > > word.list > > > > > > > > > = > > > R version 2.6.0 (2007-10-03) > > > i386-pc-mingw32 > > > > > > locale: > > > > > > LC_COLLATE=English_Canada.1252;LC_CTYPE=English_Canada.1252;LC_MONETARY=English_Canada.1252;LC_NUMERIC=C;LC_TIME=English_Canada.1252 > > > > > > attached base packages: > > > [1] stats graphics grDevices utils > > datasets > > > methods base > > > > > > other attached packages: > > > [1] Hmisc_3.4-2 gdata_2.3.1 > > > > > > loaded via a namespace (and not attached): > > > [1] cluster_1.11.9 grid_2.6.0 gtools_2.4.0 > > > lattice_0.17-1 > > > > > > > > > R version 2.6.0 (2007-10-03) > > > i386-pc-mingw32 > > > > > > locale: > > > > > > LC_COLLATE=English_Canada.1252;LC_CTYPE=English_Canada.1252;LC_MONETARY=English_Canada.1252;LC_NUMERIC=C;LC_TIME=English_Canada.1252 > > > > > > attached base packages: > > > [1] stats graphics grDevices utils > > datasets > > > methods base > > > > > > other attached packages: > > > [1] Hmisc_3.4-2 gdata_2.3.1 > > > > > > loaded via a namespace (and not attached): > > > [1] cluster_1.11.9 grid_2.6.0 gtools_2.4.0 > > > lattice_0.17-1 > > > > > > __ > > > R-help@r-project.org mailing list > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html > > > and provide commented, minimal, self-contained, > > reproducible code. > > > > > > > > > -- > > Jim Holtman > > Cincinnati, OH > > +1 513 646 9390 > > > > What is the problem you are trying to solve? > > > > > > Ask a question on any topic and get answers from real people. Go to > Yahoo! Answers and share what you know at http://ca.answers.yahoo.com > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] writing a categorical var. with condition
Hi, try this: #df <- data.frame(age=sample(20:100, 20, rep=T), age1=gl(4, length(age)/4)) df$age1[which(age %in% 12:31)] <- 1 df$age1[which(age %in% 32:51)] <- 2 df$age1[which(age %in% 52:71)] <- 3 df$age1[which(age %in% 72:99)] <- 4 -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O On 02/11/2007, sigalit mangut-leiba <[EMAIL PROTECTED]> wrote: > > Hello, > I want to create a new variable which includes 4 age categories in this > way: > > if (age>=12 && age<32) age1==1 > > if (age>=32 && age<52) age1==2 > > if (age>=52 && age<72) age1==3 > > if (age>=72 && age<100) age1==4 > > but I get the results only for the first observation. > > how can I apply this condition to all observations? > > Thanks in advance, > > Sigalit. > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lme model with replicates within a random factor
1. Consult the Pinheiro and Bates, MIXED EFFECTS MODELS ... book, especially if you will continue to use such methodology as part of your professional work. 2. I think the model you want is: Model1<-lme(shannon ~ log(chla+1)*toc*hyd_cycle,random = ~time|basin) You don't need to include the replicate term because that is automatically included as the error term in the model. Note that this model probably makes most sense if time is a factor.If time is a numeric vector, then the model implies that you expect some kind of random trend with time in each basin, and you would probably therefore want to include it as a fixed effect, too, something like: Model1<-lme(shannon ~ log(chla+1)*toc*hyd_cycle + time,random=~time|basin). This postulates some overall time trend with random slope and intercept offsets from the overall trend in each basin. Bert Gunter Genentech Nonclinical Statistics -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Stéphanie Gascón Garcia Sent: Friday, November 02, 2007 12:39 PM To: [EMAIL PROTECTED] Subject: [R] lme model with replicates within a random factor Dear all, I wonder if anyone can help me with specifying a right model for my analysis. I am a beginner to lme methods. I was unfortunately not able to find a solution to my problem on my own. Data structure: I have sampled monthly 6 basins during two hydrological cycles, and I have taken several (2 to 4) samples (replicate) for each basin and month. Im trying to relate Shannon diversity to some environmental variables, taking away pseudoreplication. Thus, I have tried an lme model with time and basin as random factors. I have put hydrological cycle as a fixed factor, since Im interested in quantifying their effect. But Im not sure if there are other possibilities to do this. This is my model structure: Model1<-lme(shannon<-log(chla+1)*hyd_cycle+toc*hyd_cycle, random=~time|basin) Note that I have not put replicate within the random structure (random=~time|basin/replicate), and this is my major concern. Im not sure if I have to include replicate in the random structure, since replicates are randomly taken each time, and so are not repeated measures within the basins. All books and internet information that I have looked at the moment are examples with repeated measures within blocks (e.g. repeated measures of the same plant and treatment). Can anyone help me with this? I would appreciate any hints and suggestions Stiphanie [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] hide or minimize graphics
On Fri, 2007-11-02 at 13:29 -0700, Felipe Carrillo wrote: > Hello all: > Is there a way to create a graph and then hide it or > just make a graph in the background (invisible). Thanks I think that we will need more information here, notably what you want to ultimately do with the graph. You could create a graphic file (eg. PDF, PS, JPG/PNG) which would not be displayed on the screen. If one of those formats would meet your ultimate goal, then see ?Devices for more information. HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] gplots 2.5.0
Announcing gplots 2.5.0 - gplots provides additional plotting functions, including several enhanced versions of base R functions. Provided functions include: balloonplot, bandplot, barplot2, boxplot.n, colorpanel, heatmap.2, hist2d, lowess, ooplot, overplot, plot.lm2, plotCI, plotmeans, qqnorm.aov, residplot, rich.color, sinkplot, smartlegend, space, textplot, wapply Changes in 2.5.0 --- New Features: - textplot() now converts tab characters to spaces before processing to avoid problems with computing height and width of text that includes tabs. - Add col2rgb() function to convert color names to rgb hex codes Bug Fixes: - Correct balloonplot.default to properly show specified x and y axis labels when explicitly provided - R/balloonplot.R: Correct error in balloonplot when z contains NA values. - Fix typos and code/doc mismatches identified by the latest R CMD check Other: - Clarify GPL version ___ R-packages mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] writing a categorical var. with condition
On Fri, 2007-11-02 at 22:02 +0200, sigalit mangut-leiba wrote: > Hello, > I want to create a new variable which includes 4 age categories in this way: > > if (age>=12 && age<32) age1==1 > > if (age>=32 && age<52) age1==2 > > if (age>=52 && age<72) age1==3 > > if (age>=72 && age<100) age1==4 > > but I get the results only for the first observation. > > how can I apply this condition to all observations? > > Thanks in advance, > > Sigalit. The if() function can only return a single result, so you would have to create something along the lines of an if...else construct. Alternatively, you can use cut(): age <- 12:99 > cut(age, breaks = c(12, 32, 52, 72, 100), labels = 1:4, include.lowest = > TRUE) [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 [35] 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 [69] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 Levels: 1 2 3 4 Note that this returns a factor. If you want an actual integer value, you would have to coerce the result. See ?cut for more information. HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] hide or minimize graphics
Hello all: Is there a way to create a graph and then hide it or just make a graph in the background (invisible). Thanks Felipe D. Carrillo Fishery Biologist US Fish & Wildlife Service Red Bluff, California 96080 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [OT] vista question
This is way off topic, but I'll try: On a windows vista machine, how can you run commands from the command prompt as administrator, please? tia __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] writing a categorical var. with condition
Hello, I want to create a new variable which includes 4 age categories in this way: if (age>=12 && age<32) age1==1 if (age>=32 && age<52) age1==2 if (age>=52 && age<72) age1==3 if (age>=72 && age<100) age1==4 but I get the results only for the first observation. how can I apply this condition to all observations? Thanks in advance, Sigalit. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] when deleting a row from a matrix gives a vector
On Nov 2, 2007, at 12:50 PM, Sarah Goslee wrote: > x <- x[1, drop=FALSE] > >> Is there any way to force the result to remain a matrix, even if it >> has only one row or column, or even only one entry? Thanks, I think you might have meant ... x <- x[1,,drop=FALSE] Note the double commas ... - VV > -- > Sarah Goslee > http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] when deleting a row from a matrix gives a vector
On Fri, 2007-11-02 at 20:47 +0100, Gabriel Valiente wrote: > Deleting a row from a matrix turns it into a vector (and dim names > are lost) if the resulting matrix has only one row or column. For > instance: > > > x <- matrix(1:10, ncol=2) > > x <- x[1,] > > turns x into > > [1] 1 6 > > instead of > > [,1] [,2] > [1,]16 > > Is there any way to force the result to remain a matrix, even if it > has only one row or column, or even only one entry? Thanks, > > Gabriel See R FAQ 7.5 Why do my matrices lose dimensions? http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-my-matrices-lose-dimensions_003f HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] when deleting a row from a matrix gives a vector
x <- x[1, drop=FALSE] > Is there any way to force the result to remain a matrix, even if it > has only one row or column, or even only one entry? Thanks, -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] when deleting a row from a matrix gives a vector
Deleting a row from a matrix turns it into a vector (and dim names are lost) if the resulting matrix has only one row or column. For instance: > x <- matrix(1:10, ncol=2) > x <- x[1,] turns x into [1] 1 6 instead of [,1] [,2] [1,]16 Is there any way to force the result to remain a matrix, even if it has only one row or column, or even only one entry? Thanks, Gabriel __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] lme model with replicates within a random factor
Dear all, I wonder if anyone can help me with specifying a right model for my analysis. I am a beginner to lme methods. I was unfortunately not able to find a solution to my problem on my own. Data structure: I have sampled monthly 6 basins during two hydrological cycles, and I have taken several (2 to 4) samples (replicate) for each basin and month. Im trying to relate Shannon diversity to some environmental variables, taking away pseudoreplication. Thus, I have tried an lme model with time and basin as random factors. I have put hydrological cycle as a fixed factor, since Im interested in quantifying their effect. But Im not sure if there are other possibilities to do this. This is my model structure: Model1<-lme(shannon<-log(chla+1)*hyd_cycle+toc*hyd_cycle, random=~time|basin) Note that I have not put replicate within the random structure (random=~time|basin/replicate), and this is my major concern. Im not sure if I have to include replicate in the random structure, since replicates are randomly taken each time, and so are not repeated measures within the basins. All books and internet information that I have looked at the moment are examples with repeated measures within blocks (e.g. repeated measures of the same plant and treatment). Can anyone help me with this? I would appreciate any hints and suggestions Stéphanie [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to test combined effects?
On Nov 2, 2007, at 12:20PM , Gang Chen wrote: > Thanks a lot for the help! > > >> First, if you would like to performa an overall test of whether >> the IQ interactions are necessary, you may find it most useful to >> use anova to compare a full and reduced model. Something like: >> >> ModelFit.full <-lme(mct~ IQ*age+IQ*I(age^2)+IQ*I(age^3), MyData, >> random=~1|ID) >> ModelFit.reduced <-lme(mct~ IQ + age+I(age^2)+I(age^3), MyData, >> random=~1|ID) >> anova(ModelFit.full, ModelFit.reduced, test="F") > > > I had done this before, but it seems that I would only get a > likelihood ratio test, not a partial F test, out of the anova. The > 'test' option with logical value in anova seems to take TRUE or > FALSE, thus either I get a likelihood ration test or not. I guess a > likelihood ratio test with ML method is legitimate in this context? I'll have to defer to others on the validity of the LR test in this context, as I've got my programmer hat on today and not my stat theory hat ... ;-) > > >> Second, you don't have the syntax right for estimable(). As >> described and shown by example in the manual page. The correct >> syntax is: >> >> library(gmodels) >> estimable(ModelFit, c('IQ:age'=1, 'IQ:I(age^2)'= 1, 'IQ:I(age^3)' >> = 1)) >> >> Note the pattern of quoted name, followed by '=', and then the >> value 1 (not zero). This will perform a single joint test whether >> these three coefficients are zero. > > > Thanks for catching the errors! Yes this works. However it gives a > t test with 1 degree of freedom, not exactly a partial F test. So > does it mean that this only tests the average effect of those 3 > terms? If so, that would be slightly different from the partial F > test I was looking for, no? Yes, this provides a 1-degree of freedom contrast between an individual with ('IQ:age'=0, 'IQ:I(age^2)'=0, 'IQ:I(age^3)'=0) and another with ('IQ:age'=1, 'IQ:I(age^2)'=1, 'IQ:I(age^3)'=1). Although we do provide a joint Wald test for 'lm', 'glm', 'aov', 'gee' or 'geese' objects, we have not done so for 'lme' objects. The code to do so is straightforward, and I'll send you a copy privately. Perhaps someone who has the stat theory hat on today can comment on the validity of the Wald X^2 here, and on the relative merits of the LR test vs the Wald test for fixed effects of an LME. In any case here is how you use the enhanced code. > library(nlme) > library(gmodels) > Orthodont$Rand <- rnorm(nrow(Orthodont)) # add a noise variable > fm2 <- lme(distance ~ age * Rand + Sex * Rand, data = Orthodont, random = ~ 1) > cmat <- cbind( "Rand"=c(1,0,0), "age:Rand"=c(0,1,0), "Rand:SexFemale"=c(0,0,1) ) > cmat Rand age:Rand Rand:SexFemale [1,]10 0 [2,]01 0 [3,]00 1 > estimable( fm2, cmat, joint.test=FALSE ) # individual contrasts Estimate Std. Errort value DF Pr(>|t|) (0 0 1 0 0 0) 0.39919525 0.9263579 0.4309298 77 0.6677233 (0 0 0 0 1 0) -0.07152143 0.0783120 -0.9132883 77 0.3639418 (0 0 0 0 0 1) 0.47758669 0.2993967 1.5951635 77 0.1147722 > attach(environment(estimable)) # make the estimable functions available to local code The following object(s) are masked from package:gmodels : CrossTable ci ci.binom coefFrame estimable fast.prcomp fast.svd fit.contrast glh.test make.contrasts print.glh.test summary.glh.test > source("~/src/r-gregmisc/gmodels/R/estimable.R") # load the modified code > estimable( fm2, cmat, joint.test=TRUE ) # joint Wald X^2 X2.stat DF Pr(>|X^2|) 1 4.876038 3 0.1811025 > q() -Greg > Gang > > >> -G >> >> >> >> On Oct 30, 2007, at 5:26PM , Gang Chen wrote: >> >>> Dieter, >>> >>> Thank you very much for the help! >>> >>> I tried both glht() in multcomp and estimable() in gmodels, but >>> couldn't get them work as shown below. Basically I have trouble >>> specifying those continuous variables. Any suggestions? >>> >>> Also it seems both glht() and estimable() would give multiple t >>> tests. Is there a way to obtain sort of partial F test? >>> >>> ModelFit<-lme(mct~ IQ*age+IQ*I(age^2)+IQ*I(age^3), MyData, >>> random=~1|ID) anova(ModelFit) >>> >>> mDF denDF F-value p-value >>> (Intercept) 1 257 54393.04 <.0001 >>> IQ 1 215 3.02 0.0839 >>> age 1 25746.06 <.0001 >>> I(age^2)1 257 8.80 0.0033 >>> I(age^3)1 25721.30 <.0001 >>> IQ:age 1 257 1.18 0.2776 >>> IQ:I(age^2) 1 257 0.50 0.4798 >>> IQ:I(age^3) 1 257 0.23 0.6284 >>> library(multcomp) glht(ModelFit, linfct = c("IQ:age = 0", "IQ:I(age^2) = 0", "IQ:I >>> (age^3) = 0")) >>> E
[R] loading installes package including all needed subpackages
Hallo, I just installed all needed packages for my project on my PC. But I cannot load all at one time. I now want to load limma. How can I realize the following plan: I want to install for example limma inclusive all needed other sub packages (add-on). Can anyone tell me the corresponding command? Thanks, Corinna Here is the result of the command library(): Pakete in Library 'D:/R/R-2.6.0/library': ada Performs boosting algorithms for a binary response affyMethods for Affymetrix Oligonucleotide Arrays affycompGraphics Toolbox for Assessment of Affymetrix Expression Measures affydataAffymetrix Data for Demonstration Purpose affyio Tools for parsing Affymetrix data files affyPLM Methods for fitting probe-level models affyQCReportQC Report Generation for affyBatch objects ALL A data package annaffy Annotation tools for Affymetrix biological metadata annotateAnnotation for microarrays AnnotationDbi Annotation Database Interface arules Mining Association Rules and Frequent Itemsets baseThe R Base Package Biobase Biobase: Base functions for Bioconductor biomaRt Interface to BioMart databases (e.g. Ensembl, Wormbase, Gramene and Uniprot) Biostrings String objects representing biological sequences, and matching algorithms bootBootstrap R (S-Plus) Functions (Canty) CategoryCategory Analysis CCl4Carbon Tetrachloride (CCl4) treated hepatocytes class Functions for Classification cluster Cluster Analysis Extended Rousseeuw et al. codetools Code Analysis Tools for R datasetsThe R Datasets Package DBI R Database Interface DynDoc Dynamic document tools e1071 Misc Functions of the Department of Statistics (e1071), TU Wien edd expression density diagnostics foreign Read Data Stored by Minitab, S, SAS, SPSS, Stata, Systat, dBase, ... gcrma Background Adjustment Using Sequence Information genefilter genefilter: methods for filtering genes from microarray experiments geneplotter Grapics related functions for Bioconductor globaltest Testing Association of Groups of Genes with a Clinical Variable GO A data package containing annotation data for GO GO.db A set of annotation maps describing the entire Gene Ontology golubEsets exprSets for golub leukemia data GOstats Tools for manipulating GO and microarrays. graph graph: A package to handle graph data structures graphicsThe R Graphics Package grDevices The R Graphics Devices and Support for Colours and Fonts gridThe Grid Graphics Package GSEABaseGene set enrichment data structures and methods hgu133a Affymetrix Human Genome U133 Set Annotation Data (hgu133a) hgu95av2Affymetrix Human Genome U95 Set Annotation Data (hgu95av2) hgu95av2.db Affymetrix Human Genome U95 Set annotation data (chip hgu95av2) hgu95av2cdf hgu95av2cdf KEGGA data package containing annotation data for KEGG keggorthgraph support for KO, KEGG Orthology KernSmooth Functions for kernel smoothing for Wand & Jones (1995) lattice Lattice Graphics limma Linear Models for Microarray Data makecdfenv CDF Environment Maker MAQCsubset Experimental Data Package: MAQCsubset marray Exploratory analysis for two-color spotted microarray data MASSMain Package of Venables and Ripley's MASS matchprobes Tools for sequence matching of probes on arrays Matrix A Matrix package for R methods Formal Methods and Classes mgcvGAMs with GCV smoothness estimation and GAMMs by REML/PQL MLInterfacesUniform interfaces to R machine learning procedures for data in Bioconductor containers multtestResampling-based multiple hypothesis testing Neve2006
Re: [R] ggplot2 - expand range?
Thanks! I thought expand was already set to c(0,0) when not specifying it. I agree I must be careful with the space left, but if a scale starts on 0, it becomes somewhat strange to see the axis start somewhere on negatives... This is my problem. Normally the issue with extra space will arise on the top and right-side of the plots, not on the bottom or left side where the axes cross. But maybe there is another way to get this... Any hints? Thanks again, Pedro At 16:40 2007/11/02, you wrote: >Hi Pedro, > >You need to set the expand parameter to c(0,0) : > >scale_y_continuous(limits=c(0,10), expand = c(0,0)) > >ggplot uses expand_range internally to ensure that you always have >some space between the data and the margins (and you should make sure >this happens in your plot too - otherwise it can be hard to see data >points on the sides) > >Hadley > >On 11/1/07, Pedro de Barros <[EMAIL PROTECTED]> wrote: > > Dear UserRs, > > > > I am trying to use systematically ggplot2 for most of my plots, but I > > am fighting some lack of documentation, which I try to overcome. > > > > I want to build a scatterplot where the axes cross exactly at (0,0). > > I tried using scale_y_continuous(limits=c(0,10)), but I always get an > > extra space at the bottom of the axes. The code I used is below. > > > > > plotdata<-data.frame(x=1:10, y=runif(10)) > > > plot<-ggplot() > > > plot<-plot+layer(data=plotdata, mapping=aes_string(x='x',y='y'), > > geom='point', stat='identity', size=4) > > > plot<-plot+ scale_y_continuous(limits=c(0,1)) > > > print(plot) > > > > I believe there may be a way to use expand_range to fix this (I think > > I read about it somewhere), but I do not seem to find out how. > > I have searched the ggplot help and > > the archives, but cannot find the answer to this issue. > > I would really appreciate if anyone could give me a pointer. > > > > I am using R2.6.0 (patched) on Windows > > > > Thanks, > > Pedro > > > > __ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > >-- >http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] counting with factors
On Fri, 2007-11-02 at 12:01 -0400, Bernd Jagla wrote: > Hi there, > I have something that appears to be a factor called drug: > > Typeof(drug) => Integer This is because the underlying data type of a factor is an integer. > As.numeric(drug) gives a long list This gives you the integer storage code for each element of the factor > Levels(drug) gives a long list, too. This effectively gives you the unique entries in the factor, each of which has been given a level. > Now I want something like the summary function does: > > I want to count how often each level occurs in the given vector. > > My problem is that summary gives me a list with counts that is incomplete > and adds the "Others" category. > Is there a way to get a count for all levels? To create a frequency *table* of the occurrences of your factor use: table(drug) See ?table Also, if you imported this data using one of the read.table() family of functions, see the 'as.is', 'colClasses' and 'stringsAsFactors' arguments, which can be set so that character columns are not converted to factors. HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] duplicate rows in a matrix
On Fri, 2007-11-02 at 09:04 -0700, Silvia Lipski wrote: > Hi! > > Is there a fast way to duplicate rows in a matrix? > I would like to do the following: > > change a matrix A like: > [,1] [,2] > [1,] Kevin 1 > [2,] Alf 2 > > into : > [,1] [,2] > [1,] Kevin 1 > [2,] Kevin 1 > [3,] Alf 2 > [4,] Alf 2 > > i.e. double all rows. The only way I could think off > was: rbind(A[1,],A[1,],A[2,],A[2,]) - which is really > impractible, of course. > > Can anyone help, please? > Thank you, > Silvia Typically, you would use something like: > A [,1][,2] [1,] "Kevin" "1" [2,] "Alf" "2" > A[rep(seq(nrow(A)), each = 2), ] [,1][,2] [1,] "Kevin" "1" [1,] "Kevin" "1" [2,] "Alf" "2" [2,] "Alf" "2" Use row indexing consisting of duplicate index values created by: > rep(seq(nrow(A)), each = 2) [1] 1 1 2 2 See ?rep and ?seq HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to test combined effects?
Thanks a lot for the help! > First, if you would like to performa an overall test of whether the > IQ interactions are necessary, you may find it most useful to use > anova to compare a full and reduced model. Something like: > > ModelFit.full <-lme(mct~ IQ*age+IQ*I(age^2)+IQ*I(age^3), MyData, > random=~1|ID) > ModelFit.reduced <-lme(mct~ IQ + age+I(age^2)+I(age^3), MyData, > random=~1|ID) > anova(ModelFit.full, ModelFit.reduced, test="F") I had done this before, but it seems that I would only get a likelihood ratio test, not a partial F test, out of the anova. The 'test' option with logical value in anova seems to take TRUE or FALSE, thus either I get a likelihood ration test or not. I guess a likelihood ratio test with ML method is legitimate in this context? > Second, you don't have the syntax right for estimable(). As > described and shown by example in the manual page. The correct > syntax is: > > library(gmodels) > estimable(ModelFit, c('IQ:age'=1, 'IQ:I(age^2)'= 1, 'IQ:I(age^3)' > = 1)) > > Note the pattern of quoted name, followed by '=', and then the > value 1 (not zero). This will perform a single joint test whether > these three coefficients are zero. Thanks for catching the errors! Yes this works. However it gives a t test with 1 degree of freedom, not exactly a partial F test. So does it mean that this only tests the average effect of those 3 terms? If so, that would be slightly different from the partial F test I was looking for, no? Gang > -G > > > > On Oct 30, 2007, at 5:26PM , Gang Chen wrote: > >> Dieter, >> >> Thank you very much for the help! >> >> I tried both glht() in multcomp and estimable() in gmodels, but >> couldn't get them work as shown below. Basically I have trouble >> specifying those continuous variables. Any suggestions? >> >> Also it seems both glht() and estimable() would give multiple t >> tests. Is there a way to obtain sort of partial F test? >> >> >>> ModelFit<-lme(mct~ IQ*age+IQ*I(age^2)+IQ*I(age^3), MyData, >> random=~1|ID) >>> anova(ModelFit) >> >> mDF denDF F-value p-value >> (Intercept) 1 257 54393.04 <.0001 >> IQ 1 215 3.02 0.0839 >> age 1 25746.06 <.0001 >> I(age^2)1 257 8.80 0.0033 >> I(age^3)1 25721.30 <.0001 >> IQ:age 1 257 1.18 0.2776 >> IQ:I(age^2) 1 257 0.50 0.4798 >> IQ:I(age^3) 1 257 0.23 0.6284 >> >>> library(multcomp) >>> glht(ModelFit, linfct = c("IQ:age = 0", "IQ:I(age^2) = 0", "IQ:I >> (age^3) = 0")) >> Error in coefs(ex[[3]]) : >>cannot interpret expression 'I''age^2' as linear function >> >>> library(gmodels) >>> estimable(ModelFit, rbind('IQ:age'=0, 'IQ:I(age^2) = 0', 'IQ:I >> (age^3) = 0')) >> Error in FUN(newX[, i], ...) : >>`param' has no names and does not match number of coefficients of >> model. Unable to construct coefficient vector >> >> Thanks, >> Gang >> >> >> On Oct 30, 2007, at 9:08 AM, Dieter Menne wrote: >> >> >>> Gang Chen mail.nih.gov> writes: >>> >>> Suppose I have a mixed-effects model where yij is the jth sample for the ith subject: yij= beta0 + beta1(age) + beta2(age^2) + beta3(age^3) + beta4(IQ) + beta5(IQ^2) + beta6(age*IQ) + beta7(age^2*IQ) + beta8(age^3 *IQ) +random intercepti + eij In R how can I get an F test against the null hypothesis of beta6=beta7=beta8=0? In SAS I can run something like contrast age*IQ 1, age^2*IQ 1, age^3 *IQ 1, but is there anything similar in R? >>> >>> Check packages multcomp and gmodels for contrast tests that work >>> with lme. >>> >>> Dieter >>> >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting- >> guide.html >> and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2 - expand range?
Hi Pedro, You need to set the expand parameter to c(0,0) : scale_y_continuous(limits=c(0,10), expand = c(0,0)) ggplot uses expand_range internally to ensure that you always have some space between the data and the margins (and you should make sure this happens in your plot too - otherwise it can be hard to see data points on the sides) Hadley On 11/1/07, Pedro de Barros <[EMAIL PROTECTED]> wrote: > Dear UserRs, > > I am trying to use systematically ggplot2 for most of my plots, but I > am fighting some lack of documentation, which I try to overcome. > > I want to build a scatterplot where the axes cross exactly at (0,0). > I tried using scale_y_continuous(limits=c(0,10)), but I always get an > extra space at the bottom of the axes. The code I used is below. > > > plotdata<-data.frame(x=1:10, y=runif(10)) > > plot<-ggplot() > > plot<-plot+layer(data=plotdata, mapping=aes_string(x='x',y='y'), > geom='point', stat='identity', size=4) > > plot<-plot+ scale_y_continuous(limits=c(0,1)) > > print(plot) > > I believe there may be a way to use expand_range to fix this (I think > I read about it somewhere), but I do not seem to find out how. > I have searched the ggplot help and > the archives, but cannot find the answer to this issue. > I would really appreciate if anyone could give me a pointer. > > I am using R2.6.0 (patched) on Windows > > Thanks, > Pedro > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] duplicate rows in a matrix
My sugestion (for an alphabetically ordered output) AA <- rbind(A,A) AA <- AA[order(AA[,1]), ] ## so your matrix gets alphabetically ordered JM On Fri, 2007-11-02 at 09:04 -0700, Silvia Lipski wrote: > Hi! > > Is there a fast way to duplicate rows in a matrix? > I would like to do the following: > > change a matrix A like: > [,1] [,2] > [1,] Kevin 1 > [2,] Alf 2 > > into : > [,1] [,2] > [1,] Kevin 1 > [2,] Kevin 1 > [3,] Alf 2 > [4,] Alf 2 > > i.e. double all rows. The only way I could think off > was: rbind(A[1,],A[1,],A[2,],A[2,]) - which is really > impractible, of course. > > Can anyone help, please? > Thank you, > Silvia > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] duplicate rows in a matrix
Hi! Is there a fast way to duplicate rows in a matrix? I would like to do the following: change a matrix A like: [,1] [,2] [1,] Kevin 1 [2,] Alf 2 into : [,1] [,2] [1,] Kevin 1 [2,] Kevin 1 [3,] Alf 2 [4,] Alf 2 i.e. double all rows. The only way I could think off was: rbind(A[1,],A[1,],A[2,],A[2,]) - which is really impractible, of course. Can anyone help, please? Thank you, Silvia __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] groups in lattice
See the argument panel.groups in panel.superpose. library(lattice) dfr <- data.frame(y = c(rnorm(10, 5, 1), rnorm(10, -5, 1)), x = rep(runif(10), 2), g = rep(c("a", "b"), each = 10)) xyplot(y ~ x, groups = g, data = dfr, panel = function(...){ panel.superpose(..., panel.groups = "panel.xyplot") panel.superpose(..., panel.groups = "panel.lmline") }) Renaud 2007/11/2, Ruud H. Koning <[EMAIL PROTECTED]>: > Hello, I must be missing something very obvious. I have a dataset with > consists of three groups, and for each group I would like to draw a > regression line in one frame. Something like > > plot.a <- xyplot(result~price,data=nl, > xlab="Standardized price",ylab="Outcome",groups=slice, > panel=function(x,y,...){ > panel.lmline(x,y,...) > } > ) > > However, only one line is drawn. If I replace panel.lmline by > panel.densityplot(x,...), I do get three densityplots in the frame. What > am I missing? > Thanks, Ruud > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Renaud LANCELOT Département Systèmes Biologiques du CIRAD CIRAD, Biological Systems Department Campus International de Baillarguet TA 30 / B F34398 Montpellier Tel +33 (0)4 67 59 37 17 Secr. +33 (0)4 67 59 37 37 Fax +33 (0)4 67 59 37 95 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] counting with factors
Hi there, I have something that appears to be a factor called drug: Typeof(drug) => Integer As.numeric(drug) gives a long list Levels(drug) gives a long list, too. Now I want something like the summary function does: I want to count how often each level occurs in the given vector. My problem is that summary gives me a list with counts that is incomplete and adds the "Others" category. Is there a way to get a count for all levels? Thanks, Bernd [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] snow and Rmpi, delayed starting-times at nodes
On Fri, 2 Nov 2007, Markus Schmidberger wrote: > Hello, > > we use R version 2.6.0, Rmpi_0.5-5 and snow_0.2-9 and have a parallel call > like this: > > clusterApply(cluster, input.list, function(input, data1, type) { }, > data1, type ) Most likely the problem is the direct use of function(...) ... here. This captures the local environment in ist closure, which is probably very large. Try defining the function you want to call at top level, or define a top level function to create your function if you do want a closure with specific tada captured. luke > > We now have the problem, that the processes at the nodes start delayed. This > means for example, node 4 starts its calculation when node 1 is finished.(see > the attached figure) > Therefore we have a lot of loss in our computation time. > > Our messages are not very big: > input.list = list of vectors. Each vector has 10 strings > data1 = one integer > type = one string > > What can we do to improve the speed? > > Thanks > Markus > > -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to test combined effects?
Ooops. One typo in the estimable command: > estimable(ModelFit, c('IQ:age'=1, 'IQ:I(age^2)'= 1, 'IQ:I(age^3)' = > 1)) (Remove a trailing space in the second string.) -G On Nov 2, 2007, at 11:51AM , Gregory Warnes wrote: > Hello Gang, > > First, if you would like to performa an overall test of whether the > IQ interactions are necessary, you may find it most useful to use > anova to compare a full and reduced model. Something like: > > ModelFit.full <-lme(mct~ IQ*age+IQ*I(age^2)+IQ*I(age^3), MyData, > random=~1|ID) > ModelFit.reduced <-lme(mct~ IQ + age+I(age^2)+I(age^3), MyData, > random=~1|ID) > anova(ModelFit.full, ModelFit.reduced, test="F") > > Second, you don't have the syntax right for estimable(). As > described and shown by example in the manual page. The correct > syntax is: > > library(gmodels) > estimable(ModelFit, c('IQ:age'=1, 'IQ:I(age^2) '= 1, 'IQ:I(age^3)' = > 1)) > > Note the pattern of quoted name, followed by '=', and then the value > 1 (not zero). This will perform a single joint test whether these > three coefficients are zero. > > -G > > > > On Oct 30, 2007, at 5:26PM , Gang Chen wrote: > >> Dieter, >> >> Thank you very much for the help! >> >> I tried both glht() in multcomp and estimable() in gmodels, but >> couldn't get them work as shown below. Basically I have trouble >> specifying those continuous variables. Any suggestions? >> >> Also it seems both glht() and estimable() would give multiple t >> tests. Is there a way to obtain sort of partial F test? >> >> >>> ModelFit<-lme(mct~ IQ*age+IQ*I(age^2)+IQ*I(age^3), MyData, >> random=~1|ID) >>> anova(ModelFit) >> >> mDF denDF F-value p-value >> (Intercept) 1 257 54393.04 <.0001 >> IQ 1 215 3.02 0.0839 >> age 1 25746.06 <.0001 >> I(age^2)1 257 8.80 0.0033 >> I(age^3)1 25721.30 <.0001 >> IQ:age 1 257 1.18 0.2776 >> IQ:I(age^2) 1 257 0.50 0.4798 >> IQ:I(age^3) 1 257 0.23 0.6284 >> >>> library(multcomp) >>> glht(ModelFit, linfct = c("IQ:age = 0", "IQ:I(age^2) = 0", "IQ:I >> (age^3) = 0")) >> Error in coefs(ex[[3]]) : >>cannot interpret expression 'I''age^2' as linear function >> >>> library(gmodels) >>> estimable(ModelFit, rbind('IQ:age'=0, 'IQ:I(age^2) = 0', 'IQ:I >> (age^3) = 0')) >> Error in FUN(newX[, i], ...) : >>`param' has no names and does not match number of coefficients of >> model. Unable to construct coefficient vector >> >> Thanks, >> Gang >> >> >> On Oct 30, 2007, at 9:08 AM, Dieter Menne wrote: >> >> >>> Gang Chen mail.nih.gov> writes: >>> >>> Suppose I have a mixed-effects model where yij is the jth sample for the ith subject: yij= beta0 + beta1(age) + beta2(age^2) + beta3(age^3) + beta4(IQ) + beta5(IQ^2) + beta6(age*IQ) + beta7(age^2*IQ) + beta8(age^3 *IQ) +random intercepti + eij In R how can I get an F test against the null hypothesis of beta6=beta7=beta8=0? In SAS I can run something like contrast age*IQ 1, age^2*IQ 1, age^3 *IQ 1, but is there anything similar in R? >>> >>> Check packages multcomp and gmodels for contrast tests that work >>> with lme. >>> >>> Dieter >>> >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting- >> guide.html >> and provide commented, minimal, self-contained, reproducible code. > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to test combined effects?
Hello Gang, First, if you would like to performa an overall test of whether the IQ interactions are necessary, you may find it most useful to use anova to compare a full and reduced model. Something like: ModelFit.full <-lme(mct~ IQ*age+IQ*I(age^2)+IQ*I(age^3), MyData, random=~1|ID) ModelFit.reduced <-lme(mct~ IQ + age+I(age^2)+I(age^3), MyData, random=~1|ID) anova(ModelFit.full, ModelFit.reduced, test="F") Second, you don't have the syntax right for estimable(). As described and shown by example in the manual page. The correct syntax is: library(gmodels) estimable(ModelFit, c('IQ:age'=1, 'IQ:I(age^2) '= 1, 'IQ:I(age^3)' = 1)) Note the pattern of quoted name, followed by '=', and then the value 1 (not zero). This will perform a single joint test whether these three coefficients are zero. -G On Oct 30, 2007, at 5:26PM , Gang Chen wrote: > Dieter, > > Thank you very much for the help! > > I tried both glht() in multcomp and estimable() in gmodels, but > couldn't get them work as shown below. Basically I have trouble > specifying those continuous variables. Any suggestions? > > Also it seems both glht() and estimable() would give multiple t > tests. Is there a way to obtain sort of partial F test? > > >> ModelFit<-lme(mct~ IQ*age+IQ*I(age^2)+IQ*I(age^3), MyData, > random=~1|ID) >> anova(ModelFit) > > mDF denDF F-value p-value > (Intercept) 1 257 54393.04 <.0001 > IQ 1 215 3.02 0.0839 > age 1 25746.06 <.0001 > I(age^2)1 257 8.80 0.0033 > I(age^3)1 25721.30 <.0001 > IQ:age 1 257 1.18 0.2776 > IQ:I(age^2) 1 257 0.50 0.4798 > IQ:I(age^3) 1 257 0.23 0.6284 > >> library(multcomp) >> glht(ModelFit, linfct = c("IQ:age = 0", "IQ:I(age^2) = 0", "IQ:I > (age^3) = 0")) > Error in coefs(ex[[3]]) : >cannot interpret expression 'I''age^2' as linear function > >> library(gmodels) >> estimable(ModelFit, rbind('IQ:age'=0, 'IQ:I(age^2) = 0', 'IQ:I > (age^3) = 0')) > Error in FUN(newX[, i], ...) : >`param' has no names and does not match number of coefficients of > model. Unable to construct coefficient vector > > Thanks, > Gang > > > On Oct 30, 2007, at 9:08 AM, Dieter Menne wrote: > > >> Gang Chen mail.nih.gov> writes: >> >> >>> >>> Suppose I have a mixed-effects model where yij is the jth sample for >>> the ith subject: >>> >>> yij= beta0 + beta1(age) + beta2(age^2) + beta3(age^3) + beta4(IQ) + >>> beta5(IQ^2) + beta6(age*IQ) + beta7(age^2*IQ) + beta8(age^3 *IQ) >>> +random intercepti + eij >>> >>> In R how can I get an F test against the null hypothesis of >>> beta6=beta7=beta8=0? In SAS I can run something like contrast >>> age*IQ >>> 1, age^2*IQ 1, age^3 *IQ 1, but is there anything similar in R? >>> >> >> Check packages multcomp and gmodels for contrast tests that work >> with lme. >> >> Dieter >> > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] snow and Rmpi, delayed starting-times at nodes
Hello, we use R version 2.6.0, Rmpi_0.5-5 and snow_0.2-9 and have a parallel call like this: clusterApply(cluster, input.list, function(input, data1, type) { }, data1, type ) We now have the problem, that the processes at the nodes start delayed. This means for example, node 4 starts its calculation when node 1 is finished.(see the attached figure) Therefore we have a lot of loss in our computation time. Our messages are not very big: input.list = list of vectors. Each vector has 10 strings data1 = one integer type = one string What can we do to improve the speed? Thanks Markus -- Dipl.-Tech. Math. Markus Schmidberger Ludwig-Maximilians-Universität München IBE - Institut für medizinische Informationsverarbeitung, Biometrie und Epidemiologie Marchioninistr. 15, D-81377 Muenchen URL: http://ibe.web.med.uni-muenchen.de Mail: Markus.Schmidberger [at] ibe.med.uni-muenchen.de __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R timeDate does not allow seconds?
Hello, Sorry if anyone gets this message twice, as my mailserver may not be working. Thanks for your response. Your idea makes a lot of sense to me, but I've been unable to get seconds to work. I ended up with this format finally: "2007-10-31_16:20:22" Problem is I am unable to get it recognized as a date using timeDate(): R> timeDate(as.character(inputdate),format="%Y-%02m-%02d_%02H.%02M.%02S") Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : missing value where TRUE/FALSE needed The R-help archives said something about non-standard formats casuing a problem, but I believe (short of the underscore) that its the seconds, not the delimiter that is causing the trouble. I've also been playing with zoo and its functions without much success either. The timeDate approach seems simplest. With so many date classes/methods in R, what is considered the standard way of dealing with it? I need to timezone or daylight saving stuff really, but seconds are imperative! (actually I've ended up with multiple events per second, which could cause future troubles, so msec may even be needed. Thanks, B. Bogart Following are all my attempts to get R to read seconds (with timeDate): > data[1,1] -> inputdate > inputdate [1] "2007-10-31_16:20:22" > inputdate = "2007-10-31_16.20.22" > timeDate(as.character(inputdate),format="%Y-%02m-%02d_%02H.%02M.%02S") Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : missing value where TRUE/FALSE needed > inputdate = "2007-10-31_16-20-22" > timeDate(as.character(inputdate),format="%Y-%02m-%02d_%02H-%02M-%02S") Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : missing value where TRUE/FALSE needed > inputdate = "16:20:22_2007-10-31" > timeDate(as.character(inputdate),format="%02H:%02M:%02S_%Y-%02m-%02d") Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : missing value where TRUE/FALSE needed > inputdate = "16-20-22_2007-10-31" > timeDate(as.character(inputdate),format="%02H-%02M-%02S_%Y-%02m-%02d") Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : missing value where TRUE/FALSE needed > inputdate = "16.20.22_2007-10-31" > timeDate(as.character(inputdate),format="%02H.%02M.%02S_%Y-%02m-%02d") Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : missing value where TRUE/FALSE needed > inputdate = "16/20/22 2007/10/31" > timeDate(as.character(inputdate),format="%02H/%02M/%02S %Y/%02m/%02d") Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : missing value where TRUE/FALSE needed > inputdate = "16.20.22 2007-10-31" > timeDate(as.character(inputdate),format="%02H.%02M.%02S %Y-%02m-%02d") Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : missing value where TRUE/FALSE needed __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R timeDate does not allow seconds?
Hello all, Sorry if anyone gets this message twice, as my mailserver may not be working. Thanks for your response. Your idea makes a lot of sense to me, but I've been unable to get seconds to work. I ended up with this format finally: "2007-10-31_16:20:22" Problem is I am unable to get it recognized as a date using timeDate(): R> timeDate(as.character(inputdate),format="%Y-%02m-%02d_%02H.%02M.%02S") Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : missing value where TRUE/FALSE needed The R-help archives said something about non-standard formats casuing a problem, but I believe (short of the underscore) that its the seconds, not the delimiter that is causing the trouble. I've also been playing with zoo and its functions without much success either. The timeDate approach seems simplest. With so many date classes/methods in R, what is considered the standard way of dealing with it? I need to timezone or daylight saving stuff really, but seconds are imperative! (actually I've ended up with multiple events per second, which could cause future troubles, so msec may even be needed. Thanks, B. Bogart Following are all my attempts to get R to read seconds (with timeDate): > data[1,1] -> inputdate > inputdate [1] "2007-10-31_16:20:22" > inputdate = "2007-10-31_16.20.22" > timeDate(as.character(inputdate),format="%Y-%02m-%02d_%02H.%02M.%02S") Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : missing value where TRUE/FALSE needed > inputdate = "2007-10-31_16-20-22" > timeDate(as.character(inputdate),format="%Y-%02m-%02d_%02H-%02M-%02S") Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : missing value where TRUE/FALSE needed > inputdate = "16:20:22_2007-10-31" > timeDate(as.character(inputdate),format="%02H:%02M:%02S_%Y-%02m-%02d") Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : missing value where TRUE/FALSE needed > inputdate = "16-20-22_2007-10-31" > timeDate(as.character(inputdate),format="%02H-%02M-%02S_%Y-%02m-%02d") Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : missing value where TRUE/FALSE needed > inputdate = "16.20.22_2007-10-31" > timeDate(as.character(inputdate),format="%02H.%02M.%02S_%Y-%02m-%02d") Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : missing value where TRUE/FALSE needed > inputdate = "16/20/22 2007/10/31" > timeDate(as.character(inputdate),format="%02H/%02M/%02S %Y/%02m/%02d") Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : missing value where TRUE/FALSE needed > inputdate = "16.20.22 2007-10-31" > timeDate(as.character(inputdate),format="%02H.%02M.%02S %Y-%02m-%02d") Error in if (regexpr("/", charvec[1])[[1]] > 0) return("%m/%d/%Y") : missing value where TRUE/FALSE needed __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] groups in lattice
Hello, I must be missing something very obvious. I have a dataset with consists of three groups, and for each group I would like to draw a regression line in one frame. Something like plot.a <- xyplot(result~price,data=nl, xlab="Standardized price",ylab="Outcome",groups=slice, panel=function(x,y,...){ panel.lmline(x,y,...) } ) However, only one line is drawn. If I replace panel.lmline by panel.densityplot(x,...), I do get three densityplots in the frame. What am I missing? Thanks, Ruud __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] RMySQL inserting data problem
Hello, I am trying to insert data in a data.frame into a database table using the RMySQL package m <- dbDriver("MySQL") con <- dbConnect(m, host = "blah", user = "blah", password = "blah", dbname = "blah") proid <- dbGetQuery(con, "select max(processed_data_id)+1 from processed_data") spot <- array.norm$arrayValues$spot_index name <- array.norm$arrayValues$name log <- array.norm$arrayValues$LogRatioNorm snr <- array.norm$arrayValues$snr empty <- NA insert <- data.frame(proid, spot, name, empty, empty, log, snr, empty, empty) dbWriteTable(con, "processed_data", insert, append=TRUE, row.name=FALSE) dbCommit(con) the table i am trying to insert into: CREATE TABLE `processed_data` ( `processed_data_id` int(6) unsigned NOT NULL, `data_id` int(6) unsigned NOT NULL, `feature_name` varchar(100), `channel1_signal` int(5), `channel2_signal` int(5), `log2_ratio` double(5,2), `flag` varchar(100), `chr_copy_num` double(5,2), `significance` double(7,4), PRIMARY KEY (`processed_data_id`,`data_id`) ) Can anyone explain why i am getting this error? Error: '.class1' is not implemented yet In addition: Warning message: In data.frame(proid, spot, name, empty, empty, log, snr, empty, : row names were found from a short variable and have been discarded Execution halted OS: Windows XP R: 2.6.0 MySQL: 5 Thanks, James Morris [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] structure data
Okay, what I did so far is to create a list of a list of a list... I don't know whether this makes sense... (it's just initialized... I have to change it for individual cases) What do you think about? plate.parameters <- c("param1","param2") temp <- c("mean","sd") vec <- vector("list",length(plate.parameters)) names(vec) <- plate.parameters vec[] <- list(temp) calculation.list <- list(vec,vec) names(calculation.list) <- c("group1", "group2") The term "parameter" means a measurement, e.g. param1 measures the size of objects, param2 is the measurement of the intensity of objects. Antje John Kane schrieb: > Sorry I misunderstood the question. My guess, and I'm > afraid that's all it is is that you would be best off > with a list. I suppose you might even want lists of > lists but I am not quite sure about what 'parameter' > means here. > --- Antje <[EMAIL PROTECTED]> wrote: > >> Yes, I know, that these methods might help to >> calculate but my question was >> more about how to structure the data that I can >> realize this easy computation >> afterwards. Due to the flexibility I need, I would >> like to avoid calculations I >> don't need... >> >> Antje >> >> >> John Kane schrieb: >>> Have a look at ?aggregate or the doBy library. >> They >>> may be what you want. >>> --- Antje <[EMAIL PROTECTED]> wrote: >>> Hello, I have a quite simple question, I guess. I have a data frame and I would like to process the data in several ways. The processing is dependent on grouping (factors) and the parameter itself. Meaning for parameter1 in the df, I would like to calculate the mean and sd when grouping by factor1. But parameter2 might be different. I thought of a structure like this: group1 param1 (mean, sd) param2 (sum) group2 param1 (mean, sd, median) param2 (mean, sd) I'm not sure how to build up this "processing >> info" structure. (The processing itself will be later based on this structure). Would you use a list? (matrix and vector are not >> so flexible for different length...) Can anybody help m with this? Antje __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. >>> >>> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, >> reproducible code. >> > > > > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Permutation test, grouped data
On Fri, 2 Nov 2007, Tom Backer Johnsen wrote: > I am perfectly aware that this question is not an R question, at least > not yet, but I have not succeeded in finding what I want in other > ways, so ... > > What I am looking for are two algorithms, preferabley in Pascal, but > other languages may do. For (a) systematic (complete) permutations > for grouped data with unequal group sizes, and (b) random permutations > for the same kind of data. The "coin" package might be of help here. Option (b) is always possible, (a) might be very slow depending on the size of your data set and the type of test statistic you are evaluating. See vignette("LegoCondInf", package = "coin") to get started. hth, Z > I know of one source: E. S. Edgington > (1980): Randomization Tests (program 4.1 and program 4.3), but those > are written in Fortran with a lot of GO TO's which probably would not > be very efficient even if I managed to manually these programs and do > a correct translation. There must be some more modern ones around, > but where? > > I need the algorithms for a program I have written for exploring > structural balance in sociometric group structures. > > Tom > > ++ > | Tom Backer Johnsen, Psychometrics Unit, Faculty of Psychology | > | University of Bergen, Christies gt. 12, N-5015 Bergen, NORWAY | > | Tel : +47-5558-9185Fax : +47-5558-9879 | > | Email : [EMAIL PROTECTED]URL : http://www.galton.uib.no/ | > ++ > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] structure data
Sorry I misunderstood the question. My guess, and I'm afraid that's all it is is that you would be best off with a list. I suppose you might even want lists of lists but I am not quite sure about what 'parameter' means here. --- Antje <[EMAIL PROTECTED]> wrote: > Yes, I know, that these methods might help to > calculate but my question was > more about how to structure the data that I can > realize this easy computation > afterwards. Due to the flexibility I need, I would > like to avoid calculations I > don't need... > > Antje > > > John Kane schrieb: > > Have a look at ?aggregate or the doBy library. > They > > may be what you want. > > --- Antje <[EMAIL PROTECTED]> wrote: > > > >> Hello, > >> > >> I have a quite simple question, I guess. I have a > >> data frame and I would like > >> to process the data in several ways. > >> The processing is dependent on grouping (factors) > >> and the parameter itself. > >> Meaning for parameter1 in the df, I would like to > >> calculate the mean and sd > >> when grouping by factor1. But parameter2 might be > >> different. I thought of a > >> structure like this: > >> > >> group1 > >> param1 (mean, sd) > >> param2 (sum) > >> > >> group2 > >> param1 (mean, sd, median) > >> param2 (mean, sd) > >> > >> I'm not sure how to build up this "processing > info" > >> structure. (The processing > >> itself will be later based on this structure). > >> Would you use a list? (matrix and vector are not > so > >> flexible for different > >> length...) > >> > >> Can anybody help m with this? > >> > >> Antje > >> > >> __ > >> R-help@r-project.org mailing list > >> https://stat.ethz.ch/mailman/listinfo/r-help > >> PLEASE do read the posting guide > >> http://www.R-project.org/posting-guide.html > >> and provide commented, minimal, self-contained, > >> reproducible code. > >> > > > > > > > > > > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Permutation test, grouped data
Hi [EMAIL PROTECTED] napsal dne 02.11.2007 15:16:37: > I am perfectly aware that this question is not an R question, at least > not yet, but I have not succeeded in finding what I want in other > ways, so ... > > What I am looking for are two algorithms, preferabley in Pascal, but > other languages may do. For (a) systematic (complete) permutations > for grouped data with unequal group sizes, and (b) random permutations > for the same kind of data. I know of one source: E. S. Edgington I am not sure if it is what you want but lll <- lapply(split(some vector, group vector), function(x) sample(1:length(x))) gives you a list of systematic permutation of the first vector in each group and you can use it for subsetting your data. for (i in no.of.groups) split(data, group vector)[[i]] [lll[[i]],] Random permutation (if I understand correctly) can be constructed by not exhaustive sampling so you can limit number of samples by size argument to sample function. Regards Petr > (1980): Randomization Tests (program 4.1 and program 4.3), but those > are written in Fortran with a lot of GO TO's which probably would not > be very efficient even if I managed to manually these programs and do > a correct translation. There must be some more modern ones around, > but where? > > I need the algorithms for a program I have written for exploring > structural balance in sociometric group structures. > > Tom > > ++ > | Tom Backer Johnsen, Psychometrics Unit, Faculty of Psychology | > | University of Bergen, Christies gt. 12, N-5015 Bergen, NORWAY | > | Tel : +47-5558-9185Fax : +47-5558-9879 | > | Email : [EMAIL PROTECTED]URL : http://www.galton.uib.no/ | > ++ > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] subsetting problem with multiple criteria: Works in some but not all cases.
Thank you Jim. That seems to work perfectly. I had looked at %in% and apparently misunderstood what it would do. Is there any place where I can read on the various %XX% functions? --- jim holtman <[EMAIL PROTECTED]> wrote: > I think the problem is with your use of "==" instead > of "%in%"; try > > matching <- subset(mydata[,c(j+1,j+7)], mydata[,j+1] > %in% lone.word) > > > > On 11/1/07, John Kane <[EMAIL PROTECTED]> wrote: > > I am trying to compare some word lists which have > an > > associate set of numbers. I want to compare word > list > > aa with bb and find only those words which are > > unique to bb, then compare bb with cc, etc. > > > > I thought that I should be able to do this by > using > > setdiff to get the unique words and then subset > the > > data frame to get the unique names and > corresponding > > numbers but I am misunderstanding something. > > > > When I run the code below a) I get lots of warning > and > > b) I get the correct results for 4 of the 5 > > comparisons. However the comparison of three with > > four (cc,dd) gives me an empty subset. > > > > Can anyone point out my error or suggest a better > way > > to do this? > > Thanks > > > > > > > > > mydata = data.frame(aa = Cs(cat, dog, horse, > cow), > > bb = c("mouse", "dog", "cow", "pigeon"), > > cc =c("emu", "rat", "crow", "cow"), > > dd = c("cow", "camel", "manatee", "parrot") , > > ee = c( "coat", "hat", "dog", "camel") , > > ff = c("knife","dog", "cow", "pigeon"), > > ann = c(1,2,3,4), > > bnn = c(5,6,7,8), > > cnn = c(9,10,11,12), > > dnn = c(13,14,15,16), > > enn = c(17,18,19,20), > > fnn = c(21,22,23,24)) > > > > wordnames <- c("word", "number") > > word.list <- rep(vector("list", 1), 5) > > > > for(j in 1:5) { > > lone.word <- setdiff(mydata[,j+1],mydata[,j]); > > lone.word > > matching <- subset(mydata[,c(j+1,j+7)], > > mydata[,j+1]==lone.word); matching > > word.list[[j]] <- matching; > names(word.list[[j]])<- > > wordnames > > } > > word.list > > > > > = > > R version 2.6.0 (2007-10-03) > > i386-pc-mingw32 > > > > locale: > > > LC_COLLATE=English_Canada.1252;LC_CTYPE=English_Canada.1252;LC_MONETARY=English_Canada.1252;LC_NUMERIC=C;LC_TIME=English_Canada.1252 > > > > attached base packages: > > [1] stats graphics grDevices utils > datasets > > methods base > > > > other attached packages: > > [1] Hmisc_3.4-2 gdata_2.3.1 > > > > loaded via a namespace (and not attached): > > [1] cluster_1.11.9 grid_2.6.0 gtools_2.4.0 > > lattice_0.17-1 > > > > > > R version 2.6.0 (2007-10-03) > > i386-pc-mingw32 > > > > locale: > > > LC_COLLATE=English_Canada.1252;LC_CTYPE=English_Canada.1252;LC_MONETARY=English_Canada.1252;LC_NUMERIC=C;LC_TIME=English_Canada.1252 > > > > attached base packages: > > [1] stats graphics grDevices utils > datasets > > methods base > > > > other attached packages: > > [1] Hmisc_3.4-2 gdata_2.3.1 > > > > loaded via a namespace (and not attached): > > [1] cluster_1.11.9 grid_2.6.0 gtools_2.4.0 > > lattice_0.17-1 > > > > __ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, > reproducible code. > > > > > -- > Jim Holtman > Cincinnati, OH > +1 513 646 9390 > > What is the problem you are trying to solve? > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] GLS with nlme
Hello All, This is my third time attempting to post this message. I don't see it in the archive, so I'm guessing it is not getting through. If I am wrong, my apologies. I am trying to do a GLS regression, (X'V^-1X)^-1X'V^-1y, using the gls() function from the nlme package. I have the covariance matrix V. I have been searching for a way to specify the correlation structure using V, and have had little luck. I have found a few other messages from people who have had the same problem. Is there a way to do this? If it requires building my own corStruct, where can I look for information to do this? Thanks, John. -- = John Janmaat, Assistant Professor of Economics IK Barber School of Arts and Sciences (Unit 6) University of British Columbia Okanagan University Way, Kelowna, BC, V1V 1V7 Canada __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rcmdr Plugin and menus.txt
Dear Haris, First, there's nothing wrong (at least that I can see) with your menu file, although I would consider using the activation field to determine whether the menu items should be activated or "grayed out" in the current context. The problem you encountered is a bug in the Commander() function that, apparently, didn't surface before because no one previously tried to define a submenu of a top-level menu introduced by a plug-in package, as opposed to a new top-level menu or a submenu of one of the standard Rcmdr top-level menus. Briefly, the expression Menus[, "menuOrItem"] == line[1, "menuOrItem"], which is meant to determine where the submenu is to be "cascaded" under its parent menu, should read Menus[, "commandOrMenu"] == line[1, "menuOrItem"]. I've now fixed this bug. I intend to upload a new version (1.3-6) of the Rcmdr package, which addresses several small problems, to CRAN soon, probably later today. Thanks for bringing this bug to my attention. John John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox > -Original Message- > From: Charilaos Skiadas [mailto:[EMAIL PROTECTED] > Sent: Friday, November 02, 2007 12:31 AM > To: John Fox > Cc: 'R-help help' > Subject: Re: [R] Rcmdr Plugin and menus.txt > > Thanks John, no hurry. > > I tried to debug it a little bit, without much success. Two things I > discovered: > 1) The exact same lines work just fine if I place them in the > Rcmdr- menus.txt file in the Rcmdr package (and add the > "testOne" function > also.) > 2) While trying to do debug(Commander), the thing I noticed > is that, when reading items from the menus.txt file, the > function seems to process them in the opposite order. So it > starts from the last item and moves up (well, I don't know if > it would move up since it crashes in the absence of the > psychMenu object). It seems the problem might be with the line: > Menus <- addMenus(Menus) > When examining Menus, I noticed that my new commands were > added at the beginning of the Menus data frame, and in a > messed up order: > > Browse[1]> Menus[1:20,1:3] > type menuOrItem operationOrParent > 8item psychMenu cascade > 1menu psychMenu topMenu > 4menu testTwoMenu psychMenu > 5item testTwoMenu command > 6item testTwoMenu command > 7item testTwoMenu command > 2item psychMenu command > 2100 menufileMenu topMenu > 3itemfileMenu command > 410 itemfileMenu command > 510 itemfileMenu command > 610 itemfileMenu command > 710 itemfileMenu command > 810 itemfileMenu command > 9itemfileMenu command > 10 menuexitMenu fileMenu > 11 itemexitMenu command > 12 itemexitMenu command > 13 itemfileMenu cascade > 14 item topMenu cascade > > > I would hazard to guess that the problem is with the call > "Menus <- insertRows(Menus, line, where)" in line 866 of > Rcmdr. But at that point things got a bit too "technical" for > me. Hope this helps narrow the problem down a bit. > > Thanks for the preprint. It is nicely written, though it > didn't shed any light on this problem. > > Haris Skiadas > Department of Mathematics and Computer Science Hanover College > > On Nov 1, 2007, at 3:32 PM, John Fox wrote: > > > Dear Haris, > > > > I'll take a look at this as soon as I have a chance, probably not > > until tomorrow. In the meantime I've attached a "preprint" of an > > article that describes how to write plug-ins. Perhaps > you'll find that > > helpful. > > (I don't > > know whether it will go through r-help, but you should receive the > > direct > > email.) > > > > Regards, > > John > > > > > > John Fox, Professor > > Department of Sociology > > McMaster University > > Hamilton, Ontario > > Canada L8S 4M4 > > 905-525-9140x23604 > > http://socserv.mcmaster.ca/jfox > > > > > >> -Original Message- > >> From: [EMAIL PROTECTED] > >> [mailto:[EMAIL PROTECTED] On Behalf Of > Charilaos Skiadas > >> Sent: Thursday, November 01, 2007 2:53 PM > >> To: R-help help > >> Subject: [R] Rcmdr Plugin and menus.txt > >> > >> Hi all, > >> > >>I'm trying to write a plugin for R Commander, following > the model of > > > >> the TeachingDemos plugin. I am struggling trying to even > add items by > >> editing the menus.txt file. I would welcome any help from > anyone who > >> has messed with it. > >> Essentially the problem I am having is: I cannot create a > submenu to > >> a newly created menu. Here is what the menus.txt file looks like: > >> > >> # typemenu/item operation/parent
[R] Odp: question on the 'stats' package
Hi [EMAIL PROTECTED] napsal dne 02.11.2007 15:11:28: > I can't find the 'stats'- package, has it changed name? Where can I find the > na.omit() function if not in 'stats'? On my computer it is installed in library folder named stats. What about yours? It shall be installed together with base R. Regards Petr > > Thank you in advance > > David > >[[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] add histograms or distributions on regression line
If you go to the source code area of the page and click on one of the icons to get the source code for that graph. The code looks a bit complex for me to figure out quickly , but it may give you a start on how to approach it. --- Chang jun xiang <[EMAIL PROTECTED]> wrote: > hello, does anyone know how to add histograms or > distributions > on regression like just like quantiles regression in > RGraphGallery > below, a very > delicate codes. Thanks alot. > > http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=109 > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] question on the 'stats' package
It's now part of the base (or default) installation. Do library() and you will see that it is already installed (and search() will show you that it is automatically loaded). --- david csongor <[EMAIL PROTECTED]> wrote: > I can't find the 'stats'- package, has it changed > name? Where can I find the > na.omit() function if not in 'stats'? > > Thank you in advance > > David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] textplot() in gplots causes problems (0x9)
Hi Jonas, You are correct that manually setting cex won't entirely remove the warning messages (note: these are *warnings* not *errors*). It will reduce them greatly, from, perhaps 40, down to 3 or so. Since the tab character won't be properly displayed anyway, you can use gsub or similar to replace it with a space. EG: pdf(file="C:/...", paper="a4", width=8, height=12) .model <- lm(.model.formula, data=database) text <- capture.output(summary(.model)) text <- gsub('\t',' ', text) textplot(, valign="top", halign="left") dev.off() As the inclusion of tab characters seems likely to be a problem for mony people, I've just added code the gplots::textplot() that will replace all occurences of tab with an appropriate number of spaces before attempting to compute text heigh or width. This will be part of the next release of gplots, which should show up on CRAN shortly. -Greg On Nov 1, 2007, at 2:18PM , Jonas Malmros wrote: > Dear Gregory, > > How can I avoid using tab character when all I want to do is to print > a model summary on my pdf device using textplot()? > How do I set the font size? If you mean using cex inside textplot, > then it does not work. Whether cex is 1 or 0.2 I get the same result, > exemplified here: > > Call: > lm(formula =...) > Resuduals: > ... > > Coefficients Estimate > (intercept)1.32 > ...... > ...... > > Std.Error t-value > (Intercept)0.2 0.1 > ......... > ......... > > Pr(>|t|) > (intercept) 0.01 > ...... > ...... > > −−− > Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > Residual standard error: 1.748... > > > Is there no solution to this problem? > I am using Vista, R2.6.0 patched, RWinEdt. > > textplot(capture.output(summary(.model)), valign="top", > halign="left", cex=0.5) > > Thanks in advance, > Jonas > > On 11/1/07, Gregory Warnes <[EMAIL PROTECTED]> wrote: >> Hi Jonas, >> >> By default, textplot() attempts to automatically select a font size >> that is 'just big enough, but not too big'. It does this by a >> binary- >> search approach where it sets a font size, then asks R to compute the >> actual width of the text to be displayed (without actually displaying >> it), then increases or decreases the font size appropriately until it >> finds the largest font that doesn't extend beyond the plot region >> vertically or horizontally. It appears that on your system, R >> doesn't know how wide a tab character is. This isn't particularly >> surprising since tab characters vary in width depending on the >> context. >> >> There are two simple solutions. First, avoid using characters R >> can't figure out sizes for (i.e. tab), or manually specify the font >> size so textplot() doesn't attempt to optimize it. >> >> I personally choose the former, avoid tab characters, since the >> appropriate font size varies greatly by device. >> >> -Greg >> >> On Oct 31, 2007, at 3:22PM , Jonas Malmros wrote: >> >>> Hello, >>> >>> I am using textplot function in gplots package to put some model >>> output inside a PDF file, but it does not seem to work properly with >>> PDF. >>> >>> I am doing follwing: >>> pdf(file="C:/...", paper="a4", width=8, height=12) >>> .model <- lm(.model.formula, data=database) >>> textplot(capture.output(summary(.model)), valign="top", >>> halign="left") >>> >>> I am getting these error messages: >>> >>> Warning messages: >>> 1: In FUN(c("C", "a", "l", "l", ":", "l", "m", "(", "f", "o", >>> "r", : >>> font width unknown for character 0x9 >>> 2: In strwidth(object, cex = cex) : font width unknown for >>> character 0x9 >>> 3: In FUN(c("C", "a", "l", "l", ":", "l", "m", "(", "f", "o", >>> "r", : >>> font width unknown for character 0x9 >>> 4: In strwidth(object, cex = cex) : font width unknown for >>> character 0x9 >>> 5: In FUN(c("C", "a", "l", "l", ":", "l", "m", "(", "f", "o", >>> "r", : >>> font width unknown for character 0x9 >>> 6: In strwidth(object, cex = cex) : font width unknown for >>> character 0x9 >>> 7: In text.default(x = xpos, y = ypos, labels = object, adj = c >>> (0, : >>> font width unknown for character 0x9 >>> 8: In text.default(x = xpos, y = ypos, labels = object, adj = c >>> (0, : >>> font width unknown for character 0x9 >>> >>> This is a tab character that causes problems, I guess. Is there any >>> way to solve this? >>> >>> Thank you in advance >>> >>> -- >>> Jonas Malmros >>> Stockholm University >>> Stockholm, Sweden >>> >>> __ >>> R-help@r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-help >>> PLEASE do read the posting guide http://www.R-project.org/posting- >>> guide.html >>> and provide commented, minimal, self-contained, reproducible code. >> >> > > > -- > Jonas Malmros > Stockholm University > Stockholm, Sweden > > __
[R] Permutation test, grouped data
I am perfectly aware that this question is not an R question, at least not yet, but I have not succeeded in finding what I want in other ways, so ... What I am looking for are two algorithms, preferabley in Pascal, but other languages may do. For (a) systematic (complete) permutations for grouped data with unequal group sizes, and (b) random permutations for the same kind of data. I know of one source: E. S. Edgington (1980): Randomization Tests (program 4.1 and program 4.3), but those are written in Fortran with a lot of GO TO's which probably would not be very efficient even if I managed to manually these programs and do a correct translation. There must be some more modern ones around, but where? I need the algorithms for a program I have written for exploring structural balance in sociometric group structures. Tom ++ | Tom Backer Johnsen, Psychometrics Unit, Faculty of Psychology | | University of Bergen, Christies gt. 12, N-5015 Bergen, NORWAY | | Tel : +47-5558-9185Fax : +47-5558-9879 | | Email : [EMAIL PROTECTED]URL : http://www.galton.uib.no/ | ++ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to see source code of nnet package
Hi, I am working on a project which needs a multinomial logit regression. So I want to reference the code of multinom in nnet package. I found nnet package is no longer in the CRAN list. But I cannot find the source code in R Core source code package either. Anyone knows how to see the source code of nnet? Luo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] question on the 'stats' package
I can't find the 'stats'- package, has it changed name? Where can I find the na.omit() function if not in 'stats'? Thank you in advance David [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] add histograms or distributions on regression line
hello, does anyone know how to add histograms or distributions on regression like just like quantiles regression in RGraphGallery below, a very delicate codes. Thanks alot. http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=109 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] A question about lme object
Hi, I have a question about the lme function in R. My question is: After I got the object from function lme, why the numIter value of the object is always NULL? Following is my code: jjww<-lme(y~x*zz,data=simul,random=~x|group, control=lmeControl(returnObject=TRUE)) attributes(jjww) jjww$numIter the first 20 observation of data simul are: > simul yx zz group 11.20722846 0.173024384 0.13729258 1 21.44590474 -0.811427991 0.13729258 1 30.18967259 -1.089059105 0.13729258 1 40.85942246 -0.078540820 0.13729258 1 51.10809195 0.140017015 0.13729258 1 61.11560752 1.334947568 0.13729258 1 70.69795732 -0.808299003 0.13729258 1 81.01416595 -1.138901175 0.13729258 1 92.17401880 1.006853317 0.13729258 1 10 0.86281233 -0.591130178 0.13729258 1 11 1.56318651 1.109186912 0.04474967 2 12 0.59594587 2.283456245 0.04474967 2 13 1.22106867 -0.447186704 0.04474967 2 14 1.31123646 0.785552336 0.04474967 2 15 1.25252110 -1.804849152 0.04474967 2 16 0.70395020 -1.128826194 0.04474967 2 17 0.75879178 0.721015450 0.04474967 2 18 3.33620547 0.036974202 0.04474967 2 19 0.54923851 -0.281621023 0.04474967 2 20 0.14961209 -0.973109765 0.04474967 2 Is there any control option to show this jjww$numIter ? Why is it always NULL? Did anyone ever get a non-NULL value of it? I am really confused by this. Thank you for any help. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] list to Matrix - remove NAs von list.
Another alternative: do.call('cbind', l[!sapply(l, function(x)all(is.na(x)))]) On 11/2/07, Petr PIKAL <[EMAIL PROTECTED]> wrote: > Hi > > [EMAIL PROTECTED] napsal dne 02.11.2007 12:00:09: > > > Thanks, > > > > I have the case that there is a NA in the list. This should not be a > column. > > But na.omit(l) does not work for lists. How to remove NAs from a list? > > > > l <- list(c(1,2,3),NA,c(1,2,3)) > > mat <- do.call(cbind, l) > > If number of NA is not big you can use > > mat[,which(!is.na(colSums(mat)))] > > to select non NA columns. > > Regards > Petr > > > > > Best > > Markus > > > > > > Dimitris Rizopoulos schrieb: > > > you can use do.call(), e.g., > > > > > > do.call(cbind, l) > > > > > > > > > I hope it helps. > > > > > > Best, > > > Dimitris > > > > > > > > > > > > Dimitris Rizopoulos > > > Ph.D. Student > > > Biostatistical Centre > > > School of Public Health > > > Catholic University of Leuven > > > > > > Address: Kapucijnenvoer 35, Leuven, Belgium > > > Tel: +32/(0)16/336899 > > > Fax: +32/(0)16/337015 > > > Web: http://med.kuleuven.be/biostat/ > > > http://www.student.kuleuven.be/~m0390867/dimitris.htm > > > > > > > > > Quoting Markus Schmidberger <[EMAIL PROTECTED]>: > > > > > >> Hello, > > >> > > >> I have a list of vectors (all the same length). How to convert the > list > > >> to a matrix? Each vector should be a column. > > >> I tried this: > > >> > > >> l <- list(c(1,2,3),c(1,2,3),c(1,2,3)) > > >> mat <- matrix( unlist(l), nrow=length(l) ) > > >> > > >> But I think this is not very efficient. Is there a better solution? > > >> > > >> Thanks > > >> Markus > > >> > > >> -- > > >> Dipl.-Tech. Math. Markus Schmidberger > > >> > > >> Ludwig-Maximilians-Universität München > > >> IBE - Institut für medizinische Informationsverarbeitung, > > >> Biometrie und Epidemiologie > > >> Marchioninistr. 15, D-81377 Muenchen > > >> URL: http://ibe.web.med.uni-muenchen.de > > >> Mail: Markus.Schmidberger [at] ibe.med.uni-muenchen.de > > >> > > >> __ > > >> R-help@r-project.org mailing list > > >> https://stat.ethz.ch/mailman/listinfo/r-help > > >> PLEASE do read the posting guide > > >> http://www.R-project.org/posting-guide.html > > >> and provide commented, minimal, self-contained, reproducible code. > > >> > > >> > > > > > > > > > > > > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm > > > > > > > > > -- > > Dipl.-Tech. Math. Markus Schmidberger > > > > Ludwig-Maximilians-Universität München > > IBE - Institut für medizinische Informationsverarbeitung, > > Biometrie und Epidemiologie > > Marchioninistr. 15, D-81377 Muenchen > > URL: http://ibe.web.med.uni-muenchen.de > > Mail: Markus.Schmidberger [at] ibe.med.uni-muenchen.de > > Tel: +49 (089) 7095 - 4599 > > > > __ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] correct wording and notation for R stuff in LaTex
If you are free to format your references to packages and functions as you please, you might follow the convention used by the Journal of Statistical Software. you can do this by adding the following to your latex file: \newcommand{\pkg}[1]{{\normalfont\fontseries{b}\selectfont #1}} \let\proglang=\textsf \let\code=\texttt then you can refer to R as \proglang{R}, to packages with e.g., \pkg{packagename} and to functions/other code as \code{functionname}. On Thu, 1 Nov 2007, Edna Bell wrote: > Hi R Gurus: > > I'm putting together an article about some R stuff in Latex. > > I refer to packages and functions. > > I think that I use {\em} for packages and {\tt} for functions. > > Is that correct, please? > > Thank you in advance! > Sincerely, > Edna Bell > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cluster analysis
AMINA SHAHZADI, The eternal question. What I do is that I generate a range of solutions, profile them on variables used to cluster the data into groups and any other information I have to profile the cluster groups on and then present the solutions to a group of others to assess meaningfulness, debate on the solutions and attempt to reach a consensus etc In many cases, eg, for algorithms based on k-means and hierarchical clustering, you are using an exploratory technique and there are no right/wrong answers to this Having used cluster analysis for years some things to look at because there is no way to answer this statistically (unless you are using a latent class type model with goodness of fit measures) are the following 1. What is the minimum size you believe to be robust for a single cluster (eg n=30, n=100) etc because the larger the number of clusters you generate relative to sample size, the smaller your clusters will be and there must be a cut-off point defined upon which you are not prepared to go any lower... 2. If you run the clusters through different algorithms, how comparable are the results (cluster stability) 2. What differences emerge between 2, 3, 4 cluster solutions etc (as you utilise larger numbers of clusters, does this still produce a meaningful result in that the clusters are distinct and unique, or are you just cutting larger clusters into smaller clusters without generating unique and usable information... Examine the clusters via a series of cross tabs (as you go from 2 to 3 to 4 cluster solutions) what happens to the members within clusters, are they distributed differently etc Thanks Paul - Original Message - From: "amna khan" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, November 02, 2007 2:19 AM Subject: [R] cluster analysis > Hi Sir > > How can we select the optimum number of clusters? > > Best Regards > > -- > AMINA SHAHZADI > Department of Statistics > GC University Lahore, Pakistan. > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R and Debian Linux
Thanks, Dirk and Christopher, for helpful comments about Debian. I'll perhaps follow up some of the major points later, but meanwhile a couple of minor comments: On 02-Nov-07 03:14:34, Dirk Eddelbuettel wrote: >| I've been to the CRAN section which deals with precompiled >| Debian binaries: >| >| http://www.stats.bris.ac.uk/R/bin/linux/debian/ >| >| When I follow the advice: >| >| "Simply add something like >| >| deb http:///bin/linux/debian stable/ > > Works for me. You did replace with something > like cran.uk.r-project.org, right? Oh yes I did! >| to the file /etc/apt/sources.list on your computer and >| install as usual." >| [...] >| [BTW, I'm trying these out as guests in virtual machines, >| using virtualbox, which seems to me to run very well] > > [ I heard there were some NAT/networking issues to go 'both ways' > towards the hosted systems? ] As I recall, I did encounter something of the sort, but worked round it by choosing a bridged connection (i.e. choose "Host Adaptor" rather than "NAT" in the Network dialogue box when setting up the VM). Best wishes, Ted. E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 02-Nov-07 Time: 12:08:42 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] useR! 2008 - last call for tutorial proposals
As most of you already know from a previous announcement, the R user conference useR! 2008 is scheduled for August 12-14, 2008, and will take place at the University of Dortmund. PRE-CONFERENCE TUTORIALS Before the official program, half-day tutorials will be offered on Monday, August 11th. We invite R users to submit proposals for three hour tutorials on special topics on R. The proposals should give a brief description of the tutorial, including goals, detailed outline, justification why the tutorial is important, background knowledge required and potential attendees. This is the last call for submitting proposals for pre-conference tutorials to [EMAIL PROTECTED] The proposals should be sent before 2007-11-09. A web page offering more information on the `useR!' conference is available at http://www.R-project.org/useR-2008 We hope to meet you in Dortmund! The conference committee: Uwe Ligges (conference), Achim Zeileis (program), Claus Weihs, Gerd Kopp (local organization), Friedrich Leisch, Torsten Hothorn ___ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-announce __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] list to Matrix - remove NAs von list.
Hi [EMAIL PROTECTED] napsal dne 02.11.2007 12:00:09: > Thanks, > > I have the case that there is a NA in the list. This should not be a column. > But na.omit(l) does not work for lists. How to remove NAs from a list? > > l <- list(c(1,2,3),NA,c(1,2,3)) > mat <- do.call(cbind, l) If number of NA is not big you can use mat[,which(!is.na(colSums(mat)))] to select non NA columns. Regards Petr > > Best > Markus > > > Dimitris Rizopoulos schrieb: > > you can use do.call(), e.g., > > > > do.call(cbind, l) > > > > > > I hope it helps. > > > > Best, > > Dimitris > > > > > > > > Dimitris Rizopoulos > > Ph.D. Student > > Biostatistical Centre > > School of Public Health > > Catholic University of Leuven > > > > Address: Kapucijnenvoer 35, Leuven, Belgium > > Tel: +32/(0)16/336899 > > Fax: +32/(0)16/337015 > > Web: http://med.kuleuven.be/biostat/ > > http://www.student.kuleuven.be/~m0390867/dimitris.htm > > > > > > Quoting Markus Schmidberger <[EMAIL PROTECTED]>: > > > >> Hello, > >> > >> I have a list of vectors (all the same length). How to convert the list > >> to a matrix? Each vector should be a column. > >> I tried this: > >> > >> l <- list(c(1,2,3),c(1,2,3),c(1,2,3)) > >> mat <- matrix( unlist(l), nrow=length(l) ) > >> > >> But I think this is not very efficient. Is there a better solution? > >> > >> Thanks > >> Markus > >> > >> -- > >> Dipl.-Tech. Math. Markus Schmidberger > >> > >> Ludwig-Maximilians-Universität München > >> IBE - Institut für medizinische Informationsverarbeitung, > >> Biometrie und Epidemiologie > >> Marchioninistr. 15, D-81377 Muenchen > >> URL: http://ibe.web.med.uni-muenchen.de > >> Mail: Markus.Schmidberger [at] ibe.med.uni-muenchen.de > >> > >> __ > >> R-help@r-project.org mailing list > >> https://stat.ethz.ch/mailman/listinfo/r-help > >> PLEASE do read the posting guide > >> http://www.R-project.org/posting-guide.html > >> and provide commented, minimal, self-contained, reproducible code. > >> > >> > > > > > > > > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm > > > > > -- > Dipl.-Tech. Math. Markus Schmidberger > > Ludwig-Maximilians-Universität München > IBE - Institut für medizinische Informationsverarbeitung, > Biometrie und Epidemiologie > Marchioninistr. 15, D-81377 Muenchen > URL: http://ibe.web.med.uni-muenchen.de > Mail: Markus.Schmidberger [at] ibe.med.uni-muenchen.de > Tel: +49 (089) 7095 - 4599 > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R News, volume 7, issue 2 is now available (fwd)
Dear useRs, The October 2007 issue of R News is now available on CRAN under the Documentation/Newsletter link. Torsten (on behalf of the R News Editorial Board) ___ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-announce __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] list to Matrix - remove NAs von list.
Thanks, I have the case that there is a NA in the list. This should not be a column. But na.omit(l) does not work for lists. How to remove NAs from a list? l <- list(c(1,2,3),NA,c(1,2,3)) mat <- do.call(cbind, l) Best Markus Dimitris Rizopoulos schrieb: > you can use do.call(), e.g., > > do.call(cbind, l) > > > I hope it helps. > > Best, > Dimitris > > > > Dimitris Rizopoulos > Ph.D. Student > Biostatistical Centre > School of Public Health > Catholic University of Leuven > > Address: Kapucijnenvoer 35, Leuven, Belgium > Tel: +32/(0)16/336899 > Fax: +32/(0)16/337015 > Web: http://med.kuleuven.be/biostat/ > http://www.student.kuleuven.be/~m0390867/dimitris.htm > > > Quoting Markus Schmidberger <[EMAIL PROTECTED]>: > >> Hello, >> >> I have a list of vectors (all the same length). How to convert the list >> to a matrix? Each vector should be a column. >> I tried this: >> >> l <- list(c(1,2,3),c(1,2,3),c(1,2,3)) >> mat <- matrix( unlist(l), nrow=length(l) ) >> >> But I think this is not very efficient. Is there a better solution? >> >> Thanks >> Markus >> >> -- >> Dipl.-Tech. Math. Markus Schmidberger >> >> Ludwig-Maximilians-Universität München >> IBE - Institut für medizinische Informationsverarbeitung, >> Biometrie und Epidemiologie >> Marchioninistr. 15, D-81377 Muenchen >> URL: http://ibe.web.med.uni-muenchen.de >> Mail: Markus.Schmidberger [at] ibe.med.uni-muenchen.de >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> >> > > > > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm > -- Dipl.-Tech. Math. Markus Schmidberger Ludwig-Maximilians-Universität München IBE - Institut für medizinische Informationsverarbeitung, Biometrie und Epidemiologie Marchioninistr. 15, D-81377 Muenchen URL: http://ibe.web.med.uni-muenchen.de Mail: Markus.Schmidberger [at] ibe.med.uni-muenchen.de Tel: +49 (089) 7095 - 4599 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] correct wording and notation for R stuff in LaTex
Edna Bell wrote: > Hi R Gurus: > > I'm putting together an article about some R stuff in Latex. > > I refer to packages and functions. > > I think that I use {\em} for packages and {\tt} for functions. > > Is that correct, please? > I think that decision depends on the editorial policies of whoever publishes the article. That's not the style used in the R man pages, though: they use the "Rd.sty" style which displays \pkg{foo} in bold. Functions are entered as \code{function} which displays using \texttt (which is the same as \tt). Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sweave, and long lasting scripts
John Lande wrote: >Dear R user, > >I am using Sweave to write my reports with R code. Unlucly my code take a >lot of time to run, and I don't want to run it multiple time, if possible, >as I am still developping the tools. > >It seems that a sweave run does not save the enviroment at the end of the >process, is there a way to avoid to lunch multiple time the same commands? >maybe it could be possible to store chunck of code results, and only call >them in the next runs. > >thank you > > [[alternative HTML version deleted]] > >__ >R-help@r-project.org mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. > > > > Hi, the package 'cacheSweave' seems to fulfil your needs. Regards, Thibaut. -- ## Thibaut JOMBART CNRS UMR 5558 - Laboratoire de Biométrie et Biologie Evolutive Universite Lyon 1 43 bd du 11 novembre 1918 69622 Villeurbanne Cedex Tél. : 04.72.43.29.35 Fax : 04.72.43.13.88 [EMAIL PROTECTED] http://lbbe.univ-lyon1.fr/-Jombart-Thibaut-.html?lang=en http://pbil.univ-lyon1.fr/software/adegenet/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Significance-Problems by using arma/xreg.
Hello. I've got a problem with arma/xreg. I would like to get a better model-fit by implenting some external explanatory variable, so I thought I can implement it by expand the arima-function with an xreg-argument: I have two stationary data vectors y and x of length 201: y <- c(0.935179888,1.099621832,1.020898987,1.031344228,1.027391172,1.034505855,0.959332043,0.999752242,1.004620032,0.969349882,1.010151201,0.974301527,1.058661595,1.032034174,1.020128405,1.000758017,1.017398344,1.006926293,0.954573759,0.912570705,0.993454547,0.960713389,1.027295127,0.995625881,1.02888089,1.05868054,1.025135985,0.983689928,0.977666211,1.033050026,1.070297717,1.055212067,1.001620248,1.06201233,1.016039772,1.059151318,0.999619963,0.978265714,1.003551008,1.038852232,1.003853711,0.931504415,1.011551463,1.034393251,0.979243349,0.961356801,1.016681954,0.99742985,0.99585959,1.021858043,0.950953391,0.992069175,1.043981733,1.027189331,1.028031541,1.026104981,1.007044244,0.958918846,1.015058862,1.032371312,1.047557049,1.023094437,1.018833668,1.01794437,0.998617914,1.014458993,0.98650118,1.008316971,1.021940613,1.037733207,1.023986962,1.032680308,1.040029784,1.077245266,1.051874866,0.994617226,1.071775398,1.041365904,1.116389765,1.007126301,0.965002025,1.008483662,0.9376974 23,1.080747815,1.036386401,1.068025896,1.074249575,1.066970225,1.029237043,1.059636508,1.049193923,0.898242066,0.88055395,0.915056333,1.111661117,0.984215305,1.08026099,0.964886598,0.984195395,1.062223756,1.006178862,1.015801476,1.031825467,0.952920137,1.020232779,1.002160906,1.087572591,1.098203044,1.088168142,1.088072929,1.038249248,0.94145,0.975751618,1.001879383,1.39815,1.004595563,0.972723737,0.956462279,1.013833761,0.950975235,1.012593537,0.985065601,0.915567548,1.007776297,1.032322747,0.978860939,0.969294333,0.931093948,0.805394349,1.045132388,1.081325659,1.025201369,1.015122585,0.950157172,1.087620665,0.976754838,0.949992181,0.896406385,0.903831694,0.921309592,0.876027456,0.918654899,1.087475731,0.966178682,0.937122162,0.893733464,0.953978817,1.120225353,1.04744569,1.087787877,1.049306954,1.033114009,1.017399342,0.99771273,1.064031766,1.038724562,1.054450603,0.996763573,0.964837672,1.029435663,0.958467792,1.030312893,0.974192282,0.96820758,1.039717729,1.0137 38116,1.036718789,1.026219201,1.007127177,1.023149744,1.002913274,0.985405566,1.008323957,1.055354704,1.034441194,1.033791899,1.012247037,1.001147328,1.028412101,1.049214295,1.028235375,1.048874205,1.0172136,1.025299806,0.972678258,0.940044158,1.017990071,1.027910044,1.026206501,1.04411013,1.033659239,1.019456171,1.030796339,1.032959973,0.970032892,1.079233429,1.047625007,1.038579427,1.001825177,0.946100153,1.023421071) x <- c(0.843804619,0.81249,1.057153783,1.068547061,1.007688519,0.984935385,1.070326884,0.994289004,1.008939789,1.07920373,0.913105667,0.842313012,0.991385522,1.020596578,1.001696836,1.06490116,1.033601729,1.033260373,0.906021767,0.94919521,1.024513681,1.022911562,1.016074142,0.939601243,0.980500442,1.079063626,1.020919744,0.962612204,0.99764207,0.980969191,0.986671938,0.984204592,0.917354746,1.047323206,0.949749294,0.908443537,1.06111898,0.962441576,0.975565628,1.10586813,1.037744031,1.017285312,1.012603559,0.955810436,0.933142446,1.015373747,1.056386834,0.946937596,1.012555766,1.013192504,0.931135355,1.076147444,1.003227606,0.938365382,0.908528184,1.05649444,1.049612935,0.933005343,1.048182893,1.081632421,1.010049416,1.011438851,1.111503119,1.073132407,0.932876478,0.960196781,1.044582733,1.03257335,1.12047871,1.083561826,0.931820644,1.072323341,1.023595603,0.924593929,0.929668552,0.925557281,1.078269046,0.937313743,1.08932839,1.035980076,0.964569239,1.056003096,0.951810007, 0.918737676,0.904073477,0.924992625,0.93747407,1.026039573,1.037892279,0.858471814,0.992776547,0.980882083,1.066402634,0.915575389,0.892538964,0.882616323,1.53935517,0.892538806,1.182789262,1.202119514,0.989003579,1.016869919,1.200128461,1.08544116,1.103910082,0.995096846,1.078868434,1.013355185,1.004245292,1.056434414,0.970341177,0.813083841,1.166037232,1.125484036,0.952783835,1.013106352,1.058511007,0.916114704,1.052831832,0.825974554,1.044062559,1.054390391,0.879116652,1.027194579,1.08125758,0.960119687,0.891430256,1.091730189,1.009407287,0.797141697,0.897504867,0.999806228,1.02736344,1.028560276,1.17642998,1.098050149,1.019933455,0.989679148,1.110110079,1.020327239,1.068935624,0.97001492,0.902092245,1.183570569,1.148048114,1.065934928,0.937034066,0.819825088,1.104389823,1.076696571,0.999734094,1.032719089,0.913750574,1.137961141,0.971786203,1.088615577,1.077240451,0.989154108,1.056669276,0.976247339,1.120540772,0.946601662,1.097869386,1.110057599,1.014249285,1.177967919 ,0.900747935,0.948066021,1.099763088,1.013614774,1.18432281,0.957559484,0.920055921,1.070607603,1.047189976,1.135872668,0.98039627,0.912237783,0.925643197,1.035440003,1.130888,0.942834705,1.037805665,1.155771185,1.033555401,0.973283749,1.077421329,1.003980233,0.840553552,0.924517299,1.038194855,1.090539934,0.845375213,1.078466887,
Re: [R] thicker axis in levelplot
Deepayan, You are a star - thank you that worked perfectly! Many thanks, Jenny On 11/1/07, Jenny Barnes <[EMAIL PROTECTED]> wrote: > Thank you for your reply - I'm afriad that just doesn't work, any other > suggestions or is there something I need to do WITH this command to make it > work? > > I really am stuck on this one and would appreciate any help offered, Does this work for you? levelplot(z~x*y, grid, cuts=50, scales=list(log="e"), xlab="", par.settings = list(axis.line=list(lwd=4))) -Deepayan ~~ Jennifer Barnes PhD student: long range drought prediction Climate Extremes Group Department of Space and Climate Physics University College London Holmbury St Mary Dorking, Surrey, RH5 6NT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Sweave, and long lasting scripts
Dear R user, I am using Sweave to write my reports with R code. Unlucly my code take a lot of time to run, and I don't want to run it multiple time, if possible, as I am still developping the tools. It seems that a sweave run does not save the enviroment at the end of the process, is there a way to avoid to lunch multiple time the same commands? maybe it could be possible to store chunck of code results, and only call them in the next runs. thank you [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] list to Matrix
you can use do.call(), e.g., do.call(cbind, l) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm Quoting Markus Schmidberger <[EMAIL PROTECTED]>: > Hello, > > I have a list of vectors (all the same length). How to convert the list > to a matrix? Each vector should be a column. > I tried this: > > l <- list(c(1,2,3),c(1,2,3),c(1,2,3)) > mat <- matrix( unlist(l), nrow=length(l) ) > > But I think this is not very efficient. Is there a better solution? > > Thanks > Markus > > -- > Dipl.-Tech. Math. Markus Schmidberger > > Ludwig-Maximilians-Universität München > IBE - Institut für medizinische Informationsverarbeitung, > Biometrie und Epidemiologie > Marchioninistr. 15, D-81377 Muenchen > URL: http://ibe.web.med.uni-muenchen.de > Mail: Markus.Schmidberger [at] ibe.med.uni-muenchen.de > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Shading area under PDF of t -distribution
try this: curve(dt(x, 74), from = -4, to = 4) x <- seq(-1.96, 1.96, len = 100) y <- dt(x, 74) polygon(c(x[1], x, x[100]), c(dt(-4, 74), y, dt(4, 74)), col = "red", border = NA) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm Quoting Chung-hong Chan <[EMAIL PROTECTED]>: > Dear R experts, > > I have plot the PDF of t distribution with df = 74. > curve(dt(x,df=74),from=-4, to=4) > > how can I shade the area under curve (for example, col="red") from > t=+- 1.996? > > Thank you. > Regards, > CH > > -- > CH Chan > Research Assistant - KWH > http://www.macgrass.com > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] function over variables in a list
Hello R-users I nowhere red in tutorials neither in r-help how to access one variable in multiple list objects. p.e i have list of 50 Length Class Mode [1,] 16 data.frame list and i want to check for the max in column 16 of all list objects: I tried max(mylist[[]][,16]) or max(mylist[[1:50]][,16]) suggestions? Thanks a lot for your help Marc -- Pt! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] list to Matrix
Hello, I have a list of vectors (all the same length). How to convert the list to a matrix? Each vector should be a column. I tried this: l <- list(c(1,2,3),c(1,2,3),c(1,2,3)) mat <- matrix( unlist(l), nrow=length(l) ) But I think this is not very efficient. Is there a better solution? Thanks Markus -- Dipl.-Tech. Math. Markus Schmidberger Ludwig-Maximilians-Universität München IBE - Institut für medizinische Informationsverarbeitung, Biometrie und Epidemiologie Marchioninistr. 15, D-81377 Muenchen URL: http://ibe.web.med.uni-muenchen.de Mail: Markus.Schmidberger [at] ibe.med.uni-muenchen.de __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Shading area under PDF of t -distribution
Chung-hong Chan gmail.com> writes: > I have plot the PDF of t distribution with df = 74. > curve(dt(x,df=74),from=-4, to=4) > > how can I shade the area under curve (for example, col="red") from t=+- 1.996? If you could used lattice plots instead, below is a modified version of the standard lattice densityplot. You can use it with a call like: densityplot(form, data=DHL, shadelimit=shadelimit, panel=panel.shadeddensityplot, shadecol='#FFEECC') I am sure Deepayan will have a more elegant solution, but this worked for me. Dieter -- # Densityplot with limits panel.shadeddensityplot = function (x, darg = list(n = 100), plot.points = "jitter", ref = FALSE, groups = NULL, jitter.amount = 0.01 * diff(current.panel.limits()$ylim), type = "p",shadelimit=0, shadecol="red", ...) { x=na.omit(x) if (ref) { reference.line <- trellis.par.get("reference.line") panel.abline(h = 0, col = reference.line$col, lty = reference.line$lty, lwd = reference.line$lwd) } plot.line <- trellis.par.get("plot.line") superpose.line <- trellis.par.get("superpose.line") if (!is.null(groups)) { panel.superpose(x, darg = darg, plot.points = plot.points, ref = FALSE, groups = groups, panel.groups = panel.densityplot, jitter.amount = jitter.amount, type = type, ...) } else { if (sum(!is.na(x)) > 1) { h <- do.call("density", c(list(x = x), darg)) lim <- current.panel.limits()$xlim id <- h$x > min(lim) & h$x < max(lim) panel.lines(x = h$x[id], y = h$y[id], ...) idp = h$x> min(lim) & h$x < shadelimit xp = h$x[idp] xp = c(xp[1],xp,xp[length(xp)]) yp = h$y[idp] yp = c(0,yp,0) panel.polygon(x = xp, y = yp,col=shadecol, ...) grid.text(x=0.01,y=0.99,default.units="npc", gp=gpar(fontsize=10),label= paste("n = ",length(x[x<=shadelimit]),"/",length(x),sep=""), just=c("left","top")) } switch(as.character(plot.points), "TRUE" = panel.xyplot(x = x, y = rep(0, length(x)), type = type, ...), rug = panel.rug(x = x, start = 0, end = 0, x.units = c("npc", "native"), type = type, ...), jitter = panel.xyplot(x = x, y = jitter(rep(0, length(x)), amount = jitter.amount), type = type, ...)) } } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] coef se in lme
Thank you very much for the reply (and hopefully I am replying back in the proper way). Do you think the delta method would be an acceptable way to estimate approximate confidence intervals for the resulting group specific coefficients (combining fixed effects and BLUPS)? Regarding the MCMC related approach, how is it possible to save the fixed and the random effects from the MCMC chain? Can this be implemented through nlme library or is there some more clear cut way (I wish I had a strong statistical background and abilities but... :)) to evaluate the empirical distribution of a parameter that is linear combination of these quantities? All the best, Irene Από: [EMAIL PROTECTED] εκ μέρους Douglas Bates Αποστολή: Τετ 17/10/2007 10:04 μμ Προς: Doran, Harold Κοιν.: Irene Mantzouni; [EMAIL PROTECTED]; R-SIG-Mixed-Models Θέμα: Re: [R] coef se in lme On 10/15/07, Doran, Harold <[EMAIL PROTECTED]> wrote: > ?vcov The vcov method returns the estimated variance-covariance matrix of the fixed-effects only. I think Irene's question is about the combination of the fixed-effects parameters and the BLUPs of the random effects that is returned by the coef method applied to an lmer object. (You may recall that you were the person who requested such a method in lme4 like the coef method in nlme :-) On the face of it this quantity should be easy to define and evaluate but in fact it is not easy to do so because these are combinations of model parameters (the fixed effects) and unobserved random variables (the random effects). It gets a bit tricky trying to decide what the variance of this combination would be. I think there is a sensible definition, or at least a computationally reasonable definition, but there are still a few slippery points in the argument. Lately I have taken to referring to the "estimates" of the random effects, what are sometimes called the BLUPs or Best Linear Unbiased Predictors, as the "conditional modes" of the random effects. That is, they are the values that maximize the density of the random effects given the observed data and the values of the model parameters. For a linear mixed model the conditional distribution of the random effects is multivariate normal so the conditional modes are also the conditional means. Also, we can evaluate the conditional variance-covariance matrix of the random effects up to a scale factor. The next part is where things get a bit hazy for me but I think it makes sense to consider the joint distribution of the estimator of the fixed-effects parameters and the random effects conditional on the data and, possibly, on the variance components. Conditional on the relative variance-covariance of the random effects (i.e. the matrix that occurs as the penalty term in the penalized least squares representation of the model) the joint distribution of the fixed-effects estimators and the random effects is multivariate normal with mean and variance-covariance matrix determined from the mixed-model equations. This big (p+q by p+q, where p is the dimension of the fixed effects and q is the dimension of the random effects) variance-covariance matrix could be evaluated and, from that, the variance of any linear combination of components. However, I have my doubts about whether it is the most sensible answer to evaluate. Conditioning on the relative variance-covariance matrix of the random effects is cheating, in a way. It would be like saying we have a known variance, $\sigma^2$ when, in fact, we are using an estimate. The fact that we don't know $\sigma^2$ is what gives rise to the t distributions and F distributions in linear models and we are all trained to pay careful attention to the number of degrees of freedom in that estimate and how it affects our ideas of the precision of the estimates of other model parameters. For mixed models, though, many practioners are quite comfortable conditioning on the value of some of the variance components but not others. It could turn out that conditioning on the relative variance-covariance of the random effects is not a big deal but I don't know. I haven't examined it in detail and I don't know of others who have. Another approach entirely is to use Markov chain Monte Carlo to examine the joint distribution of the parameters (in the Bayesian sense) and the random effects. If you save the fixed effects and the random effects from the MCMC chain then you can evaluate the linear combination of interest throughout the chain and get an empirical distribution of the quantities returned by coef. This is probably an unsatisfactory answer for Irene who may have wanted something quick and simple. Unfortunately, I don't think there is a quick, simple answer here. I suggest we move this discussion to the R-SIG-Mixed-Models list which I am cc:ing on this reply. > -Original Message- > From: [EMAIL PROTECTED] on behalf of Irene Mantzouni > Sent: Mon 10/15/2007 3:20 PM >
Re: [R] structure data
Yes, I know, that these methods might help to calculate but my question was more about how to structure the data that I can realize this easy computation afterwards. Due to the flexibility I need, I would like to avoid calculations I don't need... Antje John Kane schrieb: > Have a look at ?aggregate or the doBy library. They > may be what you want. > --- Antje <[EMAIL PROTECTED]> wrote: > >> Hello, >> >> I have a quite simple question, I guess. I have a >> data frame and I would like >> to process the data in several ways. >> The processing is dependent on grouping (factors) >> and the parameter itself. >> Meaning for parameter1 in the df, I would like to >> calculate the mean and sd >> when grouping by factor1. But parameter2 might be >> different. I thought of a >> structure like this: >> >> group1 >> param1 (mean, sd) >> param2 (sum) >> >> group2 >> param1 (mean, sd, median) >> param2 (mean, sd) >> >> I'm not sure how to build up this "processing info" >> structure. (The processing >> itself will be later based on this structure). >> Would you use a list? (matrix and vector are not so >> flexible for different >> length...) >> >> Can anybody help m with this? >> >> Antje >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, >> reproducible code. >> > > > > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.