[R] generating data
Hello I am trying to generate data in say 2D x,y for a circle. grid.circle {grid} does not do. any ides is appreciated. Thanks F.J. __ [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] generating data
Do you mean random data? Generate polar coordinates (angle in range 0..2pi, radius in range 0..1) and convert. Lutz -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Fred J. Sent: Freitag, 7. Mai 2004 09:14 To: r help Subject: [R] generating data Hello I am trying to generate data in say 2D x,y for a circle. grid.circle {grid} does not do. any ides is appreciated. Thanks F.J. __ [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
[R] Problem (Bug?) with readLines on Suze
Hello, I called readLines on Suze 9.0 with a directory as parameter instead of a file. R freezed for a very long time; this morning I could read following error message: Error in readLines(paste(/home/,foo,/,sep=)) : cannot allocate buffer in readLines under W2K I get a more logical error (cannot open file) (I'm still using R 1.8.1) cheers, Marc __ [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
[R] sampling weights for lme
Dear All, I have a complex survey data with observations having differing probabilities of selection into the sample. I would like to run a linear mixed effects model and also to use weighting that takes this into consideration. As far as I know, however, the weighting option for the lme command from nlme package (or glmmPQL from MASS, for that matter) is related to heteroscedasticity. Is there a sampling weights option for these packages that I am not aware of? Regards, Alex __ [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
[R] Gaussian Hypergeometric Series _2F_1(a,b,c;z)
Dear all, I am working on a small package which is supposed to provide evaluation of the gaussian hypergeometric series. It will be based on the Fortran-code by Robert Forrey. Does anyone beside me use this function and would be willing to test the package or discuss requirements? All the best, Daniel __ [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] Problem (Bug?) with readLines on Suze
You asked R to read a binary file line-by-line, and it did its best. Given that an incorrect operation resulted in an error message, it did reasonably well. It looks to me as if end of directory is not being detected, and I'll dig deeper to see it that can be improved. On Fri, 7 May 2004, Marc Mamin wrote: I called readLines on Suze 9.0 with a directory as parameter instead of a file. R freezed for a very long time; this morning I could read following error message: Error in readLines(paste(/home/,foo,/,sep=)) : cannot allocate buffer in readLines under W2K I get a more logical error (cannot open file) That's because on Windows a directory is not a text file. We could probably add such a check on Unix. -- 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 __ [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] Gaussian Hypergeometric Series _2F_1(a,b,c;z)
Hi Daniel try hypergeo in library(Davies) best rksh Dear all, I am working on a small package which is supposed to provide evaluation of the gaussian hypergeometric series. It will be based on the Fortran-code by Robert Forrey. Does anyone beside me use this function and would be willing to test the package or discuss requirements? All the best, Daniel __ [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 -- Robin Hankin Uncertainty Analyst Southampton Oceanography Centre SO14 3ZH tel +44(0)23-8059-7743 [EMAIL PROTECTED] (edit in obvious way; spam precaution) __ [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
[R] Rterm
Dear all, Two questions regarding rterm First: C:\Program Files\R\rw1081\bin\rterm.exe --vanilla test.r --args Arg1 Arg2 worked for me so far with r Version 1081, to start a R script with the given arguments. With R1090 C:\Program Files\R\rw1090\bin\rterm.exe --vanilla test.r --args Arg1 Arg2 There is the error message: Rterm.exe is not a valid Win32 application I tried on Windows 2000 and XP I couldn't find out what to change. Second: I would like to set the working directory as well, in the same command, when calling an r script with rterm.exe from the command line. Is there a way to do this? Can somebody help me with these issues? Thank you Johannes [[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
[R] svm question
Hi! I have a questionaccording to classifing new examples from an already trained svm. I have tarined a svm (e1071 package) with a training set of 1526 examples. Now I have another data set with 2163 examples and I want to use the already trained svm for prediction: pred-predict(a.svm,newdata); Afterwards for further processessing I add further information to the results of teh classification from the original input (also 2163 x N matrix) result-as.data.frame(cbind(newdata[81:84],pred)) But I receive an error: Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 2163, 1526 So I wonder why the svm is stick to a resultset of 1526 although I put in 2613 examples? To my mind I thought that the classification/predictin depends on the length of the feature vector not on the number of examples? Or am I doing something wrong? Thanks -- Frank G. Zoellner AG Angewandte Informatik Technische Fakultat Universitat Bielefeld phone: +49(0)521-106-2951 fax: +49(0)521-106-2992 email: [EMAIL PROTECTED] __ [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] Rterm
With R1090 C:\Program Files\R\rw1090\bin\rterm.exe --vanilla test.r --args Arg1 Arg2 There is the error message: Rterm.exe is not a valid Win32 application I tried on Windows 2000 and XP I couldn't find out what to change. Weird. Did you install in C:\Program Files\R\rw1090\? On my XP machine, it did, and rterm is valid. The above works from a command prompt, provided I wrap the executable path and name in quotes. Failing that, is it a corrupt binary install? Here's the md5 of my (working) R-1.9.0, downloaded from CRAN (NOT the patched version, and not built by me) C:\Program Files\R\rw1090\bin md5sum.exe Rterm.exe 2565cd848bbd86b964624a0490352da2 *Rterm.exe I would like to set the working directory as well, in the same command, when calling an r script with rterm.exe from the command line. Is there a way to do this? Inside R: setwd(your/path/here) With the usual warning about using / slashes, or \\ slashes (doubled). I just stick with /. Cheers Jason __ [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
[R] loess and as.POSIXct
Hi there fellow R-users, I have just upgraded to R version 1.9.0 from R version 1.7.1 for Windows. Im trying to use the loess smoother where the X-variable is an as.POSIXct variable. The following works fine with R1.7.1 but not with R1.9.0. Here is the example: dates-c('2003-08-03','2003-08-10','2003-08-17','2003-08-24','2003-08-31','2 003-09-07','2003-09-14','2003-09-21','2003-09-28','2003-10-05','2003-10-12', '2003-10-19','2003-10-26','2003-11-02','2003-11-09','2003-11-16','2003-11-23 ','2003-11-30','2003-12-07','2003-12-14','2003-12-21','2003-12-28','2004-01- 04','2004-01-11','2004-01-18','2004-01-25','2004-02-01','2004-02-08','2004-0 2-15','2004-02-22','2004-02-29','2004-03-07','2004-03-14','2004-03-21','2004 -03-28','2004-04-04','2004-04-11','2004-04-18','2004-04-25','2004-05-02') length(dates) strptime(dates,format=%Y-%m-%d) length(strptime(dates,format=%Y-%m-%d)) my.df-data.frame(Sales=rnorm(40),Dates=as.POSIXct(strptime(dates,format=%Y -%m-%d))) my.df loess(Sales~Dates,my.df) I get the following error with version 1.9.0 #Error: NA/NaN/Inf in foreign function call (arg 2) #In addition: Warning messages: #1: longer object length #is not a multiple of shorter object length in: cl == c(Date, POSIXct, POSIXlt) #2: NAs introduced by coercion Can anyone help??? Dr Wayne R. Jones Senior Statistician / Research Analyst KSS Limited St James's Buildings 79 Oxford Street Manchester M1 6SS Tel: +44(0)161 609 4084 Mob: +44(0)7810 523 713 KSS Ltd Seventh Floor St James's Buildings 79 Oxford Street Manchester M1 6SS England Company Registration Number 2800886 Tel: +44 (0) 161 228 0040 Fax: +44 (0) 161 236 6305 mailto:[EMAIL PROTECTED]http://www.kssg.com The information in this Internet email is confidential and m...{{dropped}} __ [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
[R] scores from multinomial logistic regression
Dear all, I'm interested in extracting the score from multinomial logistic regression models fit using multinom, to assess the stregth of assocation of the parameter with the response (akin to the score from clogit/cox regression). currently I'm using R 1.8.1. Is there a function that will extract the score from a multinom object or how i can get back to it? or from using glm? I investigated the documention for Design but those functions seem to apply to binary logistic. Apologies if I am missing something, Many thanks in advance, Jacqui Hall [[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
[R] contrasts in a type III anova
Hello, I use a type III anova (car package) to analyse an unbalanced data design. I have two factors and I would have the effect of the interaction. I read that the result could be strongly influenced by the contrasts. I am really not an expert and I am not sure to understand indeed about what it is... Consequently, I failed to properly used the fit.contrast function (gregmisc package) because I don't understand what the fonction need in the argument coeff. The two factors are Y (Ya, Yb,..., Ye) and Auto (Auto1, Auto2,, Auto10) The responses are binomial (counts in the matrice mat) and gaussian (variable tot). I use the glm procedure : glm1 - glm (mat ~ y*auto, data, family=binomial) glm2 - glm (tot ~ y*auto, data, family=gaussian) Subsequently I use the Type III anova : Anova (glm1, type=III) Anova (glm2, type=III) Using the contrast.treatment for both factors Y and Auto, R gives coherent results, but I really not sure that this contrasts are appropriate ! Thank's for your advices ! David __ [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] Rterm
Dear Jason, Thank you very much, the first problem is solved. It was a corrupted file. After downloading a new version rterm works! The second question: I was trying to set the working directory while I'm calling a script with Rterm.exe from the command line. Something like c:\Program Files\R\rw1090\bin\rterm.exe --vanilla workingdir=c:/data/ test.r --args Arg1 Arg2 Thank's again Johannes -Original Message- From: Jason Turner [mailto:[EMAIL PROTECTED] Sent: 07 May 2004 12:15 To: Johannes SCHNITZLER Cc: [EMAIL PROTECTED] Subject: Re: [R] Rterm With R1090 C:\Program Files\R\rw1090\bin\rterm.exe --vanilla test.r --args Arg1 Arg2 There is the error message: Rterm.exe is not a valid Win32 application I tried on Windows 2000 and XP I couldn't find out what to change. Weird. Did you install in C:\Program Files\R\rw1090\? On my XP machine, it did, and rterm is valid. The above works from a command prompt, provided I wrap the executable path and name in quotes. Failing that, is it a corrupt binary install? Here's the md5 of my (working) R-1.9.0, downloaded from CRAN (NOT the patched version, and not built by me) C:\Program Files\R\rw1090\bin md5sum.exe Rterm.exe 2565cd848bbd86b964624a0490352da2 *Rterm.exe I would like to set the working directory as well, in the same command, when calling an r script with rterm.exe from the command line. Is there a way to do this? Inside R: setwd(your/path/here) With the usual warning about using / slashes, or \\ slashes (doubled). I just stick with /. Cheers Jason __ [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
[R] x-axis tick mark labels running vertically
I'm plotting obesity rates (y-axis) vs Public Health Unit (x-axis) for the province of Ontario and would like to have the Public Health Unit names appear vertically rather than the default, horizontally. I'm actually using the 'barplot2' function in the {gregmisc} library ... I haven't been able to find a solution in either the barplot2 options or the general plotting options. Any pointers would be appreciated. - Mohamed __ [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
[R] Start problem
I had a well-working R 1.7, however, today the programme did not start, and I recieved an error message. I have uninstalled the R 1.7, and then installed R 1.9. Still it does not start, giving the error message Fatal error: invalid HOMEDRIVE. How can I get it to work? Bjorn Okland [[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
[R] help with histogram
Hi all, I need some help with the function histogram. Let x be a vector. The command hist(x,col=blue) gives an histogram for the vector x. I would like to add some colors in the graphics such that the histogram is red if abs(x)1.669 and blue otherwise...and what is the solution if I want to change the filling instead of the color Thanks for your help, Olivier __ [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] x-axis tick mark labels running vertically
On Fri, 2004-05-07 at 07:02, Mohamed Abdolell wrote: I'm plotting obesity rates (y-axis) vs Public Health Unit (x-axis) for the province of Ontario and would like to have the Public Health Unit names appear vertically rather than the default, horizontally. I'm actually using the 'barplot2' function in the {gregmisc} library ... I haven't been able to find a solution in either the barplot2 options or the general plotting options. Any pointers would be appreciated. - Mohamed You need to adjust par(las) to alter the orientation of the of the axis labels: barplot2(1:4, names.arg = c(one, two, three, four), las = 2) You can also use the axis() function separately: barplot2(1:4) axis(1, labels = c(one, two, three, four), las = 2) Setting par(las = 2) rotates the axis labels so that they are perpendicular to the axis. See ?par for more information. HTH, Marc Schwartz __ [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
R: [R] help with histogram
Maybe you want something like: x-rnorm(1000) hist(x, breaks=100, col=ifelse(abs((hist(x, breaks=100, main=))$breaks) 1.669, 4,2)) see also the density argument in ?hist Stefano -Messaggio originale- Da: Martin Olivier [mailto:[EMAIL PROTECTED] Inviato: venerdì 7 maggio 2004 14.40 A: r-help Oggetto: [R] help with histogram Hi all, I need some help with the function histogram. Let x be a vector. The command hist(x,col=blue) gives an histogram for the vector x. I would like to add some colors in the graphics such that the histogram is red if abs(x)1.669 and blue otherwise...and what is the solution if I want to change the filling instead of the color Thanks for your help, Olivier __ [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] help with histogram
Hi, you can use subset of data and superpose different histograms for each of them. hth, Marc __ [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] Bluefish Editor with R
I think you can download it here http://bluefish.openoffice.nl/index.html I used it once a while back and it's nice since it has built in support for R w/syntax highlighting. But at this point I'm wedded to Emacs. I thought it actually came bundled with a recent RedHat/Fedora Linux but now I can't find it -roger [EMAIL PROTECTED] wrote: Dear List: Somewhere in the R-Statistical Software website, I remember having read about using the opensource Bluefish editor with R. During a recent visit to the site, I could not find the link or reference. Also, when I searched the list archives (http://maths.newcastle.edu.au/~rking/R/about.html) for bluefish, the search returned no result. Has anyone in the list used bluefish as an editor for writing R commands and functions? Are there any tutorials available? TIA, Arin Basu __ [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
[R] Font and Color documentation
Hello R-ians, Could someone please point me to documentation on legal font and color specifications (and other 'par' parameters); i.e. font=6 for Times New Roman, col='Red', etc.? Searches in ?par, MASS (1st ed.) and other areas were unsuccessful. I thought I remember seeing it before...somewhere. Thanks, Iyue __ [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] sampling weights for lme
I would like to run a linear *mixed effects* model and also to use (sample) weighting ... I've been trying to do this for 2 decades :) See 9. Pfeffermann, D. , Skinner, C. J. , Holmes, D. J. , Goldstein, H. , and Rasbash, J. (1998), ``Weighting for unequal selection probabilities in multilevel models (Disc: p41-56)'', Journal of the Royal Statistical Society, Series B, Methodological, 60 , 23-40 which refers back to: 29. Pfeffermann, D. , and LaVange, L. (1989), ``Regression models for stratified multi-stage cluster samples'', Analysis of Complex Surveys, 237-260 If you don't like statistical papers, then see section 4.5 of 8. Korn, Edward Lee , and Graubard, Barry I. (1999), ``Analysis of health surveys'', John Wiley Sons (New York; Chichester) They explain the idea of using weights in a model fairly simply. And I would always recommend Rick's (us hillbillies gotta stick together:) book: 5. Valliant, Richard , Dorfman, Alan H. , and Royall, Richard M. (2000), ``Finite population sampling and inference: a prediction approach'', John Wiley Sons (New York; Chichester) as a general fun read. I didn't really answer your question but... Bob -Original Message- From: alex pegucci [mailto:[EMAIL PROTECTED] Sent: Friday, May 07, 2004 4:03 AM To: [EMAIL PROTECTED] Subject: [R] sampling weights for lme Dear All, I have a complex survey data with observations having differing probabilities of selection into the sample. I would like to run a linear mixed effects model and also to use weighting that takes this into consideration. As far as I know, however, the weighting option for the lme command from nlme package (or glmmPQL from MASS, for that matter) is related to heteroscedasticity. Is there a sampling weights option for these packages that I am not aware of? Regards, Alex __ [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
[R] Anyone in need of fast evaluation of Gaussian Hypergeometric Series?
Dear all, sorry for the repost, but I think that the subject line of my previous posting did not really make my point clear. Is there anyone who would be interesting in testing and giving me feedback about a package which evaluates the _2F_1 series and - is fast compared to the straightforward summation and - is more precise especially near to the circle of convergence |z|~1? If you are interested please send me a short note. Daniel __ [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] Rterm
Johannes SCHNITZLER wrote: The second question: I was trying to set the working directory while I'm calling a script with Rterm.exe from the command line. Something like c:\Program Files\R\rw1090\bin\rterm.exe --vanilla workingdir=c:/data/ test.r --args Arg1 Arg2 Not sure - if you could pass the working directory as an arg, then R can handle it from there - use the setwd() command. What I usually do on Un*x-like systems is to cd to the directory first, then start the R run. Something like cd my favorite dir R --vanilla ... Since you're already specifying the absolute path for Rterm, the above should work... Cheers Jason __ [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] scores from multinomial logistic regression
What do you mean by the scores? What multinom does is to fit probabilities (which you can extract by fitted()): the response is a discrete probability distribution. There is an underlying linear predictor but (a) it is K-dimensional and (b) there is a degree of ambiguity, usually resolved by setting the predictor for one category to zero (but not in this code). That linear predictor is only generated in the underlying C code. On Fri, 7 May 2004, Jacqueline Hall wrote: Dear all, I'm interested in extracting the score from multinomial logistic regression models fit using multinom, to assess the stregth of assocation of the parameter with the response (akin to the score from clogit/cox regression). currently I'm using R 1.8.1. Is there a function that will extract the score from a multinom object or how i can get back to it? or from using glm? I investigated the documention for Design but those functions seem to apply to binary logistic. -- 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 __ [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] Rterm
On Sat, 8 May 2004, Jason Turner wrote: Johannes SCHNITZLER wrote: The second question: I was trying to set the working directory while I'm calling a script with Rterm.exe from the command line. Something like c:\Program Files\R\rw1090\bin\rterm.exe --vanilla workingdir=c:/data/ test.r --args Arg1 Arg2 Not sure - if you could pass the working directory as an arg, then R can handle it from there - use the setwd() command. What I usually do on Un*x-like systems is to cd to the directory first, then start the R run. Something like cd my favorite dir R --vanilla ... Since you're already specifying the absolute path for Rterm, the above should work... That's the only way. The `working directory' is the directory from which you launch an application (although you can fix that by a shortcut). R looks in the working directory for several things, e.g. a .Rprofile file, before it ever runs any R code like setwd. If that is not a problem you can use something like (from a decent shell) (echo setwd(somewhere); cat test.r) | Rterm.exe --args Arg1 to make the first R code run change directories. Or you can have at the top of test.r setwd(Sys.getenv(WD)) and use Rterm.exe WD=c:/data test.r --args Arg1 Arg2 -- 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 __ [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
[R] How does the lm() function work?
Does the lm() function use forward, backward, stepwise or some other method of multivariable regression? Where can I look up the details? Phillip Good [[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
RE: [R] How does the lm() function work?
?step -Original Message- From: Phillip Good [mailto:[EMAIL PROTECTED] Sent: 07 May 2004 15:19 To: [EMAIL PROTECTED] Subject: [R] How does the lm() function work? Does the lm() function use forward, backward, stepwise or some other method of multivariable regression? Where can I look up the details? Phillip Good [[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 KSS Ltd Seventh Floor St James's Buildings 79 Oxford Street Manchester M1 6SS England Company Registration Number 2800886 Tel: +44 (0) 161 228 0040 Fax: +44 (0) 161 236 6305 mailto:[EMAIL PROTECTED]http://www.kssg.com The information in this Internet email is confidential and m...{{dropped}} __ [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] How does the lm() function work?
lm() itself does not implement any model selection procedures. step() and stepAIC() in the MASS library do. -roger Phillip Good wrote: Does the lm() function use forward, backward, stepwise or some other method of multivariable regression? Where can I look up the details? Phillip Good [[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] generating data
Keep in mind that the change of coordinates introduces a distortion; dxdy becomes in polar coordinates rdrdtheta. So if you wanted a uniform distribution on the disk you could generate theta uniform on [0,2pi] and r from a distribution with density f(r)=2r on [0,1]. Reid Huntsinger -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Lutz Prechelt Sent: Friday, May 07, 2004 3:43 AM To: [EMAIL PROTECTED] Subject: RE: [R] generating data Do you mean random data? Generate polar coordinates (angle in range 0..2pi, radius in range 0..1) and convert. Lutz -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Fred J. Sent: Freitag, 7. Mai 2004 09:14 To: r help Subject: [R] generating data Hello I am trying to generate data in say 2D x,y for a circle. grid.circle {grid} does not do. any ides is appreciated. Thanks F.J. __ [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 __ [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] How does the lm() function work?
Thank you. I'll install the MASS library. - Original Message - From: Roger D. Peng [EMAIL PROTECTED] To: Phillip Good [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, May 07, 2004 7:28 AM Subject: Re: [R] How does the lm() function work? lm() itself does not implement any model selection procedures. step() and stepAIC() in the MASS library do. -roger Phillip Good wrote: Does the lm() function use forward, backward, stepwise or some other method of multivariable regression? Where can I look up the details? Phillip Good [[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] Rterm
Thank you very much for the fast answers, It work's very well Johannes -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: 07 May 2004 16:16 To: Jason Turner Cc: Johannes SCHNITZLER; [EMAIL PROTECTED] Subject: Re: [R] Rterm On Sat, 8 May 2004, Jason Turner wrote: Johannes SCHNITZLER wrote: The second question: I was trying to set the working directory while I'm calling a script with Rterm.exe from the command line. Something like c:\Program Files\R\rw1090\bin\rterm.exe --vanilla workingdir=c:/data/ test.r --args Arg1 Arg2 Not sure - if you could pass the working directory as an arg, then R can handle it from there - use the setwd() command. What I usually do on Un*x-like systems is to cd to the directory first, then start the R run. Something like cd my favorite dir R --vanilla ... Since you're already specifying the absolute path for Rterm, the above should work... That's the only way. The `working directory' is the directory from which you launch an application (although you can fix that by a shortcut). R looks in the working directory for several things, e.g. a .Rprofile file, before it ever runs any R code like setwd. If that is not a problem you can use something like (from a decent shell) (echo setwd(somewhere); cat test.r) | Rterm.exe --args Arg1 to make the first R code run change directories. Or you can have at the top of test.r setwd(Sys.getenv(WD)) and use Rterm.exe WD=c:/data test.r --args Arg1 Arg2 -- 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 __ [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] contrasts in a type III anova
Dear David, The short answer is that in a two-way ANOVA (or an analogous generalized linear model), the test for the interaction doesn't depend upon the contrast type, and is identical for Type-II and Type-III (and, indeed, Type-I -- i.e., sequential) tests. It's the main-effect tests that depend upon contrast type (for Type-III tests), and for which Type-II and Type-III tests differ. There's a longer answer in the book with which the car package is associated (and a longer one still in my Applied Regression text, as well as other places). I hope this helps, John -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Jutier Sent: Friday, May 07, 2004 6:20 AM To: [EMAIL PROTECTED] Subject: [R] contrasts in a type III anova Hello, I use a type III anova (car package) to analyse an unbalanced data design. I have two factors and I would have the effect of the interaction. I read that the result could be strongly influenced by the contrasts. I am really not an expert and I am not sure to understand indeed about what it is... Consequently, I failed to properly used the fit.contrast function (gregmisc package) because I don't understand what the fonction need in the argument coeff. The two factors are Y (Ya, Yb,..., Ye) and Auto (Auto1, Auto2,, Auto10) The responses are binomial (counts in the matrice mat) and gaussian (variable tot). I use the glm procedure : glm1 - glm (mat ~ y*auto, data, family=binomial) glm2 - glm (tot ~ y*auto, data, family=gaussian) Subsequently I use the Type III anova : Anova (glm1, type=III) Anova (glm2, type=III) Using the contrast.treatment for both factors Y and Auto, R gives coherent results, but I really not sure that this contrasts are appropriate ! Thank's for your advices ! David __ [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] How does the lm() function work?
Phillip == Phillip Good [EMAIL PROTECTED] on Fri, 7 May 2004 07:40:15 -0700 writes: Phillip Thank you. I'll install the MASS library. Two things: - it's the MASS package - if library(MASS) does not work for you, you have either a very old version of R, or a broken one. In both cases, rather re-install R than trying to install MASS. But I assume you just didn't know that library(MASS) would work for you. Regards, Martin __ [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
[R] Re: R web interfaces
Hi, I don't see any replies to this, but it does seem quite a good idea, especially as the existing information (eg in the FAQ) is rather thin and probably incomprehensible to most. I have no time to do it myself, though. Someone in this lab(Andrew Young, Chad Shaw or I) would be willing to put together a page. I think it's a good way to collect a lot of current development. I look forward to meeting you there. I think circumstances will prevent me from going, which I'm disappointed about. That said, both the PI of our lab and another guy will be there(Chad Shaw Andrew Young). They will be very keen to discuss stuff more. Best, Nathan Cheers, David = Nathan Whitehouse Statistics/Programming Baylor College of Medicine Houston, TX, USA [EMAIL PROTECTED] work: 1-713-798-9029 cell:1-512-293-5840 http://rho-project.org: rho- open source web services for R. http://franklin.imgen.bcm.tmc.edu: Shaw laboratory, bcm. __ [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] help with histogram
Guazzetti == Guazzetti Stefano [EMAIL PROTECTED] on Fri, 7 May 2004 14:45:22 +0200 writes: Guazzetti Maybe you want something like: Guazzetti x-rnorm(1000) Guazzetti hist(x, breaks=100, Guazzetticol=ifelse(abs((hist(x, breaks=100, main=))$breaks) 1.669, Guazzetti4,2)) Guazzetti see also the density argument in ?hist very good! Even slightly better {not calling hist() twice} is x - rnorm(1000) hx - hist(x, breaks=100,plot=FALSE) plot(hx, col=ifelse(abs(hx$breaks) 1.669, 4, 2)) Regards, Martin __ [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
[R] Re: Sessioned R web interfaces
Frank, Both RZope and Rho solve this problem. RZope (http://www.analytics.washington.edu/statcomp/projects/rzope/)solves it by using *nix's fork command, which takes as much time as a memcopy. Rho(http://rho-project.org) solves it by maintaining a pool of idling R processes, which it maintains active can pull to do a calculation immediately. Both of these are pretty immediate allow multistep/session calculations.(As compared to CGI stuff) cheers, Nathan Here's a related question: Do any of the mentioned R-web interfaces (Rweb, R-Online, CGIwithR, RSPerl) support reusing the same R process, eliminating the startup overhead? This would be useful to me as well. Currently I use such a method on my computing cluster: All 40 compute nodes run an R process/compute server that listens at a socket for any connection and subsequent commands from another computer. When the master process disconnects, the R processes go back to listening at the socket. Connecting to the R compute servers this way takes 2 milliseconds rather than the typical ~2 second R startup time. Thanks for any tips. -Frank = Nathan Whitehouse Statistics/Programming Baylor College of Medicine Houston, TX, USA [EMAIL PROTECTED] work: 1-713-798-9029 cell:1-512-293-5840 http://rho-project.org: rho- open source web services for R. http://franklin.imgen.bcm.tmc.edu: Shaw laboratory, bcm. __ [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] scores from multinomial logistic regression
Hi, Sorry for not making this clear, By score I meant the score from the score test, for assessing the addition of a new variable to the model. (first derivative of the log likeihood/ information matrix, the ratio (score)having a chi squared distribution of appropriate df) I'm looking for something similar/appropraite for logistic regression, my outcome (response) variable has 4 categories (hence the interest in multinom), the covariates are continuous. Thanks again, Jacqui -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: 07 May 2004 15:07 To: Jacqueline Hall Cc: [EMAIL PROTECTED] Subject: Re: [R] scores from multinomial logistic regression What do you mean by the scores? What multinom does is to fit probabilities (which you can extract by fitted()): the response is a discrete probability distribution. There is an underlying linear predictor but (a) it is K-dimensional and (b) there is a degree of ambiguity, usually resolved by setting the predictor for one category to zero (but not in this code). That linear predictor is only generated in the underlying C code. On Fri, 7 May 2004, Jacqueline Hall wrote: Dear all, I'm interested in extracting the score from multinomial logistic regression models fit using multinom, to assess the stregth of assocation of the parameter with the response (akin to the score from clogit/cox regression). currently I'm using R 1.8.1. Is there a function that will extract the score from a multinom object or how i can get back to it? or from using glm? I investigated the documention for Design but those functions seem to apply to binary logistic. -- 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 __ [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
[R] randomForests and Y-scrambling on a small synthetic dataset
Dear r-help, The following dataset (generated with perl) has 10 observations of 100 dependant variables (integers drawn uniformly from [1:9]) which is split evenly between two classes.. First I show some work, and then ask two questions at the end. data - read.table (rf_input.dat) library (randomForest) # if we do randomForest one time it looks like this: rf - randomForest (factor(V101) ~. ,data=data) rf$confusion 1 2 class.error 1 5 5 0.5 2 4 6 0.4 # now we do it 100 times tnum - numeric() for (i in 1:100) { MT - data$V101 MT.rf - randomForest (factor(MT) ~ . ,data =data[-c(101)]) number - as.integer (summary ( predict(MT.rf) == MT)[3] ) tnum - c(tnum,number) } + + + + + + + # and this distribution of results (about 13 correct out of 20) quantile (tnum,probs = seq (0,1,0.1),na.rm = T) 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% 9 11 12 12 13 13 13 14 14 15 17 # now lets permute (re-randomize?) the classes and repeat 1000 times: library (gregmisc) tnum - numeric() for (i in 1:1000) { MT - permute (data$V101) MT.rf - randomForest (factor(MT) ~ . ,data =data[-c(101)]) number - as.integer (summary ( predict(MT.rf) == MT)[3] ) tnum - c(tnum,number) } # I get these results: the average is about 8 correct (out of 20) with 13 correct being at about # the 95% confidence level quantile (tnum,probs = seq (0,1,0.1),na.rm = T) 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% 14567889 10 12 18 quantile (tnum,probs = seq (0.9,1,0.01),na.rm = T) 90% 91% 92% 93% 94% 95% 96% 97% 98% 99% 100% 12 12 12 12 12 13 13 14 14 15 18 My two questions: Question 1: Naively I might have expected to get 10/20 for the Y-scrambled examples, but instead I got 8/20. Why is that? (Persumably has something to do with the randomForest only training on 2/3 of the examples.) Question 2: With my Y scrambling exercise I seem to have demonstrated that the original dataset was not random. But yet it is random by construction. Is this just a fluke, or is something wrong with my protocol? thanks in advance, Clayton__ [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] scores from multinomial logistic regression
Note the coxph docs call these `efficient scores', which helps. However, what the `score' part of a coxph object gives is not the score for the addition of a new variable, but for the addition of all the variables, as I understand it. (You could do repeated fits using init=, but that's not what you said.) I am not aware of a good way to do that even for a glm. (Smart people could make add1.lm do it, I guess.) I would just do likelihood ratio tests since computation time is unlikely to be an issue these days. On Fri, 7 May 2004, Jacqueline Hall wrote: Hi, Sorry for not making this clear, By score I meant the score from the score test, for assessing the addition of a new variable to the model. (first derivative of the log likeihood/ information matrix, the ratio (score)having a chi squared distribution of appropriate df) I'm looking for something similar/appropraite for logistic regression, my outcome (response) variable has 4 categories (hence the interest in multinom), the covariates are continuous. Thanks again, Jacqui -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: 07 May 2004 15:07 To: Jacqueline Hall Cc: [EMAIL PROTECTED] Subject: Re: [R] scores from multinomial logistic regression What do you mean by the scores? What multinom does is to fit probabilities (which you can extract by fitted()): the response is a discrete probability distribution. There is an underlying linear predictor but (a) it is K-dimensional and (b) there is a degree of ambiguity, usually resolved by setting the predictor for one category to zero (but not in this code). That linear predictor is only generated in the underlying C code. On Fri, 7 May 2004, Jacqueline Hall wrote: Dear all, I'm interested in extracting the score from multinomial logistic regression models fit using multinom, to assess the stregth of assocation of the parameter with the response (akin to the score from clogit/cox regression). currently I'm using R 1.8.1. Is there a function that will extract the score from a multinom object or how i can get back to it? or from using glm? I investigated the documention for Design but those functions seem to apply to binary logistic. -- 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 __ [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] Font and Color documentation
This is R-specific, and R was but a glimmer of the eye when MASS (1st ed) was written in 1992/3. pp. 79-84 of the current edition does have the information. I think all the information you ask for is in ?par, or that points to the appropriate place. Fonts are device specific. ?par says 'font' An integer which specifies which font to use for text. If possible, device drivers arrange so that 1 corresponds to plain text, 2 to bold face, 3 to italic and 4 to bold italic. and BTW, font 5 is always a symbol font. To go beyond that you need to look at the documentation of the device you use. Many devices (e.g. x11, windows, postscript, pdf) allow you to map fonts to those numbers. There is a whole section on `Color Specification' in ?par, which says colors() gives all the known colour names, and valid numbers are from 0 to the size of the palette. On Fri, 7 May 2004, Iyue Sung wrote: Could someone please point me to documentation on legal font and color specifications (and other 'par' parameters); i.e. font=6 for Times New Roman, col='Red', etc.? Searches in ?par, MASS (1st ed.) and other areas were unsuccessful. I thought I remember seeing it before...somewhere. -- 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 __ [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
[R] Quantile of a function
I have a simple doubt: I have a function, say: test - function (theta) { return (theta^2) } I can use: integrate (test,0,1) to obtain the area under de function. Can I do the opposite? I`d like to give the lower limit and the area I need as arguments, in order to get the upper limit. In other words, I`d like to obtain the quantile of the function (the lower limit could be 0, for example). Thank you in advance. - Yahoo! Messenger - Fale com seus amigos online. Instale agora! [[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
Re: [R] Start problem
Bjørn Økland wrote: I had a well-working R 1.7, however, today the programme did not start, and I recieved an error message. I have uninstalled the R 1.7, and then installed R 1.9. Still it does not start, giving the error message Fatal error: invalid HOMEDRIVE. How can I get it to work? Bjorn Okland [[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 Either try out r-patched or look in the R-help archives for the string Fatal error: invalid HOMEDRIVE. There were several discussions (and hints for a workaround) about that bug introduced by Microsoft's security patch. Uwe Ligges __ [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
[R] rpart for CART with weights/priors
Hi, I have a technical question about rpart: according to Breiman et al. 1984, different costs for misclassification in CART can be modelled either by means of modifying the loss matrix or by means of using different prior probabilities for the classes, which again should have the same effect as using different weights for the response classes. What I tried was this: library(rpart) data(kyphosis) #fit1 from original unweighted data set fit1 - rpart(Kyphosis ~ Age + Number + Start, data=kyphosis) #modify loss matrix loss-matrix(c(0,1,2,0),nrow=2,ncol=2) # true class? #[,1] [,2] #[1,]02 #[2,]10 predicted class? #modify priors prior=c(1/3,2/3) fit2- rpart(Kyphosis ~ Age + Number + Start, data=kyphosis, parms=list(loss=loss)) fit3 - rpart(Kyphosis ~ Age + Number + Start, data=kyphosis, parms=list(prior=prior)) fit2 fit3 par(mfrow=c(2,1)) plot(fit2) text(fit2,use.n=T) plot(fit3) text(fit3,use.n=T) #lead to similar but not identical trees (similar topology but different cutoff points), #while all other combinations (even complete reversion, i.e. preference for the other class) #lead to totally different trees... #third approach using weights: #sorting of data to design weight vector ind-order(kyphosis[,1]) kyphosis1-kyphosis[ind,] summary(kyphosis1[,1]) weight-c(rep(1,64),rep(2,17)) summary(as.factor(weight)) fit4 - rpart(Kyphosis ~ Age + Number + Start, data=kyphosis1, weights=weight) #leads to result very similar to fit2 with loss-matrix(c(0,1,2,0),nrow=2,ncol=2) #(same tree and cutoff points, but slightly different probabilities, maybe numerical artefact?) fit4 plot(fit4) text(fit4,use.n=T) #doule check with inverse loss matrix loss-matrix(c(0,1,2,0),nrow=2,ncol=2,byrow=T) fit2- rpart(Kyphosis ~ Age + Number + Start, data=kyphosis, parms=list(loss=loss)) weight-c(rep(2,64),rep(1,17)) fit4 - rpart(Kyphosis ~ Age + Number + Start, data=kyphosis1, weights=weight) fit2 fit4 #also same except for probabilities yprob I don't see 1. why the approach using prior probabilities doesn't work 2. what causes the differences in predicted probabilities in the weights approach Any idea? Thank You! C. -- __ [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] Quantile of a function
José Fernando Silva wrote: I have a simple doubt: I have a function, say: test - function (theta) { return (theta^2) } I can use: integrate (test,0,1) to obtain the area under de function. Can I do the opposite? I`d like to give the lower limit and the area I need as arguments, in order to get the upper limit. In other words, I`d like to obtain the quantile of the function (the lower limit could be 0, for example). Thank you in advance. If you really want to do it numerically (assuming your function is much more complex and the exmaple one), try e.g. solveit - function (quant, foo, lw, area) { (integrate(foo, lw, quant)$value - area)^2 } optimize(solveit, c(0, 100), foo = function(theta) theta^2, lw = 0, area = 0.95) Uwe Ligges - Yahoo! Messenger - Fale com seus amigos online. Instale agora! [[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
[R] cannot allocate vector of length 1072693248
Well, I've done everything I can think of the make the code more efficient, but it seems (if I read this error message correctly) that I'm running out of memory on what should be small data set. Here's the sequence: A vector of 30 possible identifiers For each value, query a MySQL database to pull in 80 or so records Run a few different random Forests on those data Print the results as I go rm() all the objects created in the loop, including all the old data Next value, to repeat for each identifier. Round the 3rd time through the loop, I get kicked out with: Error in as.vector(data) : cannot allocate vector of length 1072693248 This is on Mac OS X, which is UNIX-based (from freeBSD, as I understand it), so I haven't set anything special with the memory at startup. But then, I only have 80 observations running through at a time, so it doesn't seem like there should be a memory issue. Any ideas? __ [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] cannot allocate vector of length 1072693248
I think it is more likely that you have a bug. Probably you have run out of address space, as that's almost 4Gb if an integer and 8Gb if real. Can you do options(error=dump.frames) and debugger() after the error message and try to find out what `data' is and what size it is. On Fri, 7 May 2004, David L. Van Brunt, Ph.D. wrote: Well, I've done everything I can think of the make the code more efficient, but it seems (if I read this error message correctly) that I'm running out of memory on what should be small data set. Here's the sequence: A vector of 30 possible identifiers For each value, query a MySQL database to pull in 80 or so records Run a few different random Forests on those data Print the results as I go rm() all the objects created in the loop, including all the old data Next value, to repeat for each identifier. Round the 3rd time through the loop, I get kicked out with: Error in as.vector(data) : cannot allocate vector of length 1072693248 This is on Mac OS X, which is UNIX-based (from freeBSD, as I understand it), so I haven't set anything special with the memory at startup. But then, I only have 80 observations running through at a time, so it doesn't seem like there should be a memory issue. Any ideas? __ [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 -- 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 __ [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] cgi/servlets/httpd in R
Samuelson, Frank* wrote: Currently I use such a method on my computing cluster: All 40 compute nodes run an R process/compute server that listens at a socket for any connection and subsequent commands from another computer. When the master process disconnects, the R processes go back to listening at the socket. Connecting to the R compute servers this way takes 2 milliseconds rather than the typical ~2 second R startup time. Your solution seems what I am looking for, actually. Questions: 1. How do you communicate with an R process? I can only think of embedded code like SQL in Perl. 2. How do you find an R node that is open? 2.5 You are haveing cgi scripts connect to the R processes, right? Or are the R processes available for another purpose? 3. How much of your code are you willing to share :)? We are interested in making demographic analysis tools available online (life-table-ish stuff to start with, then as much as we can get grant money for). W __ [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] cannot allocate vector of length 1072693248
Thanks for the suggestion. If there's a bug in my code, I can't find it. The code runs successfully several times through. And I have only a few lines, but repeated in blocks with a few tweaks to make different predictions each time. If I comment out a line that preceeds a crash, it will run a little longer before giving up next time. So it is as if something is slowly filling up through each run, and is accumulating. But I do rm() all the objects created inside of the for loop, and then gc() before the loop is finished, also. So I'm stumped. When I called the debugger, the last item shown was the vector line, so I chose that option and typed ls()... It had only mode and x. The value of mode was any, and when I tried to display x, I expected a slew of data but instead R crashed. Don't know if that's informative or not! On 5/7/04 11:42, Prof Brian Ripley [EMAIL PROTECTED] wrote: I think it is more likely that you have a bug. Probably you have run out of address space, as that's almost 4Gb if an integer and 8Gb if real. Can you do options(error=dump.frames) and debugger() after the error message and try to find out what `data' is and what size it is. On Fri, 7 May 2004, David L. Van Brunt, Ph.D. wrote: Well, I've done everything I can think of the make the code more efficient, but it seems (if I read this error message correctly) that I'm running out of memory on what should be small data set. Here's the sequence: A vector of 30 possible identifiers For each value, query a MySQL database to pull in 80 or so records Run a few different random Forests on those data Print the results as I go rm() all the objects created in the loop, including all the old data Next value, to repeat for each identifier. Round the 3rd time through the loop, I get kicked out with: Error in as.vector(data) : cannot allocate vector of length 1072693248 This is on Mac OS X, which is UNIX-based (from freeBSD, as I understand it), so I haven't set anything special with the memory at startup. But then, I only have 80 observations running through at a time, so it doesn't seem like there should be a memory issue. Any ideas? __ [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 -- David L. Van Brunt, Ph.D. Outlier Consulting Development mailto: [EMAIL PROTECTED] __ [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] cgi/servlets/httpd in R
[EMAIL PROTECTED] wrote: Your solution seems what I am looking for, actually. Questions: FWIW, another possible option if your data is stored in an RDBMS is Postgres with PL/R; see: http://www.joeconway.com/plr/ As of Postgres 7.4 you can preload and initialize libraries at postmaster start, which means that each forked database backend includes a fully initialized copy of libR. If you are interested, there is some information available regarding how to use this with PHP to generate online charts here: http://www.joeconway.com/oscon-pres-2003-1.pdf HTH, Joe __ [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] I have some problem about save and open
If you want to save the workspace to a file, type: save.image(filename) To load the file, type: load(filename) The save that you do when you exit R saves by default to a (typically) hidden file called .Rdata. If you start R in a directory with a .Rdata file in it, R will load that file automatically. Sean - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, May 03, 2004 10:32 PM Subject: [R] I have some problem about save and open Hello R-help I use R program on linux. and when I would like to quick R, then I type q() after than has question Save workspace image? [y/n/c]: when I ans y , why not to ask about name of file. and when I would like to open last file , how can I do? thanks for your help. and sorry if my English not so good. I'm Thai people and I know English a little. Mathinee __ [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
[R] dump.frames in non-interactive mode
Hi, recover() resorts to dump.frames() when called in non-interactive sessions. However dump.frames() still puts the dump into last.dump object and not into a file, which brings the question of how to get hold of the object once the session terminates. I guess the supposed answer is that last.dump is saved in .Rdata once R exits. However I find it more convenient on day-to-day basis to use --no-save --no-restore options and avoid .Rdata. So my question is how to best set a hook, in say .Rprofile, so that in non-interactive mode (and only in it) last.dump (and only it) will be saved in a file upon exit from R. Thanks, Vadim [[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
Re: [R] dump.frames in non-interactive mode
On Fri, 7 May 2004, Vadim Ogranovich wrote: recover() resorts to dump.frames() when called in non-interactive sessions. However dump.frames() still puts the dump into last.dump object and not into a file, which brings the question of how to get hold of the object once the session terminates. This is discussed in the help file for dump.frames ... If 'dump.frames' is installed as the error handler, execution will continue even in non-interactive sessions. See the examples for how to dump and then quit. I guess the supposed answer is that last.dump is saved in .Rdata once R exits. However I find it more convenient on day-to-day basis to use --no-save --no-restore options and avoid .Rdata. So my question is how to best set a hook, in say .Rprofile, so that in non-interactive mode (and only in it) last.dump (and only it) will be saved in a file upon exit from R. dump.frames has parameters to do exactly this. -- 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 __ [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] generating data
Hello I am trying to generate data in say 2D x,y for a circle. I think data are usually collected... GP -- __ [ ] [ Giovanni Petris [EMAIL PROTECTED] ] [ Department of Mathematical Sciences ] [ University of Arkansas - Fayetteville, AR 72701 ] [ Ph: (479) 575-6324, 575-8630 (fax) ] [ http://definetti.uark.edu/~gpetris/ ] [__] __ [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
[R] Lattice xyplot - problem trying to produce multiple output files with a 'for' loop
I am stuck on trying to get the Lattice xyplot to output a separate PNG file each time through my 'for' loop. The files get produced but are empty. Here is the code. I'm running 1.9 on Windows. BTW is there a more efficient way of creating the separate output files than looping over the levels and subsetting? . lev - levels(ds$TR) for (byvar in lev) { file.png - paste(u:/data/R/Scatter_CTY_HWY_CO_TR, byvar, .png, sep=) trellis.device( device=png, file=file.png, width=1000, height=1000, pointsize=20, bg=transparent ) ds1 - subset(ds, TR == byvar, select=c(CTY, HWY, CO)) xyplot( ds1$CTY ~ ds1$HWY, groups=ds1$CO, auto.key=list(space=right), ylab=CTY, xlab=HWY) dev.off() } . --Rich Richard Kittler AMD TDG 408-749-4099 __ [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] Lattice xyplot - problem trying to produce multiple output files with a 'for' loop
[EMAIL PROTECTED] wrote: I am stuck on trying to get the Lattice xyplot to output a separate PNG file each time through my 'for' loop. The files get produced but are empty. Here is the code. I'm running 1.9 on Windows. BTW is there a more efficient way of creating the separate output files than looping over the levels and subsetting? . lev - levels(ds$TR) for (byvar in lev) { file.png - paste(u:/data/R/Scatter_CTY_HWY_CO_TR, byvar, .png, sep=) trellis.device( device=png, file=file.png, width=1000, height=1000, pointsize=20, bg=transparent ) ds1 - subset(ds, TR == byvar, select=c(CTY, HWY, CO)) xyplot( ds1$CTY ~ ds1$HWY, groups=ds1$CO, auto.key=list(space=right), ylab=CTY, xlab=HWY) dev.off() } . --Rich Richard Kittler AMD TDG 408-749-4099 __ [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 See the FAQ. you have to wrap the xyplot call with a print. I.e. for(...) { ... print(xyplot(...)) ... } __ [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
[R] Invalid HOMEDRIVE
Attempting to install the most recent R on a Windows/XP machine, I get what appears to be a normal (completely default) installation. Then when I attempt to load rgui I get the fatal error message: Invalid HOMEDRIVE. Any explanation of the error or suggestions of fixes to files or registry would be appreciated. -- Jim Stimson Email: [EMAIL PROTECTED] Web: http://www.unc.edu/~jstimson Phone: (919) 962-0428 Fax: (919) 962-0432 Home: (919) 968-0942 Department of Political Science University of North Carolina at Chapel Hill Chapel Hill, NC 27599-3265 __ [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
[R] plotting planes and lines in wireframe()
Hi R-helpers I would like to plot some planes which are perpendicular to the x-y plane, such as x=y. Is there a way to do this in wireframe? I realize that I am not plotting a function of x, y since there are infinite number of z's that satisfy the above relation Hmm... Somewhat related, I would also like to plot a line in 3 d space... Finally, if you are feeling really brave, I am interested in doing all of this based on sums generating vectors (I know there is a linear algebra term for this) -- ie generate the plane based on c_1*v_1 + c_2*v_2 for c_1 and c_2 in reals. Thanks again to all you helpful folks! W __ [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
[R] Error compiling ROracle on Windows 2000
Hello, I am trying to compile ROracle _0.5-4 under R 1.9.0 without much success. I am running Windows 2000 SP4, Visual C++ 6.0 SP6, and Oracle client 9.2.0.1.0. I was able to run the pre-compiled version of ROracle_0.5-2 under R 1.7.1, but does not work on R 1.8.1 or R 1.9.0. Here is the output from nmake: C:\Program Files\R\rw1090\library\ROracle\srcnmake Microsoft (R) Program Maintenance Utility Version 6.00.9782.0 Copyright (C) Microsoft Corp 1988-1998. All rights reserved. cl /IC:\\Program Files\\R\\rw1090\\src\\include /MT /Ox /D MSVC /D WIN32 /c RS-DBI.c Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86 Copyright (C) Microsoft Corp 1984-1998. All rights reserved. RS-DBI.c cl /IC:\\Program Files\\R\\rw1090\\src\\include /MT /Ox /D MSVC /D WIN32 /c RS-Oracle.c Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86 Copyright (C) Microsoft Corp 1984-1998. All rights reserved. RS-Oracle.c NMAKE : fatal error U1073: don't know how to make '\src\\gnuwin32\\Rdll.lib' Stop. Here is a copy of my Makefile: R_HOME = C:\\Program Files\\R\\rw1090 ORACLE_HOME = C:\\oracle\\oracle92 SRC = RS-DBI.h RS-DBI.c RS-Oracle.h RS-Oracle.pc S4R.h RLIB = $(R_HOME)\\src\\gnuwin32\\Rdll.lib OBJ = RS-DBI.obj RS-Oracle.obj ## ## The Oracle ProC/C++ precompiler and options we need (these have worked ## on Linux, Solaris, and Windows 2000). ## PROC=proc ## this is the ProC/C++ executable CODE=ANSI_C## the following are ProC/C++ options MODE=ORACLE PARSE=NONE ## don't do any C parse LINES=false## use true for debugging ROracle.dll: $(OBJ) $(RLIB) (cd $(R_HOME)\\src\\gnuwin32 lib /def:R.exp /out:Rdll.lib) link /dll /def:ROracle.def /out:ROracle.dll $(ORACLE_HOME)\\precomp\\lib\\orasql9.lib *.obj $(R_HOME)\\src\\gnuwin32\\Rdll.lib RS-DBI.obj: RS-DBI.h RS-DBI.c S4R.h cl /I$(R_HOME)\\src\\include /MT /Ox /D MSVC /D WIN32 /c RS-DBI.c RS-Oracle.obj: RS-Oracle.h RS-Oracle.c S4R.h cl /I$(R_HOME)\\src\\include /MT /Ox /D MSVC /D WIN32 /c RS-Oracle.c RS-Oracle.c: RS-Oracle.h RS-Oracle.pc $(PROC) CODE=$(CODE) MODE=$(MODE) INCLUDE=$(R_HOME)/include \ PARSE=$(PARSE) LINES=$(LINES) RS-Oracle.pc force-Rdll.lib: (cd $(R_HOME)\\src\\gnuwin32 lib /def:R.exp /out:Rdll.lib) clean: rm -f $(OBJ) *.a *.d *.rc clobber: rm -f $(RLIB) $(OBJ) RS-Oracle.c *.a *.d *.rc *.dll Thanks for your help, Mark __ [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
[R] re-ordering a vector by name
Dear R-help, Let's say `x1' and `x2' are very long vectors (length=5e5, say) with same set of names but in different order. If I want to sort `x2' in the order of `x1', I would do x2[names(x1)] but the amount of time that takes is quite prohibitive! Does anyone have any suggestion on a more efficient way to do this? If the two vectors are exactly the same length (as I said above), sorting both by names would probably be the fastest. However, if the two vectors differ in length (and the names for the shorter one are a subset of names of the longer one) then that doesn't work... Best, Andy __ [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] re-ordering a vector by name
I suspect three causes for slowness: 1) possibly names are lot of overhead (string compares, lookup, etc). 2) maybe it's just memory, in which case you could loop over chunks of the names(x1) vector 3) you're basically asking for the permutation taking names(x2) into names(x1) and then applying it to x2. The first step is a sort but perhaps the indexing code doesn't optimize that. Reid Huntsinger -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Liaw, Andy Sent: Friday, May 07, 2004 5:16 PM To: [EMAIL PROTECTED] Subject: [R] re-ordering a vector by name Dear R-help, Let's say `x1' and `x2' are very long vectors (length=5e5, say) with same set of names but in different order. If I want to sort `x2' in the order of `x1', I would do x2[names(x1)] but the amount of time that takes is quite prohibitive! Does anyone have any suggestion on a more efficient way to do this? If the two vectors are exactly the same length (as I said above), sorting both by names would probably be the fastest. However, if the two vectors differ in length (and the names for the shorter one are a subset of names of the longer one) then that doesn't work... Best, Andy __ [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 -- Notice: This e-mail message, together with any attachments,...{{dropped}} __ [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] cgi/servlets/httpd in R
Samuelson, Frank* [EMAIL PROTECTED] writes: Here's a related question: Do any of the mentioned R-web interfaces (Rweb, R-Online, CGIwithR, RSPerl) support reusing the same R process, eliminating the startup overhead? This would be useful to me as well. Greg Warnes' RSOAP allows you to pre-start a pool of processes to eliminate this under light/moderate load. It's on my lab group's WWW page. best, -tony -- [EMAIL PROTECTED]http://www.analytics.washington.edu/ Biomedical and Health Informatics University of Washington Biostatistics, SCHARP/HVTN Fred Hutchinson Cancer Research Center UW (Tu/Th/F): 206-616-7630 FAX=206-543-3461 | Voicemail is unreliable FHCRC (M/W): 206-667-7025 FAX=206-667-4812 | use Email CONFIDENTIALITY NOTICE: This e-mail message and any attachme...{{dropped}} __ [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] Invalid HOMEDRIVE
Jim Stimson wrote: Attempting to install the most recent R on a Windows/XP machine, I get what appears to be a normal (completely default) installation. Then when I attempt to load rgui I get the fatal error message: Invalid HOMEDRIVE. Any explanation of the error or suggestions of fixes to files or registry would be appreciated. 1) Follow the instructions in the posting guide, which asks you to search the archives before posting (saves us both time). 2) From there, you'll find https://www.stat.math.ethz.ch/pipermail/r-help/2004-April/048397.html Short answer - it's a bug introduced by a Microsoft critical update (out with the old bugs, in with the new!). Cheers Jason __ [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] re-ordering a vector by name
Liaw, Andy wrote: Dear R-help, Let's say `x1' and `x2' are very long vectors (length=5e5, say) with same set of names but in different order. If I want to sort `x2' in the order of `x1', I would do x2[names(x1)] but the amount of time that takes is quite prohibitive! Does anyone have any suggestion on a more efficient way to do this? If the two vectors are exactly the same length (as I said above), sorting both by names would probably be the fastest. However, if the two vectors differ in length (and the names for the shorter one are a subset of names of the longer one) then that doesn't work... Best, Andy __ [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 Hi Andy, Using match seems to be *much* faster: R x1 - 1:1; names(x1) - 1:1 R x2 - 1:1; names(x2) - 1:1 R system.time(x3 - x1[names(x2)]) [1] 1.88 0.00 1.88 NA NA R system.time(x4 - x1[match(names(x1), names(x2))]) [1] 0.01 0.00 0.01 NA NA R all.equal(x3, x4) [1] TRUE R This should also work if x1 and x2 are of diffent lengths. --sundar __ [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] plotting planes and lines in wireframe()
On Friday 07 May 2004 16:07, [EMAIL PROTECTED] wrote: Hi R-helpers I would like to plot some planes which are perpendicular to the x-y plane, such as x=y. Is there a way to do this in wireframe? I realize that I am not plotting a function of x, y since there are infinite number of z's that satisfy the above relation Hmm... Well, from R 1.9.0 onwards wireframe can draw arbitrary 3-D parametric surfaces (spheres and such) with a formula of the form z ~ x * y where x, y and z are all matrices. A plane is a very trivial application of this, e.g.: x - matrix(rep(1:10, 10), 10) y - x z - matrix(rep(1:10, each = 10), 10) wireframe(z ~ x * y) Of course, you are probably not interested in only this plane, in which case things may not be as easy, since (1) formally there's no way to specify multiple surfaces with this usage and (2) wireframe doesn't do hidden surface removal, so intersecting surfaces are messed up. But in many cases you can probably make do with a fine mesh and some innovative use of NA's. e.g. (continuing the earlier example): xx - cbind(x, NA, x) yy - cbind(y+50, NA, y^2) zz - cbind(z, NA, z) wireframe(zz ~ xx * yy) Somewhat related, I would also like to plot a line in 3 d space... That's also easy, e.g. cloud(1:3 ~ 3:1 * 1:3) (there seems to be bug with just 2 points, I'll fix that in the next release). To do this in a wireframe plot you would probably use the panel function panel.3dscatter. What's not easy, however, when you are combining planes and lines, is to make sure that the appropriate parts of the line are hidden. Finally, if you are feeling really brave, I am interested in doing all of this based on sums generating vectors (I know there is a linear algebra term for this) -- ie generate the plane based on c_1*v_1 + c_2*v_2 for c_1 and c_2 in reals. You mean the span of v_1 and v_2 ? Very easy with the approach outlined above. Visualize a rectangular grid on the c_1-c_2 plane determining the ranges of c_1 and c_2. Let's say the ranges are c1 and c2, e.g., c1 = c2 = seq(0, 1, length = 11). Next, evaluate the values of c1 and c2 on this grid as matrices: tmp = expand.grid(c1 = c1, c2 = c2) mc1 = matrix(tmp$c1, length(c1)) mc2 = matrix(tmp$c2, length(c1)) Next evaluate the corresponding points on your plane: x = v1[1] * mc1 + v2[1] * mc2 y = v1[2] * mc1 + v2[2] * mc2 z = v1[3] * mc1 + v2[3] * mc2 and plot them wireframe(z ~ x * y) If you don't like the distortion, you could use a wide range of c1 and c2 and then use appropriate x/y/zlim. Deepayan __ [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] re-ordering a vector by name
From: Sundar Dorai-Raj Liaw, Andy wrote: Dear R-help, Let's say `x1' and `x2' are very long vectors (length=5e5, say) with same set of names but in different order. If I want to sort `x2' in the order of `x1', I would do x2[names(x1)] but the amount of time that takes is quite prohibitive! Does anyone have any suggestion on a more efficient way to do this? If the two vectors are exactly the same length (as I said above), sorting both by names would probably be the fastest. However, if the two vectors differ in length (and the names for the shorter one are a subset of names of the longer one) then that doesn't work... Best, Andy Hi Andy, Using match seems to be *much* faster: R x1 - 1:1; names(x1) - 1:1 R x2 - 1:1; names(x2) - 1:1 R system.time(x3 - x1[names(x2)]) [1] 1.88 0.00 1.88 NA NA R system.time(x4 - x1[match(names(x1), names(x2))]) [1] 0.01 0.00 0.01 NA NA R all.equal(x3, x4) [1] TRUE R This should also work if x1 and x2 are of diffent lengths. --sundar Sundar, Thanks very much for the tip! However, I think the arguments in match() is backward: n = 1e4 x1 = sample(n) x2 = sample(n) names(x1) = sample(n) names(x2) = sample(n) system.time(x3 - x1[names(x2)]) [1] 5.71 0.00 6.02 NA NA system.time(x4 - x1[match(names(x1),names(x2))]) [1] 0.03 0.00 0.03 NA NA all.equal(x3, x4) [1] Names: 9997 string mismatches Mean relative difference: 0.669837 names(x3[1:5]) [1] 5391 9927 6499 1863 8287 names(x4[1:5]) [1] 2560 9914 6348 1291 5718 system.time(x4 - x1[match(names(x2),names(x1))]) [1] 0.03 0.00 0.03 NA NA names(x4[1:5]) [1] 5391 9927 6499 1863 8287 all.equal(x3, x4) [1] TRUE [Admittedly this is why I rarely use match(): I get mixed up easily.] Reid: It isn't a memory problem. For vectors of length 6e5, I killed the R process after more than 5 hours on an Opteron 248. The R process was taking up about 114MB of RAM, out of 8GB in the box. I'm rather surprised that such seemingly simple operation would take so long, especially when sorting such vectors is very fast. What am I missing? Best, Andy __ [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