[R] How to open more windows to make more graphs at once!
Dear R users, I have a data frame (test) including five columns of upper (numeric), lower (numeric), observed (numeric), best_sim (numeric) and stname (factor with 80 levels, each level with different length). Now I would like to write a short program to draw one graph as follow for each level of stname but I would like also to draw each time 12 graphs for the 12 levels of stname in the same graphic windows and save it as jpeg' file . This means at the end I will have 7 (80 levels/12=7) graphic windows and 7 jpeg files each one with 12 graphs (the last one with 8 graphs) for the 12 levels of stname. I already wrote the following script to do it each time for 12 levels of stname but I have to change script each time for the another 12 levels [line 3 in the script for example: for( i in levels(test$stname)[12:24))] and I do not know how can I save the obtained graphs (seven graphic windows) as jpeg files (e.g. plot1.jpeg, plot2.jpeg and so on). As I have 45 dataset like this it would be gr! eat if somebody can help me to complete this script to do all together for a dataset using a script. Thank you very much in advance for your cooperation, Monireh windows(9,9) par(mfrow = c(3,4)) for( i in levels(test$stname)[1:12]) { data- test[test$stname==i,] xx - c(1:length(data$upper), length(data$upper):1) yy - c(data$upper, rev(data$lower)) zz- data$observed tt- data$Best_Sim par(lab =c(10,15,2)) plot.jpeg- plot(xx,yy, type=n, xlim=c(min(xx), max(xx)), ylim=c(min(zz,yy,tt), max(yy,zz,tt)*1.4), main= i, xlab=Month (1990-2002), ylab=Discharge(m3/s), font.axis=6) polygon(xx, yy, col=green, border = NA) lines(zz, col=blue, lwd=1.5) lines(tt,col=red, lwd=1.5) legend(length(zz)-60, max(yy,zz,tt)*1.45, c(Upper Limit, Lower Limit, Observed,Best etimation) , lwd=c(10, 1,1.7,1.7), bty=n, col= c(green, white, blue,red)) } __ 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 open more windows to make more graphs at once!
Hello, See ?Devices ?dev.print e.g. X11() # opens a new screen device plot(1:10) # plots points on the device dev.print(jpeg, [args]) # prints from the X11 device to a jpeg file dev.off() # close X11 device or jpeg([args]) # opens a jpeg device (file) for plotting plot(1:10) # plots points on the device dev.off() # closes connection to the jpeg device Hope this helps. Regards, -- Nicolas Mazziotta The contents of this e-mail, including any attachments, are ...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to open more windows to make more graphs at once!
Creating more than one graphic windows is, as far as I know, not possible in R. But it's no problem to run a script which create multiply jpeg's. See ?jpeg on how to create jpeg's. Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:r-help- [EMAIL PROTECTED] Namens Faramarzi Monireh Verzonden: woensdag 7 maart 2007 9:39 Aan: r-help@stat.math.ethz.ch Onderwerp: [R] How to open more windows to make more graphs at once! Dear R users, I have a data frame (test) including five columns of upper (numeric), lower (numeric), observed (numeric), best_sim (numeric) and stname (factor with 80 levels, each level with different length). Now I would like to write a short program to draw one graph as follow for each level of stname but I would like also to draw each time 12 graphs for the 12 levels of stname in the same graphic windows and save it as jpeg' file . This means at the end I will have 7 (80 levels/12=7) graphic windows and 7 jpeg files each one with 12 graphs (the last one with 8 graphs) for the 12 levels of stname. I already wrote the following script to do it each time for 12 levels of stname but I have to change script each time for the another 12 levels [line 3 in the script for example: for( i in levels(test$stname)[12:24))] and I do not know how can I save the obtained graphs (seven graphic windows) as jpeg files (e.g. plot1.jpeg, plot2.jpeg and so on). As I have 45 dataset like this it would be gr! eat if somebody can help me to complete this script to do all together for a dataset using a script. Thank you very much in advance for your cooperation, Monireh windows(9,9) par(mfrow = c(3,4)) for( i in levels(test$stname)[1:12]) { data- test[test$stname==i,] xx - c(1:length(data$upper), length(data$upper):1) yy - c(data$upper, rev(data$lower)) zz- data$observed tt- data$Best_Sim par(lab =c(10,15,2)) plot.jpeg- plot(xx,yy, type=n, xlim=c(min(xx), max(xx)), ylim=c(min(zz,yy,tt), max(yy,zz,tt)*1.4), main= i, xlab=Month (1990-2002), ylab=Discharge(m3/s), font.axis=6) polygon(xx, yy, col=green, border = NA) lines(zz, col=blue, lwd=1.5) lines(tt,col=red, lwd=1.5) legend(length(zz)-60, max(yy,zz,tt)*1.45, c(Upper Limit, Lower Limit, Observed,Best etimation) , lwd=c(10, 1,1.7,1.7), bty=n, col= c(green, white, blue,red)) } __ 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] where can I find Durbin-Waston test tables for Confidence Level 2.5% or 0.5%?
Hi all, I am doing a two-sided DW test: H0: rho = 0 H1: rho =/= 0 My understanding is that most test statistics tables are one-sided. It's the way they created the table. So from online, by doing Googling, I found a bunch of DW tables for Confidence Level 5%. Those tables can answer my two-sided question at 5x2 = 10% confidence level. But what if I want two-sided test at 1% and 5% confidence level? Then I need 0.5% and 2.5% tables on those one-sided table. My sample size is 278, and the number of parameters is 2, these adds to the hardship of finding a good table... Could anybody give me some pointers of two-sided DW tables or 1-sided DW table with 0.5% and 2.5% confidence levels? Thanks a lot! Moreover, I appreciate any pointers about electronic tables that I can use in programs, I want to implement DW test myself, but let the program searching a table automatically... Thanks a lot! [[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] heatmap
Hello sir; I use the function heatmap.2 to draw a heatmap of microarray data,which consists of logratios. Q1 But the lengend shows the Z score and the corresponding color.But I want the legend to show the logratios and the corresponding color.How can I do it? Q1 How can I control that cluster only applied to genes(rows) or samples(columns) via heatmap.2 function?Default is cluster applied to both rows and columns. Thanks a lot! My best! __ 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 open more windows to make more graphs at once!
On Wed, 2007-03-07 at 09:39 +0100, Faramarzi Monireh wrote: Dear R users, I have a data frame (test) including five columns of upper (numeric), lower (numeric), observed (numeric), best_sim (numeric) and stname (factor with 80 levels, each level with different length). Now I would like to write a short program to draw one graph as follow for each level of stname but I would like also to draw each time 12 graphs for the 12 levels of stname in the same graphic windows and save it as jpeg' file . This means at the end I will have 7 (80 levels/12=7) graphic windows and 7 jpeg files each one with 12 graphs (the last one with 8 graphs) for the 12 levels of stname. I already wrote the following script to do it each time for 12 levels of stname but I have to change script each time for the another 12 levels [line 3 in the script for example: for( i in levels(test$stname)[12:24))] and I do not know how can I save the obtained graphs (seven graphic windows) as jpeg files (e.g. plot1.jpeg, plot2.jpeg and so on). As I have 45 dataset like this it would be gr! eat if somebody can help me to complete this script to do all together for a dataset using a script. Thank you very much in advance for your cooperation, Monireh Hi Monireh, I don't have your data set so I have generated some random data to illustrate one approach to this. ## generate some data set.seed(1234) dat - data.frame(upper = rnorm(100), lower = rnorm(100), observed = rnorm(100), best_sim = rnorm(100), stname = factor(gl(5, 20), labels = letters[1:5])) ## because this is going to be called 45 times, I've wrapped it in a ## function, foo() ## Note the filename arg. It contains %03d which means that R will ## insert a number and produce many jpegs, varying by this number ## e.g. myplot1.jpeg, myplot2.jpeg - see ?jpeg. ## the ... allow passing of arguments to jpeg foo - function(x, filename = Rplot%03d.jpeg, ...) { ## start the jpeg device jpeg(filename = filename, ...) ## store the parameter defaults and set a 2 by 2 plot regions opar - par(mfrow = c(2,2)) ## this insures that the device is closed and defaults restored on ## function exit on.exit({dev.off(); par(opar)}) ## set up a loop to go over the levels of your factor for(i in levels(x$stname)) { ## do the plotting - here you need to add the plot commands ## you really want to use - these are just examples. plot(lower ~ upper, data = x, subset = stname == i) ## this just adds a lowess line, I use with() to make it easier ## to read. with(x, lines(lowess(upper[stname == i], lower[stname == i]), col = red)) } invisible() } ## to use the function on the demo data ## uses default filename foo(dat) ## or passing arguments to jpeg() foo(dat, width = 600, height = 600, pointsize = 10) ## or using your own file name foo(dat, filename = dataset1_%03d.jpeg, width = 600, height = 600, pointsize = 10) See ?jpeg to see why this works - the filename with %03d allows R to produce several jpegs. windows(9,9) par(mfrow = c(3,4)) for( i in levels(test$stname)[1:12]) { data- test[test$stname==i,] xx - c(1:length(data$upper), length(data$upper):1) yy - c(data$upper, rev(data$lower)) zz- data$observed tt- data$Best_Sim par(lab =c(10,15,2)) In the line below, where you set the x- and y-limits, it would be simpler and more readable to use range() instead of c(min(x), max(x) - so your plot call could be: plot.jpeg- plot(xx,yy, type=n, xlim= range(xx), ylim=range(zz,yy,tt)*1.4), main= i, xlab=Month (1990-2002), ylab=Discharge(m3/s), font.axis=6) Also, you can format the y-label more nicely with: ylab = expression(paste(Discharge (, m^-3 * s^{-1}, ))) HTH G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC [f] +44 (0)20 7679 0565 UCL Department of Geography Pearson Building [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street London, UK[w] http://www.ucl.ac.uk/~ucfagls/ WC1E 6BT [w] http://www.freshwaters.org.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] good procedure to estimate ARMA(p, q)?
Hi all, I have some residuals from regression, and i suspect they have correlations in them... I am willing to cast the correlation into a ARMA(p, q) framework, what's the best way to identify the most suitable p, and q, and fit ARMA(p, q) model and then correct for the correlations in regression? I know there are functions in R, I have used them before, but I just want to see if I can do the whole procedure myself, just to improve my understanding ... Please give me some pointers! Thanks a lot [[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] Sweave issue: quotes in verbatim-like output print incorrectly
On Wed, 2007-03-07 at 15:33 +1000, Peter Dunn wrote: Hi all I love Sweave; use it all the time. But I recently received a new computer, and ever since I have had a problem I've never seen before. For example, I place the following in my Snw file: Try this in the preamble of your Snw file: \usepackage[utf8x]{inputenc} (assuming you have the inputenc package installed and available). I'm assuming you are now using a machine using UTF-8 for character encodings. I used to get that output on my linux box (FC4 - 6) before I added the above \usepackage statement. HTH G = sms - read.table(http://www.sci.usq.edu.au/staff/dunn/Datasets/applications/popular/smsspeed.dat;, header=TRUE) attach(sms) sms.lm - lm( Time ~ Age*Phone, subset=(Age30) ) summary(sms.lm) @ Standard stuff. The output appears in the corresponding LaTeX file as it should, in a verbatim-like environment as it should. But since I have had this new machine, this line of output: Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 appears in my resulting pdf document as Signif. codes: 0 ^a˘A¨Y***^a˘A´Z0.001 ^a˘A¨Y**^a˘A´Z0.01 ^a˘A¨Y*^a ˘A´Z0.05 ^a˘A¨Y.^a˘A´Z0.1 ^a˘A¨Y^a˘A´Z1 In short, every quote is replaced by garbage. This makes my output looks incredibly bad. (This is true for all cases; the above is the output from my example.) I also imagine (hope!) there is a very simple fix. Can anyone help me? Documents which used to produce the correct output document now do this, so it must be something to do with my machine set up, or R set up, rather than the documents themselves, I guess. Any help appreciated. I have no idea where to look for the solution (the FAQ. manuals and mailing archives were no help that I could see; happy to be corrected). P. version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status Patched major 2 minor 4.0 year 2006 month 11 day25 svn rev39997 language R version.string R version 2.4.0 Patched (2006-11-25 r39997) sessionInfo() R version 2.4.0 Patched (2006-11-25 r39997) i486-pc-linux-gnu locale: LC_CTYPE=en_AU.UTF-8;LC_NUMERIC=C;LC_TIME=en_AU.UTF-8;LC_COLLATE=en_AU.UTF-8;LC_MONETARY=en_AU.UTF-8;LC_MESSAGES=en_AU.UTF-8;LC_PAPER=en_AU.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_AU.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods [7] base -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC [f] +44 (0)20 7679 0565 UCL Department of Geography Pearson Building [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street London, UK[w] http://www.ucl.ac.uk/~ucfagls/ WC1E 6BT [w] http://www.freshwaters.org.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] info about R diffusion
Buongiorno a tutti mi chiamo Diego Pettena e sono uno studente universitario iscritto alla facoltà di economia. Ho da poco iniziato ad utilizzare il sitema R per l'analisi statistica, tuttavia con la presente non intendo chiederVi nulla riguardo al linguaggio o all'utilizzo del programma. Per questo mi scuso sinceramente fin da subito se questa non è la sessione adatta a cui inviare la mia richiesta. Sto svolgendo un piccolo elaborato, sempre per scopi universitari, concernente R e mi interesserebbe avere alcuni dati/statistiche riguardanti la diffusione di R nel mondo (università, privati, professionisti) magari, sempre se possibile, paragonati a quelli dei principali sistemi concorrenti. Non ho bisogno di informazioni estremamente dettagliate, mi basta avere una visione generale del grado di diffusione del programma. Se tali info non fossero in Vs possesso vi chiedo di perdonare l'intrusione e vi porgo, comunque, i miei più sentiti ringraziamenti. attendo vostre, cordiali saluti Diego Pettena Goodmorning all I'm Diego Pettena and I'm a student of economics in the Verona's University. I recently began to use R for statistical analysis; with this mail I don't want to ask you informations about the language or the use of the programme and I sincerely apologize if this is not the right session where doing my request! I'm doing a shortly article about R - for my studies - and I ask you if are available some statistics concern the level of worldwide diffusion of the programme (universities, private, professional..), and, ever if is it possible, compared with the major competitors. If theese statistics are available I ask you to send me them by mail or to say me where I can find them. Otherwise I pray you to apologize my interference and I thank you. Wiht my best regards, thanks a lot Diego Pettena [[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] where can I find Durbin-Waston test tables for Confidence Level 2.5% or 0.5%?
Michael: I am doing a two-sided DW test: H0: rho = 0 H1: rho =/= 0 My understanding is that most test statistics tables are one-sided. It's the way they created the table. ...because rho 0 is the alternative of interest in most applications. So from online, by doing Googling, I found a bunch of DW tables for Confidence Level 5%. Using tables for the DW test is difficult because it's distribution depends on the particular set of regressors used. The tables of DW just give upper and lower bounds. Back when the DW test was suggested, tables was the only way to make application of the test feasible. Today, you would either use the exact combination of chi-square distributions or an asymptotic approximation (both implemented in dwtest() from lmtest) or a bootstrap approximation (implemented in durbin.watson() from car). For 278 observations, the normal approximation should be sufficient. hth, Z __ 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] Package RODBC
Dear Alberto, please note that special characters (eg a space character) in the Excel sheet names mess up the simple way of querying provided by sqlFetch. If you have a regular case of all sheets like Sheet1: plan1 - sqlFetch(channel,Sheet1) # should work But if you have Sheet 1 ( similar..) you have to use the command sqlQuery(), which means that you have to write a proper SQL query as 2nd argument that follows proper SQL syntax (starting with SELECT, etc...). If I wanted to combine this with sheet-names already read in variables/vectors I concatenate this into a single stringsimilar to your 2nd code variant ... Of course you could also use grep() to search the position of a given sheet-name (the order of the sheets may be different that within Excel). What you get with plan1[,1] depends on what you're reading. In case that the 1st column is read as string, this is read by default as factor with n levels. You can simply convert it using as.character() ... Hope this helps, Wolfgang Mendiburu, Felipe (CIP) a écrit : Dear Alberto, channel - odbcConnectExcel(test.xls) name1 - tables[1, TABLE_NAME] # the name1 is Sheet1$ it must be: name1 - Sheet1 plan1 - sqlFetch(channel, name1) is ok or plan1 - sqlFetch(channel, Sheet1) Regards, Felipe -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Alberto Monteiro Sent: Tuesday, March 06, 2007 9:37 AM To: r-help@stat.math.ethz.ch Subject: [R] Package RODBC I have some questions about the RODBC package. library(RODBC) # required for those who want to repeat these lines 1st, I noticed that the following sequence does not work: channel - odbcConnextExcel(test.xls) tables - sqlTables(channel) name1 - tables[1, TABLE_NAME] # this should be the name plan1 - sqlFetch(channel, name1) # bang! odbcClose(channel) However, I can circumvent this with: channel - odbcConnextExcel(test.xls) tables - sqlTables(channel) name1 - tables[1, TABLE_NAME] # this should be the name plan1 - sqlQuery(channel, sprintf(select * from [%s], name1)) # ok odbcClose(channel) 2nd, it seems that only pure strings (which are not links to strings) and numerical values are correctly fetched or selected. Is this a bug? 3rd, when do something like plan1[,1] a weird message about Levels appear. What is that? Alberto Monteiro -- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wolfgang Raffelsberger, PhD Laboratoire de BioInformatique et Génomique Intégrative IGBMC 1 rue Laurent Fries, 67404 Illkirch Strasbourg, France Tel (+33) 388 65 3300 Fax (+33) 388 65 3276 [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] where can I find Durbin-Waston test tables for Confidence Level 2.5% or 0.5%?
Michael wrote: Hi all, I am doing a two-sided DW test: H0: rho = 0 H1: rho =/= 0 My understanding is that most test statistics tables are one-sided. It's the way they created the table. So from online, by doing Googling, I found a bunch of DW tables for Confidence Level 5%. Those tables can answer my two-sided question at 5x2 = 10% confidence level. But what if I want two-sided test at 1% and 5% confidence level? Then I need 0.5% and 2.5% tables on those one-sided table. My sample size is 278, and the number of parameters is 2, these adds to the hardship of finding a good table... Could anybody give me some pointers of two-sided DW tables or 1-sided DW table with 0.5% and 2.5% confidence levels? Thanks a lot! Moreover, I appreciate any pointers about electronic tables that I can use in programs, I want to implement DW test myself, but let the program searching a table automatically... Are you aware of the implementations of this test in the car, lmtest, and fMultivar packages? RSiteSearch(Durbin-Watson, restrict=function) finds those functions. Thanks a lot! [[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. -- 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] How to open more windows to make more graphs at once!
On 07-Mar-07 ONKELINX, Thierry wrote: Creating more than one graphic windows is, as far as I know, not possible in R. It is if you are running R on Linux (in which the X Windowing System -- or X -- is the standard graphical system). As it says in ?X11: This can only be done on machines that run X. Then each call to X11() opens a new graphics window, so you can have as many as you like. And, using the display parameter in X11(), if you have monitors for more than one machine on your desk you can throw each window to a monitor of your choice, giving you multiple graphics windows on multiple screens, all from the same run of R. But, as to whether/to what extent X or equivalent is available for MS Windows, that is another question on which I have no expertise. Ted. But it's no problem to run a script which create multiply jpeg's. See ?jpeg on how to create jpeg's. Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:r-help- [EMAIL PROTECTED] Namens Faramarzi Monireh Verzonden: woensdag 7 maart 2007 9:39 Aan: r-help@stat.math.ethz.ch Onderwerp: [R] How to open more windows to make more graphs at once! Dear R users, I have a data frame (test) including five columns of upper (numeric), lower (numeric), observed (numeric), best_sim (numeric) and stname (factor with 80 levels, each level with different length). Now I would like to write a short program to draw one graph as follow for each level of stname but I would like also to draw each time 12 graphs for the 12 levels of stname in the same graphic windows and save it as jpeg' file . This means at the end I will have 7 (80 levels/12=7) graphic windows and 7 jpeg files each one with 12 graphs (the last one with 8 graphs) for the 12 levels of stname. I already wrote the following script to do it each time for 12 levels of stname but I have to change script each time for the another 12 levels [line 3 in the script for example: for( i in levels(test$stname)[12:24))] and I do not know how can I save the obtained graphs (seven graphic windows) as jpeg files (e.g. plot1.jpeg, plot2.jpeg and so on). As I have 45 dataset like this it would be gr! eat if somebody can help me to complete this script to do all together for a dataset using a script. Thank you very much in advance for your cooperation, Monireh windows(9,9) par(mfrow = c(3,4)) for( i in levels(test$stname)[1:12]) { data- test[test$stname==i,] xx - c(1:length(data$upper), length(data$upper):1) yy - c(data$upper, rev(data$lower)) zz- data$observed tt- data$Best_Sim par(lab =c(10,15,2)) plot.jpeg- plot(xx,yy, type=n, xlim=c(min(xx), max(xx)), ylim=c(min(zz,yy,tt), max(yy,zz,tt)*1.4), main= i, xlab=Month (1990-2002), ylab=Discharge(m3/s), font.axis=6) polygon(xx, yy, col=green, border = NA) lines(zz, col=blue, lwd=1.5) lines(tt,col=red, lwd=1.5) legend(length(zz)-60, max(yy,zz,tt)*1.45, c(Upper Limit, Lower Limit, Observed,Best etimation) , lwd=c(10, 1,1.7,1.7), bty=n, col= c(green, white, blue,red)) } __ 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. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 07-Mar-07 Time: 09:55:12 -- XFMail -- __ 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 and SAS proc format
The down side to R's factor solution: The numerical values of factors are always 1 to number of levels. Thus, it can be tough and requires great care to work with studies that have both numerical values different from this and value labels. This situation is currently not well-supported by R. Regards, Ulrike P.S.: I fully agree with Frank regarding the annoyance one sometimes encounters with formats in SAS! You can add an attribute to a variable. In the sas.get function in the Hmisc package for example, when importing SAS variables that have PROC FORMAT value labels, an attribute 'sas.codes' keeps the original codes; these can be retrieved using sas.codes(variable name). This could be done outside the SAS import context also. Frank -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University Frank, are these attributes preserved when merging or subsetting a data frame? Are they used in R packages other than Hmisc and Design (e.g. in a simple table request)? If this is the case, my wishlist items 8658 and 8659 (http://bugs.r-project.org/cgi-bin/R/wishlist?id=8658;user=guest, http://bugs.r-project.org/cgi-bin/R/wishlist?id=8659;user=guest) can be closed. Otherwise, I maintain the opinion that there are workarounds but that R is not satisfactorily able to handle this type of data. Regards, Ulrike --- End of Original Message --- [[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] Generic distributions
Matthias Kohl wrote: in distr you can do: library(distr) N - Norm(mean = 1, sd = 2) p(N)(0.5) r(N)(100) !!! not: p(N, 0.5) or r(N, 100) !!! A detailed description of package distr is given in package distrDoc. library(distrDoc) vignette(distr) Thanks!!! This is almost perfect. It even has (some) arithmetics!!! z1 - Norm(mean = 1, sd= 0.6) z2 - Norm(mean = 2, sd= 0.8) z1+z2 Distribution Object of Class: Norm mean : 3 sd : 1 Warning message: arithmetics on distributions are understood as operations on r.v.'s see 'distrARITH()'; for switching off this warning see '?distroptions' in: print(object) Alberto Monteiro __ 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 issue: quotes in verbatim-like output print incorrectly
Gavin Simpson [EMAIL PROTECTED] writes: On Wed, 2007-03-07 at 15:33 +1000, Peter Dunn wrote: But I recently received a new computer, and ever since I have had a problem I've never seen before. For example, I place the following in my Snw file: Try this in the preamble of your Snw file: \usepackage[utf8x]{inputenc} \usepackage[utf8]{inputenc} should suffic for this. Also, utf8 is newer than utf8x. So if you only need the ISO 8859 subset of Unicode, utf8 should serve your needs. HTH Patrick -- I never used a logarithm in my life, and could not undertake to extract the square root of four without misgivings. (Georg Bernhard Shaw) __ 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] Identifying points in a plot that have duplicate values
Use the iplots package. The interactive querying works effectively for largish datasets (over 50,000 cases) where sunflower plots may not. Antony Unwin Professor of Computer-Oriented Statistics and Data Analysis, University of Augsburg, 86135 Augsburg, Germany Tel: + 49 821 5982218 http://stats.math.uni-augsburg.de/ [[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] How to open more windows to make more graphs at once!
Ted Harding wrote: Creating more than one graphic windows is, as far as I know, not possible in R. But, as to whether/to what extent X or equivalent is available for MS Windows, that is another question on which I have no expertise. X11() seems to work for Windows XP. Alberto Monteiro __ 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] anova applied to a lme object
Hi R-users, when carrying out a multiple regression, say lm(y~x1+x2), we can use an anova of the regression with summary.aov(lm(y~x1+x2)), and afterwards evaluate the relative contribution of each variable using the global Sum of Sq of the regression and the Sum of Sq of the simple regression y~x1. Now I would like to incorporate a random effect in the model, as some data correspond to the same region and others not: mylme- lme(y~x1+x2, random= ~1|as.factor(region)). I would like to know, if possible, which is the contribution of each variable to the global variability. Using anova(mylme) produce an anova table (without the Sum of Sq column), but I am not sure how can I derive the contribution of each variable from it, or even whether it is nonsense to try, nor can I derive a measure of how much variability is left unexplained. Sorry for the type of question, but I did not find a simple solution and some researchers I work with love to have relative contributions to global variability. Thanks a lot in advance, Berta __ 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] Multi-line plots with matrices in R
Hello all, I'm a new user of R, experienced with Octave/MATLAB and therefore struggling a bit with the new syntax. One of the easy things in Octave or MATLAB is to plot multiple lines or sets of points by using a matrix where either the columns or the rows contain the y-values to be plotted. Both packages automatically give each line/points their own unique colour, character etc. I'm wondering how I get the same functionality in R. For example, if X is a vector of x-values and Y is a matrix whose rows contain the y-values, I can do, apply(Y,1,lines,x=X) ... but of course everything is all in black, with the same type of line or points. I'd like each line to have its own unique colour and/or style. Another thing I'd like clarification on is the ability to update an existing plot. For example if I do, plot.window(xlim=c(0,100),ylim=c(0,1)) and then after plotting data decide I want ylim=c(0,0.5), how do I update the graphic? A new plot.window() command does nothing. Many thanks, -- Joe __ 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] Multi-line plots with matrices in R
Hi see matplot, matlines. or use forbidden for cycle. for (i in 1:n) lines(x,y[,i], col=i) or if you want to use more colours use built in rainbow, topo.colors or generate your own set. Regards Petr On 7 Mar 2007 at 12:30, Joseph Wakeling wrote: Date sent: Wed, 07 Mar 2007 12:30:46 + From: Joseph Wakeling [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] Multi-line plots with matrices in R Hello all, I'm a new user of R, experienced with Octave/MATLAB and therefore struggling a bit with the new syntax. One of the easy things in Octave or MATLAB is to plot multiple lines or sets of points by using a matrix where either the columns or the rows contain the y-values to be plotted. Both packages automatically give each line/points their own unique colour, character etc. I'm wondering how I get the same functionality in R. For example, if X is a vector of x-values and Y is a matrix whose rows contain the y-values, I can do, apply(Y,1,lines,x=X) ... but of course everything is all in black, with the same type of line or points. I'd like each line to have its own unique colour and/or style. Another thing I'd like clarification on is the ability to update an existing plot. For example if I do, plot.window(xlim=c(0,100),ylim=c(0,1)) and then after plotting data decide I want ylim=c(0,0.5), how do I update the graphic? A new plot.window() command does nothing. Many thanks, -- Joe __ 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] Multi-line plots with matrices in R
On Wed, 2007-03-07 at 12:30 +, Joseph Wakeling wrote: Hello all, I'm a new user of R, experienced with Octave/MATLAB and therefore struggling a bit with the new syntax. One of the easy things in Octave or MATLAB is to plot multiple lines or sets of points by using a matrix where either the columns or the rows contain the y-values to be plotted. Both packages automatically give each line/points their own unique colour, character etc. I'm wondering how I get the same functionality in R. For example, if X is a vector of x-values and Y is a matrix whose rows contain the y-values, I can do, apply(Y,1,lines,x=X) You want maplot here. See ?matplot but here is an example: ## generate some data to use, a matrix of Y values ## and a vector of x indices. mat - matrix(runif(100), ncol = 5) vec - seq(1, 100, length = 20) ## plot it using matplot matplot(vec, mat, type = l) # type = l to get lines There is also matlines() and matpoints() for adding lines and points to existing plots. ... but of course everything is all in black, with the same type of line or points. I'd like each line to have its own unique colour and/or style. Another thing I'd like clarification on is the ability to update an existing plot. For example if I do, plot.window(xlim=c(0,100),ylim=c(0,1)) Standard graphics in R are not modifiable after being plotted. You need to re-plot. When plotting data, I rarely need plot.window. This is what I would do: x - 1:100 * runif(100) y - seq(0,1, length = 100) * runif(100) plot(x, y, xlim = c(0, 100), ylim = c(0, 1)) # now change the limits plot(x, y, xlim = c(0, 100), ylim = c(0, 0.5)) and then after plotting data decide I want ylim=c(0,0.5), how do I update the graphic? A new plot.window() command does nothing. But it does: opar - par(mfrow = c(1,2)) plot(x, y, xlim = c(0, 100), ylim = c(0, 0.5)) plot(x, y, xlim = c(0, 100), ylim = c(0, 1)) plot.window(xlim = c(0, 100), ylim = c(0, 0.5)) points(x, y, col = red) par(opar) The points on the left plot correspond exactly to the points in red on the right plot. The axis limits have changed, but because the axes have already been labelled, these are not updated. We can illustrate this by adding axes to the top and right of that plot opar - par(mfrow = c(1,2), mar = c(5,4,4,4) + 0.1) plot(x, y, xlim = c(0, 100), ylim = c(0, 0.5)) plot(x, y, xlim = c(0, 100), ylim = c(0, 1)) plot.window(xlim = c(0, 100), ylim = c(0, 0.5)) points(x, y, col = red) axis(3) axis(4) par(opar) Note the changed axis range in the right-hand margin. The problem is that you can't use plot.window to achieve what you want, not that plot.window doesn't do anything. Many thanks, -- Joe HTH G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.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] R-2.4.1 AIX build patch.
Dear AIX useR's. Will you test it in various environment? There is not xlf in the environment where I can approach. cf. 32bit, 64bit, --enable-R-shlib, --enable-BLAS-shlib ...various cases! http://prs.ism.ac.jp/%7enakama/AIX/ -- EI-JI Nakama [EMAIL PROTECTED] \u4e2d\u9593\u6804\u6cbb [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] Package RODBC
Dear Alberto, It is better to assign a name to an area of data and not to use the name of the sheet, because this can have graphs and other data. If you this interested can see: http://tarwi.lamolina.edu.pe/~fmendiburu/Rsolutions.htm I hope that this also helps, Felipe. -Original Message- From: Wolfgang Raffelsberger [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 07, 2007 4:50 AM To: Mendiburu, Felipe (CIP) Cc: Alberto Monteiro; r-help@stat.math.ethz.ch Subject: Re: [R] Package RODBC Dear Alberto, please note that special characters (eg a space character) in the Excel sheet names mess up the simple way of querying provided by sqlFetch. If you have a regular case of all sheets like Sheet1: plan1 - sqlFetch(channel,Sheet1) # should work But if you have Sheet 1 ( similar..) you have to use the command sqlQuery(), which means that you have to write a proper SQL query as 2nd argument that follows proper SQL syntax (starting with SELECT, etc...). If I wanted to combine this with sheet-names already read in variables/vectors I concatenate this into a single stringsimilar to your 2nd code variant ... Of course you could also use grep() to search the position of a given sheet-name (the order of the sheets may be different that within Excel). What you get with plan1[,1] depends on what you're reading. In case that the 1st column is read as string, this is read by default as factor with n levels. You can simply convert it using as.character() ... Hope this helps, Wolfgang Mendiburu, Felipe (CIP) a écrit : Dear Alberto, channel - odbcConnectExcel(test.xls) name1 - tables[1, TABLE_NAME] # the name1 is Sheet1$ it must be: name1 - Sheet1 plan1 - sqlFetch(channel, name1) is ok or plan1 - sqlFetch(channel, Sheet1) Regards, Felipe -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Alberto Monteiro Sent: Tuesday, March 06, 2007 9:37 AM To: r-help@stat.math.ethz.ch Subject: [R] Package RODBC I have some questions about the RODBC package. library(RODBC) # required for those who want to repeat these lines 1st, I noticed that the following sequence does not work: channel - odbcConnextExcel(test.xls) tables - sqlTables(channel) name1 - tables[1, TABLE_NAME] # this should be the name plan1 - sqlFetch(channel, name1) # bang! odbcClose(channel) However, I can circumvent this with: channel - odbcConnextExcel(test.xls) tables - sqlTables(channel) name1 - tables[1, TABLE_NAME] # this should be the name plan1 - sqlQuery(channel, sprintf(select * from [%s], name1)) # ok odbcClose(channel) 2nd, it seems that only pure strings (which are not links to strings) and numerical values are correctly fetched or selected. Is this a bug? 3rd, when do something like plan1[,1] a weird message about Levels appear. What is that? Alberto Monteiro -- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wolfgang Raffelsberger, PhD Laboratoire de BioInformatique et Génomique Intégrative IGBMC 1 rue Laurent Fries, 67404 Illkirch Strasbourg, France Tel (+33) 388 65 3300 Fax (+33) 388 65 3276 [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] Appropriate error distribution
Hi, My name is Cristina. I'm interested in studying which continuos predictor variables (such as grooming received, rank, etc.) affect grooming given, as well a continuos variable. I'm having problems finding an appropriate family distribution to fit the GLMM I'm doing. The response variable, grooming given, has many zeros which does not allow me to use a gamma distribution. I tried with a poisson but since I had to convert the data to integers I fear loosing a lot of information (and anyway my data is originally continuos and not counts). I found in the help archive that someone with a similar problem (continuos data and many zeros) was adviced to use Tweedie models. I don't know anything about this and wouldn't kow if this is appropriate in my case and possible to apply to generalized linear mixed models. I'm wondering if anybody could provide me with any good insights on what distribution I could us and if, in the case of tweedie being a good option, if it can be used with GLMM's.. Thanks a lot, Cristina. __ 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] Memory Limits in Ubuntu Linux
David, I wouldn't give up on windows so fast. Many people have gotten the 3Gb switch to work. One used to have to modify the header of the Rgui.exe program to use the switch, but now the binary comes ready for that, so its really quite easy. I would like to hear more about why its not working for you. As for Linux, I use FC5 for which there is a 64-bit binary. But there are also 64-bit binaries for other distros. The 32-bit and 64-bit binaries are in different directories, so you should have no trouble telling them apart. I have heard good things about Ubuntu--mainly that its very easy to use--but FC5 has been pretty easy to learn too and I use the KDE desktop which gives me Kate as a text editor. You can open a terminal window in Kate to run R and set up a key like F10 to send the code from the editor to R. Its not quite as good as my Windows setup with Tinn-R, but almost as good. Thanks, Roger -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 06, 2007 5:37 PM To: Bos, Roger Subject: RE: [R] Memory Limits in Ubuntu Linux Thanks for your prompt reply! The windows 3GB switch is quite problematic - it was not useable on my machine, and there are comments about these problems around the net. Thus, on to Linux. My machine has 4Gig, and some megabytes are grabbed by my Asus motherboard, leaving some 3.56 Gig. So if I understand your suggestion, try the 64-bit version of Ubuntu (based on Debian but I had better luck with the video part of the install) and then use the corresponding image from CRAN. My fear is that the CRAN Ubuntu version might be 32-bit - any idea how to find out before I embark on another install? Which Linux do you have - you described some significant success with getting large jobs to run. And yes, I've worked hard to save memory by tweaking the code. Thanks again. On 6 Mar 2007 at 16:51, Bos, Roger wrote: David, First of all, under Windows you can get about 3GB available to R by using the /3Gb switch in your boot.ini file, assuming you have 4Gb of memory installed on your windows machine. Using that method, I have seen the memory using of my R process get as big as 2.7Gb in task manager. What's important, of course, is contiguous space, as you mentioned. There, you may want to check your code closely and make sure that its memory usage is as efficient as possible and you are storing the minimal amount you need for each run. If you don't need an object for a while consider writing it to disk and reading it back in later. Second, AFAIK to get any benefit from more memory is Linux you have to go to the 64bit version. I am a Linux newbie too, so I choose to use one of the pre-compiled binaries available on CRAN. In other words, you shouldn't have to compile anything yourself. How much memory do you have on your Linux box? I have 16Gb and I know I have ran stuff that wouldn't run on my 4Gb windows box. HTH, Roger -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Tuesday, March 06, 2007 3:44 PM To: r-help@stat.math.ethz.ch Subject: [R] Memory Limits in Ubuntu Linux I am an R user trying to get around the 2Gig memory limit in Windows, so here I am days later with a working Ubuntu, and R under Ubuntu. But - the memory problems seem worse than ever. R code that worked under windows fails, unable to allocate memory. Searching around the web, it appears that the problem may be the ability to find contguous memory for my big vectors, but a fresh boot of Ubuntu does not help either. Which way to go? 1) Try to install 64-bit version for bigger address space. Would this help? Is this workable for my Athlon 64 Dual-core? (the live cd seems to work but I never got it to boot after a disk install, but then the 386 version was no better until I learned more about Grub...I could try again if this might solve the problem) 2) Recompile R to get bigger memory capability? (I'll have to cross-post to some R forums too) This will be a challenge for a Linux newbie...like me. 3) Any other suggestions? My goal is to create a bigger neural network than fits in my Windows R version. -- David Katz www.davidkatzconsulting.com 541 482-1137 [[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. ** * This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No right to confidential or privileged treatment of this message is waived or lost by any error in
Re: [R] Autogenerate tags in tag=value pairs for
Try na.locf from the zoo package and then use merge with specified suffixes: library(zoo) f - function(x) { rownames(x) - NULL merge(x, na.locf(x[-1], na.rm = FALSE), by = 0, suffixes = c(, .by))[-1] } do.call(rbind, by(x, x$id, f)) On 3/7/07, Jon Olav Vik [EMAIL PROTECTED] wrote: Dear list, Is there a way to programmatically specify tag names for the ... (ellipsis) part of the argument list to a function? In other words, a way to do this: x - data.frame(A=1:5) if the name A was not hardcoded but given by a variable, and without resorting to: x - data.frame(1:5) names(x) - A A longer example describing my actual problem follows. Thanks in advance for any help. Best regards, Jon Olav I want to use function transformBy() in package doBy. The key is that the ... Further arguments of the form tag=value require tag to be specified, otherwise the output does not include the results of my groupwise calculations. Quoting the documentation: transformBy(doBy) Function to make groupwise transformations of data by applying the transform function to subsets of data. Usage transformBy(formula, data, ...) Arguments formula A formula with only a right hand side, see examples below data A data frame ... Further arguments of the form tag=value ### example ### # a function to replace NAs with the last non-NA value from above filldown - function(x) { notna - !is.na(x) # elements with values ix - cumsum(notna) # index to previous element (but zeros where we need NA) ix[ix==0] - NA # use [NA] as index to produce NA in output return(x[notna][ix]) # for each: return previous value if found, else NA } # illustration of how it works tmp - c(NA,NA,1,NA,3,NA,NA) cbind(tmp,filldown(tmp)) # I now want to apply filldown() to subsets of a data frame # and I want it to work on several columns # generate a data frame for illustration, # with a few non-NA values scattered round set.seed(5) # repeatable example x - data.frame(id = rep(1:4,each=6), v1=NA, v2=NA) ix - which(runif(nrow(x))0.75) x[ix,2] - rpois(length(ix),5) ix - which(runif(nrow(x))0.75) x[ix,3] - rpois(length(ix),5) x library(doBy) # the hard way -- works as required, # but I would like not having to hardcode column names v1 etc. transformBy(~id,data=x,v1.fd = filldown(v1),v2.fd = filldown(v2)) # does not work because # output includes only columns explicitly mentioned in the ... argument transformBy(~id,data=x,function(y) lapply(y,filldown)) __ 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] R and SAS proc format
Ulrike Grömping wrote: The down side to R's factor solution: The numerical values of factors are always 1 to number of levels. Thus, it can be tough and requires great care to work with studies that have both numerical values different from this and value labels. This situation is currently not well-supported by R. Regards, Ulrike P.S.: I fully agree with Frank regarding the annoyance one sometimes encounters with formats in SAS! You can add an attribute to a variable. In the sas.get function in the Hmisc package for example, when importing SAS variables that have PROC FORMAT value labels, an attribute 'sas.codes' keeps the original codes; these can be retrieved using sas.codes(variable name). This could be done outside the SAS import context also. Frank -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University Frank, are these attributes preserved when merging or subsetting a data frame? Are they used in R packages other than Hmisc and Design (e.g. in a simple table request)? no; would need to add functions like those that are used by the Hmisc label or impute functions. And they are not used outside Hmisc/Design. In fact I have little need for them as I always find the final labels as the key to analysis. If this is the case, my wishlist items 8658 and 8659 (http://bugs.r-project.org/cgi-bin/R/wishlist?id=8658;user=guest, http://bugs.r-project.org/cgi-bin/R/wishlist?id=8659;user=guest) can be closed. Otherwise, I maintain the opinion that there are workarounds but that R is not satisfactorily able to handle this type of data. R gives the framework for doing this elegantly but the user has an overhead of implementing new methods for such attributes. Cheers Frank Regards, Ulrike *--- End of Original Message ---* -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to open more windows to make more graphs at once!
Alberto Monteiro wrote: Ted Harding wrote: Creating more than one graphic windows is, as far as I know, not possible in R. But, as to whether/to what extent X or equivalent is available for MS Windows, that is another question on which I have no expertise. X11() seems to work for Windows XP. Although I believe the preferred method is windows(). Best, Jim Alberto Monteiro __ 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. -- James W. MacDonald, M.S. Biostatistician Affymetrix and cDNA Microarray Core University of Michigan Cancer Center 1500 E. Medical Center Drive 7410 CCGC Ann Arbor MI 48109 734-647-5623 ** Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues. __ 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 and SAS proc format
Jason Barnhart wrote: - Original Message - From: John Kane [EMAIL PROTECTED] To: lamack lamack [EMAIL PROTECTED]; R-help@stat.math.ethz.ch Sent: Tuesday, March 06, 2007 2:13 PM Subject: Re: [R] R and SAS proc format --- lamack lamack [EMAIL PROTECTED] wrote: Dear all, Is there an R equivalent to SAS's proc format? What does the SAS PROC FORMAT do? It formats or reformats data in the SAS system. Slightly more precisely: It creates user-defined formats, which are subsequently associated with variables and used for reading, printing, tabulating, and analyzing data. It is akin to R's factor() constructions, but not quite. For one thing, SAS's formats are separate entities - same format can be used for many variables, whereas R's factors have the formatting coded as a part of the object. For related reasons, a variable in SAS can have more distinct values than there are value labesl for, etc. It looks this: proc format; value kanefmt 1='A' 2='B' 3='C' 4='X' 5='Throw me out'; data temp; do i=1 to 10; kanevar=put(i,kanefmt.); output; end; proc print; run; And produces this: Obs i kanevar 1 1A 2 2B 3 3C 4 4X 5 5Throw me out 6 6 6 7 7 7 8 8 8 9 9 9 1010 10 But it is more robust than what is shown here. __ 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. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ 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] Calculating confidence limits on acf graphs
Hello, I was wondering if anybody could help me with this? I have plotted an acf function for a time series and am very happy with it. Now I am interested in calculating for myself the two values for the confidence intervals that are plotted on the graph of the acf. The confidence intervals do not appear to be returned from the acf function (is this true?). So far I haven't managed to calculate them myself. Can anybody help? Phil, __ 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] Power calculation for detecting linear trend
Dear people, I've a problem in doing a power calculation. In Fryer and Nicholson (1993), ICES J. mar. Sci. 50: 161-168 page 164 an example is given with the following characteristics T=5, points in time R=5, replicates Var.within=0.1 q=10, a 10% increase per year The degrees of freedom for the test are calculated as Vl=T*R-2=23 and the non-centrality parameter Dl=4.54. Using this they get a power of 0.53, but the result that I'm getting is 0.05472242. I've tried this several ways in R, but I'm not able to come up with the same number. Am I doing something wrong in the calculation of the power? Here's my code: T-5 R-5 sigmasq-0.1 q-10 Vl-(T*R)-2 Dl-(R*(T-1)*T*(T+1)/(12*sigmasq))*(log(1+(q/100)))^2 #Dl result is still similar power.1-1-pf(qf(.95,(T*R-2),1,ncp=0),(T*R-2),1,ncp=Dl) Thank you for any suggestions/help. I'm using R2.4.1, on windowsXP. Erik Meesters [[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] I need some help
Hi, I have a little problem with the installation of a new packages. The installation of R software is correct, but my server required authentication for use it, and for load a new package directly from R it is not possible. Is there a code or process for server authentication (put my login and password) in R for download directly the packages? The best regards, -- Luis Antonio Garavito Facultad de Ingeniería Universidad Nacional de Colombia Te. 3165000 Ext. 13525 [[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] Fwd: Package-RODBC-MSACCESS
I have used RODBC to get the database i can view the tables in RGUI-2.4.1 how can i query the records in R i tried with sqlQuery need some help JJ -- Lecturer J. Joshua Thomas KDU College Penang Campus Research Student, University Sains Malaysia -- Lecturer J. Joshua Thomas KDU College Penang Campus Research Student, University Sains Malaysia [[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] hopach
Dear R users, I thought this might be useful for users of the R package HOPACH (Windows version). Using R 2.4.1 in Windows XP, I found that the functions: makeoutput, boot2fuzzy and hopach2tree is not recognized by HOPACH versions 1.4.3 and 1.8.0. However, it works perfect with HOPACH version 1.6.0 downloaded from K.S. Pollard's site at UCDavis. Thanks. Roger Roger L. Vallejo, Ph.D. Computational Biologist Geneticist U.S. Department of Agriculture, ARS National Center for Cool Cold Water Aquaculture 11861 Leetown Road Kearneysville, WV 25430 Voice:(304) 724-8340 Ext. 2141 Email: [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.
[R] rattle- MSACCESS database problem
library(RGtk2) library(rattle) rattle() click the ODBC option it as the DSN i am a bit confused with this i already put my *.mdb file in C:drive i try put the DSN name as Microsoft Access driver, in the appropriate text box but i couldnt locate the table i tried the other way round open- locate the *.mdb in C:drive couldnt locate i tried RODBC aswell, but i want to use rattle to Data mine my database need someone's help -- Lecturer J. Joshua Thomas KDU College Penang Campus Research Student, University Sains Malaysia [[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] Calculating confidence limits on acf graphs
Hmm, this does not seem to be over-documented :-) But try ?plot.acf and getAnywhere(plot.acf) Then you can find in the code how the values are actually calculated. Petr Gladwin, Philip [CIB-FI] napsal(a): Hello, I was wondering if anybody could help me with this? I have plotted an acf function for a time series and am very happy with it. Now I am interested in calculating for myself the two values for the confidence intervals that are plotted on the graph of the acf. The confidence intervals do not appear to be returned from the acf function (is this true?). So far I haven't managed to calculate them myself. Can anybody help? Phil, __ 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 Klasterecky Dept. of Probability and Statistics Charles University in Prague Czech Republic __ 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 and SAS proc format
On 3/7/07, Peter Dalgaard [EMAIL PROTECTED] wrote: Jason Barnhart wrote: - Original Message - From: John Kane [EMAIL PROTECTED] To: lamack lamack [EMAIL PROTECTED]; R-help@stat.math.ethz.ch Sent: Tuesday, March 06, 2007 2:13 PM Subject: Re: [R] R and SAS proc format --- lamack lamack [EMAIL PROTECTED] wrote: Dear all, Is there an R equivalent to SAS's proc format? What does the SAS PROC FORMAT do? It formats or reformats data in the SAS system. Slightly more precisely: It creates user-defined formats, which are subsequently associated with variables and used for reading, printing, tabulating, and analyzing data. It is akin to R's factor() constructions, but not quite. For one thing, SAS's formats are separate entities - same format can be used for many variables, whereas R's factors have the formatting coded as a part of the object. For related reasons, a variable in SAS can have more distinct values than there are value labesl for, etc. It looks this: proc format; value kanefmt 1='A' 2='B' 3='C' 4='X' 5='Throw me out'; data temp; do i=1 to 10; kanevar=put(i,kanefmt.); output; end; proc print; run; And produces this: Obs i kanevar 1 1A 2 2B 3 3C 4 4X 5 5Throw me out 6 6 6 7 7 7 8 8 8 9 9 9 1010 10 But it is more robust than what is shown here. __ 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. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ 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. Also, SAS formats are used as a (somewhat cumbersome) replacement for dictionary data structures. Starting from SAS 9.1 (I believe), hash tables can be used within data steps for the same purpose (albeit still cumbersome). In this regard, not only formats but also lists could be a replacement for them. They can be used as a way to get key-value mappings. These key-value mappings (I mean, these kind of data structures) are very handy tools. I have used both factors and lists for some kind of ad hoc replacement for these data structures. Hasn't anybody considered the posibility of having these data structures implemented in R in a much python-like or java-like touch and feel? Regards, Carlos J. Gil Bellosta http://www.datanalytics.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] compiling latest version of R
Dear R-help community, I have had trouble in the past installing the latest version of R: we got the errors shown below (the computer specifications and version of R are below that). Does anybody have tips for compiling the latest version of R so that I can avoid these errors? configure make ... ... ... f90: CODE: 0 WORDS, DATA: 0 WORDS gcc -G -L/usr/local/lib -o stats.so init.o kmeans.o ansari.o bandwidths.o chisq sim.o d2x2xk.o fexact.o kendall.o ks.o line.o smooth.o prho.o swilk.o ksmooth .o loessc.o isoreg.o Srunmed.o Trunmed.o dblcen.o distance.o hclust-utils.o nl s.o HoltWinters.o PPsum.o arima.o burg.o filter.o mAR.o pacf.o starma.o port.o family.o sbart.o bsplvd.o bvalue.o bvalus.o loessf.o ppr.o qsbart.o sgram.o si nerp.o sslvrg.o stxwx.o hclust.o kmns.o eureka.o stl.o portsrc.o -L../../../.. /lib -lRblas -lg2c -lm -lgcc_s mkdir ../../../../library/stats/libs building package 'datasets' mkdir ../../../library/datasets mkdir ../../../library/datasets/R mkdir ../../../library/datasets/data Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to load shared library '/tmp/R-2.4.0/library/stats/libs/stats.so' : ld.so.1: R: fatal: relocation error: file /tmp/R-2.4.0/library/stats/libs/stat s.so: symbol __i_abs: referenced symbol not found Execution halted *** Error code 1 These are my specifications: platform sparc-sun-solaris2.10 arch sparc os solaris2.10 system sparc, solaris2.10 status major 2 minor 3.1 year 2006 month 06 day01 svn rev38247 language R version.string Version 2.3.1 (2006-06-01) Many thanks for your time in reading this problem, I look forward to hearing your suggestions and advice, Jenny ~~ Jennifer Barnes PhD student: long range drought prediction Climate Extremes Group Department of Space and Climate Physics University College London Holmbury St Mary Dorking, Surrey, RH5 6NT Tel: 01483 204149 Mob: 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] Fwd: Package-RODBC-MSACCESS
Hi, On 3/7/07, j.joshua thomas [EMAIL PROTECTED] wrote: I have used RODBC to get the database i can view the tables in RGUI-2.4.1 how can i query the records in R i tried with sqlQuery need some help A bit of code showing what you did would help others to track down what may have gone wrong. Nevertheless, this is code I used under R 2.3.1 on WinXP: library(RODBC) myaccessDB - c:/data/db1.mdb connectedMSAcc - odbcConnectAccess(myaccessDB) sqlTables(connectedMSAcc) # all the tables in the Access DB onetable - sqlFetch(connectedMSAcc, lexp) # fetching one table called 'lexp' myQuery - SELECT Country, y2001 FROM lexp WHERE y2001 82; myresults - sqlQuery(connectedMSAcc, myQuery) myresults I hope this helps? Best, Roland [[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] transform R function
Dear all, Why the transform function does not accept two statistics functions? a = data.frame(matrix(rnorm(20),ncol=2)) transform(a,M.1=mean(X1),M.2=mean(X2)) # does not works #while: transform(a,M.1=mean(X1),M2=log(abs(X2))) #works Best regards JL _ O Windows Live Spaces é seu espaço na internet com fotos (500 por mês), blog e agora com rede social http://spaces.live.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] No years() function?
Hi, I'm trying to aggregate date values using the aggregate function. For example: aggregate(data,by=list(weekdays(LM),months(LM)),FUN=length) I would also like to aggregate by year but there seems to be no years() function. Should there be one? Is there any alternative choice? Also, a hours() function would be great. Any tip on this? Thanks in advance! Sérgio Nunes __ 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] Multi-line plots with matrices in R
Gavin Simpson wrote: You want maplot here. See ?matplot but here is an example: Great! Thanks to you and Petr for pointing this out, it's exactly what I wanted. Petr's other suggestions look interesting and I'll explore them at length later. Note the changed axis range in the right-hand margin. The problem is that you can't use plot.window to achieve what you want, not that plot.window doesn't do anything. Ahhh, I see. So, it does not affect what has already been plotted, but affects how new material is inserted into the plot area. Entering plot.window(xlim=c(0,100),ylim=c(0,0.5)) axis(1) axis(2) plot.window(xlim=c(0,100),ylim=c(0,1)) axis(2) ... is instructive. :-) So, _is_ there a command which will rearrange the existing plotted items, including axes? Or does R require that I have a good idea of the space in which I want to plot from the start? Oh, and a quick cosmetic query---I notice that the axes when created are spaced apart somewhat so the axis lines do not meet at the plot origin. Is there a way to alter this so that the outline of the box, and the extreme values of the axis, match up? Thanks again, -- Joe __ 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] Power calculation for detecting linear trend
Meesters, Erik wrote: Dear people, I've a problem in doing a power calculation. In Fryer and Nicholson (1993), ICES J. mar. Sci. 50: 161-168 page 164 an example is given with the following characteristics T=5, points in time R=5, replicates Var.within=0.1 q=10, a 10% increase per year The degrees of freedom for the test are calculated as Vl=T*R-2=23 and the non-centrality parameter Dl=4.54. Using this they get a power of 0.53, but the result that I'm getting is 0.05472242. I've tried this several ways in R, but I'm not able to come up with the same number. Am I doing something wrong in the calculation of the power? Here's my code: T-5 R-5 sigmasq-0.1 q-10 Vl-(T*R)-2 Dl-(R*(T-1)*T*(T+1)/(12*sigmasq))*(log(1+(q/100)))^2 #Dl result is still similar power.1-1-pf(qf(.95,(T*R-2),1,ncp=0),(T*R-2),1,ncp=Dl) Thank you for any suggestions/help. I think your DF are upside-down: power.1-1-pf(qf(.95,1,(T*R-2),ncp=0),1,(T*R-2),ncp=Dl) power.1 [1] 0.532651 -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ 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] Plotting a broken line?
Hi, Is there a smart way in the R graphs to create a line that is broken in intervals based on the indicator given below. following is a small test graph Location,indicator,otherinfo 1.2,1,2.2 2.5,1,2.5 3.7,1,2.3 20.1,2,4.3 22.5,2,5.2 25.0,2,3.4 27.3,2,2.2 35.1,3,3.4 37.0,3,7.2 38.0,3,6.1 40.1,3,5.4 52.9,3,3.3 Right now in the plot the line is continuous, but I would like to have it broken based on the indicator. If the line of the plot reaches the last observation of indicator=1 then the line needs to stop; the next line will start at location 22.5 and continue up top 27.3; the next line goes from 35.1 up to 52.9. x-read.table(file='c:\\aldi\\testgraph.csv',sep=',',header=T) x Location indicator otherinfo 1 1.2 1 2.2 2 2.5 1 2.5 3 3.7 1 2.3 4 20.1 2 4.3 5 22.5 2 5.2 6 25.0 2 3.4 7 27.3 2 2.2 8 35.1 3 3.4 9 37.0 3 7.2 10 38.0 3 6.1 11 40.1 3 5.4 12 52.9 3 3.3 plot(x$Location,x$indicator,type='l',xlim=c(0,max(x$Location)),ylim=c(0,max(x$indicator,x$otherinfo))) points(x$Location,x$otherinfo) TIA, Aldi -- __ 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] Multi-line plots with matrices in R
On Wed, 2007-03-07 at 15:11 +, Joseph Wakeling wrote: Gavin Simpson wrote: You want maplot here. See ?matplot but here is an example: Great! Thanks to you and Petr for pointing this out, it's exactly what I wanted. Petr's other suggestions look interesting and I'll explore them at length later. Note the changed axis range in the right-hand margin. The problem is that you can't use plot.window to achieve what you want, not that plot.window doesn't do anything. Ahhh, I see. So, it does not affect what has already been plotted, but affects how new material is inserted into the plot area. Entering plot.window(xlim=c(0,100),ylim=c(0,0.5)) axis(1) axis(2) plot.window(xlim=c(0,100),ylim=c(0,1)) axis(2) ... is instructive. :-) So, _is_ there a command which will rearrange the existing plotted items, including axes? Or does R require that I have a good idea of the space in which I want to plot from the start? Not with the standard R graphics - think of the graphics window as a piece of paper and if you draw anything on it you have done so in permanent ink. If something needs changing you need a new sheet of paper and have to redraw the lot. Most people I know write their code in some text editor and send (or copy paste) it into R. It is an easy matter to edit one or two bits of your code to tweak the display and re-plot... I think you can modify lattice graphics objects and just plot (print really) them again - but again you are really redrawing the whole plot from scratch. IIRC grid might be able to do some of what you are looking for. Oh, and a quick cosmetic query---I notice that the axes when created are spaced apart somewhat so the axis lines do not meet at the plot origin. Is there a way to alter this so that the outline of the box, and the extreme values of the axis, match up? Look at ?par and xaxs and yaxs. E.g. plot(1:10, xaxs = i, yaxs = i) G Thanks again, -- Joe -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.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] How to open more windows to make more graphs at once!
Dear Monireh, try using lattice: library(lattice) set.seed(1234) dat - data.frame(months=rep(1:10,80),upper = rnorm(800)+1, lower = rnorm(800)-1, observed = rnorm(800), best.sim = rnorm(800), stname = factor(gl(80, 10))) jpeg(filename = Rplot%03d.jpeg) xyplot(best.sim+observed+lower+upper~months|stname,dat, layout=c(3,4),type=b,auto.key=T) dev.off() It should produce almost exactly what you want. Lattice is a very powerful tool for creating multiple graphics. You can customize the individual plots within the lattice using panel and prepanel functions, take a look at the documentation of the library and the documentation of xyplot and panel.xyplot. Lattice is a little bit more complex than normal plots in R, so you would have to spend more time in learning how to use its functionality, but it is worth trying. have a lot of fun JR El mié, 07-03-2007 a las 09:39 +0100, Faramarzi Monireh escribió: Dear R users, I have a data frame (test) including five columns of upper (numeric), lower (numeric), observed (numeric), best_sim (numeric) and stname (factor with 80 levels, each level with different length). Now I would like to write a short program to draw one graph as follow for each level of stname but I would like also to draw each time 12 graphs for the 12 levels of stname in the same graphic windows and save it as jpeg' file . This means at the end I will have 7 (80 levels/12=7) graphic windows and 7 jpeg files each one with 12 graphs (the last one with 8 graphs) for the 12 levels of stname. I already wrote the following script to do it each time for 12 levels of stname but I have to change script each time for the another 12 levels [line 3 in the script for example: for( i in levels(test$stname)[12:24))] and I do not know how can I save the obtained graphs (seven graphic windows) as jpeg files (e.g. plot1.jpeg, plot2.jpeg and so on). As I have 45 dataset like this it would be gr! eat if somebody can help me to complete this script to do all together for a dataset using a script. Thank you very much in advance for your cooperation, Monireh windows(9,9) par(mfrow = c(3,4)) for( i in levels(test$stname)[1:12]) { data- test[test$stname==i,] xx - c(1:length(data$upper), length(data$upper):1) yy - c(data$upper, rev(data$lower)) zz- data$observed tt- data$Best_Sim par(lab =c(10,15,2)) plot.jpeg- plot(xx,yy, type=n, xlim=c(min(xx), max(xx)), ylim=c(min(zz,yy,tt), max(yy,zz,tt)*1.4), main= i, xlab=Month (1990-2002), ylab=Discharge(m3/s), font.axis=6) polygon(xx, yy, col=green, border = NA) lines(zz, col=blue, lwd=1.5) lines(tt,col=red, lwd=1.5) legend(length(zz)-60, max(yy,zz,tt)*1.45, c(Upper Limit, Lower Limit, Observed,Best etimation) , lwd=c(10, 1,1.7,1.7), bty=n, col= c(green, white, blue,red)) } __ 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] Two-way Unbalanced multiple sample ANOVA
Hello all, I was wondering if anyone could help me formulate a Two-way ANOVA for unbalanced multiple sample data? We have a new study method aimed to help students to study for tests using computers. (I am a computer scientists, hence my soon-to-be-apparent lack of statistical knowledge). To test this study method we devised a user study where 30 participant attended 2 lectures, lecture1 and lecture2. Two test were created, test1 and test2. test1 corresponds to the material in lecture1 and test2 corresponds to the material in lecture2. The 30 participants were split into two groups, group1 and group2. group1 used our new study method to review for lecture1 and their existing study method to review the material from lecture2 group2 used our new study method to review for lecture2 and their existing study method to review the material from lecture1 Each group then took the two test. This is a repeated measure experiment because we have 2 exam scores for each participant, one using our new method to study and one not using our new method to study. The data is unbalanced because participants did not take the same test twice. From what I understand balanced data would look like IDTEST SYSTEM SCORE 1 11 80 1 10 70 1 21 90 1 20 95 2 11 70 2 10 75 2 21 80 2 20 75 But instead our data look like this: IDTEST SYSTEM SCORE 1 11 80 1 20 95 2 10 75 2 21 80 So participant 2 never took test1 using our system. Anyway, I want to look to see if our new study method had an impact one test results. Also, I want to see if the test number had an impact on the exam results. Here is some sample data: dataSet - data.frame( particID=factor(c(1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8)), whichExam=factor(c(1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2)), studyMethod=factor(c(1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1)), score=c(90,80,75,70,70,58,73,68,69,87,68,79,80,80,99,95)) From what I have read this should be how to compute and ANOVA on this data: summary(aov(score~whichExam*studyMethod+Error(particID),data=dataSet)) Error: particID Df Sum Sq Mean Sq F value Pr(F) whichExam:studyMethod 1 333.06 333.06 1.8211 0.2259 Residuals 6 1097.38 182.90 Error: Within Df Sum Sq Mean Sq F value Pr(F) whichExam1 3.062 3.062 0.1072 0.75445 studyMethod 1 203.062 203.062 7.1094 0.03721 * Residuals6 171.375 28.562 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Is this correct way do do an ANOVA test for this data? From what I can tell this means that the study method did have a statistically significant impact on the scores, is that correct? This also shows that it did not matter which test the subject took, meaning that the two test were equally difficult. What exactly do the titles Error ... mean? What are Residuals? Can anyone recommend a good book on R which covers this information, all I can find are books on SPSS? __ 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] anova applied to a lme object
The variances of the random effects and the residual variances are given by the summary function. Maybe VarCorr or varcomp gives you the answer you are looking for: library(nlme) library(ape) ?VarCorr ?ape JR El mié, 07-03-2007 a las 13:09 +0100, Berta escribió: Hi R-users, when carrying out a multiple regression, say lm(y~x1+x2), we can use an anova of the regression with summary.aov(lm(y~x1+x2)), and afterwards evaluate the relative contribution of each variable using the global Sum of Sq of the regression and the Sum of Sq of the simple regression y~x1. Now I would like to incorporate a random effect in the model, as some data correspond to the same region and others not: mylme- lme(y~x1+x2, random= ~1|as.factor(region)). I would like to know, if possible, which is the contribution of each variable to the global variability. Using anova(mylme) produce an anova table (without the Sum of Sq column), but I am not sure how can I derive the contribution of each variable from it, or even whether it is nonsense to try, nor can I derive a measure of how much variability is left unexplained. Sorry for the type of question, but I did not find a simple solution and some researchers I work with love to have relative contributions to global variability. Thanks a lot in advance, Berta __ 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. -- Dipl.-Biol. JR Ferrer Paris ~~~ Laboratorio de Biología de Organismos --- Centro de Ecología Instituto Venezolano de Investigaciones Científicas (IVIC) Apdo. 21827, Caracas 1020-A República Bolivariana de Venezuela Tel: (+58-212) 504-1452 Fax: (+58-212) 504-1088 email: [EMAIL PROTECTED] clave-gpg: 2C260A95 __ 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] compiling latest version of R
Jenny Barnes wrote: Dear R-help community, I have had trouble in the past installing the latest version of R: we got the errors shown below (the computer specifications and version of R are below that). Does anybody have tips for compiling the latest version of R so that I can avoid these errors? 1. 2.4.1 is recent, not 2.3.1 as shown at the bottom. 2. You have some R-2.4.0 in your path or set in your R_LIBS, remove that one first. Uwe Ligges configure make ... ... ... f90: CODE: 0 WORDS, DATA: 0 WORDS gcc -G -L/usr/local/lib -o stats.so init.o kmeans.o ansari.o bandwidths.o chisq sim.o d2x2xk.o fexact.o kendall.o ks.o line.o smooth.o prho.o swilk.o ksmooth .o loessc.o isoreg.o Srunmed.o Trunmed.o dblcen.o distance.o hclust-utils.o nl s.o HoltWinters.o PPsum.o arima.o burg.o filter.o mAR.o pacf.o starma.o port.o family.o sbart.o bsplvd.o bvalue.o bvalus.o loessf.o ppr.o qsbart.o sgram.o si nerp.o sslvrg.o stxwx.o hclust.o kmns.o eureka.o stl.o portsrc.o -L../../../.. /lib -lRblas -lg2c -lm -lgcc_s mkdir ../../../../library/stats/libs building package 'datasets' mkdir ../../../library/datasets mkdir ../../../library/datasets/R mkdir ../../../library/datasets/data Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to load shared library '/tmp/R-2.4.0/library/stats/libs/stats.so' : ld.so.1: R: fatal: relocation error: file /tmp/R-2.4.0/library/stats/libs/stat s.so: symbol __i_abs: referenced symbol not found Execution halted *** Error code 1 These are my specifications: platform sparc-sun-solaris2.10 arch sparc os solaris2.10 system sparc, solaris2.10 status major 2 minor 3.1 year 2006 month 06 day01 svn rev38247 language R version.string Version 2.3.1 (2006-06-01) Many thanks for your time in reading this problem, I look forward to hearing your suggestions and advice, Jenny ~~ Jennifer Barnes PhD student: long range drought prediction Climate Extremes Group Department of Space and Climate Physics University College London Holmbury St Mary Dorking, Surrey, RH5 6NT Tel: 01483 204149 Mob: 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-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] anova applied to a lme object
Thanks José Rafael, I will try with library(ape) (at the moment I cannot load it). VarCorr gives the variance estimates for the random effect and the error terms. However, what I am looking for is a measure of the explained proportion of variance, such as it is R2 in regression models, and more precisely, I am looking for a measure of the explained proprotion of variance of each of the variables considered (continuous variables and other with random slope). For example, Snijders and Bosker (2003) pg 102 dedicate a chapter in their book to how much does the multilevel model explain (chapter 7) and derive formulaes for R_1 and R_2 (variance in the first and second level respectively). Things seem to get complicated when a slope random effect is included in the model, as in my case. It seems that package HLM provides the necessary estimates. I will have a look at library(ape), thanks for the suggestion. The book I mention is: Snijders, TAB and Bosker RJ (2003). Multilevel Analysis. An introduction to basic and advanced multilevel modeling. SAGE, London. Berta - Original Message - From: José Rafael Ferrer Paris [EMAIL PROTECTED] To: Berta [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Sent: Wednesday, March 07, 2007 5:16 PM Subject: Re: [R] anova applied to a lme object The variances of the random effects and the residual variances are given by the summary function. Maybe VarCorr or varcomp gives you the answer you are looking for: library(nlme) library(ape) ?VarCorr ?ape JR El mié, 07-03-2007 a las 13:09 +0100, Berta escribió: Hi R-users, when carrying out a multiple regression, say lm(y~x1+x2), we can use an anova of the regression with summary.aov(lm(y~x1+x2)), and afterwards evaluate the relative contribution of each variable using the global Sum of Sq of the regression and the Sum of Sq of the simple regression y~x1. Now I would like to incorporate a random effect in the model, as some data correspond to the same region and others not: mylme- lme(y~x1+x2, random= ~1|as.factor(region)). I would like to know, if possible, which is the contribution of each variable to the global variability. Using anova(mylme) produce an anova table (without the Sum of Sq column), but I am not sure how can I derive the contribution of each variable from it, or even whether it is nonsense to try, nor can I derive a measure of how much variability is left unexplained. Sorry for the type of question, but I did not find a simple solution and some researchers I work with love to have relative contributions to global variability. Thanks a lot in advance, Berta __ 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. -- Dipl.-Biol. JR Ferrer Paris ~~~ Laboratorio de Biología de Organismos --- Centro de Ecología Instituto Venezolano de Investigaciones Científicas (IVIC) Apdo. 21827, Caracas 1020-A República Bolivariana de Venezuela Tel: (+58-212) 504-1452 Fax: (+58-212) 504-1088 email: [EMAIL PROTECTED] clave-gpg: 2C260A95 ___ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de __ 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] Memory Limits in Ubuntu Linux
Thanks for the tips, Roger. fyi: When I added /3GB to the boot.ini, the resulting desktop was incomplete and locked - no chance to try starting R. Searching the web lead me to believe that this was possibly a dead-end, so I abandoned this effort. Any hints on getting this to work, anyone? On 7 Mar 2007 at 8:26, Bos, Roger wrote: David, I wouldn't give up on windows so fast. Many people have gotten the 3Gb switch to work. One used to have to modify the header of the Rgui.exe program to use the switch, but now the binary comes ready for that, so its really quite easy. I would like to hear more about why its not working for you. As for Linux, I use FC5 for which there is a 64-bit binary. But there are also 64-bit binaries for other distros. The 32-bit and 64-bit binaries are in different directories, so you should have no trouble telling them apart. I have heard good things about Ubuntu--mainly that its very easy to use--but FC5 has been pretty easy to learn too and I use the KDE desktop which gives me Kate as a text editor. You can open a terminal window in Kate to run R and set up a key like F10 to send the code from the editor to R. Its not quite as good as my Windows setup with Tinn-R, but almost as good. Thanks, Roger -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 06, 2007 5:37 PM To: Bos, Roger Subject: RE: [R] Memory Limits in Ubuntu Linux Thanks for your prompt reply! The windows 3GB switch is quite problematic - it was not useable on my machine, and there are comments about these problems around the net. Thus, on to Linux. My machine has 4Gig, and some megabytes are grabbed by my Asus motherboard, leaving some 3.56 Gig. So if I understand your suggestion, try the 64-bit version of Ubuntu (based on Debian but I had better luck with the video part of the install) and then use the corresponding image from CRAN. My fear is that the CRAN Ubuntu version might be 32-bit - any idea how to find out before I embark on another install? Which Linux do you have - you described some significant success with getting large jobs to run. And yes, I've worked hard to save memory by tweaking the code. Thanks again. On 6 Mar 2007 at 16:51, Bos, Roger wrote: David, First of all, under Windows you can get about 3GB available to R by using the /3Gb switch in your boot.ini file, assuming you have 4Gb of memory installed on your windows machine. Using that method, I have seen the memory using of my R process get as big as 2.7Gb in task manager. What's important, of course, is contiguous space, as you mentioned. There, you may want to check your code closely and make sure that its memory usage is as efficient as possible and you are storing the minimal amount you need for each run. If you don't need an object for a while consider writing it to disk and reading it back in later. Second, AFAIK to get any benefit from more memory is Linux you have to go to the 64bit version. I am a Linux newbie too, so I choose to use one of the pre-compiled binaries available on CRAN. In other words, you shouldn't have to compile anything yourself. How much memory do you have on your Linux box? I have 16Gb and I know I have ran stuff that wouldn't run on my 4Gb windows box. HTH, Roger -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Tuesday, March 06, 2007 3:44 PM To: r-help@stat.math.ethz.ch Subject: [R] Memory Limits in Ubuntu Linux I am an R user trying to get around the 2Gig memory limit in Windows, so here I am days later with a working Ubuntu, and R under Ubuntu. But - the memory problems seem worse than ever. R code that worked under windows fails, unable to allocate memory. Searching around the web, it appears that the problem may be the ability to find contguous memory for my big vectors, but a fresh boot of Ubuntu does not help either. Which way to go? 1) Try to install 64-bit version for bigger address space. Would this help? Is this workable for my Athlon 64 Dual-core? (the live cd seems to work but I never got it to boot after a disk install, but then the 386 version was no better until I learned more about Grub...I could try again if this might solve the problem) 2) Recompile R to get bigger memory capability? (I'll have to cross-post to some R forums too) This will be a challenge for a Linux newbie...like me. 3) Any other suggestions? My goal is to create a bigger neural network than fits in my Windows R version. -- David Katz www.davidkatzconsulting.com 541 482-1137 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list
Re: [R] Plotting a broken line?
If you insert an NA (or row of NA's) into the data at each place you want a break (after indicator increases), then the regular plot with type='l' will break the line for you. Is this what you want? -- 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 Aldi Kraja Sent: Wednesday, March 07, 2007 9:21 AM To: r-help@stat.math.ethz.ch Subject: [R] Plotting a broken line? Hi, Is there a smart way in the R graphs to create a line that is broken in intervals based on the indicator given below. following is a small test graph Location,indicator,otherinfo 1.2,1,2.2 2.5,1,2.5 3.7,1,2.3 20.1,2,4.3 22.5,2,5.2 25.0,2,3.4 27.3,2,2.2 35.1,3,3.4 37.0,3,7.2 38.0,3,6.1 40.1,3,5.4 52.9,3,3.3 Right now in the plot the line is continuous, but I would like to have it broken based on the indicator. If the line of the plot reaches the last observation of indicator=1 then the line needs to stop; the next line will start at location 22.5 and continue up top 27.3; the next line goes from 35.1 up to 52.9. x-read.table(file='c:\\aldi\\testgraph.csv',sep=',',header=T) x Location indicator otherinfo 1 1.2 1 2.2 2 2.5 1 2.5 3 3.7 1 2.3 4 20.1 2 4.3 5 22.5 2 5.2 6 25.0 2 3.4 7 27.3 2 2.2 8 35.1 3 3.4 9 37.0 3 7.2 10 38.0 3 6.1 11 40.1 3 5.4 12 52.9 3 3.3 plot(x$Location,x$indicator,type='l',xlim=c(0,max(x$Location)) ,ylim=c(0,max(x$indicator,x$otherinfo))) points(x$Location,x$otherinfo) TIA, Aldi -- __ 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] Plotting a broken line?
Hi you shall probably cooperate with segments, so you need to extract start and end points for your lines e.g. x-c(1:6, 10:15,20:25) y-rep(c(1,2,3), each=6) plot(x,y, type=l) plot(x,y) segments(sapply(split(x,y), min),1:3, sapply(split(x,y),max),1:3) Regards Petr On 7 Mar 2007 at 10:21, Aldi Kraja wrote: Date sent: Wed, 07 Mar 2007 10:21:06 -0600 From: Aldi Kraja [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] Plotting a broken line? Send reply to: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Hi, Is there a smart way in the R graphs to create a line that is broken in intervals based on the indicator given below. following is a small test graph Location,indicator,otherinfo 1.2,1,2.2 2.5,1,2.5 3.7,1,2.3 20.1,2,4.3 22.5,2,5.2 25.0,2,3.4 27.3,2,2.2 35.1,3,3.4 37.0,3,7.2 38.0,3,6.1 40.1,3,5.4 52.9,3,3.3 Right now in the plot the line is continuous, but I would like to have it broken based on the indicator. If the line of the plot reaches the last observation of indicator=1 then the line needs to stop; the next line will start at location 22.5 and continue up top 27.3; the next line goes from 35.1 up to 52.9. x-read.table(file='c:\\aldi\\testgraph.csv',sep=',',header=T) x Location indicator otherinfo 1 1.2 1 2.2 2 2.5 1 2.5 3 3.7 1 2.3 4 20.1 2 4.3 5 22.5 2 5.2 6 25.0 2 3.4 7 27.3 2 2.2 8 35.1 3 3.4 9 37.0 3 7.2 10 38.0 3 6.1 11 40.1 3 5.4 12 52.9 3 3.3 plot(x$Location,x$indicator,type='l',xlim=c(0,max(x$Location)),ylim=c( 0,max(x$indicator,x$otherinfo))) points(x$Location,x$otherinfo) TIA, Aldi -- __ 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] error installing packages
I was finally able to get R to 'configure', 'make', and 'install' on Mandriva 2007. Itried to install gnomeGUI and I received an error. See below. At what step do I make R a shared library? Where did I go wrong? Ross == downloaded 74Kb * Installing *Frontend* package 'gnomeGUI' ... Using R Installation in R_HOME=/usr/local/lib64/R R was not built as a shared library Need a shared R library ERROR: configuration failed for package 'gnomeGUI' * Removing '/usr/local/lib64/R/library/gnomeGUI' The downloaded packages are in /root/tmp/RtmpkHUeyA/downloaded_packages Warning message: installation of package 'gnomeGUI' had non-zero exit status in: install.packages(c(gnomeGUI)) = [[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] No fit statistics for some models using sem
Hi, New to both R and SEM, so this may be a very simple question. I am trying to run a very simple path analysis using the sem package. There are 2 exogenous (FARSCH, LOCUS10) and 2 endogenous (T_ATTENT, RMTEST) observed variables in the model. The idea is that T_ATTENT mediates the effect of FARSCH and LOCUS10 on RMTEST. The RAM specification I used is FARSCH - T_ATTENT, y1x1, NA LOCUS10 - T_ATTENT, y1x2, NA FARSCH - RMTEST10, y2x1, NA LOCUS10 - RMTEST10, y2x2, NA T_ATTENT - RMTEST10, y2y1, NA FARSCH - FARSCH, x1x1, NA LOCUS10 - LOCUS10, x2x2, NA T_ATTENT - T_ATTENT, y1y1, NA RMTEST10 - RMTEST10, y2y2, NA LOCUS10 - FARSCH, x2x1, NA This model runs, but using the summary function does not return the usual model fit statistics, only the following: Model Chisquare = 0 Df = 0 Pr(Chisq) = NA Chisquare (null model) = 8526.8 Df = 6 Goodness-of-fit index = 1 BIC = 0 If I omit the last line from the RAM specification(i.e., delete LOCUS10 - FARSCH, x2x1, NA), I DO get all the usual statistics: Model Chisquare = 1303.7 Df = 1 Pr(Chisq) = 0 Chisquare (null model) = 8526.8 Df = 6 Goodness-of-fit index = 0.95864 Adjusted goodness-of-fit index = 0.58639 RMSEA index = 0.30029 90% CI: (NA, NA) Bentler-Bonnett NFI = 0.84711 Tucker-Lewis NNFI = 0.082726 Bentler CFI = 0.84712 BIC = 1294.1 My understanding is the you should always put in the correlation between exogenous predictors, but when I do this I don't get fit statistics. Can anyone help me understand what is happening here? Thank you, Ista __ 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] Fitting Data to tCopula
Hello, Has anyone successfully fit empirical data to a tCopula using the fitCopula function? If so, are there ways to pick intelligent starting values to avoid the errors such as a minor matrix not being positive definite and the initial value of 'vmmin' not being finite? I've been able to fit a normal Copula to my data, but am having diffuculty with the tCopula. Any suggestions are greatly appreciated. Thank you. Adam -- View this message in context: http://www.nabble.com/Fitting-Data-to-tCopula-tf3363801.html#a9358456 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] Failure to run mcsamp() in package arm
Dear r-helpers, I can run the examples on the mcsamp help page. For example: M1 - lmer (y1 ~ x + (1|group)) (M1.sim - mcsamp (M1)) fit using lmer, 3 chains, each with 1000 iterations (first 500 discarded) n.sims = 1500 iterations saved mean sd 2.5% 25% 50% 75% 97.5% Rhat n.eff beta.(Intercept) 0.1 0.7 -1.2 -0.3 0.1 0.5 1.4 1.0 1500 beta.x 2.5 0.4 1.7 2.2 2.5 2.7 3.2 1.0 1500 sigma.y3.8 0.3 3.3 3.6 3.7 3.9 4.3 1.061 sigma.grop.(In)1.5 0.8 0.0 1.0 1.4 1.9 3.3 1.412 eta.group.(Intercept)[1] 0.0 1.0 -2.1 -0.5 0.0 0.6 2.0 1.0 1500 eta.group.(Intercept)[2] 1.0 1.1 -0.9 0.2 0.9 1.7 3.4 1.059 eta.group.(Intercept)[3] -1.3 1.2 -4.0 -2.0 -1.3 -0.4 0.5 1.066 eta.group.(Intercept)[4] 1.3 1.1 -0.6 0.4 1.1 2.0 3.7 1.143 eta.group.(Intercept)[5] -0.7 1.0 -3.0 -1.4 -0.6 0.0 1.2 1.0 120 eta.group.(Intercept)[6] 1.5 1.2 -0.3 0.6 1.4 2.2 4.0 1.049 eta.group.(Intercept)[7] 0.3 1.0 -1.7 -0.3 0.1 0.8 2.5 1.0 440 eta.group.(Intercept)[8] -1.6 1.2 -4.0 -2.4 -1.5 -0.6 0.3 1.141 eta.group.(Intercept)[9] 0.4 1.0 -1.6 -0.2 0.2 0.9 2.7 1.0 180 eta.group.(Intercept)[10] -1.0 1.1 -3.3 -1.6 -0.9 -0.2 0.8 1.086 For each parameter, n.eff is a crude measure of effective sample size, and Rhat is the potential scale reduction factor (at convergence, Rhat=1). But when I try to do this with my own data I get an error: display(e7.lmer2) lmer(formula = baLO ~ I(baRatio - 0.985) + delta + (1 + I(baRatio - 0.985) + delta | subject), data = e7) coef.est coef.se (Intercept)-0.19 0.06 I(baRatio - 0.985) -4.95 0.74 delta 0.41 0.06 Error terms: Groups Name Std.Dev. Corr subject (Intercept)0.13 I(baRatio - 0.985) 2.57 0.45 delta 0.22 -0.12 -0.94 Residual0.39 number of obs: 494, groups: subject, 13 deviance = 551.4 e7.sim - mcsamp(e7.lmer2) Error in as.bugs.array(sims, program = lmer, n.iter = n.iter, n.burnin = n.burnin, : error in parameter sigma. in parameters.to.save I would appreciate a pointer to what the problem might be. _ 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] transform R function
lamack lamack wrote: Dear all, Why the transform function does not accept two statistics functions? a = data.frame(matrix(rnorm(20),ncol=2)) transform(a,M.1=mean(X1),M.2=mean(X2)) # does not works #while: transform(a,M.1=mean(X1),M2=log(abs(X2))) #works It's a variation of this effect: data.frame(airquality, list(x=1))#works data.frame(airquality, list(x=1, y=2)) #works not Not quite sure what the logic of that is Of course transform() isn't really intended to handle anything but transformed vectors of the same length as the original. __ 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] No fit statistics for some models using sem
It's not the correlation as such that is the problem; it's because you only have 10 degrees of freedom available with four observed variables, and you are estimating 10 parameters, which is why you get a chi square of zero. When you remove any one free parameter (such as the correlation), the model becomes identified. On 07/03/07, Ista Zahn [EMAIL PROTECTED] wrote: Hi, New to both R and SEM, so this may be a very simple question. I am trying to run a very simple path analysis using the sem package. There are 2 exogenous (FARSCH, LOCUS10) and 2 endogenous (T_ATTENT, RMTEST) observed variables in the model. The idea is that T_ATTENT mediates the effect of FARSCH and LOCUS10 on RMTEST. The RAM specification I used is FARSCH - T_ATTENT, y1x1, NA LOCUS10 - T_ATTENT, y1x2, NA FARSCH - RMTEST10, y2x1, NA LOCUS10 - RMTEST10, y2x2, NA T_ATTENT - RMTEST10, y2y1, NA FARSCH - FARSCH, x1x1, NA LOCUS10 - LOCUS10, x2x2, NA T_ATTENT - T_ATTENT, y1y1, NA RMTEST10 - RMTEST10, y2y2, NA LOCUS10 - FARSCH, x2x1, NA This model runs, but using the summary function does not return the usual model fit statistics, only the following: Model Chisquare = 0 Df = 0 Pr(Chisq) = NA Chisquare (null model) = 8526.8 Df = 6 Goodness-of-fit index = 1 BIC = 0 If I omit the last line from the RAM specification(i.e., delete LOCUS10 - FARSCH, x2x1, NA), I DO get all the usual statistics: Model Chisquare = 1303.7 Df = 1 Pr(Chisq) = 0 Chisquare (null model) = 8526.8 Df = 6 Goodness-of-fit index = 0.95864 Adjusted goodness-of-fit index = 0.58639 RMSEA index = 0.30029 90% CI: (NA, NA) Bentler-Bonnett NFI = 0.84711 Tucker-Lewis NNFI = 0.082726 Bentler CFI = 0.84712 BIC = 1294.1 My understanding is the you should always put in the correlation between exogenous predictors, but when I do this I don't get fit statistics. Can anyone help me understand what is happening here? Thank you, Ista __ 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] Plotting a broken line?
Hi Greg, Thank you for your response and a previous posting about Macros in R. Thank you also to Ken Knoblouch (Ken had the same idea as Greg's and Peter Pikal (who proposed the use of segments function). There is only a technical specific that when applying max function to find the limit of y one has to use it with max(x$indicator, na.rm =TRUE)) It worked!!! x Location indicator otherinfo 1 1.2 1 2.2 2 2.5 1 2.5 3 3.7 1 2.3 4 3.7NANA 5 20.1 2 4.3 6 22.5 2 5.2 7 25.0 2 3.4 8 27.3 2 2.2 9 27.3NANA 10 35.1 3 3.4 11 37.0 3 7.2 12 38.0 3 6.1 13 40.1 3 5.4 14 52.9 3 3.3 Aldi Greg Snow wrote: If you insert an NA (or row of NA's) into the data at each place you want a break (after indicator increases), then the regular plot with type='l' will break the line for you. Is this what you want? -- __ 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] No fit statistics for some models using sem
Dear David and Ista, I haven't looked at this model carefully, but the fact that the df are 0 suggests that the model is just-identified and therefore necessarily perfectly reproduces the covariances among the observed variables. Removing a parameter would over-identify the model, making possible the computation of the missing fit statistics. Regards, John On Wed, 7 Mar 2007 18:31:09 + David Barron [EMAIL PROTECTED] wrote: It's not the correlation as such that is the problem; it's because you only have 10 degrees of freedom available with four observed variables, and you are estimating 10 parameters, which is why you get a chi square of zero. When you remove any one free parameter (such as the correlation), the model becomes identified. On 07/03/07, Ista Zahn [EMAIL PROTECTED] wrote: Hi, New to both R and SEM, so this may be a very simple question. I am trying to run a very simple path analysis using the sem package. There are 2 exogenous (FARSCH, LOCUS10) and 2 endogenous (T_ATTENT, RMTEST) observed variables in the model. The idea is that T_ATTENT mediates the effect of FARSCH and LOCUS10 on RMTEST. The RAM specification I used is FARSCH - T_ATTENT, y1x1, NA LOCUS10 - T_ATTENT, y1x2, NA FARSCH - RMTEST10, y2x1, NA LOCUS10 - RMTEST10, y2x2, NA T_ATTENT - RMTEST10, y2y1, NA FARSCH - FARSCH, x1x1, NA LOCUS10 - LOCUS10, x2x2, NA T_ATTENT - T_ATTENT, y1y1, NA RMTEST10 - RMTEST10, y2y2, NA LOCUS10 - FARSCH, x2x1, NA This model runs, but using the summary function does not return the usual model fit statistics, only the following: Model Chisquare = 0 Df = 0 Pr(Chisq) = NA Chisquare (null model) = 8526.8 Df = 6 Goodness-of-fit index = 1 BIC = 0 If I omit the last line from the RAM specification(i.e., delete LOCUS10 - FARSCH, x2x1, NA), I DO get all the usual statistics: Model Chisquare = 1303.7 Df = 1 Pr(Chisq) = 0 Chisquare (null model) = 8526.8 Df = 6 Goodness-of-fit index = 0.95864 Adjusted goodness-of-fit index = 0.58639 RMSEA index = 0.30029 90% CI: (NA, NA) Bentler-Bonnett NFI = 0.84711 Tucker-Lewis NNFI = 0.082726 Bentler CFI = 0.84712 BIC = 1294.1 My understanding is the you should always put in the correlation between exogenous predictors, but when I do this I don't get fit statistics. Can anyone help me understand what is happening here? Thank you, Ista __ 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. John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ __ 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] sqlSave help!
Hi Everyone, I'm so confused. I've been trying to save data to a table but I keep getting an error that says the table does not exist and at other times saying that it does. So here are some statements: sqlQuery(channel, select top 1 * from TestDB.[SILICON\\holouis1].clep_tier_shift) State NB Change_Number 1IL 2005-02-08 7 It exists and I can get data from it, but if I try to use fetch or columns: sqlFetch(channel, TestDB.[SILICON\\holouis1].clep_tier_shift) Error in odbcTableExists(channel, sqtable) : 'TestDB.[SILICON\holouis1].clep_tier_shift': table not found on channel sqlColumns(channel, TestDB.[SILICON\\holouis1].clep_tier_shift) Error in sqlColumns(channel, TestDB.[SILICON\\holouis1].clep_tier_shift) : 'TestDB.[SILICON\holouis1].clep_tier_shift': table not found on channel Now if I try to save, it says error: table exists already even though I set append = T... sqlQuery(channel, select top 1 * from TestDB.[SILICON\\holouis1].clep_tier_shift) - nuts sqlSave(channel, dat= nuts, tablename=TestDB.[SILICON\\holouis1].clep_tier_shift,safer= T) Error in sqlSave(channel, dat = nuts, tablename = TestDB.[SILICON\\holouis1].clep_tier_shift, : [RODBC] ERROR: Could not SQLExecDirect S0001 2714 [Microsoft][ODBC SQL Server Driver][SQL Server]There is already an object named 'clep_tier_shift' in the database. any help would be much appreciated, thanks! -- View this message in context: http://www.nabble.com/sqlSave-help%21-tf3364399.html#a9360420 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] Query about using setdiff
Hi I have two dataframes names(DF1) = c(id, val1, val2); names(DF2) = c(id2); Ids in DF2 are a complete subset of those in DF1 How can I extract entries from DF1 where id NOT IN DF2. I tried setdiff(DF1, DF2); setdiff(DF1$id, DF2$id), etc. Although the latter eliminates the ids as required, I dont know how to extract val1 and val2 for the resultant set. Thanks Lalitha 8:00? 8:25? 8:40? Find a flick in no time __ 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] Download packages problem.
Hi, I have a little problem with the installation of a new packages. The installation of R software is correct, but my server required authentication for use it, and for load a new package directly from R it is not possible. Is there a code or process for server authentication (put my login and password) in R for download directly the packages? The best regards, -- Luis Antonio Garavito [[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] Memory Limits in Ubuntu Linux
David, Here is what my boot.ini file looks like: [boot loader] timeout=5 default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS [operating systems] multi(0)disk(0)rdisk(0)partition(1)\WINDOWS=Microsoft Windows XP Professional /noexecute=optin /fastdetect /3gb The easiest way to edit the boot.ini file is My Computer/Properties/Advanced/Startup Recovery/Edit; add the /3gb and reboot. I know that a messed up boot.ini file can be a real pain. I posted what mine looks like so you can compare yours, but I wouldn't suggest making any changes to your boot.ini except at the very end of the last line. HTH, Roger -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 07, 2007 12:27 PM To: Bos, Roger Cc: r-help@stat.math.ethz.ch Subject: RE: [R] Memory Limits in Ubuntu Linux Thanks for the tips, Roger. fyi: When I added /3GB to the boot.ini, the resulting desktop was incomplete and locked - no chance to try starting R. Searching the web lead me to believe that this was possibly a dead-end, so I abandoned this effort. Any hints on getting this to work, anyone? On 7 Mar 2007 at 8:26, Bos, Roger wrote: David, I wouldn't give up on windows so fast. Many people have gotten the 3Gb switch to work. One used to have to modify the header of the Rgui.exe program to use the switch, but now the binary comes ready for that, so its really quite easy. I would like to hear more about why its not working for you. As for Linux, I use FC5 for which there is a 64-bit binary. But there are also 64-bit binaries for other distros. The 32-bit and 64-bit binaries are in different directories, so you should have no trouble telling them apart. I have heard good things about Ubuntu--mainly that its very easy to use--but FC5 has been pretty easy to learn too and I use the KDE desktop which gives me Kate as a text editor. You can open a terminal window in Kate to run R and set up a key like F10 to send the code from the editor to R. Its not quite as good as my Windows setup with Tinn-R, but almost as good. Thanks, Roger -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 06, 2007 5:37 PM To: Bos, Roger Subject: RE: [R] Memory Limits in Ubuntu Linux Thanks for your prompt reply! The windows 3GB switch is quite problematic - it was not useable on my machine, and there are comments about these problems around the net. Thus, on to Linux. My machine has 4Gig, and some megabytes are grabbed by my Asus motherboard, leaving some 3.56 Gig. So if I understand your suggestion, try the 64-bit version of Ubuntu (based on Debian but I had better luck with the video part of the install) and then use the corresponding image from CRAN. My fear is that the CRAN Ubuntu version might be 32-bit - any idea how to find out before I embark on another install? Which Linux do you have - you described some significant success with getting large jobs to run. And yes, I've worked hard to save memory by tweaking the code. Thanks again. On 6 Mar 2007 at 16:51, Bos, Roger wrote: David, First of all, under Windows you can get about 3GB available to R by using the /3Gb switch in your boot.ini file, assuming you have 4Gb of memory installed on your windows machine. Using that method, I have seen the memory using of my R process get as big as 2.7Gb in task manager. What's important, of course, is contiguous space, as you mentioned. There, you may want to check your code closely and make sure that its memory usage is as efficient as possible and you are storing the minimal amount you need for each run. If you don't need an object for a while consider writing it to disk and reading it back in later. Second, AFAIK to get any benefit from more memory is Linux you have to go to the 64bit version. I am a Linux newbie too, so I choose to use one of the pre-compiled binaries available on CRAN. In other words, you shouldn't have to compile anything yourself. How much memory do you have on your Linux box? I have 16Gb and I know I have ran stuff that wouldn't run on my 4Gb windows box. HTH, Roger -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Tuesday, March 06, 2007 3:44 PM To: r-help@stat.math.ethz.ch Subject: [R] Memory Limits in Ubuntu Linux I am an R user trying to get around the 2Gig memory limit in Windows, so here I am days later with a working Ubuntu, and R under Ubuntu. But - the memory problems seem worse than ever. R code that worked under windows fails, unable to allocate memory. Searching around the web, it appears that the problem may be the ability to find contguous memory for my big vectors, but a fresh boot of Ubuntu does not help either. Which way to go? 1)
Re: [R] Query about using setdiff
try something along these lines (untested): DF1[DF1$id %in% DF2$id2, c(val1, val2)] DF1[!DF1$id %in% DF2$id2, c(val1, val2)] I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm Quoting lalitha viswanath [EMAIL PROTECTED]: Hi I have two dataframes names(DF1) = c(id, val1, val2); names(DF2) = c(id2); Ids in DF2 are a complete subset of those in DF1 How can I extract entries from DF1 where id NOT IN DF2. I tried setdiff(DF1, DF2); setdiff(DF1$id, DF2$id), etc. Although the latter eliminates the ids as required, I dont know how to extract val1 and val2 for the resultant set. Thanks Lalitha 8:00? 8:25? 8:40? Find a flick in no time __ 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. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ODP: Plotting a broken line?
Hi Aldi, Yet another way to do what you want. 'd' is your data frame. You cannot easily modify the attributes of the lines however... # just to set up coordinates plot( d$Location, d$otherinfo, type=n) # plot the lines invisible(by(d, d$indicator, function(dd) lines(dd$Location, dd$otherinfo))) * *** Please note that my e-mail address has changed to [EMAIL PROTECTED] *** Please update you address books accordingly. Thank you! * Michal Bojanowski ICS / Department of Sociology Utrecht University Heidelberglaan 2; 3584 CS Utrecht Room 1428 [EMAIL PROTECTED] http://www.fss.uu.nl/soc/bojanowski/ -Wiadomo¶æ oryginalna- Od: [EMAIL PROTECTED] w imieniu Aldi Kraja Wys³ano: ¦r 2007-03-07 17:21 Do: r-help@stat.math.ethz.ch Temat: [R] Plotting a broken line? Hi, Is there a smart way in the R graphs to create a line that is broken in intervals based on the indicator given below. following is a small test graph Location,indicator,otherinfo 1.2,1,2.2 2.5,1,2.5 3.7,1,2.3 20.1,2,4.3 22.5,2,5.2 25.0,2,3.4 27.3,2,2.2 35.1,3,3.4 37.0,3,7.2 38.0,3,6.1 40.1,3,5.4 52.9,3,3.3 Right now in the plot the line is continuous, but I would like to have it broken based on the indicator. If the line of the plot reaches the last observation of indicator=1 then the line needs to stop; the next line will start at location 22.5 and continue up top 27.3; the next line goes from 35.1 up to 52.9. x-read.table(file='c:\\aldi\\testgraph.csv',sep=',',header=T) x Location indicator otherinfo 1 1.2 1 2.2 2 2.5 1 2.5 3 3.7 1 2.3 4 20.1 2 4.3 5 22.5 2 5.2 6 25.0 2 3.4 7 27.3 2 2.2 8 35.1 3 3.4 9 37.0 3 7.2 10 38.0 3 6.1 11 40.1 3 5.4 12 52.9 3 3.3 plot(x$Location,x$indicator,type='l',xlim=c(0,max(x$Location)),ylim=c(0,max(x$indicator,x$otherinfo))) points(x$Location,x$otherinfo) TIA, Aldi -- __ 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.
[R] C to R
I`m doing some functions on C that gives me the x and y coordinates. I`d like to now how I can get these coordinates (both are a vector of number) on R to that I can make a graphic. I`ve already made a package with my functions, so I just wanna how about how to get the coordinates. Thanks, Heloise. __ 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] Download packages problem.
Luis Garavito [EMAIL PROTECTED] writes: Hi, I have a little problem with the installation of a new packages. The installation of R software is correct, but my server required authentication for use it, and for load a new package directly from R it is not possible. Is there a code or process for server authentication (put my login and password) in R for download directly the packages? Yes. Without telling us what operating system, what version of R, and some specifics of what you are trying and the error messages you are seeing, it is rather difficult to imagine that you will get any useful help. Please have a look at the posting guide and send an update. + seth -- Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center http://bioconductor.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.
[R] ATLAS for Pentium D and Pentium Duo Core?
Dear all, I wanted to use ATLAS to increase the computational speed of my program. I have installed R in a straightfoward way with .exe file (not building from source). However, after getting the P4 ATLAS Rblas.dll file from the CRAN directory bin/windows/contrib/ATLAS, and replacing the default Rblas.dll file in my R home directory under bin/, the speed actually decreased by 3% compared with the default Rblas file!! So what am I doing wrong? Is the above the correct procedure for using ATLAS? Or, is my machine not a Pentium 4 and hence the ATLAS file that I got from CRAN is not appropriate? If the issue lies in the processor, then please kindly let me know where to get the correct ATLAS file for the following computers: IThe first one is Pentium D 3.2 ghz, the second is a MacBook 1.83ghz dual-boot and I am running R in windows. Thank you! Jonathan Zhang Marketing Division Columbia Business School __ 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] Download packages problem.
Luis, posting a message several times usually won't help you to get answers... You did not tell us what kind of error you obtain, what packages did you try to install and how, what operating system are you using etc. To be honest, I have no idea what kind of server can be involved - R does not need any server to run on and the CRAN ftp severs work with anonymous logins. Please read the posting guide (link given below in the footer) and follow it next time. Petr Luis Garavito napsal(a): Hi, I have a little problem with the installation of a new packages. The installation of R software is correct, but my server required authentication for use it, and for load a new package directly from R it is not possible. Is there a code or process for server authentication (put my login and password) in R for download directly the packages? The best regards, -- Petr Klasterecky Dept. of Probability and Statistics Charles University in Prague Czech Republic __ 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] Read data with different column lengths
Dear r-help users, I have the following simple problem: Reading data from a file. The file is a .txt file exported (save as...) from Excel (see below for an example). The Excel file consists of two header rows (first row consists of ticker symbols of stocks, the second row consists of column explanations (Date,Px Last), followed by several rows of data. Now forget about the first two rows, I can deal with that (read separately, then extract the actual ticker symbols ADS, ALV, ...). For reading the rest, I tried several things, for example: data=read.table(infile,quote=,fill=T,dec=,,skip=2,colClasses=rep(c (character,numeric),ntickers)) or data=matrix(scan(file=infile,what=rep(c (character,numeric),ntickers),dec=,,skip=2),ncol=2*ntickers,byrow= T) where infile specifies the path to the input file and ntickers is the number of ticker-columns in the data set, so in the example below, ntickers=2. Both ways of reading the data work perfectly fine if all columns have the same length (i.e. the same number of filled rows), so if the data is given in a (filled) rectangular form. Now, as you can imagine, there are days when one stock is traded but not the other... so, there might be columns that do not have the same number of filled rows (see below, for the stock with ticker symbol ADS, only 3 trading days are shown, so this column is shorter than the data column for the stock ALV). Now, if I export such a structure to a .txt file, then all (by default) blank fields will be replaced by \t, i.e. tabs. Both reading procedures as give above have problems as they either display that the number of rows/columns do not fit together or as they read the table, but some cells are shifted to the left (for the example below, the entry 07/02/05134,7 appears in the empty field of the stock ADS which is of course not what we want). So the simple question is: How do I read such a structure? Can there be a simple solution? The problem is simply that empty cells are replace by \t which are then ignored for reading. So how do we distinguish between the empty cells that are given between the columns and the empty cells that actually fill a column to have the same length as other columns. Of course I could manually put in a certain character (e.g. a *) to fill in the gaps, but the data set is simply too large. If it helps, these blank fields only appear in the end of each column, not in the middle. As I work on a Mac (OS X 10.4), it was not possible (at least to me) to read the data directly from the Excel file vial the library RODBC or read.xls. Note, that the same problem arises, when I export the Excel file as a .csv, then all blank fields are separated by ; instead of \t and the reading procedure can also not decide if the field corresponds to an empty separating column or actually to a column with given entries, but which is simply not as long as another column in the file. Hope, you can help. I would really appreciate it. Best regards. Marius Excel example (I hope it's displayed correctly, the entry in the last row should be aligned with the last column): ADS GY Equity ALV GY Equity DatePx Last DatePx Last 07/02/0441,395 07/01/31130,234 07/02/0542,134 07/02/01133,353 07/02/0641,875 07/02/04133,824 07/02/05134,734 __ 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 avoid to overwrite object
Dear R list, I have a question in R, it could be very simple, but I don't know how to do it? for example: I assign 6 to x in beginning of of my R script code x-6 .. After many line code, I forget using x variable before, I use x again, and do assignment like this x-45 x [1] 45 then value 6 of previous x is replaced by 45. I am wondering if there are some way R can give me warning like x is used before, overwrite it or not? when I use x again? Thanks, Aimin __ 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] Failure to run mcsamp() in package arm
More problems. If I run sim(fm1 - lmer(Reaction ~ Days + (Days|Subject), sleepstudy)) from the lmer() help page. I get the error Error in mvrnorm(n.sims, bhat[j, ], V.beta) : 'Sigma' is not positive definite On Mar 7, 2007, at 1:30 PM, Michael Kubovy wrote: Dear r-helpers, I can run the examples on the mcsamp help page. For example: M1 - lmer (y1 ~ x + (1|group)) (M1.sim - mcsamp (M1)) fit using lmer, 3 chains, each with 1000 iterations (first 500 discarded) n.sims = 1500 iterations saved mean sd 2.5% 25% 50% 75% 97.5% Rhat n.eff beta.(Intercept) 0.1 0.7 -1.2 -0.3 0.1 0.5 1.4 1.0 1500 beta.x 2.5 0.4 1.7 2.2 2.5 2.7 3.2 1.0 1500 sigma.y3.8 0.3 3.3 3.6 3.7 3.9 4.3 1.061 sigma.grop.(In)1.5 0.8 0.0 1.0 1.4 1.9 3.3 1.412 eta.group.(Intercept)[1] 0.0 1.0 -2.1 -0.5 0.0 0.6 2.0 1.0 1500 eta.group.(Intercept)[2] 1.0 1.1 -0.9 0.2 0.9 1.7 3.4 1.059 eta.group.(Intercept)[3] -1.3 1.2 -4.0 -2.0 -1.3 -0.4 0.5 1.066 eta.group.(Intercept)[4] 1.3 1.1 -0.6 0.4 1.1 2.0 3.7 1.143 eta.group.(Intercept)[5] -0.7 1.0 -3.0 -1.4 -0.6 0.0 1.2 1.0 120 eta.group.(Intercept)[6] 1.5 1.2 -0.3 0.6 1.4 2.2 4.0 1.049 eta.group.(Intercept)[7] 0.3 1.0 -1.7 -0.3 0.1 0.8 2.5 1.0 440 eta.group.(Intercept)[8] -1.6 1.2 -4.0 -2.4 -1.5 -0.6 0.3 1.141 eta.group.(Intercept)[9] 0.4 1.0 -1.6 -0.2 0.2 0.9 2.7 1.0 180 eta.group.(Intercept)[10] -1.0 1.1 -3.3 -1.6 -0.9 -0.2 0.8 1.086 For each parameter, n.eff is a crude measure of effective sample size, and Rhat is the potential scale reduction factor (at convergence, Rhat=1). But when I try to do this with my own data I get an error: display(e7.lmer2) lmer(formula = baLO ~ I(baRatio - 0.985) + delta + (1 + I(baRatio - 0.985) + delta | subject), data = e7) coef.est coef.se (Intercept)-0.19 0.06 I(baRatio - 0.985) -4.95 0.74 delta 0.41 0.06 Error terms: Groups Name Std.Dev. Corr subject (Intercept)0.13 I(baRatio - 0.985) 2.57 0.45 delta 0.22 -0.12 -0.94 Residual0.39 number of obs: 494, groups: subject, 13 deviance = 551.4 e7.sim - mcsamp(e7.lmer2) Error in as.bugs.array(sims, program = lmer, n.iter = n.iter, n.burnin = n.burnin, : error in parameter sigma. in parameters.to.save I would appreciate a pointer to what the problem might be. _ 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. __ 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] No years() function?
Sérgio Nunes snunes at gmail.com writes: Hi, I'm trying to aggregate date values using the aggregate function. For example: aggregate(data,by=list(weekdays(LM),months(LM)),FUN=length) I would also like to aggregate by year but there seems to be no years() function. Should there be one? Is there any alternative choice? Also, a hours() function would be great. Any tip on this? Thanks in advance! Sérgio Nunes Well, working by analogy with the existing functions, this might work (not messing with setting up an S3 default though): apropos(weekdays) [1] weekdaysweekdays.Date weekdays.POSIXt weekdays.Date function (x, abbreviate = FALSE) format(x, ifelse(abbreviate, %a, %A)) environment: namespace:base d1 = Sys.time() years - function(x,abbreviate=FALSE) { as.numeric(format(x, ifelse(abbreviate, %y, %Y))) } hours - function(x) { as.numeric(format(x,%H)) } years(d1); hours(d1) __ 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] C to R
Hi Heloise, there's a manual online to help you with this - see here http://cran.r-project.org/doc/manuals/R-exts.html Cheers Andrew On Wed, Mar 07, 2007 at 05:29:10PM -0300, Heloise Mattos wrote: I`m doing some functions on C that gives me the x and y coordinates. I`d like to now how I can get these coordinates (both are a vector of number) on R to that I can make a graphic. I`ve already made a package with my functions, so I just wanna how about how to get the coordinates. Thanks, Heloise. __ 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] No years() function?
From the help of weekdays: Note: Other components such as the day of the month or the year are very easy to compute: just use 'as.POSIXlt' and extract the relevant component. Yet another option: help(package=chron) JR El mié, 07-03-2007 a las 15:35 +, Sérgio Nunes escribió: Hi, I'm trying to aggregate date values using the aggregate function. For example: aggregate(data,by=list(weekdays(LM),months(LM)),FUN=length) I would also like to aggregate by year but there seems to be no years() function. Should there be one? Is there any alternative choice? Also, a hours() function would be great. Any tip on this? Thanks in advance! Sérgio Nunes __ 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. -- Dipl.-Biol. JR Ferrer Paris ~~~ Laboratorio de Biología de Organismos --- Centro de Ecología Instituto Venezolano de Investigaciones Científicas (IVIC) Apdo. 21827, Caracas 1020-A República Bolivariana de Venezuela Tel: (+58-212) 504-1452 Fax: (+58-212) 504-1088 email: [EMAIL PROTECTED] clave-gpg: 2C260A95 __ 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] hwo can i get a vector that...
dear all, how can i get a vector that shows the number of the column of matrix that contains the maximum of the row ?? can´t believe in need a loop for this... i have a 100 x 3 matrix and want to get a 100 x 1 vector with values 1,2,3 . there must be a simple solution. i just cannot find it. i think am searching on the wrong end. thx for help in advance. m. __ 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] hwo can i get a vector that...
dear all, how can i get a vector that shows the number of the column of matrix that contains the maximum of the row ?? can´t believe in need a loop for this... i have a 100 x 3 matrix and want to get a 100 x 1 vector with values 1,2,3 . there must be a simple solution. i just cannot find it. i think am searching on the wrong end. thx for help in advance. m. EDIT: ok, i know the following by now :) apply(for18[,-1], 1, max, na.rm=T) but this doesn´t get me the number of the column - which is what i need... [[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] hwo can i get a vector that...
?apply ?which.max m - matrix(rnorm(12),nrow=4) m apply(m,1,which.max) Petr bunny , lautloscrew.com napsal(a): dear all, how can i get a vector that shows the number of the column of matrix that contains the maximum of the row ?? can´t believe in need a loop for this... i have a 100 x 3 matrix and want to get a 100 x 1 vector with values 1,2,3 . there must be a simple solution. i just cannot find it. i think am searching on the wrong end. thx for help in advance. m. __ 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 Klasterecky Dept. of Probability and Statistics Charles University in Prague Czech Republic __ 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] hwo can i get a vector that...
apply(yourMatrix,1,which.max) Bert Gunter Nonclinical Statistics 7-7374 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of bunny , lautloscrew.com Sent: Wednesday, March 07, 2007 2:12 PM To: r-help@stat.math.ethz.ch Subject: [R] hwo can i get a vector that... dear all, how can i get a vector that shows the number of the column of matrix that contains the maximum of the row ?? can´t believe in need a loop for this... i have a 100 x 3 matrix and want to get a 100 x 1 vector with values 1,2,3 . there must be a simple solution. i just cannot find it. i think am searching on the wrong end. thx for help in advance. m. __ 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] hwo can i get a vector that...
can´t believe in need a loop for this... No, you don't ;) want to get a 100 x 1 vector Has each row unique values? If yes: mat - matrix(rnorm(300),nr=100) vet - apply(mat,1,function(x) {return(which(x==max(x)))}) scionforbai __ 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] Failure to run mcsamp() in package arm
Andrew Robinson has gently chided me for not including more information. So here goes: R version 2.4.1 (2006-12-18) powerpc-apple-darwin8.8.0 locale: C attached base packages: [1] stats graphics grDevices utils methods base other attached packages: foreign car arm R2WinBUGSlme4 Matrix lattice 0.8-18 1.2-11.0-13 2.0-4 0.9975-13 0.9975-11 0.14-16 MASS JGR iplots JavaGD rJava 7.2-321.4-15 1.0-5 0.3-50.4-14 On Mar 7, 2007, at 4:30 PM, Michael Kubovy wrote: More problems. If I run sim(fm1 - lmer(Reaction ~ Days + (Days|Subject), sleepstudy)) from the lmer() help page. I get the error Error in mvrnorm(n.sims, bhat[j, ], V.beta) : 'Sigma' is not positive definite On Mar 7, 2007, at 1:30 PM, Michael Kubovy wrote: Dear r-helpers, I can run the examples on the mcsamp help page. For example: M1 - lmer (y1 ~ x + (1|group)) (M1.sim - mcsamp (M1)) fit using lmer, 3 chains, each with 1000 iterations (first 500 discarded) n.sims = 1500 iterations saved mean sd 2.5% 25% 50% 75% 97.5% Rhat n.eff beta.(Intercept) 0.1 0.7 -1.2 -0.3 0.1 0.5 1.4 1.0 1500 beta.x 2.5 0.4 1.7 2.2 2.5 2.7 3.2 1.0 1500 sigma.y3.8 0.3 3.3 3.6 3.7 3.9 4.3 1.061 sigma.grop.(In)1.5 0.8 0.0 1.0 1.4 1.9 3.3 1.412 eta.group.(Intercept)[1] 0.0 1.0 -2.1 -0.5 0.0 0.6 2.0 1.0 1500 eta.group.(Intercept)[2] 1.0 1.1 -0.9 0.2 0.9 1.7 3.4 1.059 eta.group.(Intercept)[3] -1.3 1.2 -4.0 -2.0 -1.3 -0.4 0.5 1.066 eta.group.(Intercept)[4] 1.3 1.1 -0.6 0.4 1.1 2.0 3.7 1.143 eta.group.(Intercept)[5] -0.7 1.0 -3.0 -1.4 -0.6 0.0 1.2 1.0 120 eta.group.(Intercept)[6] 1.5 1.2 -0.3 0.6 1.4 2.2 4.0 1.049 eta.group.(Intercept)[7] 0.3 1.0 -1.7 -0.3 0.1 0.8 2.5 1.0 440 eta.group.(Intercept)[8] -1.6 1.2 -4.0 -2.4 -1.5 -0.6 0.3 1.141 eta.group.(Intercept)[9] 0.4 1.0 -1.6 -0.2 0.2 0.9 2.7 1.0 180 eta.group.(Intercept)[10] -1.0 1.1 -3.3 -1.6 -0.9 -0.2 0.8 1.086 For each parameter, n.eff is a crude measure of effective sample size, and Rhat is the potential scale reduction factor (at convergence, Rhat=1). But when I try to do this with my own data I get an error: display(e7.lmer2) lmer(formula = baLO ~ I(baRatio - 0.985) + delta + (1 + I(baRatio - 0.985) + delta | subject), data = e7) coef.est coef.se (Intercept)-0.19 0.06 I(baRatio - 0.985) -4.95 0.74 delta 0.41 0.06 Error terms: Groups Name Std.Dev. Corr subject (Intercept)0.13 I(baRatio - 0.985) 2.57 0.45 delta 0.22 -0.12 -0.94 Residual0.39 number of obs: 494, groups: subject, 13 deviance = 551.4 e7.sim - mcsamp(e7.lmer2) Error in as.bugs.array(sims, program = lmer, n.iter = n.iter, n.burnin = n.burnin, : error in parameter sigma. in parameters.to.save I would appreciate a pointer to what the problem might be. _ 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. __ 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] hwo can i get a vector that...
Check out which.max Peter Alspach -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of bunny , lautloscrew.com Sent: Thursday, 8 March 2007 11:20 a.m. To: R-help@stat.math.ethz.ch Subject: Re: [R] hwo can i get a vector that... dear all, how can i get a vector that shows the number of the column of matrix that contains the maximum of the row ?? can´t believe in need a loop for this... i have a 100 x 3 matrix and want to get a 100 x 1 vector with values 1,2,3 . there must be a simple solution. i just cannot find it. i think am searching on the wrong end. thx for help in advance. m. EDIT: ok, i know the following by now :) apply(for18[,-1], 1, max, na.rm=T) but this doesn´t get me the number of the column - which is what i need... [[alternative HTML version deleted]] __ The contents of this e-mail are privileged and/or confidenti...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] good procedure to estimate ARMA(p, q)?
Michael wrote: Hi all, I have some residuals from regression, and i suspect they have correlations in them... I am willing to cast the correlation into a ARMA(p, q) framework, what's the best way to identify the most suitable p, and q, and fit ARMA(p, q) model and then correct for the correlations in regression? I know there are functions in R, I have used them before, but I just want to see if I can do the whole procedure myself, just to improve my understanding ... Please give me some pointers! Thanks a lot I'm assuming the data is a time series, otherwise ARIMA models might not be applicable here. I think identifying the order of ARIMA models is something of an art, because most real world models aren't as clean and simple as textbook examples. When you have several similar models, each with its own strengths and weaknesses, which one is best? In short, you want to make sure your series is stationary, look at its ACF and PACF, then try different values of p and q based on that, and finally look at the residuals (autocorrelation, distribution, etc). This is basically the Box-Jenkins methodology. The most accessible descriptions I've seen are in Forecasting: Methods and Applications by Makridakis, Wheelwright and Hyndman (chapter 7), and Forecasting with Univariate Box-Jenkins Models by Pankratz. Cheers, Gad -- Gad Abraham Department of Mathematics and Statistics The University of Melbourne Parkville 3010, Victoria, Australia email: [EMAIL PROTECTED] web: http://www.ms.unimelb.edu.au/~gabraham __ 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 to overwrite object
Decompose your code into small understandable functions. On 3/7/07, Aimin Yan [EMAIL PROTECTED] wrote: Dear R list, I have a question in R, it could be very simple, but I don't know how to do it? for example: I assign 6 to x in beginning of of my R script code x-6 .. After many line code, I forget using x variable before, I use x again, and do assignment like this x-45 x [1] 45 then value 6 of previous x is replaced by 45. I am wondering if there are some way R can give me warning like x is used before, overwrite it or not? when I use x again? Thanks, Aimin __ 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] hwo can i get a vector that...
___ max.col sounds like what you're after. -- Hong Ooi Senior Research Analyst, IAG Limited 388 George St, Sydney NSW 2000 +61 (2) 9292 1566 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of bunny , lautloscrew.com Sent: Thursday, 8 March 2007 9:12 AM To: r-help@stat.math.ethz.ch Subject: [R] hwo can i get a vector that... dear all, how can i get a vector that shows the number of the column of matrix that contains the maximum of the row ?? can´t believe in need a loop for this... i have a 100 x 3 matrix and want to get a 100 x 1 vector with values 1,2,3 . there must be a simple solution. i just cannot find it. i think am searching on the wrong end. thx for help in advance. m. __ 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. ___ The information transmitted in this message and its attachme...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to apply functions to unbalanced data in long format by factors......cant get by or aggregate to work
Hello R users, Problem...I do not understand how to use aggregate,by, or the appropriate apply to perform a function on data with more than one factor on unbalanced data... I have a data frame in the long format that does not contain balanced data. The ID is a unique identifier corresponding to the experimental unit that will later be examined by ANOVA, T-tests etc. Y is the data generated from the experiment. The factors represent the differences between each sample or run measured. str(mydata) ### sample of table at bottom of email ### 'data.frame': 129982 obs. of 6 variables: $ ID: num 7 7 7 7 7 7 8 8 8 8 ... $ time : Factor w/ 2 levels 120hr,24hr: 1 1 1 1 2 2 2 1 1 1 ... $ treatment: Factor w/ 2 levels control,trt: 1 1 1 2 2 1 1 2 1 1 ... $ expREP : Factor w/ 3 levels expREP1,expREP2,..: 1 1 1 3 1 1 1 1 2 2 ... $ techREP : Factor w/ 3 levels techREP1,techREP2,..: 3 2 1 1 1 3 1 3 3 2 ... $ Y : num 14.4 14.1 14.2 13.8 14.1 ... Could someone please help with doing something like the following 1. I would like to find the median for each unique combination of factors using the data in the long format (like finding the median of a single column of data). 2. Create a new column where the median is repeated for the number of rows of the unique factor combination 3. I would like to learn the most efficient way to do this because I want to avoid recreating the table from scratch with many commands like the series below. I will have to perform this operation on many different data sets some, with many more factors then this example. ### help me learn to use an apply or other command that will do the following # m0-mydata$cpdID[mydata$time==24hr mydata$treatment==control mydata$expREP==expREP1 mydata$techREP==techREP1] m1-mydata$Y[mydata$time==24hr mydata$treatment==control mydata$expREP==expREP1 mydata$techREP==techREP1] m2-median(m1) m3-cbind(ID=m0,time=rep(24hr,length(m1)), treatment=rep(control,length(m1)), expREP=rep(expREP1,length(m1)), techREP=rep(techREP1,length(m1)),Y=m1,Y50=rep(m2,length(m1))) # I would like to avoid writing the above hundreds of times ## I am able to reshape into wide format and then find the column medians. However restacking the data and regenerating the factors becomes very very messy on data sets with 150 columns. I am able to preform this analysis is SAS easily using BY, but I would like to know how to do it in R. I have tried these commands in a number of different variations with no luck and similar error messages test1-aggregate(mydata[,-1], list(mydata$time,mydata$treatment,mydata$expREP,mydata$techREP) ,median, na.rm=T) Error in median.default(X[[1]], ...) : need numeric data ### Y in numeric test1-by(mydata[,-1], list(mydata$time,mydata$treatment,mydata$expREP,mydata$techREP) ,median, na.rm=T) Error in median.default(data[x, ], ...) : need numeric data Thanks Alan winXP R 2.4.1 #Example data frame## mydata-as.data.frame(structure(list(cpdID = c(7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 19, 19, 19, 19, 19, 19, 23, 23, 23, 23, 23, 23, 23, 23, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47), time = structure(as.integer(c(1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 1, 2, 2, 1, 1, 2, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2, 2, 2, 1, 2, 2, 1, 2, 1, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 2, 1, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2)), .Label = c(120hr, 24hr), class = factor), treatment = structure(as.integer(c(1, 1, 1, 2, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 1, 2, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 1, 1, 2, 1, 2, 1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 1, 1, 2, 1, 2, 2, 2, 1, 1, 1, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 1, 1, 2, 1, 2, 2, 2, 2, 1, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2,
Re: [R] Read data with different column lengths
I would have thought that a csv file written out by Excel would have looked like this for your data: ADS GY Equity, ,ALV GY Equity, Date, Px Last,Date , Px Last 07/02/04, 41,395 ,07/01/31 , 130,234 07/02/05, 42,134 ,07/02/01 , 133,353 07/02/06, 41,875 ,07/02/04 , 133,824 , , 07/02/05, 134,734 Here we have commas separating the fields and this will read in the data: x - read.csv(/tempxx.csv, skip=2, header=FALSE, as.is=TRUE) str(x) 'data.frame': 4 obs. of 4 variables: $ V1: chr 07/02/04 07/02/05 07/02/06 $ V2: chr 41,395 42,134 41,875 $ V3: chr 07/01/31 07/02/01 07/02/0407/02/05 $ V4: chr 130,234 133,353 133,824 134,734 x V1 V2 V3 V4 1 07/02/0441,395 07/01/31130,234 2 07/02/0542,134 07/02/01133,353 3 07/02/0641,875 07/02/04133,824 4 07/02/05 134,734 You will have to delete the ',' from the numeric fields, The 'dec=,' on your command would have read '133,353' in as '133.353' which I don't think is what you want. You can delete the commas and convert to numeric with the following: x$V4 - as.numeric(gsub(',', '', x$V4)) x V1 V2 V3 V4 1 07/02/0441,395 07/01/31 130234 2 07/02/0542,134 07/02/01 133353 3 07/02/0641,875 07/02/04 133824 4 07/02/05 134734 So take a look at the options that you have with writing out the Excel data; you should be able to get either tab or comma delimited. If not, you can try reading in each line as a character string and then using 'substr' to split it apart assuming that you have constant width columns. On 3/7/07, Hofert Marius [EMAIL PROTECTED] wrote: Dear r-help users, I have the following simple problem: Reading data from a file. The file is a .txt file exported (save as...) from Excel (see below for an example). The Excel file consists of two header rows (first row consists of ticker symbols of stocks, the second row consists of column explanations (Date,Px Last), followed by several rows of data. Now forget about the first two rows, I can deal with that (read separately, then extract the actual ticker symbols ADS, ALV, ...). For reading the rest, I tried several things, for example: data=read.table(infile,quote=,fill=T,dec=,,skip=2,colClasses=rep(c (character,numeric),ntickers)) or data=matrix(scan(file=infile,what=rep(c (character,numeric),ntickers),dec=,,skip=2),ncol=2*ntickers,byrow= T) where infile specifies the path to the input file and ntickers is the number of ticker-columns in the data set, so in the example below, ntickers=2. Both ways of reading the data work perfectly fine if all columns have the same length (i.e. the same number of filled rows), so if the data is given in a (filled) rectangular form. Now, as you can imagine, there are days when one stock is traded but not the other... so, there might be columns that do not have the same number of filled rows (see below, for the stock with ticker symbol ADS, only 3 trading days are shown, so this column is shorter than the data column for the stock ALV). Now, if I export such a structure to a .txt file, then all (by default) blank fields will be replaced by \t, i.e. tabs. Both reading procedures as give above have problems as they either display that the number of rows/columns do not fit together or as they read the table, but some cells are shifted to the left (for the example below, the entry 07/02/05134,7 appears in the empty field of the stock ADS which is of course not what we want). So the simple question is: How do I read such a structure? Can there be a simple solution? The problem is simply that empty cells are replace by \t which are then ignored for reading. So how do we distinguish between the empty cells that are given between the columns and the empty cells that actually fill a column to have the same length as other columns. Of course I could manually put in a certain character (e.g. a *) to fill in the gaps, but the data set is simply too large. If it helps, these blank fields only appear in the end of each column, not in the middle. As I work on a Mac (OS X 10.4), it was not possible (at least to me) to read the data directly from the Excel file vial the library RODBC or read.xls. Note, that the same problem arises, when I export the Excel file as a .csv, then all blank fields are separated by ; instead of \t and the reading procedure can also not decide if the field corresponds to an empty separating column or actually to a column with given entries, but which
Re: [R] how to apply functions to unbalanced data in long format by factors......cant get by or aggregate to work
Here is one way of doing it: # create the rows for each unique combination x.split - split(seq(nrow(mydata)), list(mydata$time, mydata$treatment, + mydata$expREP, mydata$techREP), drop=TRUE) # now go through the list of indices and add the median mydata$Y50 - 0 # add the dummy median column for (i in x.split){ + mydata$Y50[i] - median(mydata$Y[i]) # median for each group + } head(mydata,20) cpdID time treatment expREP techREPY Y50 1 7 120hr control expREP1 techREP3 14.42331 15.74599 2 7 120hr control expREP1 techREP2 14.05282 15.10810 3 7 120hr control expREP1 techREP1 14.22814 14.63248 4 7 120hr trt expREP3 techREP1 13.84921 15.08641 5 7 24hr trt expREP1 techREP1 14.07648 15.17235 6 7 24hr control expREP1 techREP3 14.21394 14.63314 7 8 24hr control expREP1 techREP1 14.33992 14.81328 8 8 120hr trt expREP1 techREP3 14.36256 15.34493 9 8 120hr control expREP2 techREP3 14.01419 15.14270 10 8 120hr control expREP2 techREP2 14.09803 15.10079 11 8 120hr trt expREP1 techREP2 14.31522 15.39152 12 8 120hr trt expREP1 techREP1 14.45288 14.65430 13 8 24hr control expREP2 techREP1 13.95919 14.71188 14 8 24hr trt expREP2 techREP3 14.40640 14.36332 15 8 24hr trt expREP1 techREP2 14.04038 14.42856 16 8 24hr control expREP3 techREP3 14.22859 15.08463 17 8 24hr trt expREP1 techREP3 14.12598 14.53840 18 8 24hr trt expREP3 techREP1 13.59257 14.69984 19 8 24hr trt expREP3 techREP2 13.58308 14.85730 2010 120hr control expREP3 techREP1 13.02808 14.07448 On 3/7/07, ALAN SMITH [EMAIL PROTECTED] wrote: Hello R users, Problem...I do not understand how to use aggregate,by, or the appropriate apply to perform a function on data with more than one factor on unbalanced data... I have a data frame in the long format that does not contain balanced data. The ID is a unique identifier corresponding to the experimental unit that will later be examined by ANOVA, T-tests etc. Y is the data generated from the experiment. The factors represent the differences between each sample or run measured. str(mydata) ### sample of table at bottom of email ### 'data.frame': 129982 obs. of 6 variables: $ ID: num 7 7 7 7 7 7 8 8 8 8 ... $ time : Factor w/ 2 levels 120hr,24hr: 1 1 1 1 2 2 2 1 1 1 ... $ treatment: Factor w/ 2 levels control,trt: 1 1 1 2 2 1 1 2 1 1 ... $ expREP : Factor w/ 3 levels expREP1,expREP2,..: 1 1 1 3 1 1 1 1 2 2 ... $ techREP : Factor w/ 3 levels techREP1,techREP2,..: 3 2 1 1 1 3 1 3 3 2 ... $ Y : num 14.4 14.1 14.2 13.8 14.1 ... Could someone please help with doing something like the following 1. I would like to find the median for each unique combination of factors using the data in the long format (like finding the median of a single column of data). 2. Create a new column where the median is repeated for the number of rows of the unique factor combination 3. I would like to learn the most efficient way to do this because I want to avoid recreating the table from scratch with many commands like the series below. I will have to perform this operation on many different data sets some, with many more factors then this example. ### help me learn to use an apply or other command that will do the following # m0-mydata$cpdID[mydata$time==24hr mydata$treatment==control mydata$expREP==expREP1 mydata$techREP==techREP1] m1-mydata$Y[mydata$time==24hr mydata$treatment==control mydata$expREP==expREP1 mydata$techREP==techREP1] m2-median(m1) m3-cbind(ID=m0,time=rep(24hr,length(m1)), treatment=rep(control,length(m1)), expREP=rep(expREP1,length(m1)), techREP=rep(techREP1,length(m1)),Y=m1,Y50=rep(m2,length(m1))) # I would like to avoid writing the above hundreds of times ## I am able to reshape into wide format and then find the column medians. However restacking the data and regenerating the factors becomes very very messy on data sets with 150 columns. I am able to preform this analysis is SAS easily using BY, but I would like to know how to do it in R. I have tried these commands in a number of different variations with no luck and similar error messages test1-aggregate(mydata[,-1], list(mydata$time,mydata$treatment,mydata$expREP,mydata$techREP) ,median, na.rm=T) Error in median.default(X[[1]], ...) : need numeric data ### Y in numeric test1-by(mydata[,-1], list(mydata$time,mydata$treatment,mydata$expREP,mydata$techREP) ,median, na.rm=T) Error in median.default(data[x, ], ...) : need numeric data Thanks Alan winXP R 2.4.1 #Example data frame## mydata-as.data.frame(structure(list(cpdID = c(7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 19, 19, 19,
[R] Some problems with X11
Hi, I am really new with R, so I don't know anything about it. I have written a script (attached) which tries to do really basic stuff (such as computing basic statistics and basic plots). When I try to plot a histogram and pairs, for example, I get the following message: source(project.R) Loading required package: sp - Analysis of geostatistical data For an Introduction to geoR go to http://www.est.ufpr.br/geoR geoR version 1.6-13 (built on 2006/12/26) is now loaded - Error in title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...) : X11 font at size 8 could not be loaded I have seen some threads about this problem, though none of them really states what should be done in order to solve that problem (At least it was not clear for me!). This is the R version I have: version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 2 minor 4.1 year 2006 month 12 day18 svn rev40228 language R version.string R version 2.4.1 (2006-12-18) I am also running R on a Ubuntu Linux Edgy distro. The interesting thing is that I have this problem on my desktop only. I also have Ubuntu Edgy installed on my laptop and it is working just fine! Thank you R # # # MATH574 - Geostatistics # # Prof. Dr. Donald Myers # # # # Term-project: Anaylizing climatological data from Sao Paulo State, # # Brazil: # #- Annual precipitation (mm); and # #- Annual mean temperature (oC). # # # # * elevation data is also provided# # # # Author: Rafael Rosolem ([EMAIL PROTECTED]) # # Department: Hydrology and Water Resources# # The University of Arizona# # # # Date: 02.14.2007 # # Last update: 02.19.2007 # # # # Opening libraries library(geoR) # geoR package library(gstat) # gstat package library(scatterplot3d) # scatterplot3d package # Setting the path and file name path - /home/rafael/math574/term-project/ input - dataset_rafael.dat # Opening data file data - read.table(paste(path,input,sep=),header = TRUE) # Converting data object to geodata class data_geoR - as.geodata(data,coords.col = c(1,2),data.col = c(3,4,5)) # Basics statistics data_summary - summary(data_geoR) # Data summary data_stdev - sd(data_geoR$data) # Standard deviation data_cor - cor(data_geoR$data) # Data correlation # Histograms X11(display = ,width = 9,height = 4,pointsize = 12,bg = transparent) #png(file=paste(path,data_hist.png,sep=),height=576,width=576, #res=600,bg=transparent) par(mfrow = c(1,3)) # 1x3 graph temp_hist - hist(data_geoR$data[,temp],breaks = c(17:26), col = red,border = black, main = NULL, xlim = c(min(data_geoR$data[,temp])-1, max(data_geoR$data[,temp])+1),ylim = NULL, xlab = Temperature (oC),ylab = Freq) # Temperature prec_hist - hist(data_geoR$data[,prec],breaks = c(250*0:14), col = darkblue,border = black, main = NULL, xlim = c(min(data_geoR$data[,prec])-500, max(data_geoR$data[,prec])+500),ylim = NULL, xlab = Precipitation (mm),ylab = Freq) # Precipitation elev_hist -
[R] April Courses*** R/S+: Fundamentals and Programming Techniques - @ 6 Locations Nationwide / Ann Arbor, Hartford, Raleigh, Princeton, Seattle, Boston
XLSolutions Corporation is proud to announce our April 2007 R/S: Fundamentals and Programming Techniques - @ 6 USA locations: http://www.xlsolutions-corp.com/Rfund.htm Ann Arbor, MI *** April 23-24, 2007 Raleigh, NC *** April 19-20, 2007 Princeton, NJ *** April 26-27 , 2007 Hartford, CT *** April 26-27 , 2007 Seattle, WA *** April 30- May 1, 2007 Boston, MA *** April 30 - May 1, 2007 This two-day beginner to intermediate R/S-plus course focuses on a broad spectrum of topics, from reading raw data to a comparison of R and S. We will learn the essentials of data manipulation, graphical visualization and R/S-plus programming. We will explore statistical data analysis tools,including graphics with data sets. How to enhance your plots, build your own packages (librairies) and connect via ODBC,etc. The course will give beginners a strong foundation for becoming a versatile programmer, and will expose experienced users to skills that make a better programmer. http://www.xlsolutions-corp.com/Rfund.htm Other courses: (1) R/S System: Advanced Programming - San Francisco, March 15-16, 2007 (2) Data Mining: Practical Tools and Techniques in R/Splus - Salt Lake City, March 26-27, 2007 Ask for group discount and reserve your seat Now - Earlybird Rates. Please email us for for April-May courses. Payment due after the class! Email Sue Turner: [EMAIL PROTECTED] (1) R/S System: Advanced Programming - San Francisco, March 15-16, 2007 This advanced course is designed for people who use R or S-Plus in their day-to-day work and want to maximize the efficiency of their programs. Participants will learn in depth advanced programming techniques that are available in R and S-Plus. This course will improve your general strategies and extend your programming skills. This two-day course will introduce participants to many programming techniques and tools. In addition a special session dedicated to making S-Plus functions more efficient will focus on fast objects and fast functions. The advanced programming techniques include object orientation, classes, inheritance and methods. http://www.xlsolutions-corp.com/Radv.htm (2) Data Mining: Practical Tools and Techniques in R/Splus - Salt Lake City, March 26-27, 2007 This course gives students an understanding of R/Splus tools used to investigate the main tasks that predictive analytics and exploratory data mining is usually called upon to accomplish and data preparation which is universally held as the key to successful data mining. We focus on the most common data mining tasks which are: Description, Estimation, Prediction, Classification, Clustering, Association and the need for Dimension Reduction with Principal Components and Factor Analysis. Analytical methods used in the class include decision trees, logistic regression, neural networks, link analysis (social networks) and Kernel-based Methods (SVMs). http://www.xlsolutions-corp.com/RSMining.htm Email us for group discounts: [EMAIL PROTECTED] Phone: 206 686 1578 Visit us: www.xlsolutions-corp.com/training.htm Please let us know if you and your colleagues are interested in this class to take advantage of group discount. Register now to secure your seat! Cheers, Elvis Miller, PhD Manager Training XLSolutions Corporation 206 686 1578 www.xlsolutions-corp.com/training.htm [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] sink with R-code
I have the same question that Eusebio had: Is there a function similar to sink that redirect also R code to a file that is: sink(R001) x - c(2,-6,-4,8,5,4,1,3,4,-9,0,1) A - matrix(x, ncol=3) A A.prima - t(A) A.prima dim(A) dim(A.prima) sink() create a file R001 with contents: -- [,1] [,2] [,3] [1,]254 [2,] -64 -9 [3,] -410 [4,]831 [,1] [,2] [,3] [,4] [1,]2 -6 -48 [2,]5413 [3,]4 -901 [1] 4 3 [1] 3 4 and what I want is a file with: x - c(2,-6,-4,8,5,4,1,3,4,-9,0,1) A - matrix(x, ncol=3) A [,1] [,2] [,3] [1,]254 [2,] -64 -9 [3,] -410 [4,]831 A.prima - t(A) A.prima [,1] [,2] [,3] [,4] [1,]2 -6 -48 [2,]5413 [3,]4 -901 -- Any hint will be appreciated Eusebio Scott K. Cooley Statistical Sciences, K6-08 Battelle--Pacific Northwest Division Pacific Northwest National Laboratory P.O. Box 999 Richland, WA 99352 Phone: 509-375-3604 FAX: 509-375-2604 Email: [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] Sweave issue: quotes in verbatim-like output print incorrectly
Thanks to Gavin Simpson and Patrick Drechsler: The solution was simple. (No idea how I would have discovered these answers without this R mailing list!) Many thanks. P. Gavin Simpson [EMAIL PROTECTED] writes: On Wed, 2007-03-07 at 15:33 +1000, Peter Dunn wrote: But I recently received a new computer, and ever since I have had a problem I've never seen before. For example, I place the following in my Snw file: Try this in the preamble of your Snw file: \usepackage[utf8x]{inputenc} \usepackage[utf8]{inputenc} should suffic for this. Also, utf8 is newer than utf8x. So if you only need the ISO 8859 subset of Unicode, utf8 should serve your needs. HTH Patrick -- I never used a logarithm in my life, and could not undertake to extract the square root of four without misgivings. (Georg Bernhard Shaw) __ 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. This email (including any attached files) is confidential an...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to apply functions to unbalanced data in long format byfactors......cant get by or aggregate to work
Dear Alan, I think that podria to be of utility the function tapply.stat () of the package agricolae. see ?tapply.stat Regards, Felipe. for example: library(agricolae) attach(mydata) set1-tapply.stat(mydata[,2:5],Y,median) set2-tapply.stat(time,Y,function(x) median(x)) set3-tapply.stat(mydata[,c(2,3)],Y,function(x) median(x)) set2 timeY 1 120hr 14.94159 2 24hr 14.81914 set3 time treatmentY 1 120hr control 15.31974 2 120hr trt 14.82851 3 24hr control 15.03627 4 24hr trt 14.70249 From: [EMAIL PROTECTED] on behalf of ALAN SMITH Sent: Wed 3/7/2007 6:25 PM To: r-help@stat.math.ethz.ch Subject: [R] how to apply functions to unbalanced data in long format byfactors..cant get by or aggregate to work Hello R users, Problem...I do not understand how to use aggregate,by, or the appropriate apply to perform a function on data with more than one factor on unbalanced data... I have a data frame in the long format that does not contain balanced data. The ID is a unique identifier corresponding to the experimental unit that will later be examined by ANOVA, T-tests etc. Y is the data generated from the experiment. The factors represent the differences between each sample or run measured. str(mydata) ### sample of table at bottom of email ### 'data.frame': 129982 obs. of 6 variables: $ ID: num 7 7 7 7 7 7 8 8 8 8 ... $ time : Factor w/ 2 levels 120hr,24hr: 1 1 1 1 2 2 2 1 1 1 ... $ treatment: Factor w/ 2 levels control,trt: 1 1 1 2 2 1 1 2 1 1 ... $ expREP : Factor w/ 3 levels expREP1,expREP2,..: 1 1 1 3 1 1 1 1 2 2 ... $ techREP : Factor w/ 3 levels techREP1,techREP2,..: 3 2 1 1 1 3 1 3 3 2 ... $ Y : num 14.4 14.1 14.2 13.8 14.1 ... Could someone please help with doing something like the following 1. I would like to find the median for each unique combination of factors using the data in the long format (like finding the median of a single column of data). 2. Create a new column where the median is repeated for the number of rows of the unique factor combination 3. I would like to learn the most efficient way to do this because I want to avoid recreating the table from scratch with many commands like the series below. I will have to perform this operation on many different data sets some, with many more factors then this example. ### help me learn to use an apply or other command that will do the following # m0-mydata$cpdID[mydata$time==24hr mydata$treatment==control mydata$expREP==expREP1 mydata$techREP==techREP1] m1-mydata$Y[mydata$time==24hr mydata$treatment==control mydata$expREP==expREP1 mydata$techREP==techREP1] m2-median(m1) m3-cbind(ID=m0,time=rep(24hr,length(m1)), treatment=rep(control,length(m1)), expREP=rep(expREP1,length(m1)), techREP=rep(techREP1,length(m1)),Y=m1,Y50=rep(m2,length(m1))) # I would like to avoid writing the above hundreds of times ## I am able to reshape into wide format and then find the column medians. However restacking the data and regenerating the factors becomes very very messy on data sets with 150 columns. I am able to preform this analysis is SAS easily using BY, but I would like to know how to do it in R. I have tried these commands in a number of different variations with no luck and similar error messages test1-aggregate(mydata[,-1], list(mydata$time,mydata$treatment,mydata$expREP,mydata$techREP) ,median, na.rm=T) Error in median.default(X[[1]], ...) : need numeric data ### Y in numeric test1-by(mydata[,-1], list(mydata$time,mydata$treatment,mydata$expREP,mydata$techREP) ,median, na.rm=T) Error in median.default(data[x, ], ...) : need numeric data Thanks Alan winXP R 2.4.1 #Example data frame## mydata-as.data.frame(structure(list(cpdID = c(7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 19, 19, 19, 19, 19, 19, 23, 23, 23, 23, 23, 23, 23, 23, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47), time = structure(as.integer(c(1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 1, 2, 2, 1, 1, 2, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2, 2, 2, 1, 2, 2, 1, 2, 1, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 2, 1, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 2, 1, 1, 2, 2, 2, 2, 2,
[R] reading a text file with a stray carriage return
Hi, I'm hoping someone has a suggestion for handling a simple problem. A client gave me a comma separated value file (call it x.csv) that has an id and name and address for about 25,000 people (25,000 records). I used read.table to read it, but then discovered that there are stray carriage returns on several records. This plays havoc with read.table since it starts a new input line when it sees the carriage return. In short, the read is all wrong. I thought I could write a simple function to parse a line and write it back out, character by character. If a carriage return is found, it would simply be ignored on the writing back out part. But how do I identify a carriage return? What is the code or symbol? Is there any easier way to rid the file of carriage returns in the middle of the input lines? Any help is appreciated. Walt Paczkowski _ Walter R. Paczkowski, Ph.D. Data Analytics Corp. 44 Hamilton Lane Plainsboro, NJ 08536 (V) 609-936-8999 (F) 609-936-3733 __ 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] Passing command line parameters to a script
#!/bin/sh echo 'a=${1}; b=${2}; source(myRcodeUsing_a_and_b.R); ' | R --vanilla --quiet and you can run this from shell like: ./callR valueOfa valueOfb Best, Oleg akintayo holder wrote: Hi, Does any one know if it is possible to create an R script that can use command line parameters. I can execute an R script from the command line, but I cannot figure out how to pass parameters to the script. The only resources I have found seem somewhat involved or incomplete. Any help is appreciated. Akintayo [[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. -- Dr Oleg Sklyar | EBI-EMBL, Cambridge CB10 1SD, UK | +44-1223-494466 __ 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] reading a text file with a stray carriage return
How do you define a carriage return in the middle of a line if a carriage return is also used to delimit a line? One of the things you can do is to use 'count.fields' to determine the number of fields in each line. For those lines that are not the right length, you could combine them together with a 'paste' command when you write them out. On 3/7/07, Walter R. Paczkowski [EMAIL PROTECTED] wrote: Hi, I'm hoping someone has a suggestion for handling a simple problem. A client gave me a comma separated value file (call it x.csv) that has an id and name and address for about 25,000 people (25,000 records). I used read.table to read it, but then discovered that there are stray carriage returns on several records. This plays havoc with read.table since it starts a new input line when it sees the carriage return. In short, the read is all wrong. I thought I could write a simple function to parse a line and write it back out, character by character. If a carriage return is found, it would simply be ignored on the writing back out part. But how do I identify a carriage return? What is the code or symbol? Is there any easier way to rid the file of carriage returns in the middle of the input lines? Any help is appreciated. Walt Paczkowski _ Walter R. Paczkowski, Ph.D. Data Analytics Corp. 44 Hamilton Lane Plainsboro, NJ 08536 (V) 609-936-8999 (F) 609-936-3733 __ 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.
[R] Calling Optim() from C
Hello: I am sure this question was dealt with several years ago. Is the function vmmin() available from Rmath Standalone? If not is it possible to call optim() or nlm() from Rmath in C. Thank you. Mervyn __ 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.