[R] How to sort data points in high dimension space
Dear all, There are n points in R^p, I want to sort th data like this, first sort the data by the first coordinate, and then partition the data in to several subsets, then in every subset, sort the data by the second coordinate, then partiotion.. In general, I want to partition the high dimension space in to little cubes, and put the points in to these cubes. Could anyone tell me how to do this ? best regards, WAN, SQ [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] digital length
?Round On Dec 14, 2006, at 2:52 AM, XinMeng wrote: How can I control the digital length of data? e.g: 0.1234 is the output of an algorithm. What I want is 0.12 instead. _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] install.packages
Aimin Yan wrote: I try to type this in my R-winEdt. GH! Again and again I have to tell that RWinEdt is just some enhancement for an editor that may help for you R programming, but is not related to any error messages you receive from R! but I got these. Do you know? Yes, you are not reading any documentation at all, obviously. Please try to reduce your mail traffic on R-help by simply reading some documentation (and the posting guide!) from time to time. Thank you. Uwe Ligges Aimin install.packages('http://rh-mirror.linux.iastate.edu/CRAN/bin/windows/contrib/2.4/plotrix_2.1-6.zip') Warning in download.packages(pkgs, destdir = tmpd, available = available, : no package 'http://rh-mirror.linux.iastate.edu/CRAN/bin/windows/contrib/2.4/plotrix_2.1-6.zip' at the repositories __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] xyplot: discrete points + continuous curve per panel
Hi there is probably better solution but you can try to fiidle with this idea, which adds stight lines to each panel one after another. # based on Gabor Grothendieck's code suggestion # adds straight lines to panels in lattice plots addLine- function(...) { tcL - trellis.currentLayout() for(i in 1:nrow(tcL)) for(j in 1:ncol(tcL)) if (tcL[i,j] 0) { trellis.focus(panel, j, i, highlight = FALSE) panel.abline(...) trellis.unfocus() } } You need to change panel.abline(...) part maybe to panel.curve or panel.segments or? HTH Petr On 13 Dec 2006 at 23:22, RMan54 wrote: Date sent: Wed, 13 Dec 2006 23:22:41 -0800 (PST) From: RMan54 [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] xyplot: discrete points + continuous curve per panel I have a number of x, y observations (Time, Conc) for a number of Subjects (with subject number Subj) and Doses. I can plot the individual points with xyplot fine: xyplot(Conc ~ Time | Subj, Groups=Dose, data=myData, panel = function(x,y) { panel.xyplot(x, y) panel.superpose(???) # Needs more here } ) I also like to plot on each panel (there is one Subj per panel) a continuous curve with predictions that I can calculate from a rather complicated function: myPred - (time, subj, dose) { returns predicted value of Conc for a given time, subj and dose } The predicted curves are different for each panel. How do I plot the predictions? I have tried to add panel.superinpose in the xyplot portion but can't link to the myPred function. I also know about panel.curve but couldn't make it work. My attempt is to calculate the predictions on the fly. Is this possible? Or do I need to calculate all predictions first and put the results in a data frame. Thanks for any help, Rene -- View this message in context: http://www.nabble.com/xyplot%3A-discrete-points-%2B-continuous-curve-p er-panel-tf2818931.html#a7867892 Sent from the R help mailing list archive at Nabble.com. __ 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 and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Welcome to the R-help mailing list
Dear Colleagues I am a very new member here. If my question sounds silly to you, I apologize in advance. If I have a complicated function without an explicit expression. ( For example, the price of American put option p is a function of the current stock price S and expected future volatility sigma, but there is no clean elementary function that would map (S, sigma) to p, in fact, p has to be calculated with a sophisticated procedure. In such case, is there a function in R to find sigma, with S and p known? Also, is there a way to find the derivative of p with regard to sigma? Could anyone please shed some light on it? Your help will be highly appreciated!!! Best Bird and Fish __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Welcome to the R-help mailing list
Hi you could use interpolant() of the emulator package, for a Gaussian process approach, or approx() [or appproxfun()] if linear interpolation is acceptable. HTH Robin On 14 Dec 2006, at 10:20, Bird Fish wrote: Dear Colleagues I am a very new member here. If my question sounds silly to you, I apologize in advance. If I have a complicated function without an explicit expression. ( For example, the price of American put option p is a function of the current stock price S and expected future volatility sigma, but there is no clean elementary function that would map (S, sigma) to p, in fact, p has to be calculated with a sophisticated procedure. In such case, is there a function in R to find sigma, with S and p known? Also, is there a way to find the derivative of p with regard to sigma? Could anyone please shed some light on it? Your help will be highly appreciated!!! Best Bird and Fish __ 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 and provide commented, minimal, self-contained, reproducible code. -- 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 and provide commented, minimal, self-contained, reproducible code.
[R] two connected graphs
Hi I have two datasets, A and B, consisting of two columns of numbers representing x and y coordinates. They have 10 and 6 rows respectively. I want to plot two scattergraphs, one above the other. The lower graph to contain A (10 points) and the upper graph to contain B (six points). The x-axes of the two graphs must line up. I then want to draw straight lines that connect points of B to a particular point (or points) of A. How do I do this? -- 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 and provide commented, minimal, self-contained, reproducible code.
[R] Contents of R-packages
Hi experts, How do I see the contents of a package that looks interesting? Efter I have loded the package, is there an command that gives me the contents or even better a summary or introduction. Ralf Finne SYH University of Applied Sciences, Finland __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Fit Frechet Distribution
Hi everyone, is there a function to fit a frechet distribution? The only thing I found is gev.fit from ismev which fits a generalized extreme value distribution (if shape1 = Frechet) . Is there a function to only fit a frechet? Thank you Benjamin __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Contents of R-packages
Ralf Finne wrote: Hi experts, How do I see the contents of a package that looks interesting? Efter I have loded the package, is there an command that gives me the contents or even better a summary or introduction. library(yags) # Load the package search() # Where is the package? [1] .GlobalEnvpackage:yags [3] package:nlme package:car [5] package:stats package:graphics [7] package:grDevices package:utils [9] package:datasets package:methods [11] Autoloads package:base ls(2) # What is in the package? [1] ar1mat csmat [3] mvnsamp print.yagsResult [5] yags yags.adeqReport [7] yags.control yags.glmReport [9] yags.make.libu yags.wcorReport ?yags # Help for a particular function Also, follow the package links here for brief descriptions, reference manuals, and vignettes: http://cran.us.r-project.org/src/contrib/PACKAGES.html Ralf Finne SYH University of Applied Sciences, Finland __ 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 and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sweave, Xfig, pdflatex and \setkeys
On Wed, 13 Dec 2006 12:38:04 +0100, David Lindelöf (DL) wrote: On Tue, 2006-12-12 at 13:22 -0500, Kevin E. Thorpe wrote: Trouble is that Sweave defines (with \setkeys) the default width of \includegraphics to be 0.8 times the \textwidth. The result is that the graphic is scaled, but not the text. I was looking for a way to temporarily undefine the default width of included graphics, but without success. Does anyone know how to undo a definition that has been set with \setkeys? If you knew what setting you needed, you could try \setkeys{Gin}{width=whatever} before your include, and set it back to the default afterward with \setkeys{Gin}{width=0.8\textwidth} Yes, but the trouble is that for arbitrary figures created with Xfig I cannot know what the correct width is going to be. And I could not find any help on how to undefine variables set with \setkeys. Yes, I should document Sweave.sty much better ... \usepackage[nogin]{Sweave} in your .Rnw file will do the trick, i.e., not set any Gin keys. HTH, 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.stat.uni-muenchen.de/~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 and provide commented, minimal, self-contained, reproducible code.
[R] Function to fit a STARIMA model
Hi all, I was wondering if there is a function available in any of the R add-on packages that could be used to fit a STARIMA (Phillip E. Pfeifer and Stuart Jay Deutsch. (1980). A STARIMA Model-Building Procedure with Application to Description and Regional Forecasting, Transactions of the Institute of British Geographers 5(3), 330-349.) model? Thanks, Rajesh. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] R_Code
2006/12/13, Duncan Murdoch [EMAIL PROTECTED]: [snipped] Good description. Thank you!! -- Regards, Hans-Peter __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] lmacfPlot in fBasics
Dear R users, Once working with fBasics, in particular lmacfPlot, for producing long memory autocorrelation plot, a log-log plot is generated when there is long memory in data, otherwise an ACF plot is generated which shows no autocorrelation. A problem occures when we want to build a group of plots using par( ). After running lmacfOlot, if there is no long memory, we receive only an ACF, and if any, we receive an ACF and a log-log plot of long memory in our par( ) as well. How can i control the plots generated by lmacfPlot so that: 1- just ACF be appeard in par ( ), or 2- just log-log plot be appeared in par ( ), or 3- both ACF and log-log be appeared in par ( ), in both cases of presenting and lack of long memory in data? The plots generated by lmacfPlot are not kind of interactive. Thank you so much for help, Amir - [[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 and provide commented, minimal, self-contained, reproducible code.
[R] How do I create an object in the Global environment from a function
Hi all, Say I have created an object b in my function myfunc - function() b - 34 How can I make b an object in the Global environment and not just in the environment of myfunc? Thanks, Tim __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] How do I create an object in the Global environment from a function
[EMAIL PROTECTED] wrote: Hi all, Say I have created an object b in my function myfunc - function() b - 34 myfunc - function() b - 34 - Rainer How can I make b an object in the Global environment and not just in the environment of myfunc? Thanks, Tim __ 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 and provide commented, minimal, self-contained, reproducible code. -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology and Entomology University of Stellenbosch Matieland 7602 South Africa Tel:+27 - (0)72 808 2975 (w) Fax:+27 - (0)86 516 2782 Fax:+27 - (0)21 808 3304 (w) Cell: +27 - (0)83 9479 042 email: [EMAIL PROTECTED] [EMAIL PROTECTED] __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] question about for loop
Dear R-experts, I have a dataset of 4 patients and each patient has many records at four different time points. I have done 4 different qqnorm plots on the same graph where each plot represents the records of one patient at each time point. I would like to do the same graph for the remaining patiens, but instead of repeating the below procedure three more times I would like to have a for loop so when I run the loop I would get four graphs of the four patients at the same time, where each graph has 4 different qqnorm plots representing the data at four time points for each patient. I tried to do the loop but couldn't make it work. below is the code used to the graph for one patient. sli-4 - sli_7 contain records at four time points. dat=dataset, y=records, Slide=time point ### Patient 24 sli_4=dat$y[dat$Slide==4 dat$Control==0] sli_5=dat$y[dat$Slide==5 dat$Control==0] sli_6=dat$y[dat$Slide==6 dat$Control==0] sli_7=dat$y[dat$Slide==7 dat$Control==0] ### qq-plot of patient 24 q_sli4-qqnorm(sli_4,plot.it=FALSE) q_sli5-qqnorm(sli_5,plot.it=FALSE) q_sli6-qqnorm(sli_6,plot.it=FALSE) q_sli7-qqnorm(sli_7,plot.it=FALSE) plot(range(q_sli4,q_sli5,q_sli6,q_sli7),range(q_sli4,q_sli5,q_sli6,q_sli7),type=n, xlab = Theoretical Quantiles,col.main=blue, main = Normal Q-Q Plot of index for patient 24,ylab = Sample Quantiles) points(q_sli4,col=4,pch=0,cex=1) points(q_sli5,col=3,pch=1,cex=1) points(q_sli6,col=2,pch=2,cex=1) points(q_sli7,col=1,pch=3,cex=1) legend(topleft,c(Day 0, 56 days,112 days, 252 days),col=c(4,3,2,1), text.col=c(4,3,2,1),pch=c(0,1,2,3),bg=bisque) abline(0,0) Thanks alot for your help, All the bests, Jenny - - [[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 and provide commented, minimal, self-contained, reproducible code.
[R] loop is going to take 26 hours - needs to be quicker!
Dear R-help, I have a loop, which is set to take about 26 hours to run at the rate it's going - this is ridiculous and I really need your help to find a more efficient way of loading up my array gpcc.array: #My data is stored in a table format with all the data in one long column #running though every longitute, for every latitude, for every year. The #original data is sotred as gpcc.data2 where dim(gpcc.data2) = [476928,5] where #the 5th column is the data: #make the array in the format I need [longitude,latitude,years] gpcc.array - array(NA, c(144,72,46)) n=0 for(k in 1:46){ for(j in 1:72){ for(i in 1:144){ n - n+1 gpcc.array[i,j,k] - gpcc.data2[n,5] print(j) } } } So it runs through all the longs for every lat for every year - which is the order the data is running down the column in gpcc.data2 so n increses by 1 each time and each data point is pulled off It needs to be a lot quicker, I'd appreciate any ideas! Many thanks for taking time to read this, Jenny Barnes ~~ Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Contents of R-packages
Ralf Finne wrote: Hi experts, How do I see the contents of a package that looks interesting? Efter I have loded the package, is there an command that gives me the contents or even better a summary or introduction. The following, which was mentioned to me off the list, also provides useful summaries within R: library(help=vcd) # Summaries of vcd package and functions Ralf Finne SYH University of Applied Sciences, Finland __ 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 and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] loop is going to take 26 hours - needs to be quicker!
Jenny Barnes wrote: Dear R-help, I have a loop, which is set to take about 26 hours to run at the rate it's going - this is ridiculous and I really need your help to find a more efficient way of loading up my array gpcc.array: #My data is stored in a table format with all the data in one long column #running though every longitute, for every latitude, for every year. The #original data is sotred as gpcc.data2 where dim(gpcc.data2) = [476928,5] where #the 5th column is the data: #make the array in the format I need [longitude,latitude,years] gpcc.array - array(NA, c(144,72,46)) n=0 for(k in 1:46){ for(j in 1:72){ for(i in 1:144){ n - n+1 gpcc.array[i,j,k] - gpcc.data2[n,5] print(j) } } } I don't know if it is faster - but adding three columns to qpcc.data, one for longitude, one for lattitude and one for year (using rep() as they are in sequence) and the using reshape() might be faster? So it runs through all the longs for every lat for every year - which is the order the data is running down the column in gpcc.data2 so n increses by 1 each time and each data point is pulled off It needs to be a lot quicker, I'd appreciate any ideas! Many thanks for taking time to read this, Jenny Barnes ~~ Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code. -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology and Entomology University of Stellenbosch Matieland 7602 South Africa Tel:+27 - (0)72 808 2975 (w) Fax:+27 - (0)86 516 2782 Fax:+27 - (0)21 808 3304 (w) Cell: +27 - (0)83 9479 042 email: [EMAIL PROTECTED] [EMAIL PROTECTED] __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] loop is going to take 26 hours - needs to be quicker!
On 12/14/2006 7:56 AM, Jenny Barnes wrote: Dear R-help, I have a loop, which is set to take about 26 hours to run at the rate it's going - this is ridiculous and I really need your help to find a more efficient way of loading up my array gpcc.array: #My data is stored in a table format with all the data in one long column #running though every longitute, for every latitude, for every year. The #original data is sotred as gpcc.data2 where dim(gpcc.data2) = [476928,5] where #the 5th column is the data: #make the array in the format I need [longitude,latitude,years] gpcc.array - array(NA, c(144,72,46)) n=0 for(k in 1:46){ for(j in 1:72){ for(i in 1:144){ n - n+1 gpcc.array[i,j,k] - gpcc.data2[n,5] print(j) } } } So it runs through all the longs for every lat for every year - which is the order the data is running down the column in gpcc.data2 so n increses by 1 each time and each data point is pulled off It needs to be a lot quicker, I'd appreciate any ideas! I think the loop above is equivalent to gpcc.array - array(gpcc.data2[,5], c(144, 72, 46)) which would certainly be a lot quicker. You should check that the values are loaded in the right order (probably on a smaller example!). If not, you should change the order of indices when you create the array, and use the aperm() function to get them the way you want afterwards. Duncan Murdoch __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Delete all dimnames
Hello, how can I get rid of all dimnames so that: $amat Var3 Var2 Var1 8 1111 1 1 1 1 0 0 0 0 0 0 0 7 1110 1 0 0 0 1 0 0 0 0 0 0 6 1101 0 1 0 0 0 1 0 0 0 0 0 5 1100 0 0 0 0 0 0 1 0 0 0 0 4 1011 0 0 1 0 0 0 0 1 0 0 0 3 1010 0 0 0 0 0 0 0 0 1 0 0 2 1001 0 0 0 0 0 0 0 0 0 1 0 1 1000 0 0 0 0 0 0 0 0 0 0 1 is displayed with [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] in rows, and the same in columns. The matrix was generated using apply Serguei ___ Austrian Institute of Economic Research (WIFO) Name: Serguei Kaniovski P.O.Box 91 Tel.: +43-1-7982601-231 Arsenal Objekt 20 Fax: +43-1-7989386 1103 Vienna, Austria Mail: [EMAIL PROTECTED] A-1030 Wien http://www.wifo.ac.at/Serguei.Kaniovski [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] question about for loop
Hi well, we do not know how is your data organised so it is only a guess. On 14 Dec 2006 at 13:54, Jenny persson wrote: Date sent: Thu, 14 Dec 2006 13:54:27 +0100 (CET) From: Jenny persson [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] question about for loop Dear R-experts, I have a dataset of 4 patients and each patient has many records at four different time points. I have done 4 different qqnorm plots on the same graph where each plot represents the records of one patient at each time point. I would like to do the same graph for the remaining patiens, but instead of repeating the below procedure three more times I would like to have a for loop so when I run the loop I would get four graphs of the four patients at the same time, where each graph has 4 different qqnorm plots representing the data at four time points for each patient. I tried to do the loop but couldn't make it work. below is the code used to the graph for one patient. sli-4 - sli_7 contain records at four time points. dat=dataset, y=records, Slide=time point based on assumption dat has a column pat.no (numeric) for (i in dat$pat.no) { dat.p-dat[i,] ### Patient 24 # here change all dat to dat.p sli_4=dat$y[dat$Slide==4 dat$Control==0] sli_5=dat$y[dat$Slide==5 dat$Control==0] sli_6=dat$y[dat$Slide==6 dat$Control==0] sli_7=dat$y[dat$Slide==7 dat$Control==0] ### qq-plot of patient 24 q_sli4-qqnorm(sli_4,plot.it=FALSE) q_sli5-qqnorm(sli_5,plot.it=FALSE) q_sli6-qqnorm(sli_6,plot.it=FALSE) q_sli7-qqnorm(sli_7,plot.it=FALSE) plot(range(q_sli4,q_sli5,q_sli6,q_sli7),range(q_sli4,q_sli5,q_sli6,q _sli7),type=n, xlab = Theoretical Quantiles,col.main=blue, main = Normal Q-Q Plot of index for patient 24,ylab = Sample # here you shall consult expression or bquote help page Quantiles) points(q_sli4,col=4,pch=0,cex=1) points(q_sli5,col=3,pch=1,cex=1) points(q_sli6,col=2,pch=2,cex=1) points(q_sli7,col=1,pch=3,cex=1) legend(topleft,c(Day 0, 56 days,112 days, 252 days),col=c(4,3,2,1), text.col=c(4,3,2,1),pch=c(0,1,2,3),bg=bisque) abline(0,0) } # here is the end of your plotting However you need either to save your plots to some files (see pdf, png) or to tell to your progrem to wait with further plotting until you look at your plot. HTH Petr Thanks alot for your help, All the bests, Jenny - - [[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 and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] loop is going to take 26 hours - needs to be quicker!
Dear R-help, I forgot to mention that I need the array in that format because I am going to do the same thing for another dataset of precipitation (ncep.data2) so they are both arrays of dimensions [144,72,46] so that I can correlate them globally and plot a visual image of the global correlations between the 2 datasets One of the datasets has a land mask applied to it already so it should be clear to see the land and pick ot the locations (i.e.over Europe) where there is strongest and weakest correlation.that is the ultimate goal. Following Rainer's response I should also point out that the columns in gpcc.data2 (with dimensions dim(gpcc.data2) = [476928,5]) are: [,1]=Year, [,2]=month (which is just january so always 1), [,3]=latitude, [,4]=longitude and [,5]=data. All I want in the gpcc.array is the data not the longitudes and latitude values...hope that helps clear it up a bit! I look forward to hearing any more ideas, thanks again for your time in reading this, Jenny Barnes Jenny Barnes wrote: Dear R-help, I have a loop, which is set to take about 26 hours to run at the rate it's going - this is ridiculous and I really need your help to find a more efficient way of loading up my array gpcc.array: #My data is stored in a table format with all the data in one long column #running though every longitute, for every latitude, for every year. The #original data is sotred as gpcc.data2 where dim(gpcc.data2) = [476928,5] where #the 5th column is the data: #make the array in the format I need [longitude,latitude,years] gpcc.array - array(NA, c(144,72,46)) n=0 for(k in 1:46){ for(j in 1:72){ for(i in 1:144){ n - n+1 gpcc.array[i,j,k] - gpcc.data2[n,5] print(j) } } } I don't know if it is faster - but adding three columns to qpcc.data, one for longitude, one for lattitude and one for year (using rep() as they are in sequence) and the using reshape() might be faster? So it runs through all the longs for every lat for every year - which is the order the data is running down the column in gpcc.data2 so n increses by 1 each time and each data point is pulled off It needs to be a lot quicker, I'd appreciate any ideas! Many thanks for taking time to read this, Jenny Barnes ~~ Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code. -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology and Entomology University of Stellenbosch Matieland 7602 South Africa Tel: +27 - (0)72 808 2975 (w) Fax: +27 - (0)86 516 2782 Fax: +27 - (0)21 808 3304 (w) Cell: +27 - (0)83 9479 042 email: [EMAIL PROTECTED] [EMAIL PROTECTED] Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] sapply problem
I have encountered the following problem: I need to extract from a list of lists equally named compenents who happen to be 'one row' data frames. a trivial example would be: a - list(list( df = data.frame(A = 1, B = 2, C = 3)), list(df = data.frame(A = 4,B = 5,C = 6))) I want the extracted compenents to fill up a matrix or data frame row by row. the obvious thing to do seems: b - sapply(a, [[, df) b - t(b) now `b' looks all right: b class(b) but it turns out that all elements in this matrix are one element lists: class(b[1,1]) which prevents any further standard processing of `b' (like `colMeans', e.g.) question 1: is their a straightforward way to enforce that `b' contains simple numbers as elements right from the start (instead of something like apply(b, 1:2, class-, numeric) afterwards)? question 2: should not sapply do this further 'simplification' anyway in a situation like this (matrix elements turn out to be one-element lists)? regards joerg __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] How do I create an object in the Global environment from a function
On Dec 14, 2006, at 7:42 AM, Rainer M Krug wrote: myfunc - function() b - 34 I would add a warning here. It is generally not a good idea for a function to have side-effects. In this case, if there is a globally defined value for b already, it will be overwritten. If this function is in a package say, and someone else uses it, or you use it after a very long time and have forgotten its internals and the fact that it's messing with the Global Environment, this might lead to some bugs that are really hard to spot. Rainer Haris __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] loop is going to take 26 hours - needs to be quicker!
What about gpcc.array - array(gpcc.data2[,5], dim=c(144,72,46)) On 14/12/06, Rainer M Krug [EMAIL PROTECTED] wrote: Jenny Barnes wrote: Dear R-help, I have a loop, which is set to take about 26 hours to run at the rate it's going - this is ridiculous and I really need your help to find a more efficient way of loading up my array gpcc.array: #My data is stored in a table format with all the data in one long column #running though every longitute, for every latitude, for every year. The #original data is sotred as gpcc.data2 where dim(gpcc.data2) = [476928,5] where #the 5th column is the data: #make the array in the format I need [longitude,latitude,years] gpcc.array - array(NA, c(144,72,46)) n=0 for(k in 1:46){ for(j in 1:72){ for(i in 1:144){ n - n+1 gpcc.array[i,j,k] - gpcc.data2[n,5] print(j) } } } I don't know if it is faster - but adding three columns to qpcc.data, one for longitude, one for lattitude and one for year (using rep() as they are in sequence) and the using reshape() might be faster? So it runs through all the longs for every lat for every year - which is the order the data is running down the column in gpcc.data2 so n increses by 1 each time and each data point is pulled off It needs to be a lot quicker, I'd appreciate any ideas! Many thanks for taking time to read this, Jenny Barnes ~~ Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code. -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology and Entomology University of Stellenbosch Matieland 7602 South Africa Tel:+27 - (0)72 808 2975 (w) Fax:+27 - (0)86 516 2782 Fax:+27 - (0)21 808 3304 (w) Cell: +27 - (0)83 9479 042 email: [EMAIL PROTECTED] [EMAIL PROTECTED] __ 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 and provide commented, minimal, self-contained, reproducible code. -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] loop is going to take 26 hours - needs to be quicker!
On Thu, 2006-12-14 at 12:56 +, Jenny Barnes wrote: Dear R-help, I have a loop, which is set to take about 26 hours to run at the rate it's going - this is ridiculous and I really need your help to find a more efficient way of loading up my array gpcc.array: #My data is stored in a table format with all the data in one long column #running though every longitute, for every latitude, for every year. The #original data is sotred as gpcc.data2 where dim(gpcc.data2) = [476928,5] where #the 5th column is the data: #make the array in the format I need [longitude,latitude,years] gpcc.array - array(NA, c(144,72,46)) n=0 for(k in 1:46){ for(j in 1:72){ for(i in 1:144){ n - n+1 gpcc.array[i,j,k] - gpcc.data2[n,5] print(j) } } } So it runs through all the longs for every lat for every year - which is the order the data is running down the column in gpcc.data2 so n increses by 1 each time and each data point is pulled off It needs to be a lot quicker, I'd appreciate any ideas! Many thanks for taking time to read this, Jenny Barnes Take a whole object approach to this problem. You are also wasting a lot of time by printing the values of 'j' in the loop. gpcc.data2 - matrix(rnorm(476928 * 5), ncol = 5) dim(gpcc.data2) [1] 476928 5 str(gpcc.data2) num [1:476928, 1:5] 2.7385 -0.0438 -0.1084 0.8768 -1.0024 ... system.time(gpcc.array - array(gpcc.data2[, 5], dim = c(144, 72, 46))) [1] 0.024 0.026 0.078 0.000 0.000 You should verify the order of the values and adjust the indices accordingly, if the above results in an out of order array. HTH, Marc Schwartz __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Model formula question
Hi all, I'm not familiar with R programming and I'm trying to reproduce a result from a paper. Basically, I have a dataset which I would like to model in terms of successive increments, i.e. (y denote empirical values of y) y_1 = y1, y_2 = y1 + delta1, y_3 = y1 + delta1 + delta2. ... y_m = y1 + sum_2^m delta j where delta_j donote successive increments in the y-values, i.e. delta j = y_j - y_(j-1). In order to estimate y-values, I'm assuming that delta j is approximately equal to kj**u, such that my regression model should be something like this: ^y_1 = a1 ^y_2 = a1 + k2**u ^y_3 = a1 + k2**u + k3**u ... ^y_m = a1 + k2**u + k3**u + ... + km**u or, generically ^yi = a1 + k * sum_j=2^i j**u and I need to fit a non-linear least-squares regression model to find the tripplet a1,k,u. I had a look to the gnm package, but I don't have the lesser idea how to formulate this problem to use this package. Can someone help me with that? cheers, Ronaldo __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] loop is going to take 26 hours - needs to be quicker!
David Barron wrote: What about gpcc.array - array(gpcc.data2[,5], dim=c(144,72,46)) I guess this will be slightly faster then my suggestion :-) ? On 14/12/06, Rainer M Krug [EMAIL PROTECTED] wrote: Jenny Barnes wrote: Dear R-help, I have a loop, which is set to take about 26 hours to run at the rate it's going - this is ridiculous and I really need your help to find a more efficient way of loading up my array gpcc.array: #My data is stored in a table format with all the data in one long column #running though every longitute, for every latitude, for every year. The #original data is sotred as gpcc.data2 where dim(gpcc.data2) = [476928,5] where #the 5th column is the data: #make the array in the format I need [longitude,latitude,years] gpcc.array - array(NA, c(144,72,46)) n=0 for(k in 1:46){ for(j in 1:72){ for(i in 1:144){ n - n+1 gpcc.array[i,j,k] - gpcc.data2[n,5] print(j) } } } I don't know if it is faster - but adding three columns to qpcc.data, one for longitude, one for lattitude and one for year (using rep() as they are in sequence) and the using reshape() might be faster? So it runs through all the longs for every lat for every year - which is the order the data is running down the column in gpcc.data2 so n increses by 1 each time and each data point is pulled off It needs to be a lot quicker, I'd appreciate any ideas! Many thanks for taking time to read this, Jenny Barnes -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology and Entomology University of Stellenbosch Matieland 7602 South Africa Tel:+27 - (0)72 808 2975 (w) Fax:+27 - (0)86 516 2782 Fax:+27 - (0)21 808 3304 (w) Cell: +27 - (0)83 9479 042 email: [EMAIL PROTECTED] [EMAIL PROTECTED] __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] loop is going to take 26 hours - needs to be quicker!
Dear R-help, Thank you for the responses off everyone- you'll be please to hear Duncan that using: gpcc.array - array(gpcc.data2[,5], c(144, 72, 46)) was spot-on, worked like a dream. The data is in the correct places as I checked with the text file. It took literally 2 seconds - quite an improvement time on the predicted 26 hours :-) I really really appreciate your help, you're all very very kind people. Merry Christmas, Jenny Barnes Date: Thu, 14 Dec 2006 08:17:24 -0500 From: Duncan Murdoch [EMAIL PROTECTED] User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) MIME-Version: 1.0 To: Jenny Barnes [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch Subject: Re: [R] loop is going to take 26 hours - needs to be quicker! Content-Transfer-Encoding: 7bit X-MSSL-MailScanner-Information: Please contact the ISP for more information X-MSSL-MailScanner: No virus found X-MSSL-MailScanner-SpamCheck: not spam, SpamAssassin (score=-4.9, required 5, BAYES_00 -4.90) On 12/14/2006 7:56 AM, Jenny Barnes wrote: Dear R-help, I have a loop, which is set to take about 26 hours to run at the rate it's going - this is ridiculous and I really need your help to find a more efficient way of loading up my array gpcc.array: #My data is stored in a table format with all the data in one long column #running though every longitute, for every latitude, for every year. The #original data is sotred as gpcc.data2 where dim(gpcc.data2) = [476928,5] where #the 5th column is the data: #make the array in the format I need [longitude,latitude,years] gpcc.array - array(NA, c(144,72,46)) n=0 for(k in 1:46){ for(j in 1:72){ for(i in 1:144){ n - n+1 gpcc.array[i,j,k] - gpcc.data2[n,5] print(j) } } } So it runs through all the longs for every lat for every year - which is the order the data is running down the column in gpcc.data2 so n increses by 1 each time and each data point is pulled off It needs to be a lot quicker, I'd appreciate any ideas! I think the loop above is equivalent to gpcc.array - array(gpcc.data2[,5], c(144, 72, 46)) which would certainly be a lot quicker. You should check that the values are loaded in the right order (probably on a smaller example!). If not, you should change the order of indices when you create the array, and use the aperm() function to get them the way you want afterwards. Duncan Murdoch Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Delete all dimnames
Hi try to read ?matrix help page. It leads you to dimnames and dimmnames($amat)-NULL strips dimnames from matrix. HTH Petr On 14 Dec 2006 at 14:29, Serguei Kaniovski wrote: To: r-help@stat.math.ethz.ch From: Serguei Kaniovski [EMAIL PROTECTED] Date sent: Thu, 14 Dec 2006 14:29:25 +0100 Subject:[R] Delete all dimnames Hello, how can I get rid of all dimnames so that: $amat Var3 Var2 Var1 8 1111 1 1 1 1 0 0 0 0 0 0 0 7 1110 1 0 0 0 1 0 0 0 0 0 0 6 1101 0 1 0 0 0 1 0 0 0 0 0 5 1100 0 0 0 0 0 0 1 0 0 0 0 4 1011 0 0 1 0 0 0 0 1 0 0 0 3 1010 0 0 0 0 0 0 0 0 1 0 0 2 1001 0 0 0 0 0 0 0 0 0 1 0 1 1000 0 0 0 0 0 0 0 0 0 0 1 is displayed with [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] in rows, and the same in columns. The matrix was generated using apply Serguei ___ Austrian Institute of Economic Research (WIFO) Name: Serguei Kaniovski P.O.Box 91 Tel.: +43-1-7982601-231 Arsenal Objekt 20 Fax: +43-1-7989386 1103 Vienna, Austria Mail: [EMAIL PROTECTED] A-1030 Wien http://www.wifo.ac.at/Serguei.Kaniovski [[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 and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Model formula question
Hi all, I'm not familiar with R programming and I'm trying to reproduce a result from a paper. Basically, I have a dataset which I would like to model in terms of successive increments, i.e. (y denote empirical values of y) y_1 = y1, y_2 = y1 + delta1, y_3 = y1 + delta1 + delta2. ... y_m = y1 + sum_2^m delta j where delta_j donote successive increments in the y-values, i.e. delta j = y_j - y_(j-1). In order to estimate y-values, I'm assuming that delta j is approximately equal to kj**u, such that my regression model should be something like this: ^y_1 = a1 ^y_2 = a1 + k2**u ^y_3 = a1 + k2**u + k3**u ... ^y_m = a1 + k2**u + k3**u + ... + km**u or, generically ^yi = a1 + k * sum_j=2^i j**u and I need to fit a non-linear least-squares regression model to find the tripplet a1,k,u. I had a look to the gnm package, but I don't have the lesser idea how to formulate this problem to use this package. Can someone help me with that? cheers, Ronaldo __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] loop is going to take 26 hours - needs to be quicker!
Jenny Barnes wrote: Dear R-help, Thank you for the responses off everyone- you'll be please to hear Duncan that using: gpcc.array - array(gpcc.data2[,5], c(144, 72, 46)) was spot-on, worked like a dream. The data is in the correct places as I checked with the text file. It took literally 2 seconds - quite an improvement time on the predicted 26 hours :-) However now you cant tell your supervisor that your data manipulation will take 26 hours - giving you a day to get your Xmas shopping done... Barry __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Install R in Linux
--- Peter Dalgaard [EMAIL PROTECTED] wrote: lu kan wrote: Hi, Is it possible to install R in a linux box (Debian) without being a root. I know I can compile the R source code, but there is no F77 compiler on the box. So is it possible to install binary R without being a root? (We did see it the first time!!) In a word, no. Either you need to install the binaries as root or install sufficient build tools as root. There's a slight chance that you could unpack the Debian binaries somewhere and then fix up the paths, but you're on your own. If you really need to use it and are not root, a slow but workable approach is to install R on a USB stick and run from there. I have done this for R.2.3.1 but I have not upgraded to a newer package. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] loop is going to take 26 hours - needs to be quicker!
Dear Patrick, Thank you for the link - I'd advise anyone who's started using R to have a look at these as well - any help is always appreciated. I've downloaded the S Poetry and will hit the books tomorrow and get reading it! Jenny S Poetry may be of use to you -- especially the chapter on arrays which discusses 3 dimensional arrays in particular. 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) Jenny Barnes wrote: Dear R-help, I forgot to mention that I need the array in that format because I am going to do the same thing for another dataset of precipitation (ncep.data2) so they are both arrays of dimensions [144,72,46] so that I can correlate them globally and plot a visual image of the global correlations between the 2 datasets One of the datasets has a land mask applied to it already so it should be clear to see the land and pick ot the locations (i.e.over Europe) where there is strongest and weakest correlation.that is the ultimate goal. Following Rainer's response I should also point out that the columns in gpcc.data2 (with dimensions dim(gpcc.data2) = [476928,5]) are: [,1]=Year, [,2]=month (which is just january so always 1), [,3]=latitude, [,4]=longitude and [,5]=data. All I want in the gpcc.array is the data not the longitudes and latitude values...hope that helps clear it up a bit! I look forward to hearing any more ideas, thanks again for your time in reading this, Jenny Barnes Jenny Barnes wrote: Dear R-help, I have a loop, which is set to take about 26 hours to run at the rate it's going - this is ridiculous and I really need your help to find a more efficient way of loading up my array gpcc.array: #My data is stored in a table format with all the data in one long column #running though every longitute, for every latitude, for every year. The #original data is sotred as gpcc.data2 where dim(gpcc.data2) = [476928,5] where #the 5th column is the data: #make the array in the format I need [longitude,latitude,years] gpcc.array - array(NA, c(144,72,46)) n=0 for(k in 1:46){ for(j in 1:72){ for(i in 1:144){ n - n+1 gpcc.array[i,j,k] - gpcc.data2[n,5] print(j) } } } I don't know if it is faster - but adding three columns to qpcc.data, one for longitude, one for lattitude and one for year (using rep() as they are in sequence) and the using reshape() might be faster? So it runs through all the longs for every lat for every year - which is the order the data is running down the column in gpcc.data2 so n increses by 1 each time and each data point is pulled off It needs to be a lot quicker, I'd appreciate any ideas! Many thanks for taking time to read this, Jenny Barnes ~~ Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code. -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology and Entomology University of Stellenbosch Matieland 7602 South Africa Tel: +27 - (0)72 808 2975 (w) Fax: +27 - (0)86 516 2782 Fax: +27 - (0)21 808 3304 (w) Cell:+27 - (0)83 9479 042 email: [EMAIL PROTECTED] [EMAIL PROTECTED] Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code. Jennifer Barnes PhD student - long range drought prediction Climate Extremes Department of Space and Climate Physics University College London Holmbury St Mary, Dorking Surrey RH5 6NT 01483 204149 07916 139187 Web: http://climate.mssl.ucl.ac.uk __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] matrix - change values
Dear R Users, I have a matrix A, and I want to change every value of this matrix if these values are greater than an assuming value. For a vector it is simple, e.g. a-c(1:10); a[a5]-0. Of course, I can change matrix to vector, assign a value then change vector to matrix. But does there exist simpler way? Any suggestion are appreciate. Rob __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Delete all dimnames
Serguei Kaniovski wrote: Hello, how can I get rid of all dimnames so that: $amat Var3 Var2 Var1 8 1111 1 1 1 1 0 0 0 0 0 0 0 7 1110 1 0 0 0 1 0 0 0 0 0 0 6 1101 0 1 0 0 0 1 0 0 0 0 0 5 1100 0 0 0 0 0 0 1 0 0 0 0 4 1011 0 0 1 0 0 0 0 1 0 0 0 3 1010 0 0 0 0 0 0 0 0 1 0 0 2 1001 0 0 0 0 0 0 0 0 0 1 0 1 1000 0 0 0 0 0 0 0 0 0 0 1 is displayed with [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] in rows, and the same in columns. The matrix was generated using apply dimnames(mat) - NULL __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Install R in Linux
On 12/13/06, lu kan [EMAIL PROTECTED] wrote: Hi, Is it possible to install R in a linux box (Debian) without being a root. I know I can compile the R source code, but there is no F77 compiler on the box. So is it possible to install binary R without being a root? If you can get the F77 compiler installed you can configure, make, test and run R from its bin directory without being root. I did this last night on a SuSE box with 2.4.0 prior to doing a final make install as root. jab -- John Bollinger, CFA, CMT www.BollingerBands.com If you advance far enough, you arrive at the beginning. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] matrix - change values
[EMAIL PROTECTED] wrote: Dear R Users, I have a matrix A, and I want to change every value of this matrix if these values are greater than an assuming value. For a vector it is simple, e.g. a-c(1:10); a[a5]-0. Of course, I can change matrix to vector, assign a value then change vector to matrix. But does there exist simpler way? The same syntax as for a vector: A[A5] - 0 Remember that matrices are just vectors with a dim attribute. The dim attribute is unchanged by this operation: A - matrix(1:10, 2, 5) A [,1] [,2] [,3] [,4] [,5] [1,]13579 [2,]2468 10 A[A5] - 0 A [,1] [,2] [,3] [,4] [,5] [1,]13500 [2,]24000 Duncan Murdoch __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] The Balvenie : Remportez trois whisky d'exception
Si vous désirez visualiser ce mail au format html, recopiez l'adresse suivante dans votre navigateur: http:///view.html?id=2825ref=396150 Si vous désirez vous désinscrire, il suffit de cliquer sur le lien prévu ou de recopier l'adresse suivante dans votre navigateur: http:///desabo.html?ope=2825[EMAIL PROTECTED]client=31 [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Delete all dimnames
On 12/14/06, Serguei Kaniovski [EMAIL PROTECTED] wrote: Hello, how can I get rid of all dimnames so that: test a b c A 1 4 7 B 2 5 8 C 3 6 9 dimnames(test) - list(NULL, NULL) test [,1] [,2] [,3] [1,]147 [2,]258 [3,]369 Sarah -- Sarah Goslee http://www.functionaldiversity.org __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] matrix - change values
Rob, Try a[a5]-0 Yup. It works for matrices (and for arrays). It also works with the replacement value being a vector. For example, try b - array(1:24, dim=c(3, 4, 2)) b[(b8) (b17)] - 101:108 I think the reason it works like this is that internally array are stored as vectors. Cheers, Andy __ Andy Jaworski 518-1-01 Process Laboratory 3M Corporate Research Laboratory - E-mail: [EMAIL PROTECTED] Tel: (651) 733-6092 Fax: (651) 736-3122 [EMAIL PROTECTED] 2.pl Sent by: To [EMAIL PROTECTED] r-help@stat.math.ethz.ch at.math.ethz.chcc Subject 12/14/2006 08:01 [R] matrix - change values AM Dear R Users, I have a matrix A, and I want to change every value of this matrix if these values are greater than an assuming value. For a vector it is simple, e.g. a-c(1:10); a[a5]-0. Of course, I can change matrix to vector, assign a value then change vector to matrix. But does there exist simpler way? Any suggestion are appreciate. Rob __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Asymmetrical ANOVA / contrasts
Dear all, I have problems to code contrasts for performing an asymmetrical anova with aov(). I am using aov() because I want to get the Mean Squares for further analyses. I didn't find any solution to my problem in the help files of functions aov(), contrasts(), C(), etc. Let's say I have three locations, one with treatment P, and two with treatment C: loc=factor(c(P1,P1,P1,P1,P1,C1,C1,C1,C1,C1,C2,C2,C2,C2,C2)) And here is my variable: X=c(21,23,34,32,23,9,4,5,6,8,3,2,8,7,6) I want to test the effect of location P versus location C Here is what I have done: contrasts(loc)=contr.treatment(3) aov(X~C(loc,c(2,-1,-1))) This gives me exactly the same result as if I was doing simply aov(X~loc) without first coding for the contrasts. I have also tried: aov(X~loc,contrasts=contrasts(loc)) Could somebody tell me how to do? Any help would be greatly appreciated. Thanks, Joachim Claudet. -- º))) º))) º))) º))) º))) º))) º))) º))) Joachim Claudet PhD EPHE - CNRS FRE 2935 52, avenue Paul Alduy 66860 Perpignan cedex Tel : 33 4 68662055 Fax : 33 4 68503686 º))) º))) º))) º))) º))) º))) º))) º))) __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Stepwise regression
Dear all, I am wondering why the step() procedure in R has the description 'Select a formula-based model by AIC'. I have been using Stata and SPSS and neither package made any reference to AIC in its stepwise procedure, and I read from an earlier R-Help post that step() is really the 'usual' way for doing stepwise (R Help post from Prof Ripley, Fri, 2 Apr 1999 05:06:03 +0100 (BST)). My understanding of the 'usual' way of doing say forward regression is that variables whose p value drops below a criterion (commonly 0.05) become candidates for being included in the model, and the one with the lowest p among these gets chosen, and the step is repeated until all p values not in the model are above 0.05, cf Hosmer and Lemeshow (1989) Applied Logistic Regression. The procedure does not require examination of the AIC. I am not well aquainted with R enough to understand the codes used in step(), so can somebody tell me how step() works? Thanks very much, Tim __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Stepwise regression
Dear all, I am wondering why the step() procedure in R has the description 'Select a formula-based model by AIC'. I have been using Stata and SPSS and neither package made any reference to AIC in its stepwise procedure, and I read from an earlier R-Help post that step() is really the 'usual' way for doing stepwise (R Help post from Prof Ripley, Fri, 2 Apr 1999 05:06:03 +0100 (BST)). My understanding of the 'usual' way of doing say forward regression is that variables whose p value drops below a criterion (commonly 0.05) become candidates for being included in the model, and the one with the lowest p among these gets chosen, and the step is repeated until all p values not in the model are above 0.05, cf Hosmer and Lemeshow (1989) Applied Logistic Regression. The procedure does not require examination of the AIC. I am not well aquainted with R enough to understand the codes used in step(), so can somebody tell me how step() works? Thanks very much, Tim __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] matrix - change values
I would like to thanks everybody for helpful suggestion. Rob Od: [EMAIL PROTECTED] Do: r-help@stat.math.ethz.ch Data: 14 grudnia 2006 15:01 Temat: [R] matrix - change values Dear R Users, I have a matrix A, and I want to change every value of this matrix if these values are greater than an assuming value. For a vector it is simple, e.g. a-c(1:10); a[a5]-0. Of course, I can change matrix to vector, assign a value then change vector to matrix. But does there exist simpler way? Any suggestion are appreciate. Rob __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] two connected graphs
--- Robin Hankin [EMAIL PROTECTED] wrote: Hi I have two datasets, A and B, consisting of two columns of numbers representing x and y coordinates. They have 10 and 6 rows respectively. I want to plot two scattergraphs, one above the other. The lower graph to contain A (10 points) and the upper graph to contain B (six points). The x-axes of the two graphs must line up. I then want to draw straight lines that connect points of B to a particular point (or points) of A. How do I do this? ?par and read up on mfrow for the two graphs. Here is something that may help for the lines http://finzi.psych.upenn.edu/R/Rhelp02a/archive/1926.html The code below will work but I had to figure out the arrow coordinates by trial and error and there must be a better way. aa - c(1:10) bb - c(1:6) op - par(mfrow = c(2,1), oma=c(1,0,3,0), las=1, xpd = NA ) plot(aa) plot(bb) arrows( 3,3, 4.9, 21.5, length=0) __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Stepwise regression
On Thu, 2006-12-14 at 14:37 +, [EMAIL PROTECTED] wrote: Dear all, I am wondering why the step() procedure in R has the description 'Select a formula-based model by AIC'. I have been using Stata and SPSS and neither package made any reference to AIC in its stepwise procedure, and I read from an earlier R-Help post that step() is really the 'usual' way for doing stepwise (R Help post from Prof Ripley, Fri, 2 Apr 1999 05:06:03 +0100 (BST)). My understanding of the 'usual' way of doing say forward regression is that variables whose p value drops below a criterion (commonly 0.05) become candidates for being included in the model, and the one with the lowest p among these gets chosen, and the step is repeated until all p values not in the model are above 0.05, cf Hosmer and Lemeshow (1989) Applied Logistic Regression. The procedure does not require examination of the AIC. I am not well aquainted with R enough to understand the codes used in step(), so can somebody tell me how step() works? Thanks very much, Tim library(fortunes) fortune(stepwise) Frank Harrell: Here is an easy approach that will yield results only slightly less valid than one actually using the response variable: x - data.frame(x1, x2, x3, x4, ..., other potential predictors) x[ , sample(ncol(x))] Andy Liaw: Hmm... Shouldn't that be something like: x[, sample(ncol(x), ceiling(ncol(x) * runif(1)))] -- Frank Harrell and Andy Liaw (about alternative strategies for stepwise regression and `random parsimony') R-help (May 2005) But seriously, using: RSiteSearch(stepwise) will provide links to prior discussions on why the use of stepwise based model building is to be avoided. A copy of Frank's book (more info here): http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/RmS will also provide insight. HTH, Marc Schwartz __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] two connected graphs
See the first set of examples in the help for the cnvrt.coords function in the TeachingDemos Package. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robin Hankin Sent: Thursday, December 14, 2006 3:32 AM To: RHelp help Subject: [R] two connected graphs Hi I have two datasets, A and B, consisting of two columns of numbers representing x and y coordinates. They have 10 and 6 rows respectively. I want to plot two scattergraphs, one above the other. The lower graph to contain A (10 points) and the upper graph to contain B (six points). The x-axes of the two graphs must line up. I then want to draw straight lines that connect points of B to a particular point (or points) of A. How do I do this? -- 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] convert shingle to factor when overlap=0
What is the recommended way to convert a shingle to a factor (when overlap=0)? In other words, I want to know in which interval each observation falls. Thanks, Ben __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to avoid test for NAs in foreign function call
Supply NAOK=TRUE argument to .C; the help page for .C() contains the following: Usage .C(name, ..., NAOK = FALSE, DUP = TRUE, PACKAGE) Also, you might want to consider using the raw data type instead of integers -- that way you should have fewer problems with R code making unwanted interpretations of certain bit patterns. -- Tony Plate Knut M. Wittkowski wrote: We have packed logical vectors into integers, 32 flags at a time and then want to AND or OR these vectors of integers using other C functions. The problem: occasionally, the packed sequence of 32 logical values resembles NA, causing the error message: Error in bitAND(packed1, packed2, lenx) : NAs in foreign function call (arg 1) How does one instruct R to avoid checking for NAs? Knut M. Wittkowski, PhD,DSc -- The Rockefeller University, Center for Clinical and Translational Science Research Design and Biostatistics, 1230 York Ave #121B, Box 322, NY,NY 10021 +1(212)327-7175, +1(212)327-8450 (Fax), [EMAIL PROTECTED] http://www.rockefeller.edu/ccts/rdbs.php __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Problems with ARIMA commands
Hi! I have to fit 36 ARMA models (all combination from the order (0,0) to the order (5,5) ) to 1000 bootstrap replication from each of 1000 simulated time series following an ARMA(2,1) process. The simulated series are generated by ARIMA.SIM command. The problem is the following: the esimation procedure of ARMA coefficient stops after the estimation of a certain number of bootstrap replication (it ranges from 10,15 to 55) always before the 10-th simulated serie due to an error in solve.default(res$hessian * n.used) : Lapack routine dgesv: is the system is exactely singiular . I tried to modify the command OPTIM in the command ARIMA, it worked but not when I try to apply this modified OPTIM in the ARMA command. In other words I put an error in the OPTIM command but ARMA ignores it and gives me parameters estimation. Another (related) question is the following: is there a way to modify ARIMA command in order to get only the estimated coefficients and the AIC ? I really would like to thank for the kind attention. Best, Livio Fenga Chiacchiera con i tuoi amici in tempo reale! http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Asymmetrical ANOVA / contrasts
Dear all, I have problems to code contrasts for performing an asymmetrical anova with aov(). I am using aov() because I want to get the Mean Squares for further analyses. I didn't find any solution to my problem in the help files of functions aov(), contrasts(), C(), etc. Let's say I have three locations, one with treatment P, and two with treatment C: loc=factor(c(P1,P1,P1,P1,P1,C1,C1,C1,C1,C1,C2,C2,C2,C2,C2)) And here is my variable: X=c(21,23,34,32,23,9,4,5,6,8,3,2,8,7,6) I want to test the effect of location P versus location C Here is what I have done: contrasts(loc)=contr.treatment(3) aov(X~C(loc,c(2,-1,-1))) This gives me exactly the same result as if I was doing simply aov(X~loc) without first coding for the contrasts. I have also tried: aov(X~loc,contrasts=contrasts(loc)) Could somebody tell me how to do? Any help would be greatly appreciated. Thanks, Joachim Claudet. -- º))) º))) º))) º))) º))) º))) º))) º))) Joachim Claudet PhD EPHE - CNRS FRE 2935 52, avenue Paul Alduy 66860 Perpignan cedex Tel : 33 4 68662055 Fax : 33 4 68503686 º))) º))) º))) º))) º))) º))) º))) º))) __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Asymmetrical ANOVA / contrasts
You need to specify the how.many argument to C (otherwise it tries to be helpful by creating an additional orthogonal contrast), like this: aov(X~C(loc,c(2,-1,-1),how.many=1)) One of the ways to see what is going on is to do: fit1 - aov(X~C(loc,c(2,-1,-1)), x=TRUE) fit2 - aov(X~C(loc,c(2,-1,-1),how.many=1), x=TRUE) fit1$x fit2$x This shows you exactly the x matrix being used, in your case it also shows that you are comparing C1 to the average of C2 and P1 (factor orders the levels alphabetically by default). You may also want to look at the 'split' argument in the summary.aov function. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Joachim Claudet Sent: Thursday, December 14, 2006 9:35 AM To: r-help@stat.math.ethz.ch Subject: [R] Asymmetrical ANOVA / contrasts Dear all, I have problems to code contrasts for performing an asymmetrical anova with aov(). I am using aov() because I want to get the Mean Squares for further analyses. I didn't find any solution to my problem in the help files of functions aov(), contrasts(), C(), etc. Let's say I have three locations, one with treatment P, and two with treatment C: loc=factor(c(P1,P1,P1,P1,P1,C1,C1,C1,C1,C1,C2,C2,C2,C2,C2)) And here is my variable: X=c(21,23,34,32,23,9,4,5,6,8,3,2,8,7,6) I want to test the effect of location P versus location C Here is what I have done: contrasts(loc)=contr.treatment(3) aov(X~C(loc,c(2,-1,-1))) This gives me exactly the same result as if I was doing simply aov(X~loc) without first coding for the contrasts. I have also tried: aov(X~loc,contrasts=contrasts(loc)) Could somebody tell me how to do? Any help would be greatly appreciated. Thanks, Joachim Claudet. -- º))) º))) º))) º))) º))) º))) º))) º))) Joachim Claudet PhD EPHE - CNRS FRE 2935 52, avenue Paul Alduy 66860 Perpignan cedex Tel : 33 4 68662055 Fax : 33 4 68503686 º))) º))) º))) º))) º))) º))) º))) º))) __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] matrix - change values
A matrix is already a vector, you don't need to do the transformations, just do the same thing directly: tmp - matrix( sample(1:12), ncol=3 ) tmp [,1] [,2] [,3] [1,] 1116 [2,]379 [3,]4 128 [4,]25 10 tmp[tmp 5] - 0 tmp [,1] [,2] [,3] [1,]010 [2,]300 [3,]400 [4,]250 If on the other hand, your matrix is really a data frame then functions like lapply, sapply, transform may help. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Thursday, December 14, 2006 7:01 AM To: r-help@stat.math.ethz.ch Subject: [R] matrix - change values Dear R Users, I have a matrix A, and I want to change every value of this matrix if these values are greater than an assuming value. For a vector it is simple, e.g. a-c(1:10); a[a5]-0. Of course, I can change matrix to vector, assign a value then change vector to matrix. But does there exist simpler way? Any suggestion are appreciate. Rob __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Better way to change the name of a column in a dataframe?
Hello R users -- If I have a dataframe such as the following, named frame with the columns intended to be named col1 through col6, frame col1 col2 cmlo3 col4 col5 col6 [1,]3 10 2657 [2,]68 4 1071 [3,]75 1318 [4,] 106 5492 and I want to correct or otherwise change the name of one of the columns, I can do so with dimnames(frame)[[2]][which(dimnames(frame)[[2]]==cmlo3)] - col3 which renames the offending column: frame col1 col2 col3 col4 col5 col6 [1,]3 102657 [2,]684 1071 [3,]751318 [4,] 1065492 This seems cumbersome and not very intuitive. How can one accomplish this more simply? With thanks for any suggestions, Ben Fairbank [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] sapply problem
try this: b - as.matrix(do.call('rbind', lapply(a,'[[','df'))) str(b) num [1:2, 1:3] 1 4 2 5 3 6 - attr(*, dimnames)=List of 2 ..$ : chr [1:2] 1 2 ..$ : chr [1:3] A B C colMeans(b) A B C 2.5 3.5 4.5 b A B C 1 1 2 3 2 4 5 6 On 12/14/06, Joerg van den Hoff [EMAIL PROTECTED] wrote: I have encountered the following problem: I need to extract from a list of lists equally named compenents who happen to be 'one row' data frames. a trivial example would be: a - list(list( df = data.frame(A = 1, B = 2, C = 3)), list(df = data.frame(A = 4,B = 5,C = 6))) I want the extracted compenents to fill up a matrix or data frame row by row. the obvious thing to do seems: b - sapply(a, [[, df) b - t(b) now `b' looks all right: b class(b) but it turns out that all elements in this matrix are one element lists: class(b[1,1]) which prevents any further standard processing of `b' (like `colMeans', e.g.) question 1: is their a straightforward way to enforce that `b' contains simple numbers as elements right from the start (instead of something like apply(b, 1:2, class-, numeric) afterwards)? question 2: should not sapply do this further 'simplification' anyway in a situation like this (matrix elements turn out to be one-element lists)? regards joerg __ 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 and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] sapply problem
c - apply(b, c(1,2), unlist) c A B C [1,] 1 2 3 [2,] 4 5 6 class(c[1,1]) [1] numeric On 12/14/06, Joerg van den Hoff [EMAIL PROTECTED] wrote: I have encountered the following problem: I need to extract from a list of lists equally named compenents who happen to be 'one row' data frames. a trivial example would be: a - list(list( df = data.frame(A = 1, B = 2, C = 3)), list(df = data.frame(A = 4,B = 5,C = 6))) I want the extracted compenents to fill up a matrix or data frame row by row. the obvious thing to do seems: b - sapply(a, [[, df) b - t(b) now `b' looks all right: b class(b) but it turns out that all elements in this matrix are one element lists: class(b[1,1]) which prevents any further standard processing of `b' (like `colMeans', e.g.) question 1: is their a straightforward way to enforce that `b' contains simple numbers as elements right from the start (instead of something like apply(b, 1:2, class-, numeric) afterwards)? question 2: should not sapply do this further 'simplification' anyway in a situation like this (matrix elements turn out to be one-element lists)? regards joerg __ 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 and provide commented, minimal, self-contained, reproducible code. -- Weiwei Shi, Ph.D Research Scientist GeneGO, Inc. Did you always know? No, I did not. But I believed... ---Matrix III __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] persistant: Matlab-R
Dear list members, Could anyone tell me if there is an equivalent of the Matlab declaration 'persistant' in R? Thank you very much, Bernard Gregorry. (Matlaber converted to R). - [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] sapply problem
Joerg van den Hoff said the following on 12/14/2006 7:30 AM: I have encountered the following problem: I need to extract from a list of lists equally named compenents who happen to be 'one row' data frames. a trivial example would be: a - list(list( df = data.frame(A = 1, B = 2, C = 3)), list(df = data.frame(A = 4,B = 5,C = 6))) I want the extracted compenents to fill up a matrix or data frame row by row. the obvious thing to do seems: b - sapply(a, [[, df) b - t(b) now `b' looks all right: b class(b) but it turns out that all elements in this matrix are one element lists: class(b[1,1]) which prevents any further standard processing of `b' (like `colMeans', e.g.) question 1: is their a straightforward way to enforce that `b' contains simple numbers as elements right from the start (instead of something like apply(b, 1:2, class-, numeric) afterwards)? Try this: a - list(list(df = data.frame(A = 1, B = 2, C = 3)), list(df = data.frame(A = 4, B = 5, C = 6))) b - do.call(rbind, sapply(a, [, df)) b question 2: should not sapply do this further 'simplification' anyway in a situation like this (matrix elements turn out to be one-element lists)? I think it does as it much as it knows how. I think you might believe that matrix elements can only contain numeric values. This is not a valid assumption. Take this example: a - list(1) b - list(2) (m - matrix(c(a, b), 2, 1)) [,1] [1,] 1 [2,] 2 class(m[1, 1]) [1] list class(m[2, 1]) [1] list HTH, --sundar regards joerg __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] two connected graphs
On Thu, 14 Dec 2006, Robin Hankin wrote: Hi I have two datasets, A and B, consisting of two columns of numbers representing x and y coordinates. They have 10 and 6 rows respectively. I want to plot two scattergraphs, one above the other. The lower graph to contain A (10 points) and the upper graph to contain B (six points). The x-axes of the two graphs must line up. I then want to draw straight lines that connect points of B to a particular point (or points) of A. How do I do this? Use the grid package. You'll want to study the xscale arg of the viewport function (to set up your two plots using the same scale) Calls to grid.move.to, seekViewport, and grid.line.to can be used to connect points in different plots (viewports) [...] Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:[EMAIL PROTECTED] UC San Diego http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego 92093-0717 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] xyplot: discrete points + continuous curve per panel
I will give this a try. However, this is based on row and columns of the panels and not on the SUBJ and DOSE information that I need to calculate the continuous curve. Rene -Original Message- From: Petr Pikal [mailto:[EMAIL PROTECTED] Sent: Thursday, December 14, 2006 1:18 AM To: RMan54; r-help@stat.math.ethz.ch Subject: Re: [R] xyplot: discrete points + continuous curve per panel Hi there is probably better solution but you can try to fiidle with this idea, which adds stight lines to each panel one after another. # based on Gabor Grothendieck's code suggestion # adds straight lines to panels in lattice plots addLine- function(...) { tcL - trellis.currentLayout() for(i in 1:nrow(tcL)) for(j in 1:ncol(tcL)) if (tcL[i,j] 0) { trellis.focus(panel, j, i, highlight = FALSE) panel.abline(...) trellis.unfocus() } } You need to change panel.abline(...) part maybe to panel.curve or panel.segments or? HTH Petr On 13 Dec 2006 at 23:22, RMan54 wrote: Date sent: Wed, 13 Dec 2006 23:22:41 -0800 (PST) From: RMan54 [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] xyplot: discrete points + continuous curve per panel I have a number of x, y observations (Time, Conc) for a number of Subjects (with subject number Subj) and Doses. I can plot the individual points with xyplot fine: xyplot(Conc ~ Time | Subj, Groups=Dose, data=myData, panel = function(x,y) { panel.xyplot(x, y) panel.superpose(???) # Needs more here } ) I also like to plot on each panel (there is one Subj per panel) a continuous curve with predictions that I can calculate from a rather complicated function: myPred - (time, subj, dose) { returns predicted value of Conc for a given time, subj and dose } The predicted curves are different for each panel. How do I plot the predictions? I have tried to add panel.superinpose in the xyplot portion but can't link to the myPred function. I also know about panel.curve but couldn't make it work. My attempt is to calculate the predictions on the fly. Is this possible? Or do I need to calculate all predictions first and put the results in a data frame. Thanks for any help, Rene -- View this message in context: http://www.nabble.com/xyplot%3A-discrete-points-%2B-continuous-curve-p er-panel-tf2818931.html#a7867892 Sent from the R help mailing list archive at Nabble.com. __ 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 and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Stepwise regression
You may want to look at a book that was published more recently than 17 years ago (computing has changed a lot since then). Doing stepwise regression using p-values is one approach (and when p-values were the easiest (only) thing to compute, it was reasonable to use them). But think about how many p-values you would be computing and comparing to 0.05 in a stepwise regression, now think about how many you would have computed if your data had come from a different sample, what is your type I error rate? Is the usual p-value theory even meaningful in this situation? There are several criteria that can be used in stepwise regression to decide which term to add/drop, p-value (or F-statistic) is only 1, others include AIC, BIC, Adjusted R-squared, PRESS, gut feeling, prior knowledge, cost, ... Some of these have properties better than p-values, but most still suffer from the fact that a small change in the data can result in a very different model. Look at the lars, lasso2, and BMA packages for some more modern alternatives to stepwise regression. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Thursday, December 14, 2006 9:28 AM To: r-help@stat.math.ethz.ch Subject: [R] Stepwise regression Dear all, I am wondering why the step() procedure in R has the description 'Select a formula-based model by AIC'. I have been using Stata and SPSS and neither package made any reference to AIC in its stepwise procedure, and I read from an earlier R-Help post that step() is really the 'usual' way for doing stepwise (R Help post from Prof Ripley, Fri, 2 Apr 1999 05:06:03 +0100 (BST)). My understanding of the 'usual' way of doing say forward regression is that variables whose p value drops below a criterion (commonly 0.05) become candidates for being included in the model, and the one with the lowest p among these gets chosen, and the step is repeated until all p values not in the model are above 0.05, cf Hosmer and Lemeshow (1989) Applied Logistic Regression. The procedure does not require examination of the AIC. I am not well aquainted with R enough to understand the codes used in step(), so can somebody tell me how step() works? Thanks very much, Tim __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Model formula
Hi there, I've sent this e-mail to the list twice but didn't get it back from the list. Have it reach list members? cheers, Ronaldo -- Forwarded message -- From: Ronaldo Prati [EMAIL PROTECTED] Date: 14/12/2006 11:59 Subject: Model formula question To: r-help@stat.math.ethz.ch Hi all, I'm not familiar with R programming and I'm trying to reproduce a result from a paper. Basically, I have a dataset which I would like to model in terms of successive increments, i.e. (y denote empirical values of y) y_1 = y1, y_2 = y1 + delta1, y_3 = y1 + delta1 + delta2. ... y_m = y1 + sum_2^m delta j where delta_j donote successive increments in the y-values, i.e. delta j = y_j - y_(j-1). In order to estimate y-values, I'm assuming that delta j is approximately equal to kj**u, such that my regression model should be something like this: ^y_1 = a1 ^y_2 = a1 + k2**u ^y_3 = a1 + k2**u + k3**u ... ^y_m = a1 + k2**u + k3**u + ... + km**u or, generically ^yi = a1 + k * sum_j=2^i j**u and I need to fit a non-linear least-squares regression model to find the tripplet a1,k,u. I had a look to the gnm package, but I don't have the lesser idea how to formulate this problem to use this package. Can someone help me with that? cheers, Ronaldo __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] rotated histogram
I would like to make a scatterplot, with a histogram of the x and y variables above and to the right . I can use layout to set up the areas, and hist(x,y) works fine for the upper histogram. However, I need a rotated histogram on the right, and I don't know how to do this. I've seen a solution with a bar plot on the right, but I'd like to use a histogram. Do you know how I can do this? Steve __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] rotated histogram
On Thu, 2006-12-14 at 13:53 -0500, steve wrote: I would like to make a scatterplot, with a histogram of the x and y variables above and to the right . I can use layout to set up the areas, and hist(x,y) works fine for the upper histogram. However, I need a rotated histogram on the right, and I don't know how to do this. I've seen a solution with a bar plot on the right, but I'd like to use a histogram. Do you know how I can do this? Steve What's wrong with the example in ?layout below the comment: ##-- Create a scatterplot with marginal histograms - ? HTH, Marc Schwartz __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] two connected graphs
Hi Charles C. Berry wrote: On Thu, 14 Dec 2006, Robin Hankin wrote: Hi I have two datasets, A and B, consisting of two columns of numbers representing x and y coordinates. They have 10 and 6 rows respectively. I want to plot two scattergraphs, one above the other. The lower graph to contain A (10 points) and the upper graph to contain B (six points). The x-axes of the two graphs must line up. I then want to draw straight lines that connect points of B to a particular point (or points) of A. How do I do this? Use the grid package. You'll want to study the xscale arg of the viewport function (to set up your two plots using the same scale) Calls to grid.move.to, seekViewport, and grid.line.to can be used to connect points in different plots (viewports) See the example in The grid Graphics Package R News 2(2) http://cran.r-project.org/doc/Rnews/Rnews_2002-2.pdf Paul [...] Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:[EMAIL PROTECTED] UC San Diego http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego 92093-0717 __ 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 and provide commented, minimal, self-contained, reproducible code. -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 [EMAIL PROTECTED] http://www.stat.auckland.ac.nz/~paul/ __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] persistant: Matlab-R
It might be helpful to those not familiar with Matlab to tell us what function persistent does. Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bernard Gregory Sent: Thursday, December 14, 2006 1:14 PM To: r-help@stat.math.ethz.ch Subject: [R] persistant: Matlab-R Dear list members, Could anyone tell me if there is an equivalent of the Matlab declaration 'persistant' in R? Thank you very much, Bernard Gregorry. (Matlaber converted to R). - [[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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error to install fMultivar package
Hello, I tried the first issue of Dirk and it was all right: This would be quicker: $ sudo apt-get install r-cran-fmulitvar (I've already had enabled the Universe repositories in /etc/apt/sources.list. ) I think it was realy related with some lib and packages dependencies. Thank's for all! Gilberto. Em (10:18:04), Dirk Eddelbuettel escreveu: On Wed, Dec 13, 2006 at 09:34:04AM -0300, gsmatos1 wrote: Content-Description: Mail message body Hi, I tried to install fMultivar package but an error occurs that I could not understand. (I've been worked with linux / Ubuntu 6.06 LTS) This would be quicker: $ sudo apt-get install r-cran-fmulitvar (if you enabled the Universe repositories in /etc/apt/sources.list). install.packages(fMultivar) ... trying URL 'http://lmq.esalq.usp.br/CRAN/src/contrib/fMultivar_221.10065.tar.gz' Content type 'application/x-gzip' length 1152747 bytes opened URL == downloaded 1125Kb * Installing *source* package 'fMultivar' ... ** libs gcc -I/usr/share/R/include -I/usr/share/R/include -fpic -g -O2 -std=gnu99 -c 00A-randomF77.c -o 00A-randomF77.o gcc -I/usr/share/R/include -I/usr/share/R/include -fpic -g -O2 -std=gnu99 -c 00B-GarchBEKK.c -o 00B-GarchBEKK.o g77 -fpic -g -O2 -c 42A-1ReggressionModelling.f -o 42A-1ReggressionModelling.o g77 -fpic -g -O2 -c 42A-2RegressionModelling.f -o 42A-2RegressionModelling.o gcc -I/usr/share/R/include -I/usr/share/R/include -fpic -g -O2 -std=gnu99 -c 42A-3RegressionModelling.c -o 42A-3RegressionModelling.o g77 -fpic -g -O2 -c 42B-RegressionTests.f -o 42B-RegressionTests.o g77 -fpic -g -O2 -c 46A-VectorMatrixAddon.f -o 46A-VectorMatrixAddon.o gcc -I/usr/share/R/include -I/usr/share/R/include -fpic -g -O2 -std=gnu99 -c 46B-MissingValues.c -o 46B-MissingValues.og77 -fpic -g -O2 -c 47B-MultivariateDistribution.f -o 47B-MultivariateDistribution.o gcc -I/usr/share/R/include -I/usr/share/R/include -fpic -g -O2 -std=gnu99 -c runfunc.c -o runfunc.o gcc -shared -o fMultivar.so 00A-randomF77.o 00B-GarchBEKK.o 42A-1ReggressionModelling.o 42A-2RegressionModelling.o 42A-3RegressionModelling.o 42B-RegressionTests.o 46A-VectorMatrixAddon.o 46B-MissingValues.o 47B-MultivariateDistribution.o runfunc.o -lblas-3 -lg2c -lm -lgcc_s -L/usr/lib/R/lib -lR /usr/bin/ld: cannot find -lblas-3 collect2: ld returned 1 exit status make: *** [fMultivar.so] Error 1 ERROR: compilation failed for package 'fMultivar' ** Removing '/usr/local/lib/R/site-library/fMultivar' The downloaded packages are in /tmp/RtmpXxDoFd/downloaded_packages Warning message: installation of package 'fMultivar' had non-zero exit status in: install.packages(fMultivar) It is a FAQ for Debian and Ubuntu -- you forgot to install r-base-dev which provides a fairly complete development emv. for R on Debian / Ubuntu, so do $ sudo apt-get install r-base-dev Besides, given that there _is_ a source package, you could also use its information on Build-Dependencies: $ sudo apt-get build-dep r-cran-fmultivar Hth, Dirk Thanks in advance for any help! Gilberto. __ 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 and provide commented, minimal, self-contained, reproducible code. -- Hell, there are no rules here - we're trying to accomplish something. -- Thomas A. Edison __ 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 and provide commented, minimal, self-contained, reproducible code. -- __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] two connected graphs
If you're not already familiar with M N plots (by Diaconis and Friedman), you should have a look at: http://www.slac.stanford.edu/cgi-wrap/getdoc/slac-pub-2495.pdf Hadley On 12/14/06, Robin Hankin [EMAIL PROTECTED] wrote: Hi I have two datasets, A and B, consisting of two columns of numbers representing x and y coordinates. They have 10 and 6 rows respectively. I want to plot two scattergraphs, one above the other. The lower graph to contain A (10 points) and the upper graph to contain B (six points). The x-axes of the two graphs must line up. I then want to draw straight lines that connect points of B to a particular point (or points) of A. How do I do this? -- 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] How do I create an object in the Global environment from a function
Please note that help(-) says: The operators '-' and '-' cause a search to made through the environment for an existing definition of the variable being assigned. If such a variable is found (and its binding is not locked) then its value is redefined, otherwise assignment takes place in the global environment. Thus, if you really want to make sure to assign it to the global environment you should do: assign(b, value, envir=globalenv()) /Henrik On 12/14/06, Rainer M Krug [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Hi all, Say I have created an object b in my function myfunc - function() b - 34 myfunc - function() b - 34 - Rainer How can I make b an object in the Global environment and not just in the environment of myfunc? Thanks, Tim __ 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 and provide commented, minimal, self-contained, reproducible code. -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology and Entomology University of Stellenbosch Matieland 7602 South Africa Tel:+27 - (0)72 808 2975 (w) Fax:+27 - (0)86 516 2782 Fax:+27 - (0)21 808 3304 (w) Cell: +27 - (0)83 9479 042 email: [EMAIL PROTECTED] [EMAIL PROTECTED] __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] persistant: Matlab-R
At 3:10 PM -0500 12/14/06, Charles Annis, P.E. wrote: It might be helpful to those not familiar with Matlab to tell us what function persistent does. Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com Independent response (I was not the original poster) help persistent PERSISTENT Define persistent variable. PERSISTENT X Y Z defines X, Y, and Z as variables that are local to the function in which they are declared yet their values are retained in memory between calls to the function. Persistent variables are similar to global variables because MATLAB creates permanent storage for both. They differ from global variables in that persistent variables are known only to the function in which they are declared. This prevents persistent variables from being changed by other functions or from the MATLAB command line. Persistent variables are cleared when the M-file is cleared from memory or when the M-file is changed. To keep an M-file in memory until MATLAB quits, use MLOCK. If the persistent variable does not exist the first time you issue the PERSISTENT statement, it will be initialized to the empty matrix. It is an error to declare a variable persistent if a variable with the same name exists in the current workspace. See also global, clear, mlock, munlock, mislocked. Reference page in Help browser doc persistent -- ** The contents of this message do not reflect any position of the U.S. Government or NOAA. ** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center 1352 Lighthouse Avenue Pacific Grove, CA 93950-2097 e-mail: [EMAIL PROTECTED] (Note new e-mail address) voice: (831)-648-9029 fax: (831)-648-8440 www: http://www.pfeg.noaa.gov/ Old age and treachery will overcome youth and skill. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] persistant: Matlab-R
It is just my guess that the 'open.account' example in 10.7 Scope of Introduciton to R is what you are after. If I understand what 'presistent' means, the 'total' in the example is approximately equal to a persistent variable. On Thu, 14 Dec 2006, Bernard Gregory wrote: Dear list members, Could anyone tell me if there is an equivalent of the Matlab declaration 'persistant' in R? Thank you very much, Bernard Gregorry. (Matlaber converted to R). - [[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 and provide commented, minimal, self-contained, reproducible code. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:[EMAIL PROTECTED] UC San Diego http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego 92093-0717 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] xyplot: discrete points + continuous curve per panel
On 12/13/06, RMan54 [EMAIL PROTECTED] wrote: I have a number of x, y observations (Time, Conc) for a number of Subjects (with subject number Subj) and Doses. I can plot the individual points with xyplot fine: xyplot(Conc ~ Time | Subj, Groups=Dose, data=myData, panel = function(x,y) { panel.xyplot(x, y) panel.superpose(???) # Needs more here } ) I also like to plot on each panel (there is one Subj per panel) a continuous curve with predictions that I can calculate from a rather complicated function: myPred - (time, subj, dose) { returns predicted value of Conc for a given time, subj and dose } The predicted curves are different for each panel. How do I plot the predictions? I have tried to add panel.superinpose in the xyplot portion but can't link to the myPred function. I also know about panel.curve but couldn't make it work. My attempt is to calculate the predictions on the fly. Is this possible? Or do I need to calculate all predictions first and put the results in a data frame. Depends on how much work you are willing to do. There is no reason for panel.curve to not work, provided you give it a curve to plot. This is normally done in the form of a vectorized function of one variable, which will be called with a vector of values spanning the x-axis of your plot. It is your responsibility to construct such a function inside each panel (presumably it would involve your myPred function). The easy way, that generally works well for longitudinal data (with increasing x values within a panel), is to add a column of predicted values to your data frame. For most model fitting routines in R, the paradigm is: fm - some.model(y ~ whatever, data = mydata, ...) mydata$fit - fitted(fm) xyplot(y + fit ~ whatever, type = list(p, l), distribute.type = TRUE) A real example being: library(lme4) data(Oxboys, package = nlme) Oxboys$fit - fitted(lmer(height ~ age + (1|Subject), data = Oxboys)) xyplot(height + fit ~ age | Subject, Oxboys, type = c(p, l), distribute.type = TRUE, aspect = xy) Things will be more complicated if you already have a grouping variable (the solution is to pass down the vector of fitted values to the panel function and use 'subscripts' to retrieve the ones that belong in the panel). -Deepayan __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] max.col: bug or just oddity?
I've noticed that the max.col function with the default random option often gives unexpected results. For instance, in this test, it seems clear what the answer should be: # second col should always be max x1 = cbind(1:10, 2:11, -Inf) # this works fine max.col(x1, first) [1] 2 2 2 2 2 2 2 2 2 2 # this gives random answers max.col(x1) [1] 3 1 1 2 3 3 1 3 1 1 Ouch! max.col is randomizing across all values. Even without infinite values, something similar can happen: # test 2 --- tolerance problems # clearly column 3 is the max x1 = cbind(-1e9 * 1:10, 1:10, 2:11) # again, first method works: max.col(x1, first) [1] 3 3 3 3 3 3 3 3 3 3 # but random doesn't max.col(x1) [1] 2 3 2 3 3 2 2 2 3 2 The max.col docs say there is a relative tolerance of 1e-5, relative to the largest entry in the row, but it's really using the maximum absolute value entry in the row (appl/maxcol.c, line 35 in R 2.4.0). Is this necessary for some sort of S-plus compatibility? If so, I think it would be good to make this absolute value property very clear in the docs, since it can cause subtle bugs (and did for me). Personally, I think the behavior is much nicer with the following patch: --- rplain/R-2.4.0/src/appl/maxcol.c2006-04-09 18:19:58.0 -0400 +++ R-2.4.0/src/appl/maxcol.c 2006-12-14 15:30:56.0 -0500 @@ -26,13 +26,14 @@ do_rand = *ties_meth == 1; for (r = 0; r n_r; r++) { - /* first check row for any NAs and find the largest abs(entry) */ + /* first check row for any NAs and find the largest entry */ large = 0.0; isna = FALSE; for (c = 0; c *nc; c++) { a = matrix[r + c * n_r]; if (ISNAN(a)) { isna = TRUE; break; } - if (do_rand) large = fmax2(large, fabs(a)); + if (!R_FINITE(a)) continue; + if (do_rand) large = fmax2(large, a); } if (isna) { maxes[r] = NA_INTEGER; continue; } --- END - This gives the expected behavior in the two examples above. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] persistant: Matlab-R
It looks like the same process can be accomplished by using 'local' and declaring the 'persistant' variables in a local scope, then the function within that same scope, for example: inc - local( { n - 0; function(){n - n + 1; return(n)} } ) inc function(){n - n + 1; return(n)} environment: 0x09a8fee0 inc() [1] 1 inc() [1] 2 inc() [1] 3 inc() [1] 4 Using local in R is a little more flexible in that you can have variables that are shared between multiple functions, but not easily accessable to the world at large: n - 5 incdec - local( {n - 0; + list(inc=function(){ n - n+1; return(n) }, + dec=function(){ n - n-1; return(n) } + )}) incdec$inc() [1] 1 incdec$inc() [1] 2 incdec$inc() [1] 3 incdec$dec() [1] 2 incdec$dec() [1] 1 incdec$inc() [1] 2 n [5] Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bernard Gregory Sent: Thursday, December 14, 2006 11:14 AM To: r-help@stat.math.ethz.ch Subject: [R] persistant: Matlab-R Dear list members, Could anyone tell me if there is an equivalent of the Matlab declaration 'persistant' in R? Thank you very much, Bernard Gregorry. (Matlaber converted to R). - [[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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] rotated histogram
I guess it's ok; I was wondering why there is no argument to hist that allows rotation (e.g. rotated=TRUE) Steve Marc Schwartz wrote: On Thu, 2006-12-14 at 13:53 -0500, steve wrote: I would like to make a scatterplot, with a histogram of the x and y variables above and to the right . I can use layout to set up the areas, and hist(x,y) works fine for the upper histogram. However, I need a rotated histogram on the right, and I don't know how to do this. I've seen a solution with a bar plot on the right, but I'd like to use a histogram. Do you know how I can do this? Steve What's wrong with the example in ?layout below the comment: ##-- Create a scatterplot with marginal histograms - ? __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Better way to change the name of a column in a dataframe?
Ben, Unless I misunderstand your question, why not just use names(frame)[3]-col3 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Nicely formatted tables
If I use latex(summary(X)) where X is a data frame with four variables I get something like Rainfall Education PopdenNonwhite Min. :10.00 Min. : 9.00 Min. :1441 Min. : 0.80 1st Qu.:32.75 1st Qu.:10.40 1st Qu.:3104 1st Qu.: 4.95 Median :38.00 Median :11.05 Median :3567 Median :10.40 Mean :37.37 Mean :10.97 Mean :3866 Mean :11.87 3rd Qu.:43.25 3rd Qu.:11.50 3rd Qu.:4520 3rd Qu.:15.65 Max. :60.00 Max. :12.30 Max. :9699 Max. :38.50 where the row headings are repeated four times times. Is there an easy way to get a nicely formatted table, something like Rainfall Education PopdenNonwhite Min. 10.00 9.0014410.80 1st Qu. 32.75 10.4031044.95 Median 38.00 11.053567 10.40 Mean 37.37 10.973866 11.87 3rd Qu. 43.25 11.504520 15.65 Max. 60.00 12.309699 38.50 Steve __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Nicely formatted tables
steve wrote: If I use latex(summary(X)) where X is a data frame with four variables I get something like Rainfall Education PopdenNonwhite Min. :10.00 Min. : 9.00 Min. :1441 Min. : 0.80 1st Qu.:32.75 1st Qu.:10.40 1st Qu.:3104 1st Qu.: 4.95 Median :38.00 Median :11.05 Median :3567 Median :10.40 Mean :37.37 Mean :10.97 Mean :3866 Mean :11.87 3rd Qu.:43.25 3rd Qu.:11.50 3rd Qu.:4520 3rd Qu.:15.65 Max. :60.00 Max. :12.30 Max. :9699 Max. :38.50 where the row headings are repeated four times times. Is there an easy way to get a nicely formatted table, something like Rainfall Education PopdenNonwhite Min. 10.00 9.0014410.80 1st Qu. 32.75 10.4031044.95 Median 38.00 11.053567 10.40 Mean 37.37 10.973866 11.87 3rd Qu. 43.25 11.504520 15.65 Max. 60.00 12.309699 38.50 Hmm, no. Not without further ado. The function summary.data.frame produces a table with character entries like Min. : 1.00 . To do better, you first have to note that it can only possibly work for purely numeric data frames. If you have one of those, then you might base something off sapply(X, summary), except that it won't work if only some columns have NA's. Here's an idea: my.summary - function(x){s - summary(x); if (length(s)==6) c(s,NA's=0) else s} sapply(airquality,my.summary) Ozone Solar.R Wind Temp Month Day Min. 1.00 7.0 1.700 56.00 5.000 1.0 1st Qu. 18.00 115.8 7.400 72.00 6.000 8.0 Median 31.50 205.0 9.700 79.00 7.000 16.0 Mean 42.13 185.9 9.958 77.88 6.993 15.8 3rd Qu. 63.25 258.8 11.500 85.00 8.000 23.0 Max.168.00 334.0 20.700 97.00 9.000 31.0 NA's 37.00 7.0 0.000 0.00 0.000 0.0 However, there's an issue with the NA count getting displayed to three decimal places... __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Nicely formatted tables
On Thu, 2006-12-14 at 16:37 -0500, steve wrote: If I use latex(summary(X)) where X is a data frame with four variables I get something like Rainfall Education PopdenNonwhite Min. :10.00 Min. : 9.00 Min. :1441 Min. : 0.80 1st Qu.:32.75 1st Qu.:10.40 1st Qu.:3104 1st Qu.: 4.95 Median :38.00 Median :11.05 Median :3567 Median :10.40 Mean :37.37 Mean :10.97 Mean :3866 Mean :11.87 3rd Qu.:43.25 3rd Qu.:11.50 3rd Qu.:4520 3rd Qu.:15.65 Max. :60.00 Max. :12.30 Max. :9699 Max. :38.50 where the row headings are repeated four times times. Is there an easy way to get a nicely formatted table, something like Rainfall Education PopdenNonwhite Min. 10.00 9.0014410.80 1st Qu. 32.75 10.4031044.95 Median 38.00 11.053567 10.40 Mean 37.37 10.973866 11.87 3rd Qu. 43.25 11.504520 15.65 Max. 60.00 12.309699 38.50 Steve The problem is that summary(), as above, returns a character based table/matrix. For example, using the 'iris' data set: summary(iris[, 1:4]) Sepal.LengthSepal.Width Petal.LengthPetal.Width Min. :4.300 Min. :2.000 Min. :1.000 Min. :0.100 1st Qu.:5.100 1st Qu.:2.800 1st Qu.:1.600 1st Qu.:0.300 Median :5.800 Median :3.000 Median :4.350 Median :1.300 Mean :5.843 Mean :3.057 Mean :3.758 Mean :1.199 3rd Qu.:6.400 3rd Qu.:3.300 3rd Qu.:5.100 3rd Qu.:1.800 Max. :7.900 Max. :4.400 Max. :6.900 Max. :2.500 str(summary(iris[, 1:4])) 'table' chr [1:6, 1:4] Min. :4.300 1st Qu.:5.100 ... - attr(*, dimnames)=List of 2 ..$ : chr [1:6] ... ..$ : chr [1:4] Sepal.Length Sepal.Width Petal.Length Petal.Width Hence, the numbers are not separate from the labels, but part of the table elements. I might be tempted to construct a better underlying function that just returned the summary statistics as unformatted numbers in a matrix. It seems to me that there are such functions, for example in the Hmisc and the doBY packages, on CRAN. Since you are using latex(), you already have Hmisc. That being said, you could brute force something like this: # See ?strsplit and ?sapply mat - matrix(sapply(strsplit(summary(iris[, 1:4]), :), [[, 2), ncol = 4) mat [,1] [,2] [,3] [,4] [1,] 4.300 2.000 1.000 0.100 [2,] 5.100 2.800 1.600 0.300 [3,] 5.800 3.000 4.350 1.300 [4,] 5.843 3.057 3.758 1.199 [5,] 6.400 3.300 5.100 1.800 [6,] 7.900 4.400 6.900 2.500 Then add the row and column titles: rownames(mat) - c(Min, 1st Qu, Median, Mean, 3rd Qu, Max) colnames(mat) - colnames(iris[1:4]) mat Sepal.Length Sepal.Width Petal.Length Petal.Width Min4.300 2.000 1.000 0.100 1st Qu 5.100 2.800 1.600 0.300 Median 5.800 3.000 4.350 1.300 Mean 5.843 3.057 3.758 1.199 3rd Qu 6.400 3.300 5.100 1.800 Max7.900 4.400 6.900 2.500 latex(mat, file = ) % latex.default(mat, file = ) % \begin{table}[!tbp] \begin{center} \begin{tabular}{l}\hline\hline \multicolumn{1}{l}{mat} \multicolumn{1}{c}{Sepal.Length} \multicolumn{1}{c}{Sepal.Width} \multicolumn{1}{c}{Petal.Length} \multicolumn{1}{c}{Petal.Width} \\ \hline Min4.300 2.000 1.000 0.100 \\ 1st Qu5.100 2.800 1.600 0.300 \\ Median5.800 3.000 4.350 1.300 \\ Mean5.843 3.057 3.758 1.199 \\ 3rd Qu6.400 3.300 5.100 1.800 \\ Max7.900 4.400 6.900 2.500 \\ \hline \end{tabular} \end{center} \end{table} HTH, Marc Schwartz __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Better way to change the name of a column in a dataframe?
Ben Fairbank [EMAIL PROTECTED] wrote: [...] I want to correct or otherwise change the name of one of the columns, I can do so with dimnames(frame)[[2]][which(dimnames(frame)[[2]]==cmlo3)] - col3 This seems cumbersome and not very intuitive. How can one accomplish this more simply? This is slightly simpler than what you had: names(frame)[which(names(frame) == cmlo3)] - col3 There are probably better ways still. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] legend/plotmath/substitute problem
Dear R Experts, I am trying to produce a legend for a series of plots which are generated in a loop. The legend is supposed to look like this: 2000: gamma=1.8 where gamma is replaced by the greek letter and both the year and the value of gamma are stored in variables. Everything works fine as long as I have only one data series: year = 2001 g = 1.9 plot(1) legend('top', legend=substitute(paste(year, ': ', gamma, '=', g), list(year=year, g=g)) ) My problem starts, when I want to put more than one series of data in the plot and accordingly need one legend row per data series: year1 = 2001 year2 = 2005 g1 = 1.9 g2 = 1.7 plot(1) legend('top', legend=c( substitute(paste(year, ': ', gamma, '=', g), list(year=year1, g=g1)), substitute(paste(year, ': ', gamma, '=', g), list(year=year2, g=g2)) ) ) This obviously does not produce the desired result. Apparently, I am not generating a list of expressions, as intended. So I thought, maybe R uses a variety of the recycling rule here and tried: year = c(2001, 2005) g = c(1.9, 1.7) plot(1) legend('top', legend=list( substitute(paste(year, ': ', gamma, '=', g), list(year=year, g=g)), ) ) No succes, either... I have read and re-read the documentation for legend, expression, substitute and plotmath but can't figure it out. Even drinking a cup of tea prepared from fine-cut man page printouts didn't lead to satori. I'm probably missing something simple. Any hints are highly appreciated. Thanks Philipp -- Dr. Philipp PagelTel. +49-8161-71 2131 Dept. of Genome Oriented Bioinformatics Fax. +49-8161-71 2186 Technical University of Munich 85350 Freising, 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Nicely formatted tables
How about: apply(iris[, 1:4], 2, summary) Sepal.Length Sepal.Width Petal.Length Petal.Width Min. 4.300 2.0001.000 0.100 1st Qu.5.100 2.8001.600 0.300 Median 5.800 3.0004.350 1.300 Mean 5.843 3.0573.758 1.199 3rd Qu.6.400 3.3005.100 1.800 Max. 7.900 4.4006.900 2.500 Max -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Marc Schwartz Sent: Thursday, December 14, 2006 5:02 PM To: steve Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Nicely formatted tables On Thu, 2006-12-14 at 16:37 -0500, steve wrote: If I use latex(summary(X)) where X is a data frame with four variables I get something like Rainfall Education PopdenNonwhite Min. :10.00 Min. : 9.00 Min. :1441 Min. : 0.80 1st Qu.:32.75 1st Qu.:10.40 1st Qu.:3104 1st Qu.: 4.95 Median :38.00 Median :11.05 Median :3567 Median :10.40 Mean :37.37 Mean :10.97 Mean :3866 Mean :11.87 3rd Qu.:43.25 3rd Qu.:11.50 3rd Qu.:4520 3rd Qu.:15.65 Max. :60.00 Max. :12.30 Max. :9699 Max. :38.50 where the row headings are repeated four times times. Is there an easy way to get a nicely formatted table, something like Rainfall Education PopdenNonwhite Min. 10.00 9.0014410.80 1st Qu. 32.75 10.4031044.95 Median 38.00 11.053567 10.40 Mean 37.37 10.973866 11.87 3rd Qu. 43.25 11.504520 15.65 Max. 60.00 12.309699 38.50 Steve The problem is that summary(), as above, returns a character based table/matrix. For example, using the 'iris' data set: summary(iris[, 1:4]) Sepal.LengthSepal.Width Petal.LengthPetal.Width Min. :4.300 Min. :2.000 Min. :1.000 Min. :0.100 1st Qu.:5.100 1st Qu.:2.800 1st Qu.:1.600 1st Qu.:0.300 Median :5.800 Median :3.000 Median :4.350 Median :1.300 Mean :5.843 Mean :3.057 Mean :3.758 Mean :1.199 3rd Qu.:6.400 3rd Qu.:3.300 3rd Qu.:5.100 3rd Qu.:1.800 Max. :7.900 Max. :4.400 Max. :6.900 Max. :2.500 str(summary(iris[, 1:4])) 'table' chr [1:6, 1:4] Min. :4.300 1st Qu.:5.100 ... - attr(*, dimnames)=List of 2 ..$ : chr [1:6] ... ..$ : chr [1:4] Sepal.Length Sepal.Width Petal.Length Petal.Width Hence, the numbers are not separate from the labels, but part of the table elements. I might be tempted to construct a better underlying function that just returned the summary statistics as unformatted numbers in a matrix. It seems to me that there are such functions, for example in the Hmisc and the doBY packages, on CRAN. Since you are using latex(), you already have Hmisc. That being said, you could brute force something like this: # See ?strsplit and ?sapply mat - matrix(sapply(strsplit(summary(iris[, 1:4]), :), [[, 2), ncol = 4) mat [,1] [,2] [,3] [,4] [1,] 4.300 2.000 1.000 0.100 [2,] 5.100 2.800 1.600 0.300 [3,] 5.800 3.000 4.350 1.300 [4,] 5.843 3.057 3.758 1.199 [5,] 6.400 3.300 5.100 1.800 [6,] 7.900 4.400 6.900 2.500 Then add the row and column titles: rownames(mat) - c(Min, 1st Qu, Median, Mean, 3rd Qu, Max) colnames(mat) - colnames(iris[1:4]) mat Sepal.Length Sepal.Width Petal.Length Petal.Width Min4.300 2.000 1.000 0.100 1st Qu 5.100 2.800 1.600 0.300 Median 5.800 3.000 4.350 1.300 Mean 5.843 3.057 3.758 1.199 3rd Qu 6.400 3.300 5.100 1.800 Max7.900 4.400 6.900 2.500 latex(mat, file = ) % latex.default(mat, file = ) % \begin{table}[!tbp] \begin{center} \begin{tabular}{l}\hline\hline \multicolumn{1}{l}{mat} \multicolumn{1}{c}{Sepal.Length} \multicolumn{1}{c}{Sepal.Width} \multicolumn{1}{c}{Petal.Length} \multicolumn{1}{c}{Petal.Width} \\ \hline Min4.300 2.000 1.000 0.100 \\ 1st Qu5.100 2.800 1.600 0.300 \\ Median5.800 3.000 4.350 1.300 \\ Mean5.843 3.057 3.758 1.199 \\ 3rd Qu6.400 3.300 5.100 1.800 \\ Max7.900 4.400 6.900 2.500 \\ \hline \end{tabular} \end{center} \end{table} HTH, Marc Schwartz __ 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 and provide commented, minimal, self-contained, reproducible code. -- LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}}
Re: [R] Nicely formatted tables
On Thu, 2006-12-14 at 17:09 -0500, Kuhn, Max wrote: How about: apply(iris[, 1:4], 2, summary) Sepal.Length Sepal.Width Petal.Length Petal.Width Min. 4.300 2.0001.000 0.100 1st Qu.5.100 2.8001.600 0.300 Median 5.800 3.0004.350 1.300 Mean 5.843 3.0573.758 1.199 3rd Qu.6.400 3.3005.100 1.800 Max. 7.900 4.4006.900 2.500 Max snip Yep, that will do it too Max. :-) Thanks for pointing it out. Clearly, in need of more oxygen to the old cranium... Regards, Marc __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Better way to change the name of a column in a dataframe?
Hi, names(frame)[names(frame) == cmlo3] - col3 should also work Cheers Andrew On Thu, Dec 14, 2006 at 05:05:20PM -0500, Mike Prager wrote: Ben Fairbank [EMAIL PROTECTED] wrote: [...] I want to correct or otherwise change the name of one of the columns, I can do so with dimnames(frame)[[2]][which(dimnames(frame)[[2]]==cmlo3)] - col3 This seems cumbersome and not very intuitive. How can one accomplish this more simply? This is slightly simpler than what you had: names(frame)[which(names(frame) == cmlo3)] - col3 There are probably better ways still. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ 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 and provide commented, minimal, self-contained, reproducible code. -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 http://www.ms.unimelb.edu.au/~andrewpr http://blogs.mbs.edu/fishing-in-the-bay/ __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Install R in Linux
Perhaps you might have a look at the quantian live distribution. If you can boot your PC from this you have access to R and you should be able to acess and use any data files on your hard disk. The current Quantian live DVD is based on Knoppix 4.02 (I think). I have installed the Quantian DVD on a USB hard drive and boot from a knoppix 4.02 live CD on one PC Best Regards John On 13/12/06, lu kan [EMAIL PROTECTED] wrote: Hi, Is it possible to install R in a linux box (Debian) without being a root. I know I can compile the R source code, but there is no F77 compiler on the box. So is it possible to install binary R without being a root? Send instant messages to your online friends http://uk.messenger.yahoo.com [[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 and provide commented, minimal, self-contained, reproducible code. -- John C Frain Trinity College Dublin Dublin 2 Ireland www.tcd.ie/Economics/staff/frainj/home.html mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] legend/plotmath/substitute problem
On 12/14/2006 5:05 PM, Philipp Pagel wrote: Dear R Experts, I am trying to produce a legend for a series of plots which are generated in a loop. The legend is supposed to look like this: 2000: gamma=1.8 where gamma is replaced by the greek letter and both the year and the value of gamma are stored in variables. Everything works fine as long as I have only one data series: year = 2001 g = 1.9 plot(1) legend('top', legend=substitute(paste(year, ': ', gamma, '=', g), list(year=year, g=g)) ) My problem starts, when I want to put more than one series of data in the plot and accordingly need one legend row per data series: year1 = 2001 year2 = 2005 g1 = 1.9 g2 = 1.7 plot(1) legend('top', legend=c( substitute(paste(year, ': ', gamma, '=', g), list(year=year1, g=g1)), substitute(paste(year, ': ', gamma, '=', g), list(year=year2, g=g2)) ) ) This obviously does not produce the desired result. Apparently, I am not generating a list of expressions, as intended. So I thought, maybe R uses a variety of the recycling rule here and tried: The problem is that legend wants an expression, but substitute() isn't returning one, it's returning a call, and c(call1,call2) produces a list of two calls, not an expression holding two calls. So the following would work, but there might be something more elegant: year1 = 2001 year2 = 2005 g1 = 1.9 g2 = 1.7 plot(1) legend('top', legend=c( as.expression(substitute(paste(year, ': ', gamma, '=', g), list(year=year1, g=g1))), as.expression(substitute(paste(year, ': ', gamma, '=', g), list(year=year2, g=g2))) ) ) Duncan Murdoch year = c(2001, 2005) g = c(1.9, 1.7) plot(1) legend('top', legend=list( substitute(paste(year, ': ', gamma, '=', g), list(year=year, g=g)), ) ) No succes, either... I have read and re-read the documentation for legend, expression, substitute and plotmath but can't figure it out. Even drinking a cup of tea prepared from fine-cut man page printouts didn't lead to satori. I'm probably missing something simple. Any hints are highly appreciated. Thanks Philipp __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] legend/plotmath/substitute problem
On Thu, Dec 14, 2006 at 06:25:49PM -0500, Duncan Murdoch wrote: On 12/14/2006 5:05 PM, Philipp Pagel wrote: My problem starts, when I want to put more than one series of data in the plot and accordingly need one legend row per data series: year1 = 2001 year2 = 2005 g1 = 1.9 g2 = 1.7 plot(1) legend('top', legend=c( substitute(paste(year, ': ', gamma, '=', g), list(year=year1, g=g1)), substitute(paste(year, ': ', gamma, '=', g), list(year=year2, g=g2)) ) ) This obviously does not produce the desired result. Apparently, I am not generating a list of expressions, as intended. So I thought, maybe R uses a variety of the recycling rule here and tried: The problem is that legend wants an expression, but substitute() isn't returning one, it's returning a call, and c(call1,call2) produces a list of two calls, not an expression holding two calls. So the following would work, but there might be something more elegant: Thanks a lot! Learned something, again. cu Philipp -- Dr. Philipp PagelTel. +49-8161-71 2131 Dept. of Genome Oriented Bioinformatics Fax. +49-8161-71 2186 Technical University of Munich 85350 Freising, 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Contents of R-packages
How about library(help=yags) miltinho Chuck Cleland [EMAIL PROTECTED] escreveu: Ralf Finne wrote: Hi experts, How do I see the contents of a package that looks interesting? Efter I have loded the package, is there an command that gives me the contents or even better a summary or introduction. library(yags) # Load the package search() # Where is the package? [1] .GlobalEnv package:yags [3] package:nlme package:car [5] package:stats package:graphics [7] package:grDevices package:utils [9] package:datasets package:methods [11] Autoloads package:base ls(2) # What is in the package? [1] ar1mat csmat [3] mvnsamp print.yagsResult [5] yags yags.adeqReport [7] yags.control yags.glmReport [9] yags.make.libu yags.wcorReport ?yags # Help for a particular function Also, follow the package links here for brief descriptions, reference manuals, and vignettes: http://cran.us.r-project.org/src/contrib/PACKAGES.html Ralf Finne SYH University of Applied Sciences, Finland __ 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 and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ 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 and provide commented, minimal, self-contained, reproducible code. - [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Nicely formatted tables
apply(iris[, 1:4], 2, summary) Nice solution! However, latex(apply(iris[, 1:4], 2, summary)) has the odd effect that the upper left corner is apply. This is the title, so to produce a file abc.tex and have an empty upper left corner you need latex(apply(iris[, 1:4], 2, summary),title=,file=abc.tex) And, since I wanted a more compact table, the following works just as expected: latex(format(apply(iris[, 1:4], 2, summary),digits=2),title=,file=abc.tex) thank you! Steve __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] sorting by name
Hi all, I'm not sure that there is really a way to do this, but I thought I'd see if anyone knew. I have a file with 1 to n columns all named something like X1, X2, X3Xn. I have another file that has in one column n number of rows. Each row has a number in it (not in order; the ordering of the numbers is important but it isn't in count order). Basically, I would like to order the columns in the first file by the numbers in the rows of the second file. So, if file#2 has these numbers in rows 1-4: [,1] [1,] 2 [2,] 3 [3,] 1 [4,] 4 I would like the first file to look like this: X2 X3 X1 X4 1 Instead of the original order: X1 X2 X3 X4 1 Is this possible? The point of this all is to run a stepwise linear regression that first regresses on X2, then adds in X3, X1, X4 in that order, stopping at each step to assess whether to drop one or more of the previously added variables. Thank you in advance for any suggestions! Brooke LaFlamme __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] sorting by name
This is trivial. help([) and An Introduction to R will tell you how. P.S. As earlier posts today have mentioned, stepwise variable selection is generally a bad idea. Bert Gunter Genentech Nonclinical Statistics South San Francisco, CA 94404 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Brooke LaFlamme Sent: Thursday, December 14, 2006 4:34 PM To: r-help@stat.math.ethz.ch Subject: [R] sorting by name Hi all, I'm not sure that there is really a way to do this, but I thought I'd see if anyone knew. I have a file with 1 to n columns all named something like X1, X2, X3Xn. I have another file that has in one column n number of rows. Each row has a number in it (not in order; the ordering of the numbers is important but it isn't in count order). Basically, I would like to order the columns in the first file by the numbers in the rows of the second file. So, if file#2 has these numbers in rows 1-4: [,1] [1,] 2 [2,] 3 [3,] 1 [4,] 4 I would like the first file to look like this: X2 X3 X1 X4 1 Instead of the original order: X1 X2 X3 X4 1 Is this possible? The point of this all is to run a stepwise linear regression that first regresses on X2, then adds in X3, X1, X4 in that order, stopping at each step to assess whether to drop one or more of the previously added variables. Thank you in advance for any suggestions! Brooke LaFlamme __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] xyplot: discrete points + continuous curve per panel
Great. I will be trying to use panel.curve and pass a custom curve function as first argument (called test() below). I can use which. packet to get access to the panel number to produce the correct curve for each panel but what I really need is the active Subj (actSubj) for each panel. Not sure but it seems that Subj is passed on to the functions but in replicates. Here is what I came up with to eliminate the replication and to calculate activeSubj for each panel in test(). Is this the correct way? How can I pass on Subj and Dose directly to test()? Thanks, Rene test -function(x) { activeSubj - unique(Subj)[which.packet()] x # returns y=x for testing only } xyplot(Conc ~ Time | Subj, groups=Dose, data = mydata, as.table=T, panel = function(x,y) { panel.xyplot(x,y) panel.curve(test, n=2) } ) Deepayan Sarkar wrote: On 12/13/06, RMan54 [EMAIL PROTECTED] wrote: I have a number of x, y observations (Time, Conc) for a number of Subjects (with subject number Subj) and Doses. I can plot the individual points with xyplot fine: xyplot(Conc ~ Time | Subj, Groups=Dose, data=myData, panel = function(x,y) { panel.xyplot(x, y) panel.superpose(???) # Needs more here } ) I also like to plot on each panel (there is one Subj per panel) a continuous curve with predictions that I can calculate from a rather complicated function: myPred - (time, subj, dose) { returns predicted value of Conc for a given time, subj and dose } The predicted curves are different for each panel. How do I plot the predictions? I have tried to add panel.superinpose in the xyplot portion but can't link to the myPred function. I also know about panel.curve but couldn't make it work. My attempt is to calculate the predictions on the fly. Is this possible? Or do I need to calculate all predictions first and put the results in a data frame. Depends on how much work you are willing to do. There is no reason for panel.curve to not work, provided you give it a curve to plot. This is normally done in the form of a vectorized function of one variable, which will be called with a vector of values spanning the x-axis of your plot. It is your responsibility to construct such a function inside each panel (presumably it would involve your myPred function). The easy way, that generally works well for longitudinal data (with increasing x values within a panel), is to add a column of predicted values to your data frame. For most model fitting routines in R, the paradigm is: fm - some.model(y ~ whatever, data = mydata, ...) mydata$fit - fitted(fm) xyplot(y + fit ~ whatever, type = list(p, l), distribute.type = TRUE) A real example being: library(lme4) data(Oxboys, package = nlme) Oxboys$fit - fitted(lmer(height ~ age + (1|Subject), data = Oxboys)) xyplot(height + fit ~ age | Subject, Oxboys, type = c(p, l), distribute.type = TRUE, aspect = xy) Things will be more complicated if you already have a grouping variable (the solution is to pass down the vector of fitted values to the panel function and use 'subscripts' to retrieve the ones that belong in the panel). -Deepayan __ 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 and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/xyplot%3A-discrete-points-%2B-continuous-curve-per-panel-tf2818931.html#a7886826 Sent from the R help mailing list archive at Nabble.com. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] How to load Rcmd without Commander() ?
I would like to use the reliability() function in Rcmdr package, but not the GUI, so I would to load Rcmd without Commander() running automatically. Is there any easy way to get it? Thanks. -- Ronggui Huang Department of Sociology Fudan University, Shanghai, China 黄荣贵 复旦大学社会学系 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Better way to change the name of a column in a dataframe?
Ben Fairbank wrote: Hello R users -- If I have a dataframe such as the following, named frame with the columns intended to be named col1 through col6, frame col1 col2 cmlo3 col4 col5 col6 [1,]3 10 2657 [2,]68 4 1071 [3,]75 1318 [4,] 106 5492 and I want to correct or otherwise change the name of one of the columns, I can do so with dimnames(frame)[[2]][which(dimnames(frame)[[2]]==cmlo3)] - col3 which renames the offending column: frame col1 col2 col3 col4 col5 col6 [1,]3 102657 [2,]684 1071 [3,]751318 [4,] 1065492 This seems cumbersome and not very intuitive. How can one accomplish this more simply? well I would simply use names(frame)[3] = 'col3' (supposing you know the column number of your offending column anyway). __ 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 and provide commented, minimal, self-contained, reproducible code.