Re: [R] uniform integer RNG 0 to t inclusive
Prof Ripley, You are absolutely correct, this code will not work at all - for starters, M isn't correctly initialized, etc. I edited my code in tinn-r and never ran it before posting... my apologies, I always seem to be too quick off the mark to reply - despite the 4*runif(1) suggestion in the posting guide... I hadn't realized before what significant difference the replace=TRUE would make to the runtime... Now I can just use the sample() code you suggested and remove my runif() code altogether, as sample(t+1, 1, replace=TRUE) - 1 will work fine with t - 2e9 which is considerably more that I need. Thanks again to both Prof Ripley and Duncan Murdoch, Sean O'Riordain affiliation - NULL On 19/09/06, Prof Brian Ripley [EMAIL PROTECTED] wrote: On Tue, 19 Sep 2006, Sean O'Riordain wrote: Hi Duncan, Thanks for that. In the light of what you've suggested, I'm now using the following: # generate a random integer from 0 to t (inclusive) if (t 1000) { # to avoid memory problems... M - sample(t, 1) } else { while (M t) { M - as.integer(urand(1,min=0, max=t+1-.Machine$double.eps)) } } sample(t, 1) is a sample from 1:t, not 0:t. You need sample(t+1, 1, replace=TRUE) - 1 which works in all cases up to INT_MAX-1, and beyond that you need to worry about the resolution of the RNG (and to use floor not as.integer). There is no such thing as urand in base R cheers and Thanks, Sean On 18/09/06, Duncan Murdoch [EMAIL PROTECTED] wrote: On 9/18/2006 3:37 AM, Sean O'Riordain wrote: Good morning, I'm trying to concisely generate a single integer from 0 to n inclusive, where n might be of the order of hundreds of millions. This will however be used many times during the general procedure, so it must be reasonably efficient in both memory and time... (at some later stage in the development I hope to go vectorized) The examples I've found through searching RSiteSearch() relating to generating random integers say to use : sample(0:n, 1) However, when n is large this first generates a large sequence 0:n before taking a sample of one... this computer doesn't have the memory for that! You don't need to give the whole vector: just give n, and you'll get draws from 1:n. The man page is clear on this. So what you want is sample(n+1, 1) - 1. (Use replace=TRUE if you want a sample bigger than 1, or you'll get sampling without replacement.) When I look at the documentation for runif(n, min, max) it states that the generated numbers will be min = x = max. Note the = max... Actually it says that's the range for the uniform density. It's silent on the range of the output. But it's good defensive programming to assume that it's possible to get the endpoints. How do I generate an x such that the probability of being (the integer) max is the same as any other integer from min (an integer) to max-1 (an integer) inclusive... My attempt is: urand.int - function(n,t) { as.integer(runif(n,min=0, max=t+1-.Machine$double.eps)) } # where I've included the parameter n to help testing... Because of rounding error, t+1-.Machine$double.eps might be exactly equal to t+1. I'd suggest using a rejection method if you need to use this approach: but sample() is better in the cases where as.integer() will work. Duncan Murdoch is floor() better than as.integer? Is this correct? Is the probability of the integer t the same as the integer 1 or 0 etc... I have done some rudimentary testing and this appears to work, but power being what it is, I can't see how to realistically test this hypothesis. Or is there a a better way of doing this? I'm trying to implement an algorithm which samples into an array, hence the need for an integer - and yes I know about sample() thanks! :-) { incidentally, I was surprised to note that the maximum value returned by summary(integer_vector) is pretty and appears to be rounded up to a nice round number, and is not necessarily the same as max(integer_vector) where the value is large, i.e. of the order of say 50 million } Is version etc relevant? (I'll want to be portable) version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 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 in advance for your help. Sean O'Riordain affiliation - NULL __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R
Re: [R] uniform integer RNG 0 to t inclusive
Hi Duncan, Thanks for that. In the light of what you've suggested, I'm now using the following: # generate a random integer from 0 to t (inclusive) if (t 1000) { # to avoid memory problems... M - sample(t, 1) } else { while (M t) { M - as.integer(urand(1,min=0, max=t+1-.Machine$double.eps)) } } cheers and Thanks, Sean On 18/09/06, Duncan Murdoch [EMAIL PROTECTED] wrote: On 9/18/2006 3:37 AM, Sean O'Riordain wrote: Good morning, I'm trying to concisely generate a single integer from 0 to n inclusive, where n might be of the order of hundreds of millions. This will however be used many times during the general procedure, so it must be reasonably efficient in both memory and time... (at some later stage in the development I hope to go vectorized) The examples I've found through searching RSiteSearch() relating to generating random integers say to use : sample(0:n, 1) However, when n is large this first generates a large sequence 0:n before taking a sample of one... this computer doesn't have the memory for that! You don't need to give the whole vector: just give n, and you'll get draws from 1:n. The man page is clear on this. So what you want is sample(n+1, 1) - 1. (Use replace=TRUE if you want a sample bigger than 1, or you'll get sampling without replacement.) When I look at the documentation for runif(n, min, max) it states that the generated numbers will be min = x = max. Note the = max... Actually it says that's the range for the uniform density. It's silent on the range of the output. But it's good defensive programming to assume that it's possible to get the endpoints. How do I generate an x such that the probability of being (the integer) max is the same as any other integer from min (an integer) to max-1 (an integer) inclusive... My attempt is: urand.int - function(n,t) { as.integer(runif(n,min=0, max=t+1-.Machine$double.eps)) } # where I've included the parameter n to help testing... Because of rounding error, t+1-.Machine$double.eps might be exactly equal to t+1. I'd suggest using a rejection method if you need to use this approach: but sample() is better in the cases where as.integer() will work. Duncan Murdoch is floor() better than as.integer? Is this correct? Is the probability of the integer t the same as the integer 1 or 0 etc... I have done some rudimentary testing and this appears to work, but power being what it is, I can't see how to realistically test this hypothesis. Or is there a a better way of doing this? I'm trying to implement an algorithm which samples into an array, hence the need for an integer - and yes I know about sample() thanks! :-) { incidentally, I was surprised to note that the maximum value returned by summary(integer_vector) is pretty and appears to be rounded up to a nice round number, and is not necessarily the same as max(integer_vector) where the value is large, i.e. of the order of say 50 million } Is version etc relevant? (I'll want to be portable) version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 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 in advance for your help. Sean O'Riordain affiliation - NULL __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] uniform integer RNG 0 to t inclusive
Good morning, I'm trying to concisely generate a single integer from 0 to n inclusive, where n might be of the order of hundreds of millions. This will however be used many times during the general procedure, so it must be reasonably efficient in both memory and time... (at some later stage in the development I hope to go vectorized) The examples I've found through searching RSiteSearch() relating to generating random integers say to use : sample(0:n, 1) However, when n is large this first generates a large sequence 0:n before taking a sample of one... this computer doesn't have the memory for that! When I look at the documentation for runif(n, min, max) it states that the generated numbers will be min = x = max. Note the = max... How do I generate an x such that the probability of being (the integer) max is the same as any other integer from min (an integer) to max-1 (an integer) inclusive... My attempt is: urand.int - function(n,t) { as.integer(runif(n,min=0, max=t+1-.Machine$double.eps)) } # where I've included the parameter n to help testing... is floor() better than as.integer? Is this correct? Is the probability of the integer t the same as the integer 1 or 0 etc... I have done some rudimentary testing and this appears to work, but power being what it is, I can't see how to realistically test this hypothesis. Or is there a a better way of doing this? I'm trying to implement an algorithm which samples into an array, hence the need for an integer - and yes I know about sample() thanks! :-) { incidentally, I was surprised to note that the maximum value returned by summary(integer_vector) is pretty and appears to be rounded up to a nice round number, and is not necessarily the same as max(integer_vector) where the value is large, i.e. of the order of say 50 million } Is version etc relevant? (I'll want to be portable) version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 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 in advance for your help. Sean O'Riordain affiliation - NULL __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] subsetting a data set
Hi Graham, Try creating a new column with the two levels that you want... something along the lines of (warning untested!!!) GQ1[(GQ1$Status == Expert) | (GQ1$Status == Ecol),]$newColumn - AllEcol GQ1[GQ1$Status == Stake,]$newColumn - Stake and then do the by(GQ1[,Max], list(GQ1$NewColumn), summary) when in doubt... break the problem into smaller chunks... :-) cheers, Sean On 08/09/06, Graham Smith [EMAIL PROTECTED] wrote: Petr, Thanks again, but the data is GQ1, Max is a variable (column) So I have used by(GQ1[,Max], list(GQ1$Status), summary) Which is very good, and is better than the way I did it before by summarising for each status level individually, but that still isn't combing the data for Status == Expert and Status = Ecol So at the moment the status variable has 3 levels Expert, Ecol and Stake, I want to analsye that at two levels: Expert and Ecol combined into a new level called AllEcol and the exsiting level Stake It is this combining the levels that has got me stuck. Thanks again, Graham On 08/09/06, Petr Pikal [EMAIL PROTECTED] wrote: Sorry, I did not notice that in your case Max is not a function but your data. So probably by(Max[, your.columns], list(Max$status), summary) is maybe what you want. HTH Petr On 8 Sep 2006 at 10:31, Petr Pikal wrote: From: Petr Pikal [EMAIL PROTECTED] To: Graham Smith [EMAIL PROTECTED], r-help@stat.math.ethz.ch Date sent: Fri, 08 Sep 2006 10:31:12 +0200 Priority: normal Subject:Re: [R] subsetting a data set Hi I am not sure if your Max is the same as max so I am not sure what you exactly want from your data. However you shall consult ?tapply, ?by, ?aggregate and maybe also ?[ together with chapter 2 in intro manual in docs directory. aggregate(data[, some.columns], list(data$factor1, data$factor2), max) will give you maximum for specified columns based on spliting the data according to both factors Also connection summary with max is not common and I wonder what is your output in this case. I believe that there are six same numbers. However R is case sensitive and maybe Max does something different from max. In my case it throws an error. HTH Petr On 8 Sep 2006 at 8:06, Graham Smith wrote: Date sent:Fri, 8 Sep 2006 08:06:16 +0100 From: Graham Smith [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] subsetting a data set I have a data set called GQ1, which has 20 variables one of which is a factor called Status at thre levels Expert, Ecol and Stake I have managed to evaluate some of the data split by status using commands like: summary (Max[Status==Ecol]) BUT how do I produce asummary for Ecol and Expert combined, the only example I can find suggsts I could use summary (Max[Status==Ecol Status==Expert]) but that doesn't work. Additionally on the same vein, if I cannot work out how to create a new data set that would contain all the data for all the variables but only for the data where Status = Ecol, or where status equalles Ecol and Expert. I know this is yet again a very simple problem, but I really can't find the solution in the help or the books I have. Many thanks, Graham [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [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-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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 the p-values or t-values from the lm's results
Hi there Zhang, While there might be a better way... an ugly but generic way of accessing this type of information is to use str() and a little experimentation... here is a little history() of what I did to find it... a str(a) str(logr) a[[1]] a[[2]] a[[3]] a[[4]] a[[4]][[1]] a[[4]][1,] a[[4]][,4] and hey presto... we have it... :-) now if I actually understood what was going on here I'd probably be faster... but it is pretty generic and you can almost always get at those things using this technique... no doubt somebody with more knowledge will explain why it works :-) cheers, Sean On 20/08/06, zhijie zhang [EMAIL PROTECTED] wrote: Dear friends, After running the lm() model, we can get summary resluts like the following: Coefficients: Estimate Std. Error t value Pr(|t|) x1 0.115620.10994 1.052 0.2957 x2 -0.138790.09674 -1.435 0.1548 x3 0.010510.09862 0.107 0.9153 x4 0.141830.08471 1.674 0.0975 . x5 0.189950.10482 1.812 0.0732 . x6 0.248320.10059 2.469 0.0154 * x7 -0.044250.11008 -0.402 0.6886 x8 0.051460.10290 0.500 0.6182 - **the program maybe : data-matrix(rnorm(900),ncol=9) #9variables,1dependent var,8independent data-data.frame(data) names(data)-c('y','x1','x2','x3','x4','x5','x6','x7','x8') logr-lm(y~x1+x2+x3+x4+x5+x6+x7+x8-1,data) a-summary(logr) Could i extract the p-values or t-values from the a$Coefficients, i searched the attributes(a), but don't find the options,how to do that? Thanks very much! -- Kind Regards, Zhi Jie,Zhang , [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] String manipulation and formatting
Does it have to be a stop char ., or could it be a separate parameter, i.e. put in a comma, then the 10 becomes an integer... s/ On 18/07/06, Prof Brian Ripley [EMAIL PROTECTED] wrote: On Tue, 18 Jul 2006, Bashir Saghir (Aztek Global) wrote: Thanks to Richard, Gabor and Marc for some nice solutions to my request. I have a new problem: xify(30.10) [1] X.X xify(30.11) [1] XXX.XXX The problem originates from: as.numeric(unlist(strsplit(as.character(15.10), \\.))) [1] 15 1 as.numeric(unlist(strsplit(as.character(15.11), \\.))) [1] 15 11 It seems to boils down to: as.character(15.10) [1] 15.1 A simple solution is: xify(15.10) [1] X.XX I was wondering if there is a simple way for xify to see the zero of the 10 without having to force the user to add quotes around the format? No, as the parser has converted '15.10' to a numeric constant. What is the problem with asking users to enter strings as strings? -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html 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] References verifying accuracy of R for basic statisticalcalculations and tests
Please don't shoot! q: would it be a good idea to use these datasets as a basis for some regression tests? Sean On 14/07/06, Rau, Roland [EMAIL PROTECTED] wrote: Hi, [mailto:[EMAIL PROTECTED] On Behalf Of Corey Powell Do you know of any references that verify the accuracy of R for basic statistical calculations and tests. The results of these studies should indicate that R results are the same as the results of other statistical packages to a certain number of decimal places on some benchmark calculations. I don't know of any references, but maybe you can somehow verify the accuracy of R by running some analysis with the NIST Statistical Reference Datasets; the URL is http://www.itl.nist.gov/div898/strd/ So maybe you can run the analyses mentioned there and say that R (hopefully) returned the correct results. Hope this helps, Roland -- This mail has been sent through the MPI for Demographic Rese...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Generating random normal distribution with mean 0 and standard deviation 1
?rnorm On 14/07/06, Neuro LeSuperHéros [EMAIL PROTECTED] wrote: Hello, This must be really simple, but I can't find it on R Site search. I need to generate a random normally distributed series with mean 0 and sd 1. In Matlab, this code is randn(n). The closest I found is runif(20,-1,1) but this forces a maximum and a minimum, and there's no way to specify a standard deviation of 1. sd(runif(20,-1,1)) [1] 0.578164 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] PowerPoint
or try win.metafile() if i'm in a hurry, (in windows) i just right click on the graph and select Copy as Metafile and paste directly into powerpoint... Sean On 23/06/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: Note that jpg, bmp and png are in less desirable bit mapped formats whereas eps is in a more desirable vector format (magnification and shrinking does not involve loss of info) and so would be preferable from a quality viewpoint. See: http://www.stc-saz.org/resources/0203_graphics.pdf On 6/23/06, Doran, Harold [EMAIL PROTECTED] wrote: Use the functions in library(grDevices) for jpeg, bmp, or png formats. Or, you can use postscript() for an eps file. Of course, I personally think tex files make for much better looking presentations if you can be persuaded. Harold -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Marc Bernard Sent: Friday, June 23, 2006 7:28 AM To: r-help@stat.math.ethz.ch Subject: [R] PowerPoint Dear All, I am looking for the best way to use graphs from R (like xyplot, curve ...) for a presentation with powerpoint. I used to save my plot as pdf and after to copy them as image in powerpoint but the quality is not optimal by so doing. Another completely independent question is the following: when I use main in the xyplot, the main title is very close to my plot, i.e. no ligne separate the main and the plot. I would like my title to be well distinguished from the plots. I would be grateful for any improvements... Many thanks, Bernard, - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Qurey : How to add trendline( st. line) in Graph
lines(predict(lm(g~f))~f,lty=2) or if its a curvy line you're looking for... lines(predict(loess(g~f))~f,lty=3) On 19/06/06, priti desai [EMAIL PROTECTED] wrote: How to add trendline (i.e. straight line passing through maximum points) in graph. I have worked on the data given below. Please tell me how to add trendline in the graph. The script is as follows === start # The data is as follows data - c( 0.01, 0.02, 0.04, 0.13, 0.17 , 0.19 , 0.21 , 0.27 , 0.27 , 0.28, 0.29, 0.37, 0.41, 0.49, 0.51, 0.52, 0.54, 0.57, 0.62, 0.63, 0.68, 0.73, 0.74, 0.79, 0.81, 0.81, 0.82, 0.86, 0.94, 0.96, 1.02, 1.10, 1.10, 1.20, 1.29, 1.36, 1.40, 1.41, 1.44, 1.45, 1.62, 1.67, 1.69, 1.78, 1.82, 2.11, 2.13, 2.14, 2.24, 2.29, 2.34, 2.40, 2.46, 2.70, 2.83, 2.98, 3.00, 3.30, 3.53, 3.70, 3.86, 3.90, 3.91, 3.98, 5.01, 5.23, 6.05, 6.12, 10.41, 10.73) # P-P plot average - mean(data) lambda- (1/average) e - c(1:70) f - c((e-.5)/70) Fx- c(1 - exp(-lambda*data)) g - sort(Fx) plot(f,g) = end Awaiting your positive reply. Regards. Priti. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] can I call user-created functions without source() ?
Indeed, some folk say that the documentation should be written before the code... Sean On 19/06/06, Duncan Murdoch [EMAIL PROTECTED] wrote: 2. If you use the package system, you will be encouraged to create man pages for your functions. This is work, but I think it pays off in the end. I often find that when I document a function I realize an error in the design, and I end up improving it. It's also useful to have documentation for functions that you don't use every day, or when using functions written by someone else. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] how to successfully remove missing values for a repeated measures analysis
Spencer, A number of times I've been wrecking my head trying to solve a problem, and when I thought I'd tried everything possible (all the docs that I can think of, web searches etc...) I start re-reading the posting guide (I've no idea how many times I've read it now)... and 9 times out of 10, the answer is there for me... :-) Like yesterday... I had forgotten about the posting-guide (why Sean? why?) and I was trying to get windows to startup with a default entry for CRAN so I don't have to select *everytime*... which was starting to annoy me... a lot... eventually after running out of options I started down the posting guide route... and it turns out I've been starting using --vanilla, so I turned that off and hey presto... it worked... :-) Takeaway... now I read the posting guide earlier in the problem solving process :-) cheers, Sean On 20/06/06, Spencer Graves [EMAIL PROTECTED] wrote: I don't see enough information for me to diagnose the problem. If it were my problem, I'd print out some assessment of the results of every step you've described below. This should expose the step in which things disappear. Hope this helps. Spencer Graves p.s. I almost never attach a data.frame. It can be done, but I just find the mechanisms too subtle for my brain. I use with routinely, but I know I can't include an assignment inside with, because with creates a frame and then discards it after it's done. Anything I created inside with gets thereby discarded. p.p.s. If you'd like more help from this listserve, PLEASE do read the posting guide! www.R-project.org/posting-guide.html. People who follow that posting guide seem more likely to solve their own problems in the process of preparing a question for the listserve. If that fails, they are more likely to get a useful reply quickly. Clean, crisp questions sometimes generate a feeding frenzy of replies. Questions that are harder to understand often get ignored. Bob Green wrote: Hello , I am hoping for some advice. I want to run a repeated measures ANOVA. The primary problem is that my attempt to remove missing values created a dataset of missing values. The data set consists of 92 rows (1 row per participant) x 186 variables. The steps of the analysis undertaken are outlined below (#). Any assistance is appreciated in relation to how to remove the missing values so the analysis is run. Feedback regarding the prior steps is also welcomed . Bob Green #Step 1 study1dat - read.csv(c:\\study1.csv,header=T) attach (study1dat) outcome - c(t1frq, t2frq,t3frq,t4frq) grp - factor( rep(group, 2,length=368) ) time - gl(4,92,length=368) subject - gl(92,1,length=368) data.frame(subject, grp, time, outcome) # there are 3 missing values in $outcome #Step 2 - create a new data frame removing missing values from variable $outcome d2-study1dat[!is.na(outcome),] #the previous step generates NA values. #Step 3 detach original data set attach dataset without missing values detach(study1dat) attach(d2) The following object(s) are masked _by_ .GlobalEnv : time The following object(s) are masked from package:datasets : sleep #Step 4 run analysis library(nlme) anova(lme(outcome ~ grp * time, random = ~ 1 | subject)) #The data is the format below subject grp time outcome 1 1 01 4 2 2 01 3 3 3 01 7 4 4 01 0 5 5 01 1 6 6 01 7 7 7 01 7 8 8 01 7 9 9 01 7 10 10 01 5 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] a question about a simply figure
Hi Zhang Jian, If I say plot(t$no,t$leiji), then the lower bound is neatly set at about 25... (I'm not sure how I can measure the bounds on the current plot - but I'm sure it can be found!) You can set the bounds on the y-axis to be between 0 and 100 by saying plot(fre$no,fre$leiji,ylim=c(0,100)) cheers, Sean On 02/06/06, zhang jian [EMAIL PROTECTED] wrote: I think there is a question in R. I donot know the reason. This is my data about comulative percentage figure. The result is not right. The first point (no=1,leiji=26.94350) in the plot figure was showen in a lower location. Why? Thanks ! fre no leiji 1 1 26.94350 2 2 46.86401 3 3 60.59032 4 4 72.17355 5 5 77.85521 6 6 82.05853 7 7 85.56495 8 8 87.64378 9 9 89.42997 10 10 91.01150 11 11 92.32409 12 12 93.48106 13 13 94.62618 14 14 95.47530 15 15 96.25000 16 16 96.71516 17 17 97.14648 18 18 97.51522 19 19 97.86367 20 20 98.10217 21 21 98.32544 22 22 98.51658 23 23 98.69756 24 24 98.85995 25 25 99.00372 26 26 99.11874 27 27 99.22192 28 28 99.32510 29 29 99.42659 30 30 99.49932 31 31 99.56360 32 32 99.61265 33 33 99.66001 34 34 99.70737 35 35 99.75304 36 36 99.79702 37 37 99.83424 38 38 99.86130 39 39 99.88836 40 40 99.91373 41 41 99.93572 42 42 99.95264 43 43 99.96448 44 44 99.97294 45 45 99.97970 46 46 99.98647 47 47 99.99154 48 48 99.99493 49 49 99.99662 50 50 99.99831 51 51 100.0 plot(fre$no,fre$leiji) [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] plot xy data with error bars
Hi Petr, I just needed to add an 'attach/detach' to get it going. A-data.frame(x=1:10, y=1:10, erx=rnorm(10)^2, ery=rnorm(10)^2) attach(A) plot(x,y) arrows(x,y,x+erx/10,y, angle=90, length=.1) arrows(x,y,x-erx/10,y, angle=90, length=.1) arrows(x,y,x,y-ery/10, angle=90, length=.1) arrows(x,y,x,y+ery/10, angle=90, length=.1) detach(A) cheers and thanks! Sean On 25/05/06, Petr Pikal [EMAIL PROTECTED] wrote: Hi On 25 May 2006 at 1:08, Tibi Codilean wrote: Date sent: Thu, 25 May 2006 01:08:20 +0100 From: Tibi Codilean [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] plot xy data with error bars Dear All, I have x,y data with errors associated with both x and y. What would be the easiest way of creating plots with both x and y error bars? I know there is some function(s) in some package(s) for error bar plotting but if you want to use your own, use arrows A-data.frame(x=1:10, y=1:10, erx=rnorm(10)^2, ery=rnorm(10)^2) plot(x,y) arrows(x,y,x+erx/10,y, angle=90, length=.1) arrows(x,y,x-erx/10,y, angle=90, length=.1) arrows(x,y,x,y-ery/10, angle=90, length=.1) arrows(x,y,x,y+ery/10, angle=90, length=.1) HTH Petr Thanks __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html 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 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] win2k memory problem with merge()'ing repeatedly (long email)
Good afternoon, I have a 63 small .csv files which I process daily, and until two weeks ago they processed just fine and only took a matter of moments and had non noticeable memory problem. Two weeks ago they have reached 318 lines and my script broke. There are some missing-values in some of the files. I have tried hard many times over the last two weeks to create a small repeatable example to give you but I've failed - unless I use my data it works fine... :-( Am I missing something obvious? (again) A line in a typical file has lines which look like : 01/06/2005,1372 Though there are three files which have two values (files 3,32,33) and these have lines which look like... 01/06/2005,1766, or 15/05/2006,289,114 a1 - read.csv(file1.csv,header=F) etc... a63 - read.csv(file63.csv,header=F) names(a1) - c(mdate,file1.column.description) atot - merge(a1,a2,all=T) followed by repeatedly doing... atot - merge(atot, a3,all=T) atot - merge(atot, a4,all=T) etc... I normally start R with --vanilla. What appears to happen is that atot doubles in size each iteration and just falls over due to lack of memory at about i=17... even though the total memory required for all of these individual a1...a63 is only 1001384 bytes (doing an object.size() on a1..a63) at this point I've been trying to pin down this problem for two weeks and I just gave up... The following works fine as I'd expect with minimal memory usage... for (i in 3:67) { datelist - as.Date(start.date)+0:(count-1) #remove a couple of elements... datelist - datelist[-(floor(runif(nacount)*count))] a2 - as.data.frame(datelist) names(a2) - mdate vname - paste(value, i, sep=) a2[vname] - runif(length(datelist)) #a2[floor(runif(nacount)*count), vname] - NA # atot - merge(atot,a2,all=T) i - 2 a.eval.text - paste(merge(atot, a, i, , all=T), sep=) cat(a.eval.text is: -, a.eval.text, -\n, sep=) atot - eval(parse(text=a.eval.text)) cat(i:, i, , gc(), \n) } this works fine... but on my files (as per attached 'lastsave.txt' file) it just gobbles memory. Am I doing something wrong? I (wrongly?) expected that repeatedly merge(atot,aN) would only increase the memory requirement linearly (with jumps perhaps as we go through a 2^n boundary)... which is what happens when merging simulated data.frames as above... no problem at all and its really fast... The attached text file shows a (slightly edited) session where the memory required by the merge() operation just doubles with each use... and I can only allow it to run until i=17!!! I've even run it with gctorture() set on... with similar, but excruciatingly slow results... Is there any relevant info that I'm missing? Unfortunately I am not able to post the contents of the files to a public list like this... As per a previous thread, I know that I can use a list to handle these dataframes - but I had difficulty with the syntax of a list of dataframes... I'd like to know why the memory requirements for this merge just explode... cheers, (and thanks in advance!) Sean O'Riordain == version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status Patched major 2 minor 3.0 year 2006 month 05 day09 svn rev38014 language R version.string Version 2.3.0 Patched (2006-05-09 r38014) Running on Win2k with 1Gb ram. I also tried it (with the same results) on 2.2.1 and 2.3.0. R : Copyright 2006, The R Foundation for Statistical Computing Version 2.3.0 Patched (2006-05-09 r38014) ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. gc() used (Mb) gc trigger (Mb) max used (Mb) Ncells 178186 4.8 407500 10.9 35 9.4 Vcells 73112 0.6 786432 6.0 333585 2.6 # take the information in the .csv files created from the emails setwd(C:/Documents and Settings/c_oriordain_s/My Documents/pasip/mms/mms_emails) # the input file from Amdocs (as supplied by revenue assurance) amdocs_csv_filename - amdocs_volumes_revised4.csv # where shall we put the output plot file copypath - ient1dfs001\\general\\Process Improvement Projects\\Process Improvement Projects Repository\\Active Projects\\MMS\\01 Measure\\ # set to F (false) instead of T (true) if you're just tricking around and you don't # want to be copying over
Re: [R] win2k memory problem with merge()'ing repeatedly (long email)
Thank you very much indeed Bogdan! a2[duplicated(a2$mdate),] value2 mdate 3180 2006-05-10 3220 2006-05-13 3240 2006-05-14 3260 2006-05-15 3280 2006-05-16 What a relief to know what is causing this problem... now to sort out the root cause! cheers and thanks again! Sean On 22/05/06, bogdan romocea [EMAIL PROTECTED] wrote: Repeated merge()-ing does not always increase the space requirements linearly. Keep in mind that a join between two tables where the same value appears M and N times will produce M*N rows for that particular value. My guess is that the number of rows in atot explodes because you have some duplicate values in your files (having the same duplicate date in each data frame would cause atot to contain 4, then 8, 16, 32, 64... rows for that date). -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sean O'Riordain Sent: Monday, May 22, 2006 10:12 AM To: r-help Subject: [R] win2k memory problem with merge()'ing repeatedly (long email) Good afternoon, I have a 63 small .csv files which I process daily, and until two weeks ago they processed just fine and only took a matter of moments and had non noticeable memory problem. Two weeks ago they have reached 318 lines and my script broke. There are some missing-values in some of the files. I have tried hard many times over the last two weeks to create a small repeatable example to give you but I've failed - unless I use my data it works fine... :-( Am I missing something obvious? (again) A line in a typical file has lines which look like : 01/06/2005,1372 Though there are three files which have two values (files 3,32,33) and these have lines which look like... 01/06/2005,1766, or 15/05/2006,289,114 a1 - read.csv(file1.csv,header=F) etc... a63 - read.csv(file63.csv,header=F) names(a1) - c(mdate,file1.column.description) atot - merge(a1,a2,all=T) followed by repeatedly doing... atot - merge(atot, a3,all=T) atot - merge(atot, a4,all=T) etc... I normally start R with --vanilla. What appears to happen is that atot doubles in size each iteration and just falls over due to lack of memory at about i=17... even though the total memory required for all of these individual a1...a63 is only 1001384 bytes (doing an object.size() on a1..a63) at this point I've been trying to pin down this problem for two weeks and I just gave up... The following works fine as I'd expect with minimal memory usage... for (i in 3:67) { datelist - as.Date(start.date)+0:(count-1) #remove a couple of elements... datelist - datelist[-(floor(runif(nacount)*count))] a2 - as.data.frame(datelist) names(a2) - mdate vname - paste(value, i, sep=) a2[vname] - runif(length(datelist)) #a2[floor(runif(nacount)*count), vname] - NA # atot - merge(atot,a2,all=T) i - 2 a.eval.text - paste(merge(atot, a, i, , all=T), sep=) cat(a.eval.text is: -, a.eval.text, -\n, sep=) atot - eval(parse(text=a.eval.text)) cat(i:, i, , gc(), \n) } this works fine... but on my files (as per attached 'lastsave.txt' file) it just gobbles memory. Am I doing something wrong? I (wrongly?) expected that repeatedly merge(atot,aN) would only increase the memory requirement linearly (with jumps perhaps as we go through a 2^n boundary)... which is what happens when merging simulated data.frames as above... no problem at all and its really fast... The attached text file shows a (slightly edited) session where the memory required by the merge() operation just doubles with each use... and I can only allow it to run until i=17!!! I've even run it with gctorture() set on... with similar, but excruciatingly slow results... Is there any relevant info that I'm missing? Unfortunately I am not able to post the contents of the files to a public list like this... As per a previous thread, I know that I can use a list to handle these dataframes - but I had difficulty with the syntax of a list of dataframes... I'd like to know why the memory requirements for this merge just explode... cheers, (and thanks in advance!) Sean O'Riordain == version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status Patched major 2 minor 3.0 year 2006 month 05 day09 svn rev38014 language R version.string Version 2.3.0 Patched (2006-05-09 r38014) Running on Win2k with 1Gb ram. I also tried it (with the same results) on 2.2.1 and 2.3.0. R
Re: [R] Unreadable labels
Hi Maciej, fyi - on winxp-pro 2.3.0-patched and up to date MASS - I can clearly read the labels, except the start of the word 'black' is clipped, but the font size is fine. cheers, Sean On 21/05/06, Maciej Bliziński [EMAIL PROTECTED] wrote: Playing around with examples from MASS4, I found a font problem in the mosaicplot in R-2.3.0. It doesn't happen in other plots. Running this example from MASS4, page 326... library(MASS) caith1 - as.matrix(caith) names(dimnames(caith1)) - c(eyes, hair) mosaicplot(caith1, color = TRUE) ...I get an image as attached. The column and row labels are unreadable. It is true for both x11() and png() devices. I can adjust the font sizes with the cex.axis argument and get a readable labels if the parameter is correct (0.8 works here), but the general problem it's not really the font sizes. There are small versions of the screen fonts that _are_ readable. I believe I should be able to get small, but readable labels. It's not possible to specify a font, because mosaicplot doesn't accept the font.axis parameter. Looking at the demo(graphics), I can also recognize some unreadable labels. Do you think it's only the matter of the X-Window system? Installed fonts? Any hints appreciated. Regards, Maciej -- Maciej Bliziński [EMAIL PROTECTED] http://automatthias.wordpress.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 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] merge problem... extra lines appear in the presence of NAs
Good morning! I've searched the docs etc... Am I doing something wrong or is this a bug? I'm doing a merge of two dataframes and getting extra rows in the resulting dataframe - the dataframes being merged might have NAs... count - 10 nacount - 3 a1 - as.data.frame(as.Date(2005-06-01)+0:(count-1)) names(a1) - mdate a1$value - runif(count) a1[floor(runif(nacount)*count),]$value - NA a2 - as.data.frame(as.Date(2005-06-01)+0:(count-1)) names(a2) - mdate a2$value2 - runif(count) #a2[floor(runif(nacount)*count),]$value2 - NA a1 mdate value 1 2005-06-09NA 2 2005-06-02 0.5287683 3 2005-06-03 0.7563833 4 2005-06-09NA 5 2005-06-05 0.1027646 6 2005-06-06 0.7775884 7 2005-06-07 0.2993592 8 2005-06-09NA 9 2005-06-09 0.7434682 10 2005-06-10 0.2096477 a2 mdatevalue2 1 2005-06-01 0.5347852 2 2005-06-02 0.9322765 3 2005-06-03 0.9106499 4 2005-06-04 0.6810564 5 2005-06-05 0.5871867 6 2005-06-06 0.8123808 7 2005-06-07 0.9675379 8 2005-06-08 0.9470369 9 2005-06-09 0.7493767 10 2005-06-10 0.8864103 atot - merge(a1,a2,all=T) However, I find the following results to be quite un-intuitive - are they correct? May I draw your attention to lines 9:12... Should lines 9:11 be there? atot mdate valuevalue2 1 2005-06-01NA 0.5347852 2 2005-06-02 0.5287683 0.9322765 3 2005-06-03 0.7563833 0.9106499 4 2005-06-04NA 0.6810564 5 2005-06-05 0.1027646 0.5871867 6 2005-06-06 0.7775884 0.8123808 7 2005-06-07 0.2993592 0.9675379 8 2005-06-08NA 0.9470369 9 2005-06-09NA 0.7493767 10 2005-06-09NA 0.7493767 11 2005-06-09NA 0.7493767 12 2005-06-09 0.7434682 0.7493767 13 2005-06-10 0.2096477 0.8864103 Note with no NAs, it works perfectly and as expected... a1 - as.data.frame(as.Date(2005-06-01)+0:(count-1)) names(a1) - mdate a1$value - runif(count) #a1[floor(runif(nacount)*count),]$value - NA atot - merge(a1,a2,all=T) atot mdate valuevalue2 1 2005-06-01 0.35002519 0.5347852 2 2005-06-02 0.76318940 0.9322765 3 2005-06-03 0.32759570 0.9106499 4 2005-06-04 0.47218729 0.6810564 5 2005-06-05 0.74435374 0.5871867 6 2005-06-06 0.81415290 0.8123808 7 2005-06-07 0.04774783 0.9675379 8 2005-06-08 0.21799101 0.9470369 9 2005-06-09 0.99472758 0.7493767 10 2005-06-10 0.41974293 0.8864103 R started in each case with --vanilla _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status Patched major 2 minor 3.0 year 2006 month 05 day11 svn rev38037 language R version.string Version 2.3.0 Patched (2006-05-11 r38037) win-xp-pro sp2 - binary installs from CRAN it works in a similar way if I say atot - merge(a1,a2,by.x=mdate,by.y=mdate,all=T) or even atot - merge(a1,a2,by=mdate,all=T) also tested on versions 2.2.1, 2.3.0 cheers, Sean O'Riordain (ps. ctrl-v paste wouldn't work on 2.4.0-dev downloaded this morning - didn't try very hard though) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] (Nothing to do with) merge problem... extra lines appear in the presence of NAs
Apologies all! Thank you Brian Sean On 20/05/06, Prof Brian Ripley [EMAIL PROTECTED] wrote: I think you forgot to read over your own message before sending it: take a look at a1 which has FOUR rows with mdate == 2005-06-09. Those correspond to rows to 9:12 in the result, as you are merging on 'mdate'. You example is not reproducible, of course, since you used random values. Perhaps you intended a1[floor(runif(nacount)*count), value] - NA On Sat, 20 May 2006, Sean O'Riordain wrote: Good morning! [Or afternoon in Europe, ] I've searched the docs etc... Am I doing something wrong or is this a bug? I'm doing a merge of two dataframes and getting extra rows in the resulting dataframe - the dataframes being merged might have NAs... count - 10 nacount - 3 a1 - as.data.frame(as.Date(2005-06-01)+0:(count-1)) names(a1) - mdate a1$value - runif(count) a1[floor(runif(nacount)*count),]$value - NA a2 - as.data.frame(as.Date(2005-06-01)+0:(count-1)) names(a2) - mdate a2$value2 - runif(count) #a2[floor(runif(nacount)*count),]$value2 - NA a1 mdate value 1 2005-06-09NA 2 2005-06-02 0.5287683 3 2005-06-03 0.7563833 4 2005-06-09NA 5 2005-06-05 0.1027646 6 2005-06-06 0.7775884 7 2005-06-07 0.2993592 8 2005-06-09NA 9 2005-06-09 0.7434682 10 2005-06-10 0.2096477 a2 mdatevalue2 1 2005-06-01 0.5347852 2 2005-06-02 0.9322765 3 2005-06-03 0.9106499 4 2005-06-04 0.6810564 5 2005-06-05 0.5871867 6 2005-06-06 0.8123808 7 2005-06-07 0.9675379 8 2005-06-08 0.9470369 9 2005-06-09 0.7493767 10 2005-06-10 0.8864103 atot - merge(a1,a2,all=T) However, I find the following results to be quite un-intuitive - are they correct? May I draw your attention to lines 9:12... Should lines 9:11 be there? atot mdate valuevalue2 1 2005-06-01NA 0.5347852 2 2005-06-02 0.5287683 0.9322765 3 2005-06-03 0.7563833 0.9106499 4 2005-06-04NA 0.6810564 5 2005-06-05 0.1027646 0.5871867 6 2005-06-06 0.7775884 0.8123808 7 2005-06-07 0.2993592 0.9675379 8 2005-06-08NA 0.9470369 9 2005-06-09NA 0.7493767 10 2005-06-09NA 0.7493767 11 2005-06-09NA 0.7493767 12 2005-06-09 0.7434682 0.7493767 13 2005-06-10 0.2096477 0.8864103 Note with no NAs, it works perfectly and as expected... a1 - as.data.frame(as.Date(2005-06-01)+0:(count-1)) names(a1) - mdate a1$value - runif(count) #a1[floor(runif(nacount)*count),]$value - NA atot - merge(a1,a2,all=T) atot mdate valuevalue2 1 2005-06-01 0.35002519 0.5347852 2 2005-06-02 0.76318940 0.9322765 3 2005-06-03 0.32759570 0.9106499 4 2005-06-04 0.47218729 0.6810564 5 2005-06-05 0.74435374 0.5871867 6 2005-06-06 0.81415290 0.8123808 7 2005-06-07 0.04774783 0.9675379 8 2005-06-08 0.21799101 0.9470369 9 2005-06-09 0.99472758 0.7493767 10 2005-06-10 0.41974293 0.8864103 R started in each case with --vanilla _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status Patched major 2 minor 3.0 year 2006 month 05 day11 svn rev38037 language R version.string Version 2.3.0 Patched (2006-05-11 r38037) win-xp-pro sp2 - binary installs from CRAN it works in a similar way if I say atot - merge(a1,a2,by.x=mdate,by.y=mdate,all=T) or even atot - merge(a1,a2,by=mdate,all=T) also tested on versions 2.2.1, 2.3.0 cheers, Sean O'Riordain (ps. ctrl-v paste wouldn't work on 2.4.0-dev downloaded this morning - didn't try very hard though) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Precision in estimating log
Anthony, in the same way that we're not allowed to say if(x==0) if x is a real number, we can't say that 0.05=1-0.95... as 1-0.95 is not represented as a base 10 number on the computer, but in some base 2^i depending on your computer...and the representation is not necessarily exact... i.e. one-third (1/3) isn't representable exactly as a decimal number, but I'd guess that it is in some other base... I know it only answers part of your question... but perhaps that helps? cheers, Sean On 19/05/06, Gichangi, Anthony [EMAIL PROTECTED] wrote: Hi R-users, I have the following code: f -function(x,p)sqrt(-(x^2)-2*log(1-p)) r1 -sqrt(-2*log(1-0.95)) r2 -sqrt(-2*log(0.05)) on executing i get the following results f(r1,0.95) [1] 0 f(r2,0.95) [1] NaN Warning message: NaNs produced in: sqrt(-(x^2) - 2 * log(1 - p)) I tried to track the problem and found that the answer to log(0.05) is different from the answer to log(1-0.95) which is ofcourse not true and hence it causes problems in the code print(log(0.05),digit=22) [1] -2.9957322735539909 print(log(1-0.95),digit=22) [1] -2.99573227355399 Any possible explanation ? Regards Anthony __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] uniform and clumped point plots
Perhaps you're looking for something along the lines of Sobol sequences - refer Section 7.7 of Numerical Recipes in C by Press et al. Sean On 18/05/06, Ben Bolker [EMAIL PROTECTED] wrote: Beutel, Terry S Terry.Beutel at dpi.qld.gov.au writes: I am trying to generate two dimensional random coordinates. For randomly distributed data I have simply used xy-cbind(runif(100),runif(100)) However I also want to generate coordinates that are more uniformly distributed, and coordinates that are more contagiously distributed than the above. here are some pictures I made for a talk recently, using the Poisson cluster process function from splancs and the Strauss process from spatial (I think) library(splancs) library(spatial) set.seed(1001) sq - as.matrix(data.frame(x=c(0,1,1,0,0),y=c(0,0,1,1,0))) p.cl - pcp.sim(rho=10,m=10,s2=0.001,region.poly=sq) plot(p.cl) n - nrow(p.cl) p.ran - matrix(runif(2*n),nrow=n,dimnames=list(NULL,c(x,y))) ppregion() p.reg - Strauss(n,c=0.1,r=0.1) p.reg - matrix(c(p.reg$x,p.reg$y),nrow=n,dimnames=list(NULL,c(x,y))) all - data.frame(rbind(p.cl,p.ran,p.reg), tr=rep(c(clustered,random,regular),each=n)) library(lattice) lattice.options(default.theme = ltheme) ## set as default ltheme - col.whitebg() ltheme$xyplot.background$col - transparent ## change strip bg trellis.par.set(theme=col.whitebg()) print(xyplot(y~x|tr,data=all,layout=c(3,1),aspect=iso,scales=list(draw=FALSE), bg=transparent,pch=16)) Ben Bolker __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Please help me to combine two datasets.
merge(data.set.1, data.set.2) but how do I know which rows to drop in ds1? if data.set.2 had dates, you could say merge(data.set.1, data.set.2, by.x=Date, by.y=Date, all=T) or do you just want to drop the first length(data.set.1)-length(data.set.2) from data.set.1? do you have NA values? cheers, Sean On 11/05/06, Arun Kumar Saha [EMAIL PROTECTED] wrote: Dear r-users, Suppose I have two data sets data set-1 Date height 1/11/2005 10 2/11/2005 23 3/11/2005 54 4/11/2005 21 5/11/2005 22 data set-2 weight 32 45 11 Now I want to combine this two data sets. i.e. i want to see: Date height weight --- 3/11/2005 54 32 4/11/2005 21 45 5/11/2005 22 11 Can any one give me the required r-code to perform this? Thanks and regards, Arun [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] data input strategy - lots of csv files
Good morning, I have currently 63 .csv files most of which have lines which look like 01/06/05,23445 Though some files have two numbers beside each date. There are missing values, and currently the longest file has 318 rows. (merge() is losing the head and doing runaway memory allocation - but thats another question - I'm still trying to pin that issue down and make a small repeatable example) Currently I'm reading in these files with lines like a1 - read.csv(daft_file_name_1.csv,header=F) ... a63 - read.csv(another_silly_filename_63.csv,header=F) and then i'm naming the columns in these like... names(a1)[2] - silly column name ... names(a63)[2] - daft column name then trying to merge()... atot - merge(a1, a2, all=T) and then using language manipulation to loop atot - merge(atot, a3, all=T) ... atot - merge(atot, a63, all=T) etc... followed by more language manipulation for() { rm(a1) } etc... i.e. for (i in 2:63) { atot - merge(atot, eval(parse(text=paste(a, i, sep=))), all=T) # eval(parse(text=paste(a,i,[1] - NULL,sep=))) cat(i is , i, gc(), \n) # now delete these 63 temporary objects... # e.g. should look like rm(a33) eval(parse(text=paste(rm(a,i,), sep=))) } eventually getting a dataframe with the first column being the date, and the subsequent 63 columns being the data... with missing values coded as NA... so my question is... is there a better strategy for reading in lots of small files (only a few kbytes each) like that which are timeseries with missing data... which doesn't go through the above awkwardness (and language manipulation) but still ends up with a nice data.frame with NA values correctly coded etc. Many thanks, Sean O'Riordain __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Please help me to combine two datasets.
Hi Arun, so to clarify: you want to drop the first length(data.set.1)-length(data.set.2) rows... so you might say... new.ds1 - data.set.1[(-(length(data.set.1)-length(data.set.2)),] and then add a new column... new.ds.combined - cbind(new.ds1, data.set.2) cheers, Sean On 11/05/06, Arun Kumar Saha [EMAIL PROTECTED] wrote: Dear Sean, Thanks for this reply. But my problem is not solved. Actually I want to drop first two rows from dataset-1 and then combine them. Can you give me any idea? Thanks and regards, Arun On 5/11/06, Sean O'Riordain [EMAIL PROTECTED] wrote: merge(data.set.1, data.set.2) but how do I know which rows to drop in ds1? if data.set.2 had dates, you could say merge(data.set.1, data.set.2, by.x=Date, by.y=Date, all=T) or do you just want to drop the first length(data.set.1)-length(data.set.2) from data.set.1? do you have NA values? cheers, Sean On 11/05/06, Arun Kumar Saha [EMAIL PROTECTED] wrote: Dear r-users, Suppose I have two data sets data set-1 Date height 1/11/2005 10 2/11/2005 23 3/11/2005 54 4/11/2005 21 5/11/2005 22 data set-2 weight 32 45 11 Now I want to combine this two data sets. i.e. i want to see: Date height weight --- 3/11/2005 54 32 4/11/2005 21 45 5/11/2005 22 11 Can any one give me the required r-code to perform this? Thanks and regards, Arun [[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 -- Arun Kumar Saha, M.Sc.[C.U.] S T A T I S T I C I A N[Analyst] RISK MANAGEMENT DIVISION Transgraph Consulting [ www.transgraph.com] Hyderabad, INDIA Contact # Home: (91-033) 25558038 Office: (91-040) 30685012 Ext. 17 FAX: (91-040) 55755003 Mobile: 919849957010 E-Mail: [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
Re: [R] Boxplot and range of x-axis
Hi Rainer, boxplot(liste1,ylim=c(1,6)) boxplot(liste2,ylim=c(1,6)) or would you prefer boxplot(liste1,liste2) cheers, S/ On 11/05/06, Rainer Hahnekamp [EMAIL PROTECTED] wrote: Hello there, could somebody help me with this: I have to create a lot of boxplots but with same range concerning the x-axis. For example I have following data: liste1 - c(3,4,5,3,3,4,4) liste2 - c(1,2,3,4,6) png(file = liste1.png) boxplot(liste1) png(file = liste2.png) boxplot(liste2) q() Works perfectly, but what I need would be that both boxplots have their x-axis from 1-6. Hopefully you could give me a hint.B Greetings, -Rainer Hahnekamp __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] data input strategy - lots of csv files
Thank you folks - most helpful as always! Now I have a bit of studying to do :-) I've never really understood before how to use lapply (or anyother apply) so this gives me a real problem relating to my own to work with! Thanks again, Sean On 11/05/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: Assuming: my.files - c(file1.csv, file2.csv, ..., filen.csv) use read.zoo in the zoo package and merge.zoo (which can do a multiway merge): library(zoo) do.call(merge, lapply(my.files, read.zoo, ...any.other.read.zoo.args...)) After loading zoo see: vignette(zoo) ?read.zoo ?merge.zoo On 5/11/06, Sean O'Riordain [EMAIL PROTECTED] wrote: Good morning, I have currently 63 .csv files most of which have lines which look like 01/06/05,23445 Though some files have two numbers beside each date. There are missing values, and currently the longest file has 318 rows. (merge() is losing the head and doing runaway memory allocation - but thats another question - I'm still trying to pin that issue down and make a small repeatable example) Currently I'm reading in these files with lines like a1 - read.csv(daft_file_name_1.csv,header=F) ... a63 - read.csv(another_silly_filename_63.csv,header=F) and then i'm naming the columns in these like... names(a1)[2] - silly column name ... names(a63)[2] - daft column name then trying to merge()... atot - merge(a1, a2, all=T) and then using language manipulation to loop atot - merge(atot, a3, all=T) ... atot - merge(atot, a63, all=T) etc... followed by more language manipulation for() { rm(a1) } etc... i.e. for (i in 2:63) { atot - merge(atot, eval(parse(text=paste(a, i, sep=))), all=T) # eval(parse(text=paste(a,i,[1] - NULL,sep=))) cat(i is , i, gc(), \n) # now delete these 63 temporary objects... # e.g. should look like rm(a33) eval(parse(text=paste(rm(a,i,), sep=))) } eventually getting a dataframe with the first column being the date, and the subsequent 63 columns being the data... with missing values coded as NA... so my question is... is there a better strategy for reading in lots of small files (only a few kbytes each) like that which are timeseries with missing data... which doesn't go through the above awkwardness (and language manipulation) but still ends up with a nice data.frame with NA values correctly coded etc. Many thanks, Sean O'Riordain __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Newbie question about read.table
Hi David, you might need to either: a) attach(birthweight) or b) glm(low~age,binomial, data=birthweight) refer ?attach / ?glm cheers, Sean On 11/05/06, David Kaplan [EMAIL PROTECTED] wrote: Here is the code with the error birthweight - read.table(c:/bw.dat, header = T) summary(glm(low~age,binomial)) Error in eval(expr, envir, enclos) : object low not found The read.table function works fine and when look at the data it shows the variable names across the top. The data come from SPSS which I read out into a .dat file. Thanks - Original Message - From: Sean O'Riordain [EMAIL PROTECTED] To: David Kaplan [EMAIL PROTECTED] Sent: Thursday, May 11, 2006 1:46 PM Subject: Re: [R] Newbie question about read.table Hi David, Can you show us the code that you're trying to use? cheers, Sean On 11/05/06, David Kaplan [EMAIL PROTECTED] wrote: Hi When I use the read.table function with header = T, I notice that it gives me the variable names along the top as I expect. But, when I then attempt an analysis, e.g. regression, it doesn't recognize the variable names. Am I missing a step. Thank you David [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R binaries, platform independent and Design of Experiments
On 02/09/05, Nam-Ky Nguyen [EMAIL PROTECTED] wrote: b) You do NOT want to do numerical computations on software available in Java byte code. You do not want to do heavy numerical computations with R either. Most statistical calculation using R requires a fraction of a second and I cannot see a real difference between say 0.05 second and 0.07 second. NKN. It is my understanding that the problem with Java is that it wasn't written with serious numerical computation in mind - as far as I know only in the latest version have Sun started to be address this issue. The byte code for the java virtual machine has a flawed numerical model which is not fully compliant with the IEEE754 standard - this has nothing to do with speed of computation. Furthermore the integer model is very restrictive when you want to work on random numbers using bit-twiddling. cheers! Sean __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Reference manual is not available in the help menu of the rgui
Actually, I've started reading the reference manual... :-) I printed it out 2-to-a-page and I'm working my way through it, in order to learn about the full capabilities of the base system... I know I'm not going to remember everything, but when I bump into a particular problem, I'll know what type of solutions to use and what sort of keywords to search for... frequently the problem with help is knowing that vital keyword when I in my ignorant non-statistician way want to use another vocabularly... :-) cheers! Sean On 02/09/05, Duncan Murdoch [EMAIL PROTECTED] wrote: Alvarez Pedro wrote: Dear R list, I have installed R 2.1.1 for Windows. In the help menu of the Rgui I can load all manuals except the reference manual. I downloaded the reference manual from the cran-site separately and saved it into the same folder as the other manuals but still it is not available in the menu. How can I solve this problem? Re-install, and this time check the box to install that manual. But as Peter says, it's not really very useful, it's just a collection of man pages from the base packages. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] The Perils of PowerPoint
I can't lay my hands n it at the moment - its around here somewhere, but in Numerical Methods That Work by Forman Acton, the author points out that the result of computation should be insight, not numbers ps. an excellent book if you haven't seen it. https://enterprise.maa.org/ecomtpro/Timssnet/products/TNT_products.cfm cheers, Sean On 02/09/05, Achim Zeileis [EMAIL PROTECTED] wrote: On Fri, 2 Sep 2005 12:27:45 -0500 [EMAIL PROTECTED] wrote: -Original Message- From: ... Robert Baer Sent: Friday, September 02, 2005 11:30 AM It is wrong to blame ANY tool for our own shortcomings! Surely a fortune! thx, added to the devel-version of fortunes. But allow me one remark: Although the above is certainly true, there are computational tools that help us better to realize or avoid our own shortcomings whereas others will make it harder to arrive at the right conclusions. I agree that PowerPoint cannot be blamed for the crash of the space shuttle, but I also see the point that the way presentations are generated in PowerPoint (or graphics in Excel) can easily tempt people into producing presentations/graphics that conceal what is important. This is certainly not an excuse, but I think some criticism (even if phrased a bit provocatively) should be allowed. just my EUR 0.02. Z David L. Reiner __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] memory
Ferran, What are you trying to do with such a large matrix? with 7e9 cells and a linear algorithm which is quite unlikely, your problem solution is likely to take a very long time(tm)... just quickly... at one micro-second per operation (very optimistic?) and 7e9 operations, thats 7e9/1e6/60 [1] 116.6667 minutes... if we're doing something a little more complicated than linear, say O(n^2.5) on a square matrix of 7e9 cells, then we're talking (7e9^.5)^2.5/1e6/60 [1] 33745.92 minutes... As Brian Ripley said, if you really want to to this then you must use another operating system which can handle more than 32-bit addressing, one such would be linux running and built for a 64-bit platform - of which there are a few. cheers! Sean On 30/08/05, Ferran Carrascosa [EMAIL PROTECTED] wrote: Thanks Prof Brian for your answers, I have read about 'ref' package to work with more efficient memory work. Anybody know if this package could help me to work with a 700.000 x 10.000 matrix? I will have problems with ref package on: - Limit of 2 Gb in R for Windows. -The maximum cells in one object 2*10^9 (aprox.) Thanks in advance, -- Ferran Carrascosa 2005/8/30, Prof Brian Ripley [EMAIL PROTECTED]: On Mon, 29 Aug 2005, Ferran Carrascosa wrote: Hi, I have a matrix with 700.000 x 10.000 cells with floating point data. I would like to work with the entire table but I have a lot of memory problems. I have read the ?memory I work with Win 2000 with R2.1.0 The only solution that I have applied is: memory.limit(size=2048) But now my problems are: - I need to work with more than 2 Gb. How I can exceed this limit? Re-read the rw-FAQ, or (preferably) get a more capable OS on a 64-bit CPU. - When apply some algorithms, the maximum cells in one object 2*10^9 (aprox.) is reached. You will never get that many cells (that is the address space in bytes, and they are several bytes each). Please do as the posting guide asks and report accurately what happened. Please could you send me some advises/strategies about the work with large amount of data in R? R have a way to work with less memory needs? Your matrix has 7e09 cells (assuming you are using . as a thousands separator) and needs 5.6e10 bytes to store. Your OS has a memory address limit of 3.2e09 bytes. Don't blame R for being limited by your OS. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] [newbie] Want to perform some simple regressions.
Hi Thomas, I'm not an expert - so I might use incorrect terminology, but hopefully you'll get the picture! Assuming that you've got your data in a .CSV file, you'd first read in your data, where the first three lines might look like... x,y 0,2.205954909440447 1,8.150580118785099 # load the info into a data.frame called mydata mydata - read.csv(mycsvfile.csv,header=TRUE) # now attach to this data.frame, so that the internal attach(mydata) # now do the regression and store it in the object myregr myregr - lm(y~x) # print out the info from myregr myregr # to get more info from myregr use the summary() method... summary(myregr) There is an enormous quantity of documentation available, though it takes a little while to learn to use it properly and get the full effectiveness from it... I strongly recommend that you read the Posting Guide http://www.R-project.org/posting-guide.html which will help you. For more information, have a look at the introduction to R; which is a tad terse in places - so read it slowly :-) Have a look also at the other documentation http://www.r-project.org/other-docs.html In particular I'd recommend John Maindonalds online book at http://cran.r-project.org/other-docs.html cheers! Sean On 28/08/05, Thomas Baruchel [EMAIL PROTECTED] wrote: On Sun, Aug 28, 2005 at 09:48:15AM +0200, Thomas Baruchel wrote: Is R the right choice ? Please, could you step by step show me how you would do on this example (data below) in order to let me I forgot my data :-( 0 2.205954909440447 1 8.150580118785099 2 15.851323727378597 3 22.442795956953574 4 29.358579800271354 5 36.46060528847214 6 43.7516923268591 7 51.223688311610026 8 58.86610205087116 9 66.66821956399055 10 74.61990268453171 11 82.71184423952718 12 90.93560520053082 13 99.28356700194489 14 107.74885489906521 15 116.3252559311549 16 125.00714110112291 17 133.78939523822717 18 142.6673553086964 19 151.63675679510055 20 160.69368733376777 21 169.834546691509 22 179.05601219606618 23 188.35500882314003 24 197.72868324657364 25 207.17438125936408 26 216.68962806440814 27 226.2721110130965 28 235.9196644372003 29 245.63025627606442 30 255.40197624835042 31 265.23302535689197 32 275.12170654792556 33 285.06641637317705 34 295.0656375259694 35 305.1179321414606 36 315.2219357669857 37 325.3763519217964 38 335.5799471767038 39 345.8315466936063 40 356.13003017290697 41 366.4743281636434 42 376.8634186969678 43 387.2963242085816 44 397.77210871999046 45 408.2898752521091 46 418.8487634479048 47 429.44794738349896 48 440.08663354951693 49 450.76405898653184 50 461.479489560246 51 472.2322183636179 52 483.02156423451737 53 493.84687037869463 54 504.707503088911 55 515.6028505520102 56 526.5323217365377 57 537.4953453542455 58 548.4913688894654 59 559.5198576909147 60 570.5802941210067 61 581.6721767581994 62 592.7950196483222 63 603.9483516011882 64 615.1317155291274 65 626.3446678243708 66 637.586724806 67 648.8576269992603 68 660.1568089487967 69 671.4839283904737 70 682.838600952985 71 694.2204526835204 72 705.6291196304554 73 717.0642474479981 74 728.5254910213728 75 740.0125141112243 76 751.5249890160294 77 763.062596251391 78 774.6250242451752 79 786.2119690475241 80 797.8231340548524 81 809.4582297469931 82 821.1169734367211 83 832.7990890309349 84 844.5043068028273 85 856.2323631744205 Regards, -- Thomas Baruchel __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] writing to a fixed format (fortran) file
?sprintf more C than fortran, but you get the idea :-) cheers! Sean On 27/08/05, Duncan Golicher [EMAIL PROTECTED] wrote: Could anyone help with what should be a simple task? I have data as a fixed format (fortran) table. I have no trouble getting it into R using read.table. Each column is separated by a space, including the first column that begins with a space, and aligned. It reads into R as if separated by tabs. However I want to manipulate two columns of data then write the results out into exactly the same fortran format for use in another program. It should be simple, but I've tried a variety of experiments with print, cat and format, none of which have come close. Here is a sample of the data. 1 11 19.5 2.42 0.02 5.81 9.7 0.4 102. 4.8 320. 4.8 2 11 0.0 0.00 0.00 0.00 4.7 -4.0 178. 5.4 301. 0.2 3 11 8.2 1.64 0.08 6.93 6.9 -3.6 275. 2.7 84. -11.1 4 11 0.0 0.00 0.00 0.00 20.6 -4.8 221. 5.6 327. -10.4 5 11 0.0 0.00 0.00 0.00 11.6 8.2 168. 4.3 269. 6.8 6 11 0.0 0.00 0.00 0.00 18.7 16.9 155. 5.6 287. 8.2 7 11 0.0 0.00 0.00 0.00 7.0 2.1 195. 2.7 22. 0.1 8 11 0.0 0.00 0.00 0.00 17.6 6.5 281. 2.0 146. 1.5 9 11 41.2 1.54 0.82 6.96 12.2 7.8 268. 5.5 356. 4.5 10 11 0.0 0.00 0.00 0.00 14.6 -1.4 250. 3.6 344. 6.4 11 11 0.0 0.00 0.00 0.00 14.5 -3.7 300. 0.00. -16.9 12 11 0.0 0.00 0.00 0.00 8.8 -2.6 308. 0.00. 2.9 13 11 0.0 0.00 0.00 0.00 6.4 1.6 226. 3.3 335. 3.8 -- Dr Duncan Golicher Ecologia y Sistematica Terrestre Conservación de la Biodiversidad El Colegio de la Frontera Sur San Cristobal de Las Casas, Chiapas, Mexico Email: [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 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] plotting GAM
Hi Emil, can you give us a working example of what you're trying to do? cheers! Sean ps. as per the posting-guide... :-) On 24/08/05, Tkadlec Emil [EMAIL PROTECTED] wrote: Dear colleagues, I would like to have GAM regression lines (package gam) thicker than the default setting does. Is there any way to change the width of regression line when plotting gam.objects from the package GAM with more than one predictor? Changing lwd parameter in plot function controls all line components, including points making them thicker as well, which is not what I would like to have. Thanks for help. Best, Emil ** Emil Tkadlec Palacky UniversityPrF UP Faculty of Sciencekatedra ekologie Department of Ecology tr. Svobody 26 tr. Svobody 26771 46 OLOMOUC 771 46 Olomouctel. 58 563 4561 Czech Republic email: [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 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] plotting GAM
Emil, I've no clue what gam() does nor how it works, but saying that is it possible to use lines(,lwd=???) in someway and plot on top of the original line? cheers, Sean On 24/08/05, Tkadlec Emil [EMAIL PROTECTED] wrote: Sear Sean, here is the more working example (I use the latest version of everything on my PC): x1-runif(100,-5,5) x2-runif(100,1,50) e-rnorm(100) y-.3*x1-0.5*x2+e mod-gam(y~s(x1)+s(x2)) par(mfrow=c(1,2)) plot(mod,residuals=T,se=T) So you get two figs. My concern is to enlarge the regression line, not the point or enything else. Best, Emil Hi Emil, can you give us a working example of what you're trying to do? cheers! Sean ps. as per the posting-guide... :-) On 24/08/05, Tkadlec Emil [EMAIL PROTECTED] wrote: Dear colleagues, I would like to have GAM regression lines (package gam) thicker than the default setting does. Is there any way to change the width of regression line when plotting gam.objects from the package GAM with more than one predictor? Changing lwd parameter in plot function controls all line components, including points making them thicker as well, which is not what I would like to have. Thanks for help. Best, Emil ** Emil Tkadlec Palacky UniversityPrF UP Faculty of Sciencekatedra ekologie Department of Ecology tr. Svobody 26 tr. Svobody 26771 46 OLOMOUC 771 46 Olomouctel. 58 563 4561 Czech Republic email: [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 ** Emil Tkadlec Palacky UniversityPrF UP Faculty of Sciencekatedra ekologie Department of Ecology tr. Svobody 26 tr. Svobody 26771 46 OLOMOUC 771 46 Olomouctel. 58 563 4561 Czech Republic email: [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
Re: [R] read a table ignoring specific rows ?
Can you read in the entire file as a data.frame; and then construct a new data.frame which excludes some rows? perhaps something along the lines of... fred.file - data.frame() fred.file - edit(fred.file) fred.file colA colB colC 1142 2233 3354 4433 552 25 fred.new - fred.file[fred.file$colC = 3,] fred.new colA colB colC 1142 2233 4433 s/ On 22/08/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Dear R users, First of all sorry for this question, surely quite naive. (I searched on the R site but was unable to find by myself). I have a table, called infile : 1 2 3 4 5 6 7 8 9 I would like to read it and ignore the rows with 1st element 3 I do it now with a for loop, and it's ok, but I was expecting something simpler, like : intable = read.table(infile); newtable = intable[isgoodrow(intable)]; where : isgoodrow = function(therow) {if (therow$V1 3) return(F) else return(T);}; (... but this don't work). So, could somebody please tell me if there is a way to read a table ignoring specific rows, without using a for loop ? ... and if yes how ? Thanks Vincent __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] A. Mani : Avoiding loops
Hi, I'm not sure what you actually want from your email (following the posting guide is a good way of helping you explain things to the rest of us in a way we understand - it might even answer your question! I'm only a beginner at R so no doubt one of our expert colleagues will help me... fred - data.frame() fred - edit(fred) fred A B C D E 1 1 2 X Y 1 2 2 3 G L 1 3 3 1 G L 5 fred[,3] [1] X G G Levels: G X fred[fred[,3]==G,] A B C D E 2 2 3 G L 1 3 3 1 G L 5 so at this point I can create a new dataframe with column 3 (C) == G; either explicitly or implicitly... and if I want to calculate the sum() of column E, then I just say something like... sum(fred[fred[,3]==G,][,5]) [1] 6 now naturally being a bit clueless at manipulating stuff in R, I didn't know how to do this before I started... and you guys only get to see the lines that I typed in and got a successful result... according to section 6 of the Introduction to R manual which comes with R, I could also have said sum(fred[fred$C==G,]$E) [1] 6 Hmmm I wonder would it be reasonable to put an example of this type into section 2.7 of the Introduction to R? cheers! Sean On 18/08/05, A. Mani [EMAIL PROTECTED] wrote: Hello, I want to avoid loops in the following situation. There is a 5-col dataframe with col headers alone. two of the columns are non-numeric. The problem is to calculate statistics(scores) for each element of one column. The functions depend on matching in the other non-numeric column. A B C E F 1 2 X Y 1 2 3 G L 1 3 1 G L 5 and so on ...3+ entries. I need scores for col E entries which depend on conditional implications. Thanks, A. Mani Member, Cal. Math. Soc __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Console
Hi Daniela, Which platform are you working on? If you're working within a console on windows-98, then the answer is entirely different to working under linux or RGui on windows. This is why the Posting Guide says to give platform details :-) cheers! Sean On 18/08/05, Daniela Salvini [EMAIL PROTECTED] wrote: I am at my first steps with R... and I already notice that the console has a quite limited number of lines. Can anyone tell me how to visualise all the information, which is actually present? I only see the last part of the output, which obviosly exceeds the maximum number of rows in the console. Thank you very much for your help! Daniela [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to repeat code snippet for several variables in a data frame?
Sander, consider writing a function to do your plotting, then pass in the dataframe name so... something along the lines of... # create a function which takes two arguments # mydf - a dataframe of a particular format... eg. the abc column is number 4 # i the column we want to aggregate and plot this time around... myplotfn - function(mydf,i) { # body of the function # extract the relevant column - i colval - mydf[3+i] tmp - aggregate(colval, list( mydf$bins, mydf$groups), mean) # grab the name of the column we're working on; eg. abc colnam.r - names(mydf)[3+i] colnames(tmp) - c(bins, groups, colnam.r) tmp #pltName - paste(line_datGrassChem_, colnam.r, .eps, sep=) #postscript(pltName) labs - c(-15/-9,-9/-6,-6/-3,-3/0) sps - trellis.par.get(superpose.symbol) sps$pch - 1:4 trellis.par.set(superpose.symbol, sps) # create the proper formula for plotting something like abc ~ bins myformula - as.formula(paste(colnam.r, ~ bins)) xyplot( myformula, data = tmp, groups = groups, type = list(p, l), scales = list(x = list(labels=labs)), layout = c(1,1), key = list(columns = 4, text = list(paste(unique(tmp$groups))), points = Rows(sps, 1:4) ) ) #dev.off() } # then call it by myplotfn(test,1) myplotfn(test,2) myplotfn(test,3) obviously this can be put in a loop :-) So how did I figure out how to do this? well in the introduction manual it talks about functions... the tricky bit was the substitution of abc into the relevant places... I didn't know how to convert the string formula abc ~ bins into a formula that I could plot, so first off, I looked at ?plot, in there it mentioned ?plot.formula and in there it mentioned the class formula so I said ?formula where it mentioned as.formula()... bingo... this allowed me to say myformula - as.formula(abc ~ bins) So I made this into a learning experience for me :-) I'm relatively new to R... so giving myself little problems like this is a good way of learning R... and hopefully helping somebody else! :-) I'm pretty sure that there is a better way of doing this in R - but this works :-) cheers Sean On 15/08/05, Sander Oom [EMAIL PROTECTED] wrote: Dear all, I have a data frame containing the results of an experiment. Like this: a-seq(1,4,by=1) b-seq(1,2,by=1) test-expand.grid(b,a,a) colnames(test)-c(replicates,bins, groups) test$abc - rnorm(32) test$def - rnorm(32) test$ghi - rnorm(32) test The following code snippet aggregates the data for one variable and then draws a plot: tmp - aggregate(test$abc, list( test$bins, test$groups), mean) colnames(tmp) - c(bins, groups, abc) tmp #pltName - paste(line_datGrassChem_, abc, .eps, sep=) #postscript(pltName) labs - c(-15/-9,-9/-6,-6/-3,-3/0) sps - trellis.par.get(superpose.symbol) sps$pch - 1:4 trellis.par.set(superpose.symbol, sps) xyplot( abc ~ bins, data = tmp, groups = groups, type = list(p, l), scales = list(x = list(labels=labs)), layout = c(1,1), key = list(columns = 4, text = list(paste(unique(tmp$groups))), points = Rows(sps, 1:4) ) ) #dev.off() How can I wrap R code around this code snippet, such that I can repeat the same code snippet for all other variables in the data frame (i.e. def, ghi, etc.). Thanks for your suggestions! Sander. -- Dr Sander P. Oom Animal, Plant and Environmental Sciences, University of the Witwatersrand Private Bag 3, Wits 2050, South Africa Tel (work) +27 (0)11 717 64 04 Tel (home) +27 (0)18 297 44 51 Fax +27 (0)18 299 24 64 Email [EMAIL PROTECTED] Web www.oomvanlieshout.net/sander __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to get a list work in RData file
you know about ?history Sean On 16/08/05, Liaw, Andy [EMAIL PROTECTED] wrote: If you want to keep track of the function call that produced an object, usually you need to do that inside the function that's being called, e.g., test.xy - function(x,y) { + xy - x+y + attr(xy, Call) - match.call() + xy + } xyadd - test.xy(x=2, y=3) xyadd [1] 5 attr(,Call) test.xy(x = 2, y = 3) str(xyadd) atomic [1:1] 5 - attr(*, Call)= language test.xy(x = 2, y = 3) Andy From: Xiyan Lon Dear R-Helper, I want to know how I get a list work which I saved in RData file. For example, test.xy - function(x,y) { +xy - x+y +xy + } xyadd - test.xy(x=2, y=3) xyadd [1] 5 x1 - c(2,43,60,8) y1 - c(91,7,5,30) xyadd1 - test.xy(x=x1, y=y1) xyadd1 [1] 93 50 65 38 save(list = ls(all=TRUE), file = testxy.RData) rm(list=ls(all=TRUE)) load(C:/R/useR/testxy.RData) ls() [1] test.xy x1 xyadd xyadd1 y1 ls.str(pat=xyadd) xyadd : num 5 xyadd1 : num [1:4] 93 50 65 38 When I run, I know the result like above xyadd [1] 5 xyadd1 [1] 93 50 65 38 what I want to know, is there any function to make the result like: xyadd test.xy(x=2, y=3) and xyadd1 test.xy(x=x1, y=y1) Best, Xiyan Lon __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problems runing R CMD check
hi! start - control panel - system - advanced - environmental variables probably better to be working in a directory with no spaces in the path... s/ On 13/08/05, Aleš Žiberna [EMAIL PROTECTED] wrote: Hello! I have a problem checking the package. Firstly, I do not know how to specify the package to check. I tied specify it by supplying the path and by runing the R CMD check in the directory of the package. In addition to that, I get an error bellow. Any suggestions on how to set TMPDIR would be greatly appriciated! C:\Ales\Statistika\Blocno modeliranje\dr\blockmodelingR CMD check * checking for working latex ...Error: environment variable TMPDIR not set (or s et to unusable value) and no default available. at D:\PROGRA~1\R\rw2011\share\perl/R/Utils.pm line 72 Thank you in advance for any help! Ales Ziberna P.S.: I am runing R 2.1.1 on Win XP, SP2. I installed rtools, mingw, perl as suggested in the manuals.Here are some details about R: platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor1.1 year 2005 month06 day 20 language R __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] evaluating string variables
use paste() to construct the file name e.g. fn - paste(i,.mat,sep=) Sean On 12/08/05, Leonardo Sepulveda Durán [EMAIL PROTECTED] wrote: Hello!!! I have a folder (C:/R/) with matrix files, named by number, i.e. 0.mat, 1.mat,...,1250.mat. In this case, they are 5x5 simetric matrices. I would like to compute a property for each matrix and put calculated values into a data frame for posterior ploting and printing. Below there is an example for 7 matrices (0.mat..6.mat) #define data frame L - data.frame(frame=numeric(7), L=numeric(7)) f0-1/(5*(5-1)) # first variable for computation #loop over matrices, Open it , calculate property and put into data frame for(i in 0:6){ m-matrix(scan('C:/R/i.mat', n=5*5),5,5, byrow=TRUE) # load matrix f1-geodist(m) f2-sum(colSums(f1$gdist)) l -f0*f2 # Calculate property L[i+1, ]-c(i,l) # Fill data frame } but the matrix cannot be loaded, because it try to open a file named i.mat. I don`t know how to loop with a counter named 'i', and use it to define the name of the file too. How can i do it? I have not found the way. Leonardo __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] connexion problem getHdata (HMisc)
Hi Anne, does update.packages() work, or does it just hang? cheers! Sean On 11/08/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Sorry about the missing info, I'm just trying to do too many things at the same time! I installed R on my Windows2000 computer (no choice there) . version platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor1.1 year 2005 month06 day 20 language R Hmisc version: 3.0-6 ; On my home computer (LINUX and Windows XT) with the same (latest) R and Hmisc version installed, I had no problem with getHdata... Thanks Anne Frank E Harrell Jr [EMAIL PROTECTED] 09.08.2005 22:19 A [EMAIL PROTECTED] cc r-help@stat.math.ethz.ch Objet Re: [R] connexion problem getHdata (HMisc) [EMAIL PROTECTED] wrote: ** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. ** Hi Just installing R and some packages in my new job; trying to download dataset directly from biostatistics dptm of Vanderbilt University using getHdata from Hmisc I get the following: Error in file (file, r) : connexion openinig not possible Furthermore : connexion to 'biostat.mc.vanderbilt.edu' impossible on port 80 Can one get around this problem? NOTE: I am not an administrator on the system Anne Piotet It is hard for me to help when you provided no code and no output from typing version at the command prompt. You also did not include the version of Hmisc. I tried a small test: library(Hmisc) getHdata(titanic3) and it worked fine, using the most recent Hmisc. Frank tél: 022 809 54 36 e-mail: [EMAIL PROTECTED] Office cantonal de l'assurance-invalidité (OCAI) rue de Lyon 97 1203 Genève GE [[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 -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] solution: package install probs. win-xp. file move
Hi, This is just an FYI documenting a conflict between R and Google-Desktop. The solution was to click on the Google-Desktop icon in the systray and click on Pause Indexing. I also temporarily suspended anti-virus scanning before successfully install.packages(VR) many times without getting an error message. I was getting an intermittant failure when I tried to install a package or update a package under Win-XP-Pro-sp2. There is 5gb of free space on the drive and I'm an admistrator on this machine and most times (but not every time) I tried to upgrade.packages() or install.packages() I got the following error message unable to move temporary installation message. It appears to be a file-locking issue with the Google-Desktop search - ie. during the few seconds that install.packages() creates a file directory tree, google-desktop starts reading these files and then prevents this tree from being moved to its correct place under \library cheers, Sean == Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 I installed todays 2.2.0-pre and I get exactly the same thing. The first time I did it, no problem; I exit out of R-2.2.0-pre (and 2.1.1) and go back into 2.2.0-pre and type 'install.packages(VR)' and I get the unable to move temporary installation. I've searched the archives and the web for the phrase unable to move temporary installation; I've looked for similar bugs at r-bugs and I found nothing. Clearly something to do with file locking on windows - possibly anti-virus? cheers, Sean == e.g. install.packages(VR) --- Please select a CRAN mirror for use in this session --- trying URL 'http://cran.uk.r-project.org/bin/windows/contrib/2.1/VR_7.2-17.zip' Content type 'application/zip' length 1570833 bytes opened URL downloaded 1534Kb bundle 'VR' successfully unpacked and MD5 sums checked The downloaded packages are in C:\Documents and Settings\soriorda\Local Settings\Temp\Rtmp9355\downloaded_packages updating HTML package descriptions Warning message: unable to move temporary installation 'C:\Program Files\R\rw2011\library\file11565\MASS' to 'C:\PROGRA~1\R\rw2011\library\MASS' = R : Copyright 2005, The R Foundation for Statistical Computing Version 2.2.0 Under development (unstable) (2005-08-04 r35153M) install.packages(VR) --- Please select a CRAN mirror for use in this session --- trying URL 'http://cran.uk.r-project.org/bin/windows/contrib/2.2/VR_7.2-17.zip' Content type 'application/zip' length 1570833 bytes opened URL downloaded 1534Kb bundle 'VR' successfully unpacked and MD5 sums checked The downloaded packages are in C:\Documents and Settings\soriorda\Local Settings\Temp\Rtmp10612\downloaded_packages updating HTML package descriptions Warning message: unable to move temporary installation 'C:\Program Files\R\R-2.2.0dev\library\file17748\MASS' to 'C:\PROGRA~1\R\R-22~1.0DE\library\MASS' __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] help regarding functions loops
Hi Rangesh, Perhaps I mis-understand your question, but it could be as simple as... p - 1-exp(-exp(s)) In R, this is vectorized such that a new vector is calculated - one value for each value of s, so p will have the same length as s. In the Introduction to R read up on vectors and how to avoid loops. cheers! Sean On 06/08/05, Rangesh Kunnavakkam [EMAIL PROTECTED] wrote: I am new to R,so excuse me if its too basic. I have a vector of scores S= {s1,s2,s3,sn} n could be very large. I want to find p-value for each score and I have the formula pvalue= 1-exp(-exp(S)) so any ideas how to get this new vector P={p1,p2,p3,p4,p5pn} thankyou in advance Rangesh __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] nnet package for OS X
Hi Lisa, as far as I know, nnet is part of the VR bundle which is a recommended package... refer http://www.stats.bris.ac.uk/R/src/contrib/Descriptions/VR.html so just try library(nnet) and see what happens! cheers! Sean On 02/08/05, Lisa Schweitzer [EMAIL PROTECTED] wrote: Hello every one-- My sincere apologies if I have missed something obvious, but I need to construct some multinomial logit models. I remember using nnet for this in the past, but I am having trouble locating a OS X version of this (it's been a year or so since I had to use it). I found a Windows version, but when I try to install across platforms, it crashes R immediately--no error messages or anything helpful. Can any one direct me to a repository, or alternatively, to another package readily available Mac side that can do simple multinomial logit models? This is basic survey data--nothing fancy needed. All best, Lisa __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R: graphics devices
Alan, I'm not sure what you mean... perhaps plot(y~x) # to the screen pdf(myplot.pdf) plot(y~x) # write the plot to the file dev.off() # close the file dev.off() # close the graphics window s/ On 29/07/05, Clark Allan [EMAIL PROTECTED] wrote: a simple question how does one produce plots on two different graphics devices? / allan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R: graphics devices
actually X11() also works under windows! X11() plot(y~x) X11() plot(q~x) On 29/07/05, Chuck Cleland [EMAIL PROTECTED] wrote: Is this on windows? If so, how about the following: windows() plot(y~x) windows() plot(q~x) For me, this creates two different plot _windows_ and you could tile them to see each side-by-side. But I'm not sure how that would be preferable to having the plots in the same window. What exactly do you mean by different screens? Clark Allan wrote: one could use the par command to plot several plots on 1 graphics device. i would like to do the following: say plot(y~x) on one screen and then plot(q~w) on another screen so that one can see both of them together but not on the same graphics device. Sean O'Riordain wrote: Alan, I'm not sure what you mean... perhaps plot(y~x) # to the screen pdf(myplot.pdf) plot(y~x) # write the plot to the file dev.off() # close the file dev.off() # close the graphics window s/ On 29/07/05, Clark Allan [EMAIL PROTECTED] wrote: a simple question how does one produce plots on two different graphics devices? / allan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 452-1424 (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
Re: [R] How to save the object of linear regression in file and load it later
Hi Bahoo! I've found the R/Rpad Reference Card quite good at helping me find this sort of information... i.e. towards the bottom of the first column of the first page it says... save(file,...) saves the specified ojects (...) in the XDR platform independent binary format if I then say ?save it tells me that ?load is what you're looking for at another date... cheers! Sean On 25/07/05, Bahoo [EMAIL PROTECTED] wrote: Hi, I am using locfit for regression. After I do out = locfit(...), I want to save out in a file, and load it later for prediction. How should I do it? Thanks! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] The steps of building library in R 2.1.1
Just a few thoughts... Good documentation helps everybody - the beginners and the experts (less beginner questions if there is thorough and accessible documentation. I fully appreciate that this is a volunteer effort - I'm just trying to pin down some places where we have documentation issues. Docs can be in a number of different forms - reference, examples, carefully and throughly explained. I personally find it difficult to understand reference type material until I have seen a worked example, and some of the reference material is a little light on the examples for me, and others like me who thrive on examples. The Linux-HOWTO collection are a good example of step-by-step documentation... If you're an expert, then you can read it fast and skip... otherwise you read every line. Since R comes as a computer package and a statistics thingy... the questions on this list come in three forms - those that are very 'package', e.g. how do I reduce the space between two graphs - to the statistics questions how reliable is the coefficient of determination in the presence of outliers (which shouldn't really be asked here), and then the how do I do 'statistic X' in R - how do I calculate a confidence interval around the coefficent of determination in R?. The standard documentation got me so far in learning about R - I got a copy of MASS, S-Programming, Introductory Statistics with R, and Michael Crawley's new book Statistics : An Introduction using R - along with every online book I could find on CRAN and elsewhere. Unfortunately for me, my experience leaves me in between the beginner books and the more advanced texts like MASS, David, Schervish etc... The learning curve is steep - but then like many people, I'd like to be able to do sophisticated modelling with deep understanding and no effort :-) I feel there is a bit of a hole in the middle of the documentation which could be attacked from both sides - the introduction element is starting to be covered - it's the next step up from that. And yes before you ask I would like to help - but my statistics knowledge is very poor! Should this conversation go to r-devel? Thanks for listening, Sean On 21/07/05, Uwe Ligges [EMAIL PROTECTED] wrote: Duncan Murdoch wrote: On 7/21/2005 10:29 AM, Uwe Ligges wrote: Gabor Grothendieck wrote: I think you have been using R too long. Something like this is very much needed. There are two problems: 1. the process itself is too complex (need to get rid of perl, integrate package development tools with package installation procedure [it should be as easy as downloading a package], remove necessity to set or modify any environment variables including the path variables). 2. there is too much material to absorb just to create a package. The manuals are insufficient. A step-by-step simplification is very much needed. Its no coincidence that there are a number of such descriptions on the net (google for 'making creating R package') since I would guess that just about everyone has significant problems in creating their first package on Windows. OK, if people really think this is required, I will sit down on a clean Windows XP machine, do the setup, and write it down for the next R Help Desk in R News -- something like Creating my first R package under Windows? If anybody else is willing to contribute and can write something up in a manner that is *not* confusing or misleading (none of the other material spread over the web satisfies this requirement, AFAICS), she/he is invited to contribute, of course. BTW, everybody else is invited to submit proposals for R Help Desk!!! That sounds great. Could you also take notes as you go about specific problems in the writeup in the R-admin manual, so it can be improved for the next release? Of course. Another thing you could do which would be valuable: get a student or someone else who is reasonably computer literate, but unfamiliar with R details, to do this while you sit watching and recording their mistakes. Good idea. Uwe Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] convert to chron objects
are those dates in m/d/y or d/m/y ? ?chron and watch out for format = c(dates = d/m/y, times = h:m:s) On 13/07/05, Gabor Grothendieck [EMAIL PROTECTED] wrote: [I had some emails problems so I am sending this again. Sorry if you get it twice.] On 7/13/05, Gabor Grothendieck [EMAIL PROTECTED] wrote: On 7/13/05, Young Cho [EMAIL PROTECTED] wrote: Hi, I have a column of a dataframe which has time stamps like: eh$t[1] [1] 06/05/2005 01:15:25 and was wondering how to convert it to chron variable. Thanks a lot. Try this: # test data frame eh containing a factor variable t eh - data.frame(t = c(06/05/2005 01:15:25, 06/07/2005 01:15:25)) # substring converts factor to character and extracts substring chron(dates = substring(eh$t, 1, 10), times = substring(eh$t, 12)) See ?chron for more info. There is an article on dates in R News 4/1 and although it does not specifically answer this question it may be useful with chron and also provides a reference to more chron info elsewhere. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R: to the power
(-8+0i)^(1/3) [1] 1+1.732051i ie complex... On 12/07/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: hi all why does R do this: (-8)^(1/3)=NaN the answer should be : -2 a silly question but i kept on getting errors in some of my code due to this problem. i solve the problem as follows: say we want : (-a)^(1/3) then : sign(a)*(a^(1/3)) works but there has to be a simpler way of soing such a simple mathematical operation. thanking you / allan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problem compiling R 2.1.* on SUSE 9.2
Hi! what point exactly in the command sequence does it fail? during make? or make install? You might try saving the output and the error from the build into a file? Something along the lines of ./configure 21 filename or even ./configure 21 filename | tee configure_output.txt etc. cheers! Sean On 7/8/05, J Dougherty [EMAIL PROTECTED] wrote: I have been unable to compile either R 2.1.0 or 2.1.1 under SUSE 9.2. The system simply hangs as far as I can tell. All key board and mouse service dies. I have had no problem compiling earlier versions of R through 2.0.1, aside from remembering to include readline in the configuration. Configure runs without any warnings except that Info or html versions of the R Manuals. The SUSE 9.2 install is generic with KDE 3.3 as the principal GUI. Compiling also crashes under GNOME. Because of the system hang, I can't provide any error codes. Perusing /var/log/messages doesn't seem to yield any clues. The system is a KDE AMD XP 2100, there is 1 GB of system ram, less than 10% of the harddisk space is in use, videocard is an nVidia GeForce4 Ti 4400. The OS is SUSE 9.2 and it has current updates for security. JWDougherty __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Tempfile error
Hi Harold, I know nothing about Sweave (though it certainly sounds like a great idea!). Does Sweave hold these files open simultaneously - many operating systems wouldn't be able to cope with 20,000 simultaneously open files. Could you be running out of disk space? or inodes - if you're on a unix type system? can the directory hold that many files? can the disk hold that many files? Many filesystems are formatted with an assumption about the average file size. Perhaps if you told us what type of operating system and type(s) of filesystem(s)? cheers! Sean On 7/6/05, Doran, Harold [EMAIL PROTECTED] wrote: Dear List: I am encountering an error that I can't resolve. I'm looping through rows of a dataframe to generate individual tex files using Sweave. At random points along the way, I encounter the following error Error in file() : cannot find unused tempfile name At which point Sweave halts. There isn't a logical pattern that I can identify in terms of why the program stops at certain points. It just seems to be random as far as I can tell. I've searched the archives and of course Sweave FAQs but haven't found much that sheds light on what this error indicates and what I should do to resolve it. There are approximately 20,000 rows, meaning that about 20,000 tex files are created. If I sample 5,000 or even 10,000 and run the program, I do not encounter an error. It only occurs when I run the program on the full dataframe and even then the error is not occuring at the same point. That is, the row at which the program halts varies each time. Does anyone have any thoughts on this problem? -Harold [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] finding out more about an object, e.g. lm
Hi! I'm trying to use lm(y~x) amongst others in an automated way; I've gone through the section on indexing in R-lang and I've looked MASS4. How do I find out more about the structure of the returned object? In perl I can look at object structure pretty-printed in the debugger - is there an R equivalent? I've used coef(lm(y~x))[[1]] and coef(lm(y~x))[[2]] to extract the intercept; but while summary(lm(y~x)) prints R-squared... it isn't entirely obvious how to extract this value as a scalar. ?lm doesn't give me the information by saying unlist(summary(lm(y~x))) it prints $r.squared [1] 0.267 so now I can say my.r.sq - summary(lm(y~x))$r.squared but is there a better way? on my small lm model unlist(lm(y~x)) is a pretty long list! :-) Many thanks in advance, Sean O'Riordain __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] hellow
Hi, I suggest that you read the 'posting guide' - refer the bottom of all emails on the list. http://www.R-project.org/posting-guide.html (il ne faut que d'aller chez http://www.r-project.org/ vous meme). Sean karima alem wrote: can i ask you for logiciel R - Dialoguez en direct avec vos amis grâce à Yahoo! Messenger ! [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] access R remotely
This likely means that either R is not installed on that machine or the R binary is not in your PATH. : try asking your IT guy where R is installed... say Mr.IT.Guy says that R is installed in /usr/local/bin... then /usr/local/bin/R to start R... cheers, Sean. array chip wrote: Hi, not sure if this is kind of question that should be asked here, but here it is: I am trying to access R installed on a remote cluster (Linus), but I got the error message that R command not found when I simply typed R after the prompt after having successfully accessed the remote cluster using SSH. what could be the reason of the problem? is the problem on the cluster side or on my side? I am not a IT person at all, so I don't know much detail... Our IT guy on the cluster side is working on the problem, but seems not very efficiently targeting the problem. Thanks for any suggestion. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R commands
Hi Andy, I know it doesn't answer all of your questions but have you read the Posting guide (see the bottom of all posts) ? http://www.R-project.org/posting-guide.html and in particular, try reading An Introduction to R, chapter 9? Note that in R, looping is relatively slow - if you can do things using a vector, this is much better. Try going to the R-project.org homepage and on the left hand side you'll see Search - does searching for bootstrap monte carlo answer your first question? cheers, Sean Chou Andy wrote: I'm a R beginner. Recently I conduct a project about expected return that involves using R for calculations. I encounter three questions as follow: Q1. How to use R to demonstrate bootstrapping and Monte Carlo simulation under 10,000 times of random selection? Q2. How to do a loop in R? Q3. How to use R to do binominal tree calculation under multiple periods? I'm perplexed by the R commands, so any hints or examples will be highly appreciated. Andy _ MSN Mobile MSN Messenger __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R programming
Hi Henrick, if you checked the posting guide (refer the bottom of all emails) you'd have spotted a link # R Language Definition (aka `R Language Manual') describes the R language, data objects, etc. http://cran.r-project.org/doc/manuals/R-lang.pdf cheers, Sean ps. R is indeed a full and complete language Andersson, Henrik wrote: I have been using R for a few months to plot my data, and fit statistical models and so on. It is stated that R is not only a package for statistcs and graphics but also a programming language. Currently I am working with Fortran 90 to do numerical simulations (1D reactive -transport), and subsequently visualize it in some external software (spreadsheet). As I now started using R I will plot my results using R, but my question is: Could I use R as a replacement for the Fortran program, or is programming in R more restricted? E.g. is it possible to use subroutines in R? If you think programming in R is great and you have some documentation, please point me to it. Thanks, Henrik Andersson - Henrik Andersson Netherlands Institute of Ecology - Centre for Estuarine and Marine Ecology P.O. Box 140 4400 AC Yerseke Phone: +31 113 577473 mailto:[EMAIL PROTECTED] http://www.nioo.knaw.nl/ppages/handersson __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] LCG with modulo 2^30
Hi Raheem, Firstly - fair warning...I'm not an R expert at all! However it is my understanding that the expression for i in 1:m creates a full vector in memory of all the consecutive numbers 1 to m... (i presume these are 4-byte ints here otherwise it would have fallen over before 2^29), but taking the minimal assumption of ints these take 4 bytes... 1:2^29 requires (2^29)*4 bytes of memory - running on a 32-bit platform you have an absolute maximum of about 2^32 bytes of addressable memory (some memory will be taken by the os...). if you start R and say gc() it'll tell you about memory allocated... then try k-c(1:2^24); gc() and you might get a response something like... gc() used (Mb) gc trigger (Mb) Ncells 208431 5.6 407500 10.9 Vcells 73157 0.6 786432 6.0 k - c(1:2^24) gc() used (Mb) gc trigger (Mb) Ncells 208431 5.6 407500 10.9 Vcells 8428997 64.4 17108043 130.6 if you REALLY want to interate to 2^32 without allocating a huge memory vector like that try using your own counter and a while loop instead which won't allocate more memory than you have - but this will likely be SLOW... something along the lines of i - 0 while (i 2^32) { # now we do stuff i - i+1 } i'm quite sure that there are more 'R-ish' ways of doing things... btw. what are you trying to achieve? Sean Enayetur Raheem wrote: I can't run a function which generates random numbrers using linear congruential generator. My multiplier is a=5+8^6, increment is b=1 and modulo is m=2^30. the code I have written works for modulo upto m=2^28. For m= 2^29 , it says, can not allocate memory for the vector or something like that. For m= 2^31 or more, its says the argument for i in 1:m is too large in magnitude. I tried to increase the memory size but it did not work. Any help will be appreciated. Thanks. Raheem __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R killed on Solaris
Hi Ott, could it be a per process limit or ulimits set? i don't have a solaris box here so i can't remember what the appropriate commands are... cheers, Sean Ott Toomet wrote: Hello, I am running a preliminary data-processing job on solaris. Basically, the program reads a large number of ascii-lines (about 1M) by blocks (size 25000 lines), selects suitable observations (around 5000) and writes the results into a dataframe for latter processing. The problem is that when I run the job interactively (in emacs/ESS), everything works fine. If I try to run it from shell using R CMD BATCH, R will be killed after around 100 000 lines. Solaris says simply killed and thats it. The total memory consumption seems not to be a problem, around 200M on a 4G machine. Any suggestions? Has anyone else seen something similar? Best wishes Ott --- this is R 1.7.1, compiled as 32-bit appication, on 64bit sparc solaris 9 (sunos 5.9). __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R and RS232-Interface?
Hi, Personally, I would avoid Java for hardware handling - in my experience this is tricky and very hardware specific. Sascha, is this for a Unix type machine or under windows? If under Unix/Linux, it should not be particularly difficult to send characters and receive characters in C through a plain rs-232 port - though I don't have any code examples for you. Just open the relevant /dev/cua0 (or whatever it is called on your machine) in character mode and treat it like a file. cheers, Sean Henrik Bengtsson wrote: Hi, I recall I've seen a RS232-interface communication class in Java a few years ago. I can't remember for what platforms it were written for (I think it relied on some native code). If you find it, you then might be able to use the SJava package by Omegahat (http://www.omegahat.org/RSJava/). A long shot, but it might be better than nothing. Cheers Henrik Bengtsson -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Morach Sascha, moracsa1 Sent: den 14 november 2003 17:27 To: [EMAIL PROTECTED] Subject: [R] R and RS232-Interface? Hi there Does any one of you know something about R and an implemented RS232-Interface? Are there any packages? Or is it possible to write an extensions or something like that in C/C++ ? The problem is that i should handle the information from a measuring device via the RS232-Interface (probably you know LabVIEW, which provides this functionality). These informations should then directly be handled by R. Is this possible? (I hope I found the right words, I'm swiss, J ) thanks Sascha Morach, diplomastudent, ZHW __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailma n/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Ignoring Errors in Simulations
?try Ken Kelley wrote: Hello all. I'm doing a simulation study and every so often I get an error that stops the simulation. I would like to ignore the errors *and* identify the particular iterations where they occurred. I have tried: options(error = expression(NULL)) which I thought would ignore the error, but the simulation is still stopped when an error occurs. I do not think try() is a good idea because of the significant computational time (that I think) it would add. Specifically I am using factanal() from the mva library and the error is: Error in factanal(Data, factors = 1, rotation = none) : Unable to optimize from these starting value(s) -I am using R 1.7.1 on a Windows XP machine. Although increasing the number of starting values attempted would reduces the number or errors, I'm looking for a way that they are ignored and these (likely) untrustworthy results identified. Thanks for any thoughts, Ken __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Visualising Vectors
Hi Laura, you should find some useful information in the latest R news Volume 3/2, October 2003 http://cran.r-project.org/doc/Rnews/ refer page 8 where Paul's figure 2 shows some novel symbols showing China Sea Wind Speed, Direction and Temperature... plotted by lat.long. s. Laura Quinn wrote: I sent a mail last week asking for some advise in relation to displaying wind vectors on a contour map of a region. Whilst I have had some useful feedback relating to the second part of this question (namely how to animate a time series of still frames), I haven't recieved any advise on how I might create the still images of the spatially distributed wind vector data at any given time point. Firstly, is there a way in which I can input orographical information (x,y,z co ords) into R to create a map, secondly, is there a way in which i can superimpose a visual wind vector (i.e. arrow of certain length and certain orientation) onto such a map? thanks in advance, Laura __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] r-ish ? how can i improve my code?
Hi Folks, I'm trying to learn R. One of my intentions is to do some Monte-Carlo type modelling of road accidents. Below, to simplify things, I've appended a little program which does a 'monte-carlo' type simulation. However, it is written in a way which seems a bit un-natural in R. Could someone help me make this a bit more R-ish please? Or is there a completely different approach I should be taking? Many thanks in advance, Sean O'Riordain seanpor AT acm.org n - 900; # number of valid items required... x - numeric(n); y - numeric(n); z - numeric(n); c - 1; # current 'array' pointer tc - 0; # total items actually looked at... while (c = n) { x[c] = runif(1, 0, 1); y[c] = runif(1, 0, 1); z[c] = sqrt(x[c]^2 + y[c]^2); if (z[c] 1) c - c + 1; tc - tc + 1; } print('overwork' ratio); print(tc/(c-1)); plot(x,y); __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] r-ish ? how can i improve my code?
Hi Patrick, Spencer, Thanks for that! Both your solutions are MUCH quicker! afaik overwork_ratio = 4/pi # what a hard way to calculate this :-) The real problem I'm actually working on is a little more complicated :-) - 6 'random' variables, and 18 dependant variables (at last count)... currently only 4 computed terms in the 'if() c-c+1' statement... I just created the x,y area problem as a simple example of the style I was using. In the past I've worked on other 'accident' related problems and one difficulty was in getting enough final 'z' values to be statistically significant as there was an enormous rejection ratio - but it was running on a 486 written in compiled turbo pascal and it would take days of work... I'll have a go at recoding using your techniques. Many Thanks, Sean Patrick Burns wrote: For this particular problem you can probably use polar coordinates. But something similar to your code could be: x - runif(900) y - runif(900) z - sqrt(x^2 + y^2) okay - z 1 while(any(!okay)) { n.bad - sum(!okay) x[!okay] - runif(n.bad) y[!okay] - runif(n.bad) z - sqrt(x^2 + y^2) # restricting to !okay may or may not be useful okay - z 1 } Patrick Burns Burns Statistics [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and A Guide for the Unwilling S User) Sean O'Riordain wrote: Hi Folks, I'm trying to learn R. One of my intentions is to do some Monte-Carlo type modelling of road accidents. Below, to simplify things, I've appended a little program which does a 'monte-carlo' type simulation. However, it is written in a way which seems a bit un-natural in R. Could someone help me make this a bit more R-ish please? Or is there a completely different approach I should be taking? Many thanks in advance, Sean O'Riordain seanpor AT acm.org n - 900; # number of valid items required... x - numeric(n); y - numeric(n); z - numeric(n); c - 1; # current 'array' pointer tc - 0; # total items actually looked at... while (c = n) { x[c] = runif(1, 0, 1); y[c] = runif(1, 0, 1); z[c] = sqrt(x[c]^2 + y[c]^2); if (z[c] 1) c - c + 1; tc - tc + 1; } print('overwork' ratio); print(tc/(c-1)); plot(x,y); __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help