Re: [R] Creating tables with std errors beneath estimates
Brian Quinif bquinif at gmail.com writes: What I need to do is make tables with the std. errors beneath the estimates in parentheses (standard econ style). How can I make a dataframe with that format? Best prepare the output in R as strings; there are alternatives in LaTeX, but it can be more work. r = data.frame(dollar = runif(10), stddollar=(abs(runif(10 r1 = data.frame(dollarstd = as.character(sprintf(%4.2f (% 4.2f),r$dollar,r$stddollar))) If you don't like the rather C-ish sprintf, you can use format(C) instead. Dieter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] for bclust in package e1071
Linda Lei wrote: Hi All, Could you please help with the error I get from the following codes? Library(cluster) data(iris) bc1 - bclust(iris[,2:5], 3, base.method=clara, base.centers=5) Then I got: Committee Member: 1(1)(2)(3)(4)(5)(6)(7)(8)(9)(10)(11)(12)(13)(14)(15)(16)(17)(18)(19)(20) Error in bclust(iris[, 2:5], 3, base.method = clara, base.centers = 5): Could not find valid cluster solution in 20 replications I don't quite understand what the error means here and how to fix it? You cannot use clara() with bclust(). The cluster function must accept an argument centers in order to work. Uwe Ligges Thank you! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] New behavior in estimable(), bug or feature?
CG Pettersson cg.pettersson at evp.slu.se writes: Fitting and reducing a first model for grain yield went smoothly. When I wanted to look at the fixed effects with estimable() I got an error message claiming that I was using the wrong variable names, estimable wanted the variable names in the form usually given by fixed.effects(). ... What is happening? Is there a new namecheck in estimable acting a little over-enthusiastic or what? Yes, estimable has change that it accepts parameter NAMES now, and this might collide with some implicit typecasting: Docs: If cm is a vector, it should contained named elements each of which gives the coefficient to be applied to the corresponding parameter. Since you did not provide a runnable example, I cannot check in detail what was wrong. Dieter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] simple if statement
I am ashamed to be asking this question, but I couldn't find the solution anywhere. Searching for if and R is not very productive... I cannot get a simple if statement to work. I have data on college students. I want to make a string variable that has the names of the years. That is, when the year variable i is equal to 1, I want to have a variable called years equal to Freshmen. I tried this years - Freshmen if i==1 years - Sophomores if i==2 and so on, but I couldn't get it to work. How can I get this variable to work? Thanks, BQ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] cclust causes R to crash when using manhattan kmeans
Dear R users, When I run the following code, R crashes: require(cclust) x - matrix(c(0,0,0,1.5,1,-1), ncol=2, byrow=TRUE) cclust(x, centers=x[2:3,], dist=manhattan, method=kmeans) While this works: cclust(x, centers=x[2:3,], dist=euclidean, method=kmeans) I'm posting this here because I am not sure if it is a bug. I've been searching for a manhattan kmeans method and I found a solution by using the package amap: require(amap) Kmeans(x, x[2:3,], method=manhattan) This works for me, so I don't need the cclust package anymore. Anyway, I wanted to report the cclust behaviour. R version 2.2.1, 2005-12-20, i386-pc-mingw32 Cheers, Timo -- Timo Becker Phonetics Austrian Academy of Sciences Acoustics Research Institute __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] simple if statement
How about the following, if you really want characters or just leave as factor i - round(runif(10, 1, 4)) years - as.character(factor(i, labels = c(Freshman, Sophomore, Junior, Senior))) HTH, ken __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R CMD check for packages in a bundle
Hi everyone What you are trying to do does work, I do it all the time, but there are a few details to work out. Because of the above differences I actually generate the DESCRIPTION* files from my Makefile, differently depending on the target. I do too. Having a DESCRIPTION.in is irrelevant: having a Contains: line in DESCRIPTION is the test used. Can we please read the posting guide and not use R-help for 'questions and discussion about code development in R' which is the description of the R-devel list. The posting guide appears to be ambiguous here. If anything, it said to me that R-help was the appropriate list, being The ‘main’ R mailing list, for discussion about problems and solutions using R to solve problems while Questions likely to prompt discussion unintelligible to non- programmers or topics that are too technical for R-help's audience should go to R-devel. I would have said that my bundle problem fell in the first category and not the second: I use the package management features of R to solve problems---and there's no C / C++ in the question. I was just in some confusion about the status of DESCRIPTION.in, which doesn't really count as code development, IMO. Hence R-help. Can we make the which list section of the posting guide more explicit here? I have a similar dilemma for many posts. -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] simple if statement
Hi Ken, Thanks for the help, but I should have mentioned that I want to do this within a loop. Perhaps it would be better for me to explain my exact situation. I am running two loops so that I can calculate estimates for years 1,2,3,4 and a categorical GPA variable that takes on three values 0,1,2 with only one set of commands. Within the two loops I want to make LaTeX tables with the estimates. I want to create a caption with some thing like Low GPA Freshmen (Low GPA corresponds to 0) and so on for each table generated by the loops. The year variable is called uga.yr and the GPA variable is c.gpa Do you know of a good way to do that? Right now I have this command: #Generate LaTeX output of table latex(Estimates, file=paste(i, j, tex, sep = .), caption=paste(i, j ,sep = .), ctable=TRUE, rowlabel='',digits=3) i is the variable for the loop for the years j is the variable for the loop for the gpa Right now I get tables with captions that say 1.0 (for example) whereas I would like them to say Low GPA Freshmen Thanks, BQ 2006/4/7, Ken Knoblauch [EMAIL PROTECTED]: How about the following, if you really want characters or just leave as factor i - round(runif(10, 1, 4)) years - as.character(factor(i, labels = c(Freshman, Sophomore, Junior, Senior))) HTH, ken __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] simple if statement
On Fri, 7 Apr 2006, Brian Quinif wrote: I am ashamed to be asking this question, but I couldn't find the solution anywhere. Searching for if and R is not very productive... I cannot get a simple if statement to work. I have data on college students. I want to make a string variable that has the names of the years. That is, when the year variable i is equal to 1, I want to have a variable called years equal to Freshmen. I tried this years - Freshmen if i==1 years - Sophomores if i==2 and so on, but I couldn't get it to work. How can I get this variable to work? Most simply: years - c(Freshmen, Sophomores)[i] What you seem to be trying to do can be written if(i == 1) years - Freshmen if(i == 2) years - Sophomores but then 'years' is undefined if !i %in% c(1,2). Better ways to program that are years - switch(i, Freshmen, Sophomores) (which gives NULL otherwise) or years - if(i == 1) Freshmen elseif(i == 2) Sophomores else unknown of (vectorized) years - ifelse(i == 1, Freshmen, ifelse(i == 2, Sophomores, unknown)) But the first solution is both vectorized and simple. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] cclust causes R to crash when using manhattan kmeans
On Fri, 07 Apr 2006 09:02:46 +0200, Timo Becker (TB) wrote: Dear R users, When I run the following code, R crashes: require(cclust) x - matrix(c(0,0,0,1.5,1,-1), ncol=2, byrow=TRUE) cclust(x, centers=x[2:3,], dist=manhattan, method=kmeans) While this works: cclust(x, centers=x[2:3,], dist=euclidean, method=kmeans) I'm posting this here because I am not sure if it is a bug. I've been searching for a manhattan kmeans method and I found a solution by using the package amap: require(amap) Kmeans(x, x[2:3,], method=manhattan) This works for me, so I don't need the cclust package anymore. Anyway, I wanted to report the cclust behaviour. R version 2.2.1, 2005-12-20, i386-pc-mingw32 Thanks, this is indeed a bug, and has not been noticed yet because it seems to apply only for very small data sets like your example, for larger data sets it seems to works fine: R require(cclust) Loading required package: cclust [1] TRUE R x=matrix(rnorm(100), ncol=2) R cclust(x, centers=x[2:3,], dist=manhattan, method=kmeans) Clustering on Training Set Number of Clusters: 2 Sizes of Clusters: 33 17 Algorithm converged after 4 iterations. Changes: 12 3 1 1 2 side notes: * cclust is no longer actively maintained, the code has been integrated in my more general package flexclust, see also http://www.ci.tuwien.ac.at/~leisch/papers/Leisch-2006.pdf (but cclust in flexclust has the same bug, so thanks a lot for reporting it). * r-help is not really the correct place to report bugs, please try to contact the package maintainer first, or use r-devel (but only if the maintainer does not respond to a direct email). This is not because we want to hide bugs from the public, but simply to reduce traffic on the lists. Best, Fritz -- --- Prof. Dr. Friedrich Leisch Institut für Statistik Tel: (+49 89) 2180 3165 Ludwig-Maximilians-Universität Fax: (+49 89) 2180 5308 Ludwigstraße 33 D-80539 München http://www.ci.tuwien.ac.at/~leisch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] cclust causes R to crash when using manhattan kmeans
Timo Becker wrote: Dear R users, When I run the following code, R crashes: require(cclust) x - matrix(c(0,0,0,1.5,1,-1), ncol=2, byrow=TRUE) cclust(x, centers=x[2:3,], dist=manhattan, method=kmeans) While this works: cclust(x, centers=x[2:3,], dist=euclidean, method=kmeans) I'm posting this here because I am not sure if it is a bug. I've been searching for a manhattan kmeans method and I found a solution by using the package amap: require(amap) Kmeans(x, x[2:3,], method=manhattan) This works for me, so I don't need the cclust package anymore. Anyway, I wanted to report the cclust behaviour. Please report it to its mainatiner (CCing). Uwe Ligges R version 2.2.1, 2005-12-20, i386-pc-mingw32 Cheers, Timo __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] partitioning cluster function
On Wed, 5 Apr 2006 12:58:00 -0700, Linda Lei (LL) wrote: Hi All, For the function bclust(e1071), the argument base.method is explained as must be the name of a partitioning cluster function returning a list with the same components as the return value of 'kmeans'. In my understanding, there are three partitioning cluster functions in R, which are clara, pam, fanny. Then I check each of them to see which of them can get same components as the return value of kmeans, by using the following codes: The functions in the cluster package will not work, because they have different interface (names of arguments and return values). cclust from the package of the same name can be used together with kmeans, but note that that is no longer actively maintained (see my email to r-help from a few minutes ago). Best, Fritz -- --- Prof. Dr. Friedrich Leisch Institut für Statistik Tel: (+49 89) 2180 3165 Ludwig-Maximilians-Universität Fax: (+49 89) 2180 5308 Ludwigstraße 33 D-80539 München http://www.ci.tuwien.ac.at/~leisch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] problem with statetable function in msm
Vassily Shvets wrote: Just a note to say if you use msm you may find that statetable returns an incorrect statetable: you can then build an incorrect model and not even know that statetable was the villain. shfets __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html If you think there is a bug in msm, the mainatiner is probably interested in fixing it. So it would be a good idea to ask him (the maintainer) kindly if there is a problem and you should provide a reproducible example that shows the error or even better provide a suggestion fo a fix. Telling the world that you *think* there is a bug in some package without any further information (such as an reproducible example) is certainly not the way to go! You could also say the sofware product X returns incorrect results. This is probably true for most software products I know, including R. Uwe Ligges __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] simple if statement
On Fri, Apr 07, 2006 at 02:58:00AM -0400, Brian Quinif wrote: I have data on college students. I want to make a string variable that has the names of the years. That is, when the year variable i is equal to 1, I want to have a variable called years equal to Freshmen. I tried this years - Freshmen if i==1 years - Sophomores if i==2 What you are looking for is not an if clause but logical indexing: years[years==Freshmen] - 1 years[years==Sophomores] - 2 Of course it's still a character vector so you will have to do years = as.numeric(years) Have a look at the manual (Introduciotn to R) for more details. Another question is what you have in mind. To me it looks like what you are trying to do is make a factor on your own. Maybe this is what you want: factor(years) or maybe factor(years, levels=c(Freshmen, Sophomores)) if you want more control over the coding. cu Philipp -- Dr. Philipp PagelTel. +49-8161-71 2131 Dept. of Genome Oriented Bioinformatics Fax. +49-8161-71 2186 Technical University of Munich Science Center Weihenstephan 85350 Freising, Germany and Institute for Bioinformatics / MIPS Tel. +49-89-3187 3675 GSF - National Research Center Fax. +49-89-3187 3585 for Environment and Health Ingolstädter Landstrasse 1 85764 Neuherberg, Germany http://mips.gsf.de/staff/pagel __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] simple if statement
On Fri, Apr 07, 2006 at 09:55:47AM +0200, Philipp Pagel wrote: On Fri, Apr 07, 2006 at 02:58:00AM -0400, Brian Quinif wrote: I tried this years - Freshmen if i==1 years - Sophomores if i==2 What you are looking for is not an if clause but logical indexing: years[years==Freshmen] - 1 years[years==Sophomores] - 2 [...] OK - I'll have to comment myself: I misread your message and it does not make sense for you question. Others have given good answers in the meantime... cu Philipp -- Dr. Philipp PagelTel. +49-8161-71 2131 Dept. of Genome Oriented Bioinformatics Fax. +49-8161-71 2186 Technical University of Munich Science Center Weihenstephan 85350 Freising, Germany and Institute for Bioinformatics / MIPS Tel. +49-89-3187 3675 GSF - National Research Center Fax. +49-89-3187 3585 for Environment and Health Ingolstädter Landstrasse 1 85764 Neuherberg, Germany http://mips.gsf.de/staff/pagel __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] rpart.predict error--subscript out of bounds
Leon wrote: Hi, I am using rpart to do leave one out cross validation, but met some problem, Data is a data frame, the first column is the subject id, the second column is the group id, and the rest columns are numerical variables, Data[1:5,1:10] sub.id group.id X3262.345 X3277.402 X3369.036 X3439.895 X3886.935 X3939.054 X3953.777 X3970.352 1 32613 HAM_TSP 417.7082 430.4895 619.4776 720.8246 1048.1290 374.4598 770.4653 646.8712 2 32616 HAM_TSP 2553.5913 1113.4997 225.5340 274.5644 1105.7908 363.4623 2380.1872 784.9196 3 32617 HAM_TSP 291.6596 314.7322 238.3287 315.8305 982.6276 299.5855 1059.1140 540.8592 4 32628 HAM_TSP 456.9504 508.2278 552.3632 719.9989 1306.6299 446.6184 1352.9955 867.4219 5 32629 HAM_TSP 898.8879 640.2680 342.5477 386.5816 811.6709 518.0244 715.9886 441.1622 Example, I use the first sample as test set, the rest as training set fit - rpart(as.factor(Data[-1,2]) ~., Data[-1, -c(1:2 ) ], minbucket=2 ) predict(fit, Data[1,],type='prob') Error in predict.rpart(fit, Data[1, ]) : subscript out of bounds rpart has only seen one class so far, hence the tree consists of the root only. Uwe Ligges but when I changes the parameter of type into 'class' it works well predict(fit, Data[1,-c(1:2)],type='class') [1] HTLV_Carrier Levels: HAM_TSP HTLV_Carrier Leukemia Normal Could anyone tell me what is the problem with it? Thanks very much in advance! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] cclust causes R to crash when using manhattan kmeans
Uwe Ligges schrieb: Timo Becker wrote: Dear R users, When I run the following code, R crashes: require(cclust) x - matrix(c(0,0,0,1.5,1,-1), ncol=2, byrow=TRUE) cclust(x, centers=x[2:3,], dist=manhattan, method=kmeans) While this works: cclust(x, centers=x[2:3,], dist=euclidean, method=kmeans) I'm posting this here because I am not sure if it is a bug. I've been searching for a manhattan kmeans method and I found a solution by using the package amap: require(amap) Kmeans(x, x[2:3,], method=manhattan) This works for me, so I don't need the cclust package anymore. Anyway, I wanted to report the cclust behaviour. Please report it to its mainatiner (CCing). Uwe Ligges I've already done that on February, 17th, but got no reply. Perhaps my mail was caught by a spam filter. Another explanation could be that as [EMAIL PROTECTED] wrote: * cclust is no longer actively maintained, the code has been integrated in my more general package flexclust, see also http://www.ci.tuwien.ac.at/~leisch/papers/Leisch-2006.pdf (but cclust in flexclust has the same bug, so thanks a lot for reporting it). Because of this and because I did not know if it really is a bug (in this case I should have posted it to the R-bugs mailing list) I posted it here. Greetings, Timo R version 2.2.1, 2005-12-20, i386-pc-mingw32 Cheers, Timo -- Timo Becker Phonetics Austrian Academy of Sciences Acoustics Research Institute __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] documenting s4 methods in package
Why do some functions build chm help and others do not? Is there something in the .Rd file that specifies this? Thanks, Steve -Original Message- From: Duncan Murdoch [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 04, 2006 2:22 PM To: Steven Lacey Cc: 'Thomas Lumley'; r-help@stat.math.ethz.ch Subject: Re: [R] documenting s4 methods in package On 4/4/2006 1:58 PM, Steven Lacey wrote: Thomas, Correction! If I remove the \seealso line the missing ~~fun~~ disppears (thank you!), but now chm appears at the end of the line decribing the help page building. Most lines do not have that, only text htm1 latex example. What does the chm signify and how does one get rid of it? chm indicates that you have built a compiled HTML version of your man page. It will be shown in Windows if you ask for help after options(chmhelp=TRUE). You can edit the MkRules file to disable production of this kind of help page. Duncan Murdoch Thanks, Steve -Original Message- From: Steven Lacey [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 04, 2006 1:54 PM To: 'Thomas Lumley' Cc: 'r-help@stat.math.ethz.ch' Subject: RE: [R] documenting s4 methods in package Thomas, If I delete the \seealso section, I still get the same strange behavior. Shouldn't removing that line fix the problem? Thanks, Steve -Original Message- From: Thomas Lumley [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 04, 2006 10:13 AM To: Steven Lacey Cc: r-help@stat.math.ethz.ch Subject: Re: [R] documenting s4 methods in package On Tue, 4 Apr 2006, Steven Lacey wrote: Hi, I have written a package that contains many s4 generic functions and associated methods. I am having a lot of trouble getting R to build the help pages for these generic functions without reporting, missing link(s): ~~fun~~, which means that it cannot find the appropriate function when code in the example section of the help is run. Right? No. It means that you still have \link{~~fun~~} in the \seealso section. -thomas After some playing around I can get it to build the help without missing a link, but often I am not sure what I have done to correct the problem and it takes a lot of time. For instance, I had the package build the help without missing a function link. I then added a argument to two different functions and updated the corresponding .rd help files and now when R build the help pages it reports missing link(s): ~~fun~~. What is going on? Below is the code from the help file and the associated s4 method. Any help would be greatly appreciated. Steve GENERIC FUNCTION AND METHODS setGeneric(getRemovedDf.OAD,function(x,y,z,simplify=TRUE,descrip=FA L SE){st andardGeneric(getRemovedDf.OAD)}) setMethod(getRemovedDf.OAD,status.or.rm.v1, function(x,y,z,simplify,descrip){ if(length(0[EMAIL PROTECTED]) mailto:[EMAIL PROTECTED]) 0){ pred - unlist(lapply([EMAIL PROTECTED],function(x)x[1])) resp - unlist(lapply([EMAIL PROTECTED],function(x)x[2])) out - data.frame(pred,resp) names(out) - c(y,z) return(out) } else { return(data.frame()) } } ) setMethod(getRemovedDf.OAD,sa, function(x,y,z,simplify,descrip){ i - unlist(lapply([EMAIL PROTECTED],function(x)length([EMAIL PROTECTED]))) if(all(i==0)){ return(list()) } else { if(simplify) [EMAIL PROTECTED](along=i)[i==0]] mailto:[EMAIL PROTECTED](along=i)[i==0]]-NULL -NULL tmp - lapply([EMAIL PROTECTED],getRemovedDf.OAD,[EMAIL PROTECTED],[EMAIL PROTECTED]) if(descrip){ f - as.data.frame(descrip[!history%in%names([EMAIL PROTECTED])]) return(lapply(tmp,function(x)cbind(f,x))) } else { return(tmp) } } } ) MAN FILE \name{getRemovedDf.OAD} \alias{getRemovedDf.OAD} %- Also NEED an '\alias' for EACH other topic documented here. \title{ ~~function to do ... ~~ } \description{ ~~ A concise (1-5 lines) description of what the function does. ~~ } \usage{ getRemovedDf.OAD(x, y, z, simplify = TRUE, descrip=FALSE) } %- maybe also 'usage' for other objects documented here. \arguments{ \item{x}{ ~~Describe \code{x} here~~ } \item{y}{ ~~Describe \code{y} here~~ } \item{z}{ ~~Describe \code{z} here~~ } \item{simplify}{ ~~Describe \code{simplify} here~~ } \item{descrip}{ ~~Describe \code{descrip} here~~ } } \details{ ~~ If necessary, more details than the __description__ above ~~ } \value{ ~Describe the value returned If it is a LIST, use \item{comp1 }{Description of 'comp1'} \item{comp2 }{Description of 'comp2'} ... } \references{ ~put references to the literature/web site here ~ } \author{ ~~who you are~~ } \note{ ~~further notes~~ } ~Make other sections like Warning with \section{Warning }{} ~ \seealso{ ~~objects to See
Re: [R] documenting s4 methods in package
On 4/7/2006 6:03 AM, Steven Lacey wrote: Why do some functions build chm help and others do not? Is there something in the .Rd file that specifies this? They all build it (if you have the appropriate variable defined in the makefile). The difference is that other formats are redone with every build, while chm is only redone when the file changes. This is because the other formats don't save intermediate files; they need to be processed anew each time. This is really an r-devel question. If you want to continue discussion, please move it there. Duncan Murdoch Thanks, Steve -Original Message- From: Duncan Murdoch [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 04, 2006 2:22 PM To: Steven Lacey Cc: 'Thomas Lumley'; r-help@stat.math.ethz.ch Subject: Re: [R] documenting s4 methods in package On 4/4/2006 1:58 PM, Steven Lacey wrote: Thomas, Correction! If I remove the \seealso line the missing ~~fun~~ disppears (thank you!), but now chm appears at the end of the line decribing the help page building. Most lines do not have that, only text htm1 latex example. What does the chm signify and how does one get rid of it? chm indicates that you have built a compiled HTML version of your man page. It will be shown in Windows if you ask for help after options(chmhelp=TRUE). You can edit the MkRules file to disable production of this kind of help page. Duncan Murdoch Thanks, Steve -Original Message- From: Steven Lacey [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 04, 2006 1:54 PM To: 'Thomas Lumley' Cc: 'r-help@stat.math.ethz.ch' Subject: RE: [R] documenting s4 methods in package Thomas, If I delete the \seealso section, I still get the same strange behavior. Shouldn't removing that line fix the problem? Thanks, Steve -Original Message- From: Thomas Lumley [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 04, 2006 10:13 AM To: Steven Lacey Cc: r-help@stat.math.ethz.ch Subject: Re: [R] documenting s4 methods in package On Tue, 4 Apr 2006, Steven Lacey wrote: Hi, I have written a package that contains many s4 generic functions and associated methods. I am having a lot of trouble getting R to build the help pages for these generic functions without reporting, missing link(s): ~~fun~~, which means that it cannot find the appropriate function when code in the example section of the help is run. Right? No. It means that you still have \link{~~fun~~} in the \seealso section. -thomas After some playing around I can get it to build the help without missing a link, but often I am not sure what I have done to correct the problem and it takes a lot of time. For instance, I had the package build the help without missing a function link. I then added a argument to two different functions and updated the corresponding .rd help files and now when R build the help pages it reports missing link(s): ~~fun~~. What is going on? Below is the code from the help file and the associated s4 method. Any help would be greatly appreciated. Steve GENERIC FUNCTION AND METHODS setGeneric(getRemovedDf.OAD,function(x,y,z,simplify=TRUE,descrip=FA L SE){st andardGeneric(getRemovedDf.OAD)}) setMethod(getRemovedDf.OAD,status.or.rm.v1, function(x,y,z,simplify,descrip){ if(length(0[EMAIL PROTECTED]) mailto:[EMAIL PROTECTED]) 0){ pred - unlist(lapply([EMAIL PROTECTED],function(x)x[1])) resp - unlist(lapply([EMAIL PROTECTED],function(x)x[2])) out - data.frame(pred,resp) names(out) - c(y,z) return(out) } else { return(data.frame()) } } ) setMethod(getRemovedDf.OAD,sa, function(x,y,z,simplify,descrip){ i - unlist(lapply([EMAIL PROTECTED],function(x)length([EMAIL PROTECTED]))) if(all(i==0)){ return(list()) } else { if(simplify) [EMAIL PROTECTED](along=i)[i==0]] mailto:[EMAIL PROTECTED](along=i)[i==0]]-NULL -NULL tmp - lapply([EMAIL PROTECTED],getRemovedDf.OAD,[EMAIL PROTECTED],[EMAIL PROTECTED]) if(descrip){ f - as.data.frame(descrip[!history%in%names([EMAIL PROTECTED])]) return(lapply(tmp,function(x)cbind(f,x))) } else { return(tmp) } } } ) MAN FILE \name{getRemovedDf.OAD} \alias{getRemovedDf.OAD} %- Also NEED an '\alias' for EACH other topic documented here. \title{ ~~function to do ... ~~ } \description{ ~~ A concise (1-5 lines) description of what the function does. ~~ } \usage{ getRemovedDf.OAD(x, y, z, simplify = TRUE, descrip=FALSE) } %- maybe also 'usage' for other objects documented here. \arguments{ \item{x}{ ~~Describe \code{x} here~~ } \item{y}{ ~~Describe \code{y} here~~ } \item{z}{ ~~Describe \code{z} here~~ } \item{simplify}{ ~~Describe \code{simplify} here~~ } \item{descrip}{ ~~Describe
[R] fuzzy classification and dissimilarity matrix
Hello, I want to make a fuzzy classification from a dissimilarity matrix (calculated with daisy from package 'cluster'). I have tried to use fanny (package cluster) but I have the same problems than described in a previous message (http://tolstoy.newcastle.edu.au/R/help/05/05/4546.html) i.e. it always gives me two clusters in the results (even if k is different from 2) with the same memberships for all cluster. One solution suggested to the previous message was to use cmeans from package e1071. The problem is that it seems that cmeans doesn't work with dissimilarity matrix and I have to use daisy because I have mixed data. What can I do ? Jeanne Vallet [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] creating files using for loop
On 4/7/06, Brian Quinif [EMAIL PROTECTED] wrote: I tried that, and the problem seems to be that the results of the 'paste'ing are enclosed in quotes...that is the paste yields '101.tex'. Of course, that is what I said I wanted above, and it should work for that particular instance, but I also want to be able to create estimates.101 and estimates.201, for example. That is, I want to be able to just generate the value of sub.dataset[i] and follow it or precede it by whatever I choose, not necessarily quotation marks. Don't confuse the result of printing it with what is stored in it: x - paste(101, tex, sep = .) x [1] 101.tex cat(x) 101.tex nchar(x) [1] 7 Note that there are 7 characters in x. Thanks, BQ 2006/4/7, Gabor Grothendieck [EMAIL PROTECTED]: See ?paste and try: paste(sub.dataset[i], tex, sep = .) On 4/7/06, Brian Quinif [EMAIL PROTECTED] wrote: I would like to use a for loop to run estimations on 12 different subsets of a dataset. I have the basics of my script figured out, but I am having problems getting the loop to name some files as I would like. Here is a sketch of my code: sub.dataset - c(101, 201) #Assume I only have two subsets which I call 101 and 201 for (i in 1:length(sub.dataset)) { #Estimation commands here...unimportant for this question #Estimates - matrix of estimation resultsI will write out to LaTeX latex(Estimates, file=sub.dataset[i].tex) } So, the latex command is what's problematic here. How can I get my for loop to put file='101.tex' and file='201.tex' (or many similar things) where I want it to. I could just as easily want to put something like 101$variable1 or 201$variable1. Sorry for such a basic question regarding for loops, but thanks for the help. Brian __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] strange matrix behaviour: is there a matrix with one row?
Consider this: y - matrix(1:8, ncol=2) is.matrix(y[-c(1,2),]) [1] TRUE is.matrix(y[-c(1,2,3),]) [1] FALSE is.matrix(y[-c(1,2,3,4),]) [1] TRUE It seems like an inconsistent behaviour: - with 2 or more rows we have a matrix - with 1 row we do not have a matrix and - with 0 rows we have a matrix again I just stumbled on this behaviour, because I had a problem with my program in which I have assumed that matrix with some rows removed is still a matrix, which seems to be mostly true, but it is not true if only one row is left. Comments? Suggestions? How to work around this problem - without to many if statements? Best regards, Ryszard __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] fdim package questions
I have a basic question on the mechanics of fdim. I am calculating the information dimension of tree distributions. What I have are positions of trees within a plot (x data in one column, y data in another). My question is this: how does fdim combine the data from both columns to calculate the fractal dimension? Does it create an internal image of the points? I know it's basic, but I'm used to calculating dimensions of images, not datasets. I'm just a little skeptical of how the information dimension can be calculated from datasets instead of images. I've already attempted to send this e-mail to the package authors, but the e-mail addresses within the package no longer work. Thank you. Sincerely, Jim Milks Graduate Student Environmental Sciences Ph.D. Program Wright State University Dayton, OH 45435 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Why is transform=km the default for cox.zph?
To enhance my understanding, and that of my students, I have a question about cox.zph in the survival package. If I have correctly gleaned the high-level point from the 1994 Biometrika paper of Grambsch and Therneau, it looks to me like cox.zph provides a mechanism to test for a simple trend in plots of a function of time, g(t) versus the scaled schoenfeld residuals and it also provides some built-in ones and the capability to provide your own. It also appears to me that different forms look at different departures from proportionality. So, my question is what are the advantages and disadvantages of the default transform=km compared to say, identity or log? Thank you. Kevin -- Kevin E. Thorpe Biostatistician/Trialist, Knowledge Translation Program Assistant Professor, Department of Public Health Sciences Faculty of Medicine, University of Toronto email: [EMAIL PROTECTED] Tel: 416.946.8081 Fax: 416.946.3297 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] strange matrix behaviour: is there a matrix with one row?
this is documented: check ?[. You need to specify drop = FALSE, i.e., is.matrix(y[-c(1,2,3), , drop = FALSE]) 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://www.med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: [EMAIL PROTECTED] To: Gabor Grothendieck [EMAIL PROTECTED] Cc: Brian Quinif [EMAIL PROTECTED]; r-help@stat.math.ethz.ch; [EMAIL PROTECTED] Sent: Friday, April 07, 2006 3:16 PM Subject: [R] strange matrix behaviour: is there a matrix with one row? Consider this: y - matrix(1:8, ncol=2) is.matrix(y[-c(1,2),]) [1] TRUE is.matrix(y[-c(1,2,3),]) [1] FALSE is.matrix(y[-c(1,2,3,4),]) [1] TRUE It seems like an inconsistent behaviour: - with 2 or more rows we have a matrix - with 1 row we do not have a matrix and - with 0 rows we have a matrix again I just stumbled on this behaviour, because I had a problem with my program in which I have assumed that matrix with some rows removed is still a matrix, which seems to be mostly true, but it is not true if only one row is left. Comments? Suggestions? How to work around this problem - without to many if statements? Best regards, Ryszard __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] strange matrix behaviour: is there a matrix with one row?
[EMAIL PROTECTED] y - matrix(1:8, ncol=2) is.matrix(y[-c(1,2),]) [1] TRUE is.matrix(y[-c(1,2,3),]) [1] FALSE is.matrix(y[-c(1,2,3,4),]) [1] TRUE It seems like an inconsistent behaviour: - with 2 or more rows we have a matrix - with 1 row we do not have a matrix and - with 0 rows we have a matrix again ?'[' explains it. Using your example: is.matrix(y[-c(1, 2), , drop=FALSE]) [1] TRUE is.matrix(y[-c(1, 2, 3), , drop=FALSE]) [1] TRUE is.matrix(y[-c(1, 2, 3, 4), , drop=FALSE]) [1] TRUE -- François Pinard http://pinard.progiciels-bpi.ca __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] strange matrix behaviour: is there a matrix with one row?
Use drop = FALSE in your subscripting calls. That will retain matrixness. For example: y - matrix(1:8, ncol = 2) is.matrix(y[-c(1,2,3),,drop = FALSE] More info is on the help page for [. You can type: ?[ to get it from the command line. Hope this helps, Matt Wiener -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Friday, April 07, 2006 9:16 AM To: Gabor Grothendieck Cc: Brian Quinif; r-help@stat.math.ethz.ch; [EMAIL PROTECTED] Subject: [R] strange matrix behaviour: is there a matrix with one row? Consider this: y - matrix(1:8, ncol=2) is.matrix(y[-c(1,2),]) [1] TRUE is.matrix(y[-c(1,2,3),]) [1] FALSE is.matrix(y[-c(1,2,3,4),]) [1] TRUE It seems like an inconsistent behaviour: - with 2 or more rows we have a matrix - with 1 row we do not have a matrix and - with 0 rows we have a matrix again I just stumbled on this behaviour, because I had a problem with my program in which I have assumed that matrix with some rows removed is still a matrix, which seems to be mostly true, but it is not true if only one row is left. Comments? Suggestions? How to work around this problem - without to many if statements? Best regards, Ryszard __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Command line support tools - suggestions?
I'm interested in any thoughts that people have about this idea - what errors do you commonly see, and how can they be dealt with? Another (selfish) idea: a guide for programmers coming from other languages that highlights the differences between languages. For example, a perl to R guide or C to R. This is a slightly different concept, but might be a little easier to pin down. Larry Howe __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] strange matrix behaviour: is there a matrix with one row?
On Fri, 7 Apr 2006, Dimitris Rizopoulos wrote: this is documented: check ?[. You need to specify drop = FALSE, i.e., is.matrix(y[-c(1,2,3), , drop = FALSE]) It's not only documented, it's a FAQ. -thomas 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://www.med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: [EMAIL PROTECTED] To: Gabor Grothendieck [EMAIL PROTECTED] Cc: Brian Quinif [EMAIL PROTECTED]; r-help@stat.math.ethz.ch; [EMAIL PROTECTED] Sent: Friday, April 07, 2006 3:16 PM Subject: [R] strange matrix behaviour: is there a matrix with one row? Consider this: y - matrix(1:8, ncol=2) is.matrix(y[-c(1,2),]) [1] TRUE is.matrix(y[-c(1,2,3),]) [1] FALSE is.matrix(y[-c(1,2,3,4),]) [1] TRUE It seems like an inconsistent behaviour: - with 2 or more rows we have a matrix - with 1 row we do not have a matrix and - with 0 rows we have a matrix again I just stumbled on this behaviour, because I had a problem with my program in which I have assumed that matrix with some rows removed is still a matrix, which seems to be mostly true, but it is not true if only one row is left. Comments? Suggestions? How to work around this problem - without to many if statements? Best regards, Ryszard __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] [Q] Format of a plot axis label
Dear R-users Can anyone please tell me how to format a label of a plot? I found that R uses a floating point number (e.g. 2.0) sometimes and an integer number (e.g. 2) other times in lables of a plot even though no floating number is needed to show the lables. How can I get R to use only integer numbers in the plot labels? Thanks in advance. Young-Jin [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Dealing with missing values in HeatMap generation
Hi, I want to generate a heatmap for my data (in a matrix). However, the data has some missing values (represented as blank). I get the following errors (with the blanks and with blanks replaced by NA and including the option rm.na = TURE): filename = input_heatmap.txt g - as.matrix(filedata) fg - rainbow(nrow(g), start=0, end=.3) gg - rainbow(ncol(g), start=0, end=.3) hg - heatmap(g, col = cm.colors(256), scale=column,na.rm = TRUE, + RowSideColors = fg, ColSideColors = gg, margin=c(5,10), + xlab = Average per Species, ylab= Pathways, + main = heatmap(Ka/Ks Average Data per Species, ..., scale = \column\)) Error in heatmap(g, col = cm.colors(256), scale = column, na.rm = TRUE, : 'x' must be a numeric matrix Is there anyway to deal with it? Second question: What is the basis for generation of the dendrogram (over the heatmap) in the heatmap? Is it simple hierarchical clustering? Thanks in advance Himanshu __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Why is transform=km the default for cox.zph?
On Fri, 7 Apr 2006, Kevin E. Thorpe wrote: To enhance my understanding, and that of my students, I have a question about cox.zph in the survival package. If I have correctly gleaned the high-level point from the 1994 Biometrika paper of Grambsch and Therneau, it looks to me like cox.zph provides a mechanism to test for a simple trend in plots of a function of time, g(t) versus the scaled schoenfeld residuals and it also provides some built-in ones and the capability to provide your own. It also appears to me that different forms look at different departures from proportionality. Yes. The tests are approximately score tests against beta(t)=beta0+beta1*g(t) So, my question is what are the advantages and disadvantages of the default transform=km compared to say, identity or log? The person most likely to be able to answer this question is the author of the code, Terry Therneau, who doesn't (AFAIK) read any of the R mailing lists. I think he still reads s-news, though. One advantage of transform=km is that there are always observed events when the KM estimator is changing, so it doesn't try to pick up changes in hazard ratio where there is no information. This is good behaviour for a default, especially if you assume that anyone with an actual hypothesis as to g(t) will specify transform= explicitly. An obvious disadvantage is the lack of ready interpretation of beta*g(t). -thomas Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] a statistics question
Hi there, I have a statistics question on a classification problem: Suppose I have 1000 binary variables and one binary dependent variable. I want to find a way similar to PCA, in which I can find a couple of combinations of those variables to discriminate best according to the dependent variable. It is not only for dimension reduction, but more important, for finding best way to construct features. This is NOT CDA since the explanatory variables are NOT continuous. I knew the existence of that method since I consulted before with a professor but I forgot the name of the method.. sigh... I am also wondering if R has already some function or package addressing this kind of problem. Thanks -- Weiwei Shi, Ph.D Did you always know? No, I did not. But I believed... ---Matrix III [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] [Q] Format of a plot axis label
Do you mean the axis tick annotations, the xlab, the ylab or what? (It is the xlab and ylab that are quite explicitly called 'axis label' in the documentation.) If you mean the axis tick annotations, please show us an example where R uses an unnecessary (in your view) '.0'. The internal code uses the same algorithm as print.default(), and so will use the same number of decimal places for all the annotations on one (non-log-scale) axis. R is very programmable, and you can use par(xaxt=n) followed by a call to axis(1) specifying at= and label= to get precisely what you want for the x axis (amend in the obvious way for the y axis). On Fri, 7 Apr 2006, Young-Jin Lee wrote: Dear R-users Can anyone please tell me how to format a label of a plot? I found that R uses a floating point number (e.g. 2.0) sometimes and an integer number (e.g. 2) other times in lables of a plot even though no floating number is needed to show the lables. How can I get R to use only integer numbers in the plot labels? Thanks in advance. Young-Jin [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Aggregating an its series
I'm using a very long irregular time-series of air temperature and relative humidity of this kind (this is an extract only) its.format(% Y%d%m %X) base T H 20020601 12.00.00 27.1 47 20020601 15.00.00 29.1 39 20020601 18.00.00 27.4 39 20020601 21.00.00 24.0 40 20020602 0.00.00 22.0 73 20020602 3.00.00 19.2 49 20020602 6.00.00 19.5 74 20020602 9.00.00 24.8 45 20020602 12.00.00 27.7 NA 20020602 15.00.00 29.2 39 20020602 18.00.00 27.2 44 20020602 21.00.00 23.9 50 20020603 0.00.00 21.0 75 20020603 3.00.00 19.6 65 20020603 6.00.00 19.8 71 20020603 9.00.00 23.2 67 20020603 12.00.00 24.9 65 20020603 15.00.00 21.7 74 20020603 18.00.00 22.8 63 20020603 21.00.00 21.2 75 20020604 0.00.00 18.0 91 I would like to aggregate T and H by day and produce another its of this kind aggr T H 20020601 NA NA 20020602 NA NA 20020603 NA NA 20020604 NA NA where the daily average of T and H (not counting the NA values) is is put in aggr. What is the quickest way to get this result? Thanks Vittorio __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Dealing with missing values in HeatMap generation
On 4/7/06 11:54 AM, Himanshu Ardawatia [EMAIL PROTECTED] wrote: Sean Davis wrote: On 4/7/06 11:01 AM, Himanshu Ardawatia [EMAIL PROTECTED] wrote: Hi, I want to generate a heatmap for my data (in a matrix). However, the data has some missing values (represented as blank). I get the following errors (with the blanks and with blanks replaced by NA and including the option rm.na = TURE): filename = input_heatmap.txt g - as.matrix(filedata) fg - rainbow(nrow(g), start=0, end=.3) gg - rainbow(ncol(g), start=0, end=.3) hg - heatmap(g, col = cm.colors(256), scale=column,na.rm = TRUE, + RowSideColors = fg, ColSideColors = gg, margin=c(5,10), + xlab = Average per Species, ylab= Pathways, + main = heatmap(Ka/Ks Average Data per Species, ..., scale = \column\)) Error in heatmap(g, col = cm.colors(256), scale = column, na.rm = TRUE, : 'x' must be a numeric matrix We can't see from your example what filedata is, so we can't tell what g is. Is there anyway to deal with it? You will need to assure that g is a numeric matrix. Second question: What is the basis for generation of the dendrogram (over the heatmap) in the heatmap? Is it simple hierarchical clustering? Reading the ?heatmap page will help here. It describes what the defaults for clustering actually are. Sean Thanks for the quick reply! the data table is as follows (Here I have put 'NA', but I could also have just a 'space' in other files): Please see. mousemouse1ratrat1humanhuman1chimp path10.120.320.481.20.670.580.01 path20.130.900.091.60.230.500.09 path30.200.320.050.450.890.340.04 path40.230.650.920.670.780.780.91 path50.890.010.011.01'NA'0.980.79 path60.780.320.131.990.540.080.56 path70.340.54'NA'0.320.700.450.34 path80.150.860.850.560.970.860.11 path90.100.120.082.010.370.570.04 But from your code above, you never load these data. Sean __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Dealing with missing values in HeatMap generation
Hi, 'g' must be a numeric matrix and obviously it's not (suspect it's character?). If 'g' is numeric in your example depends on how you read data into 'filedata' and this step is missing in your code (maybe you just forgot to use read.table?). See ?read.table for that, and use argument colClasses if required. Am Friday 07 April 2006 17:01 schrieb Himanshu Ardawatia: Hi, I want to generate a heatmap for my data (in a matrix). However, the data has some missing values (represented as blank). I get the following errors (with the blanks and with blanks replaced by NA and including the option rm.na = TURE): filename = input_heatmap.txt g - as.matrix(filedata) fg - rainbow(nrow(g), start=0, end=.3) gg - rainbow(ncol(g), start=0, end=.3) hg - heatmap(g, col = cm.colors(256), scale=column,na.rm = TRUE, + RowSideColors = fg, ColSideColors = gg, margin=c(5,10), + xlab = Average per Species, ylab= Pathways, + main = heatmap(Ka/Ks Average Data per Species, ..., scale = \column\)) Error in heatmap(g, col = cm.colors(256), scale = column, na.rm = TRUE, : 'x' must be a numeric matrix Is there anyway to deal with it? Second question: What is the basis for generation of the dendrogram (over the heatmap) in the heatmap? Is it simple hierarchical clustering? Thanks in advance Himanshu __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Aggregating an its series
aggregate(base,by=list(as.factor(format(dates(base),%Y%m%d))),mean,na. rm=T) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Vittorio Sent: Friday, April 07, 2006 11:38 AM To: r-help@stat.math.ethz.ch Subject: [R] Aggregating an its series I'm using a very long irregular time-series of air temperature and relative humidity of this kind (this is an extract only) its.format(% Y%d%m %X) base T H 20020601 12.00.00 27.1 47 20020601 15.00.00 29.1 39 20020601 18.00.00 27.4 39 20020601 21.00.00 24.0 40 20020602 0.00.00 22.0 73 20020602 3.00.00 19.2 49 20020602 6.00.00 19.5 74 20020602 9.00.00 24.8 45 20020602 12.00.00 27.7 NA 20020602 15.00.00 29.2 39 20020602 18.00.00 27.2 44 20020602 21.00.00 23.9 50 20020603 0.00.00 21.0 75 20020603 3.00.00 19.6 65 20020603 6.00.00 19.8 71 20020603 9.00.00 23.2 67 20020603 12.00.00 24.9 65 20020603 15.00.00 21.7 74 20020603 18.00.00 22.8 63 20020603 21.00.00 21.2 75 20020604 0.00.00 18.0 91 I would like to aggregate T and H by day and produce another its of this kind aggr T H 20020601 NA NA 20020602 NA NA 20020603 NA NA 20020604 NA NA where the daily average of T and H (not counting the NA values) is is put in aggr. What is the quickest way to get this result? Thanks Vittorio __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] a statistics question
It sounds as though 'logic regression' might help. See Ruczinski I, Kooperberg C, LeBlanc ML (2003). Logic Regression, Journal of Computational and Graphical Statistics, 12, 475-511. and the LogicReg package. Peter Ehlers Weiwei Shi wrote: Hi there, I have a statistics question on a classification problem: Suppose I have 1000 binary variables and one binary dependent variable. I want to find a way similar to PCA, in which I can find a couple of combinations of those variables to discriminate best according to the dependent variable. It is not only for dimension reduction, but more important, for finding best way to construct features. This is NOT CDA since the explanatory variables are NOT continuous. I knew the existence of that method since I consulted before with a professor but I forgot the name of the method.. sigh... I am also wondering if R has already some function or package addressing this kind of problem. Thanks -- Weiwei Shi, Ph.D Did you always know? No, I did not. But I believed... ---Matrix III [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] a statistics question
Weiwei, You could also look into using one of several methods of classification that calculate the weight of individual predictors in producing a correct result based on some version of cross-validation. One that I use relatively often is randomForest (in the randomForest package). Sean On 4/7/06 12:34 PM, Peter Ehlers [EMAIL PROTECTED] wrote: It sounds as though 'logic regression' might help. See Ruczinski I, Kooperberg C, LeBlanc ML (2003). Logic Regression, Journal of Computational and Graphical Statistics, 12, 475-511. and the LogicReg package. Peter Ehlers Weiwei Shi wrote: Hi there, I have a statistics question on a classification problem: Suppose I have 1000 binary variables and one binary dependent variable. I want to find a way similar to PCA, in which I can find a couple of combinations of those variables to discriminate best according to the dependent variable. It is not only for dimension reduction, but more important, for finding best way to construct features. This is NOT CDA since the explanatory variables are NOT continuous. I knew the existence of that method since I consulted before with a professor but I forgot the name of the method.. sigh... I am also wondering if R has already some function or package addressing this kind of problem. Thanks -- Weiwei Shi, Ph.D Did you always know? No, I did not. But I believed... ---Matrix III [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] fuzzy classification and dissimilarity matrix
Jeanne == Jeanne Vallet [EMAIL PROTECTED] on Fri, 7 Apr 2006 12:43:59 +0200 writes: Jeanne Hello, I want to make a fuzzy classification from a Jeanne dissimilarity matrix (calculated with daisy from Jeanne package 'cluster'). I have tried to use fanny Jeanne (package cluster) but I have the same problems than Jeanne described in a previous message Jeanne (http://tolstoy.newcastle.edu.au/R/help/05/05/4546.html) Jeanne i.e. it always gives me two clusters in the results Jeanne (even if k is different from 2) with the same Jeanne memberships for all cluster. One solution suggested Jeanne to the previous message was to use cmeans from Jeanne package e1071. The problem is that it seems that Jeanne cmeans doesn't work with dissimilarity matrix and I Jeanne have to use daisy because I have mixed data. What Jeanne can I do ? This looks like a bug in fanny(), actually somewhere in its Fortran code. Following the above URL leads to a reproducible example -- eventually! -- from Matthias Temple, though a relatively large example. I'd like to look at the bug and fix it as soon as possible. If you want you can also send me (privately, not via R-help!) your dissmilarity object {resulting from daisy()}, or preferably your data set and the exact calls you used {daisy(), then fanny()}, to produce the outcome you mention above. Regards, Martin Maechler, ETH Zurich Jeanne Jeanne Vallet Jeanne [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] more documentation on lmer?
Hello. Is there any documentation on the lmer function in the lme4 package beyond what was published in the May 2005 R News (vol.5/1)? As well, has the nonlinear version of lmer appeared yet? Bill Shipley North American Editor, Annals of Botany Editor, Population and Community Biology series, Springer Publishing Département de biologie, Université de Sherbrooke, Sherbrooke (Québec) J1K 2R1 CANADA [EMAIL PROTECTED] http://callisto.si.usherb.ca:8080/bshipley/ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] documentation for lmer?
Hello. Besides the short paper in the May 2005 edition of R News, I have not found any documentation concerning the lmer function in the lme4 package. Does anyone know of anything more substatial? Also, does anyone know if the nonlinear equivalent of lmer exists yet? Thanks. Bill Shipley [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] a statistics question
The goal of logic regression is to find predictors that are Boolean (logical) combinations of the original predictors, which might be more like what I need. The rf's variable importance evaluations and oob might help feature selection but not feature construction, which is more of my concern. Thanks for any further suggestion or explanation. On 4/7/06, Sean Davis [EMAIL PROTECTED] wrote: Weiwei, You could also look into using one of several methods of classification that calculate the weight of individual predictors in producing a correct result based on some version of cross-validation. One that I use relatively often is randomForest (in the randomForest package). Sean On 4/7/06 12:34 PM, Peter Ehlers [EMAIL PROTECTED] wrote: It sounds as though 'logic regression' might help. See Ruczinski I, Kooperberg C, LeBlanc ML (2003). Logic Regression, Journal of Computational and Graphical Statistics, 12, 475-511. and the LogicReg package. Peter Ehlers Weiwei Shi wrote: Hi there, I have a statistics question on a classification problem: Suppose I have 1000 binary variables and one binary dependent variable. I want to find a way similar to PCA, in which I can find a couple of combinations of those variables to discriminate best according to the dependent variable. It is not only for dimension reduction, but more important, for finding best way to construct features. This is NOT CDA since the explanatory variables are NOT continuous. I knew the existence of that method since I consulted before with a professor but I forgot the name of the method.. sigh... I am also wondering if R has already some function or package addressing this kind of problem. Thanks -- Weiwei Shi, Ph.D Did you always know? No, I did not. But I believed... ---Matrix III [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Weiwei Shi, Ph.D Did you always know? No, I did not. But I believed... ---Matrix III [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] finding common elements in a list
Suppose I have a list where I want to extract only the elements that occur in every component. For instance in the list foo I want to know that the numbers 2 and 3 occur in every component. The solution I have seems unnecessarily clunky. TIA, Andy foo - list(x = 1:10, y=2:11, z=1:3) bar -unlist(foo) bartab - table(bar) as.numeric(names(bartab)[bartab==length(foo)]) [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] a statistics question
Jerry Friedman's RuleFit finds important rules, which I guess can be thought of as features... Andy From: Weiwei Shi The goal of logic regression is to find predictors that are Boolean (logical) combinations of the original predictors, which might be more like what I need. The rf's variable importance evaluations and oob might help feature selection but not feature construction, which is more of my concern. Thanks for any further suggestion or explanation. On 4/7/06, Sean Davis [EMAIL PROTECTED] wrote: Weiwei, You could also look into using one of several methods of classification that calculate the weight of individual predictors in producing a correct result based on some version of cross-validation. One that I use relatively often is randomForest (in the randomForest package). Sean On 4/7/06 12:34 PM, Peter Ehlers [EMAIL PROTECTED] wrote: It sounds as though 'logic regression' might help. See Ruczinski I, Kooperberg C, LeBlanc ML (2003). Logic Regression, Journal of Computational and Graphical Statistics, 12, 475-511. and the LogicReg package. Peter Ehlers Weiwei Shi wrote: Hi there, I have a statistics question on a classification problem: Suppose I have 1000 binary variables and one binary dependent variable. I want to find a way similar to PCA, in which I can find a couple of combinations of those variables to discriminate best according to the dependent variable. It is not only for dimension reduction, but more important, for finding best way to construct features. This is NOT CDA since the explanatory variables are NOT continuous. I knew the existence of that method since I consulted before with a professor but I forgot the name of the method.. sigh... I am also wondering if R has already some function or package addressing this kind of problem. Thanks -- Weiwei Shi, Ph.D Did you always know? No, I did not. But I believed... ---Matrix III [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Weiwei Shi, Ph.D Did you always know? No, I did not. But I believed... ---Matrix III [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] documentation for lmer?
The vignette in the mlmRev package might be of some help. Andy From: Bill Shipley Hello. Besides the short paper in the May 2005 edition of R News, I have not found any documentation concerning the lmer function in the lme4 package. Does anyone know of anything more substatial? Also, does anyone know if the nonlinear equivalent of lmer exists yet? Thanks. Bill Shipley [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] how to run stepAIC starting with NULL model?
Hello, I'm trying to figure out how to run the stepAIC function starting with the NULL model. I can call the null model (e.g., lm(y ~ NULL)), but using this object in stepAIC doesn't seem to work. The objective is to calculate AICc. This can be done if stepAIC can be run starting with the NULL model; the (2p(p-1)/(n-p-1))to get AICc would be added to the final step AIC value. Can anyone suggest how to run stepAIC beginning with the NULL model, and sequentially adding and removing variables (essentially a bottom-up approach)? Thanks, Josh Robins School of Fisheries and Ocean Sciences University of Alaska Fairbanks Juneau Center (206) 331-8633 [EMAIL PROTECTED] http://students.washington.edu/jbrobins __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] how to run stepAIC starting with NULL model?
Joshua B Robins wrote: Hello, I'm trying to figure out how to run the stepAIC function starting with the NULL model. I can call the null model (e.g., lm(y ~ NULL)), but using this object in stepAIC doesn't seem to work. I don't know what doesn't seem to work means here, but your null model is equivalent to lm(y ~ 1) and stepAIC handles both just fine for me. Did you specify 'scope' with an 'upper' component? Peter Ehlers The objective is to calculate AICc. This can be done if stepAIC can be run starting with the NULL model; the (2p(p-1)/(n-p-1))to get AICc would be added to the final step AIC value. Can anyone suggest how to run stepAIC beginning with the NULL model, and sequentially adding and removing variables (essentially a bottom-up approach)? Thanks, Josh Robins School of Fisheries and Ocean Sciences University of Alaska Fairbanks Juneau Center (206) 331-8633 [EMAIL PROTECTED] http://students.washington.edu/jbrobins __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] finding common elements in a list
Here is one solution: all(unlist(lapply(foo, function(x) c(2,3) %in% x))) [1] TRUE This doesn't have the restriction of assuming that the components of the list have unique elements, as the original solution does. Patrick Burns [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and A Guide for the Unwilling S User) Andy Bunn wrote: Suppose I have a list where I want to extract only the elements that occur in every component. For instance in the list foo I want to know that the numbers 2 and 3 occur in every component. The solution I have seems unnecessarily clunky. TIA, Andy foo - list(x = 1:10, y=2:11, z=1:3) bar -unlist(foo) bartab - table(bar) as.numeric(names(bartab)[bartab==length(foo)]) [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Multiple ablines
Thanks in advance, I have searched and read the archives extensively and have been unable to find a question (solution) exactly mimicking my problem. I have created a scatterplot simulation of data through which I have drawn a linear regression in this manner: points(y~x, pch=*, col=black) lm(y~x) fm=lm(y~x) abline(fm, col=red) This works. The problem arises in that I would like to run my simulation multiple times, to plot the data points together on the same plot, and more importantly the regression lines of the simulated data. Therefore, I have placed the code within the loop of the simulation. This works fine for points(), I can watch the additional points being added to the plot as the simulations run. However, when I include abline() it gives this error: Error in abline(a, b, h, v, untf, col, lty, lwd, ...) : 'a' and 'b' must be finite I can take the code as written and place it outside of the loop and it works fine, plotting the points and regression line for the data of the last run of the simulation. And as I said I can plot all of the points from the multiple simulations. However, I cannot plot the regressions of those points together. Additionally, I have set the loop to one iteration and received the same error. I would greatly appreciate assistance. Thanks, Alex __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] saving estimates from a for loop for later use
Thanks to the help of many on this list, I am now an R user and have been able to write some functioning code to do matching estimation. I have two for loops (i in 1:3, and j in 0:2). Within the loops, I had been creating matrices of relevant estimation coefficents in order to make lots of LaTeX tables. Well, now I want to be able to combine the results of many different estimations from within the loops into one larger table outside the loops. How can I save the estimation results from each iteration of the estimation within a loop for later use outside the loop? Thanks, BQ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] CLI Issue
Hello, I have a script that must be executed by R at the CLI completely ... without halting execution on encountering an error (object not found). Rcmdr works fine, but source behaves strangely in R-2.1... Thanks, -- A. Mani Member, Cal. Math. Soc [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] saving estimates from a for loop for later use
use a 'list'; x - list() for (i in 1:3) for (j in 0:2) { .your calculations. x[[as.character(i)]][[as.character(j)]] - yourResults } On 4/7/06, Brian Quinif [EMAIL PROTECTED] wrote: Thanks to the help of many on this list, I am now an R user and have been able to write some functioning code to do matching estimation. I have two for loops (i in 1:3, and j in 0:2). Within the loops, I had been creating matrices of relevant estimation coefficents in order to make lots of LaTeX tables. Well, now I want to be able to combine the results of many different estimations from within the loops into one larger table outside the loops. How can I save the estimation results from each iteration of the estimation within a loop for later use outside the loop? Thanks, BQ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Jim Holtman Cincinnati, OH +1 513 646 9390 (Cell) +1 513 247 0281 (Home) What the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] saving estimates from a for loop for later use
I kind of understand this recommendation, but I can't figure out how to work with x once I have created it. Here is some fully reproducible code. It creates a 4x1 matrices within the loops. Once done with the looping, I want to cbind these matrices together. I know it's a simple question, but I can't figure it out. x - list() for (i in 2:3) for (j in 11:12) { estimates - matrix(c(i,j,i+j,i*j),nrow=4) x[[as.character(i)]][[as.character(j)]] - estimates } So, once I've done this, how can I reference, say, the estimates matrix created when i=2 and j=12? Thanks, BQ 2006/4/7, jim holtman [EMAIL PROTECTED]: use a 'list'; x - list() for (i in 1:3) for (j in 0:2) { .your calculations. x[[as.character(i)]][[as.character(j)]] - yourResults } On 4/7/06, Brian Quinif [EMAIL PROTECTED] wrote: Thanks to the help of many on this list, I am now an R user and have been able to write some functioning code to do matching estimation. I have two for loops (i in 1:3, and j in 0:2). Within the loops, I had been creating matrices of relevant estimation coefficents in order to make lots of LaTeX tables. Well, now I want to be able to combine the results of many different estimations from within the loops into one larger table outside the loops. How can I save the estimation results from each iteration of the estimation within a loop for later use outside the loop? Thanks, BQ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Jim Holtman Cincinnati, OH +1 513 646 9390 (Cell) +1 513 247 0281 (Home) What the problem you are trying to solve? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Time Series Objects/ MC Simulation
I don't have a direct answer to your question, but in case you are interested in a general introduction to time series capabilties in R, I will suggest the following: 1. Ch. 14 in Venables and Ripley (2002) Modern Applied Statistics with S, 4th ed. (Springer) 2. The zoo vignette plus Gabor Grothendieck and Thomas Petzoldt. R help desk: Date and time classes in R. R News, 4(1):29-32, June 2004 (www.r-project.org - newsletter ... ). 3. The vignettes dse1, and dse2, available with the dse bundle. 4. If all you want is to Monte Carlo time series, then item 2 might suffice -- unless you want to simulate events occurring in different time zones, and you want to manage the subtleties of trading day differences in different countries, etc., in which case you need fCalendar in www.rmetrics.org - White Paper on timeDate/timeSeries (on left). hope this helps. spencer graves Keith Sabol wrote: I am attempting to value convertible bonds through a Monte Carlo approach. I want to express call schedules as date-price tuples. Naturally, these tuples need to be expanded to match the frequency of the innovations in the MC process. 1. Is there a straigh-forward way to accomplish this expansion? 2. I have noted the existance of ts, its, zoo and fCalendar. Does anyone have an opion on the relative merits of these, particularly with respect to speed in a simulation framework? Your assistance and insights are appreciated. Keith __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] saving estimates from a for loop for later use
If the matrices you're storing inside the loop are all the same dimension (as in your example), it's probably better to store them in an array; e.g.: i1 - 2:3 i2 - 11:12 x - array(0, c(4, 1, length(i1), length(i2))) for (i in seq(along=i1)) { for (j in seq(along=i2)) { x[, , i, j] - matrix(c(i1[i], i2[j], i1[i] + i2[j], i1[i]*i2[j]), nrow=4) } } dimnames(x) - list(NULL, NULL, i1, i2) x[, , 2, 11, drop=FALSE] x[, , 3, 11, drop=FALSE] (Notice you need the drop=FALSE to keep it a matrix, because it only has one column.) Andy From: Brian Quinif I kind of understand this recommendation, but I can't figure out how to work with x once I have created it. Here is some fully reproducible code. It creates a 4x1 matrices within the loops. Once done with the looping, I want to cbind these matrices together. I know it's a simple question, but I can't figure it out. x - list() for (i in 2:3) for (j in 11:12) { estimates - matrix(c(i,j,i+j,i*j),nrow=4) x[[as.character(i)]][[as.character(j)]] - estimates } So, once I've done this, how can I reference, say, the estimates matrix created when i=2 and j=12? Thanks, BQ 2006/4/7, jim holtman [EMAIL PROTECTED]: use a 'list'; x - list() for (i in 1:3) for (j in 0:2) { .your calculations. x[[as.character(i)]][[as.character(j)]] - yourResults } On 4/7/06, Brian Quinif [EMAIL PROTECTED] wrote: Thanks to the help of many on this list, I am now an R user and have been able to write some functioning code to do matching estimation. I have two for loops (i in 1:3, and j in 0:2). Within the loops, I had been creating matrices of relevant estimation coefficents in order to make lots of LaTeX tables. Well, now I want to be able to combine the results of many different estimations from within the loops into one larger table outside the loops. How can I save the estimation results from each iteration of the estimation within a loop for later use outside the loop? Thanks, BQ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Jim Holtman Cincinnati, OH +1 513 646 9390 (Cell) +1 513 247 0281 (Home) What the problem you are trying to solve? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] saving estimates from a for loop for later use
Thanks for the suggestion, but I do not know how to get it to work for the actual matrix I want to create. This is not reproducible, but here is the form of the matrix I want: #above I compute satt.yr.hrs and satt.full.load using Match() Estimates - matrix(c(satt.yr.hrs$est, paste('(',satt.yr.hrs$se,')',sep=''), satt.full.load$est, paste('(',satt.full.load$se,')',sep='')), nrow=4) In my real program, I have 3 loops with i in 1:3, j in 1:3 and m in 1:6. I want to be able to combine the various versions of Estimates in many combinations to make tables. BQ 2006/4/7, Liaw, Andy [EMAIL PROTECTED]: If the matrices you're storing inside the loop are all the same dimension (as in your example), it's probably better to store them in an array; e.g.: i1 - 2:3 i2 - 11:12 x - array(0, c(4, 1, length(i1), length(i2))) for (i in seq(along=i1)) { for (j in seq(along=i2)) { x[, , i, j] - matrix(c(i1[i], i2[j], i1[i] + i2[j], i1[i]*i2[j]), nrow=4) } } dimnames(x) - list(NULL, NULL, i1, i2) x[, , 2, 11, drop=FALSE] x[, , 3, 11, drop=FALSE] (Notice you need the drop=FALSE to keep it a matrix, because it only has one column.) Andy From: Brian Quinif I kind of understand this recommendation, but I can't figure out how to work with x once I have created it. Here is some fully reproducible code. It creates a 4x1 matrices within the loops. Once done with the looping, I want to cbind these matrices together. I know it's a simple question, but I can't figure it out. x - list() for (i in 2:3) for (j in 11:12) { estimates - matrix(c(i,j,i+j,i*j),nrow=4) x[[as.character(i)]][[as.character(j)]] - estimates } So, once I've done this, how can I reference, say, the estimates matrix created when i=2 and j=12? Thanks, BQ 2006/4/7, jim holtman [EMAIL PROTECTED]: use a 'list'; x - list() for (i in 1:3) for (j in 0:2) { .your calculations. x[[as.character(i)]][[as.character(j)]] - yourResults } On 4/7/06, Brian Quinif [EMAIL PROTECTED] wrote: Thanks to the help of many on this list, I am now an R user and have been able to write some functioning code to do matching estimation. I have two for loops (i in 1:3, and j in 0:2). Within the loops, I had been creating matrices of relevant estimation coefficents in order to make lots of LaTeX tables. Well, now I want to be able to combine the results of many different estimations from within the loops into one larger table outside the loops. How can I save the estimation results from each iteration of the estimation within a loop for later use outside the loop? Thanks, BQ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Jim Holtman Cincinnati, OH +1 513 646 9390 (Cell) +1 513 247 0281 (Home) What the problem you are trying to solve? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Notice: This e-mail message, together with any attachment...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] saving estimates from a for loop for later use
Another possibility is to create a data.frame. I've just put one statistic, sum, in it but you could put in as many as you like: g - expand.grid(i = 1:2, j = 1:2, k = 1:3) f - function(x) with(x, c(i = i, j = j, k = k, sum = i+j+k)) do.call(rbind, lapply(split(g, rownames(g)), f)) i j k sum 1 1 1 1 3 2 2 1 1 4 3 1 2 1 4 4 2 2 1 5 5 1 1 2 4 6 2 1 2 5 7 1 2 2 5 8 2 2 2 6 9 1 1 3 5 10 2 1 3 6 11 1 2 3 6 12 2 2 3 7 On 4/7/06, Brian Quinif [EMAIL PROTECTED] wrote: Thanks for the suggestion, but I do not know how to get it to work for the actual matrix I want to create. This is not reproducible, but here is the form of the matrix I want: #above I compute satt.yr.hrs and satt.full.load using Match() Estimates - matrix(c(satt.yr.hrs$est, paste('(',satt.yr.hrs$se,')',sep=''), satt.full.load$est, paste('(',satt.full.load$se,')',sep='')), nrow=4) In my real program, I have 3 loops with i in 1:3, j in 1:3 and m in 1:6. I want to be able to combine the various versions of Estimates in many combinations to make tables. BQ 2006/4/7, Liaw, Andy [EMAIL PROTECTED]: If the matrices you're storing inside the loop are all the same dimension (as in your example), it's probably better to store them in an array; e.g.: i1 - 2:3 i2 - 11:12 x - array(0, c(4, 1, length(i1), length(i2))) for (i in seq(along=i1)) { for (j in seq(along=i2)) { x[, , i, j] - matrix(c(i1[i], i2[j], i1[i] + i2[j], i1[i]*i2[j]), nrow=4) } } dimnames(x) - list(NULL, NULL, i1, i2) x[, , 2, 11, drop=FALSE] x[, , 3, 11, drop=FALSE] (Notice you need the drop=FALSE to keep it a matrix, because it only has one column.) Andy From: Brian Quinif I kind of understand this recommendation, but I can't figure out how to work with x once I have created it. Here is some fully reproducible code. It creates a 4x1 matrices within the loops. Once done with the looping, I want to cbind these matrices together. I know it's a simple question, but I can't figure it out. x - list() for (i in 2:3) for (j in 11:12) { estimates - matrix(c(i,j,i+j,i*j),nrow=4) x[[as.character(i)]][[as.character(j)]] - estimates } So, once I've done this, how can I reference, say, the estimates matrix created when i=2 and j=12? Thanks, BQ 2006/4/7, jim holtman [EMAIL PROTECTED]: use a 'list'; x - list() for (i in 1:3) for (j in 0:2) { .your calculations. x[[as.character(i)]][[as.character(j)]] - yourResults } On 4/7/06, Brian Quinif [EMAIL PROTECTED] wrote: Thanks to the help of many on this list, I am now an R user and have been able to write some functioning code to do matching estimation. I have two for loops (i in 1:3, and j in 0:2). Within the loops, I had been creating matrices of relevant estimation coefficents in order to make lots of LaTeX tables. Well, now I want to be able to combine the results of many different estimations from within the loops into one larger table outside the loops. How can I save the estimation results from each iteration of the estimation within a loop for later use outside the loop? Thanks, BQ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Jim Holtman Cincinnati, OH +1 513 646 9390 (Cell) +1 513 247 0281 (Home) What the problem you are trying to solve? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Notice: This e-mail message, together with any attachment...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] CLI Issue
Maybe clt.examp() in TeachingDemos is what you want. 2006/4/8, A Mani [EMAIL PROTECTED]: Hello, I have a script that must be executed by R at the CLI completely ... without halting execution on encountering an error (object not found). Rcmdr works fine, but source behaves strangely in R-2.1... Thanks, -- A. Mani Member, Cal. Math. Soc [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- 黄荣贵 Deparment of Sociology Fudan University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] saving estimates from a for loop for later use
Hi Andy, I apologize for the flat structure of my code. I do not know much about programming conventions. I think your solution will work quite well, but could you clarify a couple of things? In the line x - array('', c(4, 1, 6, 2, 3)) where do the numbers 4, 1, 6, 2, 3 come from. Here are my guesses: 4 = number of rows in orignal matrix Estimates 1 = ? 6 comes from m (m in 1:6) 2 comes from j (j in 1:2) 3 comes from i (i in 1:3) BQ 2006/4/7, Liaw, Andy [EMAIL PROTECTED]: If all the looping variables are of the form 1:k for some k (i.e., they can be use as indices in arrays), you can do something like: x - array('', c(4, 1, 6, 2, 3)) for (m in 1:6) { for (i in 1:2) { for (j in 1:3) { compute `Estimates' x[, , m, i, j] - Estimates } } } You still need to tack on the rownames and colnames to x. Andy From: Brian Quinif Thanks for the suggestion, but I do not know how to get it to work for the actual matrix I want to create. This is not reproducible, but here is the form of the matrix I want: #above I compute satt.yr.hrs and satt.full.load using Match() Estimates - matrix(c(satt.yr.hrs$est, paste('(',satt.yr.hrs$se,')',sep=''), satt.full.load$est, paste('(',satt.full.load$se,')',sep='')), nrow=4) In my real program, I have 3 loops with i in 1:3, j in 1:3 and m in 1:6. I want to be able to combine the various versions of Estimates in many combinations to make tables. BQ 2006/4/7, Liaw, Andy [EMAIL PROTECTED]: If the matrices you're storing inside the loop are all the same dimension (as in your example), it's probably better to store them in an array; e.g.: i1 - 2:3 i2 - 11:12 x - array(0, c(4, 1, length(i1), length(i2))) for (i in seq(along=i1)) { for (j in seq(along=i2)) { x[, , i, j] - matrix(c(i1[i], i2[j], i1[i] + i2[j], i1[i]*i2[j]), nrow=4) } } dimnames(x) - list(NULL, NULL, i1, i2) x[, , 2, 11, drop=FALSE] x[, , 3, 11, drop=FALSE] (Notice you need the drop=FALSE to keep it a matrix, because it only has one column.) Andy From: Brian Quinif I kind of understand this recommendation, but I can't figure out how to work with x once I have created it. Here is some fully reproducible code. It creates a 4x1 matrices within the loops. Once done with the looping, I want to cbind these matrices together. I know it's a simple question, but I can't figure it out. x - list() for (i in 2:3) for (j in 11:12) { estimates - matrix(c(i,j,i+j,i*j),nrow=4) x[[as.character(i)]][[as.character(j)]] - estimates } So, once I've done this, how can I reference, say, the estimates matrix created when i=2 and j=12? Thanks, BQ 2006/4/7, jim holtman [EMAIL PROTECTED]: use a 'list'; x - list() for (i in 1:3) for (j in 0:2) { .your calculations. x[[as.character(i)]][[as.character(j)]] - yourResults } On 4/7/06, Brian Quinif [EMAIL PROTECTED] wrote: Thanks to the help of many on this list, I am now an R user and have been able to write some functioning code to do matching estimation. I have two for loops (i in 1:3, and j in 0:2). Within the loops, I had been creating matrices of relevant estimation coefficents in order to make lots of LaTeX tables. Well, now I want to be able to combine the results of many different estimations from within the loops into one larger table outside the loops. How can I save the estimation results from each iteration of the estimation within a loop for later use outside the loop? Thanks, BQ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Jim Holtman Cincinnati, OH +1 513 646 9390 (Cell) +1 513 247 0281 (Home) What the problem you are trying to solve? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Notice: This e-mail message, together with any attachment...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Notice: This e-mail message,