Re: [R] F values from a Repeated Measures aov
Alex Baugh wrote: Hi Folks, I have repeated measures for data on association time (under 2 acoustic condtions) in male and female frogs as they grow to adulthood (6 timepoints). Thus, two within-subject variables (Acoustic Condition: 2 levels, Timepoint: 6 levels) and one between-subject variable (Sex:male or female). I am pretty sure my distributions depart from normality but I would first like to simply run a RM anova on the data. My problem is that when I do this I generate different values of F for my main effects and interaction when I do the analysis in [R] and SPSS - so I don't know which one to believe. Here is my code in R: mydata.tab=read.delim(mydata.txt, header=T) #read in my data mydata.tab$Timepoint=as.factor(mydata.tab$Timepoint)#col headings are factors so df are correct mydata.tab$Acx.Cond=as.factor(mydata.tab$Acx.Cond) mydata.tab$Sex=as.factor(mydata.tab$Sex) aov.F=aov(Targ.Assoc.Time~(Timepoint*Acx.Cond*Sex) + Error(Subject/(Timepoint*Acx.Cond))+(Sex), data=mydata.tab) #run aov where i look at the main effects of Timepoint, Acoustic Condition and Sex as well as all the interactions therein on the amount of time a frog spends associating with the target sound. Include anything to do with Subject in the error term. Does this look right for a Repeated Measures ANOVA, or am I missing something to make it RM and that explains the large discrepancies in my F-values between [R] and SPSS? Nothing obviously wrong to my eyes. There's a stray (Sex) term, but I don't think that actually does anything. I assume that your data are balanced and complete. Apart from that it coincides with my expectation of what SPSS would do. You'd give us a better chance of helping if you actually included some output on the two systems. If you approach this as a multivariate linear model (with 12-dimensional response), then you can also use the features of anova.mlm (the example on the help page is quite similar to your setup). This takes a bit more work, but it give the epsilon corrections that people like to calculate for these models. As soon as I get this canonical aov code figured out I want to derive my p-values by bootstrapping my F distributions, but first I need those canonical F's. Thanks -Alex -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R help
Does your res.dat only have one row and you want this to one variable? For read.table each new case has to start on a new line. If your data are in a just one row for a variable format, res - scan(C:/Documents and Settings/db/Desktop/res.dat) will probably do what you want. Debasish Roy wrote: I tried to read a dataset and then draw a histogram with a freqeuncy density curve fitted on the top of this. I used the command res - read.table(C:/Documents and Settings/db/Desktop/res.dat) and found res[1:5] V1 V2 V3 V4 V5 1 -0.4806 0.5075 0.0491 -0.7985 -0.666 Then I got the following when I troied to plot it hist(res) Error in hist.default(res) : 'x' must be numeric Even I tried hist(res[,2]) which is showing a blank plot. My suspision is something is wrong in the way the data was read (with V1, V2, V3 etc). Can someone please help me how to get rid of this problem ? Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Erich Neuwirth, University of Vienna Faculty of Computer Science Computer Supported Didactics Working Group Visit our SunSITE at http://sunsite.univie.ac.at Phone: +43-1-4277-39464 Fax: +43-1-4277-39459 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Simulation study in R
Here I am in a simulation study where I want to find different values of x and y such that f(x,y)=c (some known constant) w.r.t. x, y 0, y=x and x=c1 (another known constant). Can anyone please tell me how to do it efficiently in R. One way I thought that I will draw different random numbers from uniform dist according to that constraints and pick those which satisfy f(x,y)=c. However it is not I think computationally efficient. Can anyone here suggest me any other efficient approach? Regards, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] nls plinear formula
I want to fit a nonlinear model of the form: Y=A+B*X1+C*X2+log(X3/(X3+D)) I think that the best way is to use the plinear algorithm, but I don't know how to specify the formula in the nls function. I've tried: Y~cbind(rep(1,times=length(Y)),X1,X2,log(X3/(X3+D))) But this fits the model: Y=A+B*X1+C*X2+D1*log(X3/(X3+D)) How can I specify the formula correctly? Thanks, M __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Simulation study in R
Are the pairs (x,y) belong to some lattice or can change continuously? Does f assume some discrete values (or is constant on sets of positive measure)? If not then it will be hard to randomly select x and y which satisfy the exact equality (this still can happen since there are finitely many computer numbers, but their number is quite large!). So if f change continuously you may need the condition |f(x,y) - c| epsilon for some epsilon 0. Regards, Moshe. --- Arun Kumar Saha [EMAIL PROTECTED] wrote: Here I am in a simulation study where I want to find different values of x and y such that f(x,y)=c (some known constant) w.r.t. x, y 0, y=x and x=c1 (another known constant). Can anyone please tell me how to do it efficiently in R. One way I thought that I will draw different random numbers from uniform dist according to that constraints and pick those which satisfy f(x,y)=c. However it is not I think computationally efficient. Can anyone here suggest me any other efficient approach? Regards, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Simulation study in R
x, y are cont. variable, and f also have to be cont.. And your second suggestion is correct of course, it actually should be |f(x,y) - c| epsilon Thanks On Tue, Apr 29, 2008 at 12:34 PM, Moshe Olshansky [EMAIL PROTECTED] wrote: Are the pairs (x,y) belong to some lattice or can change continuously? Does f assume some discrete values (or is constant on sets of positive measure)? If not then it will be hard to randomly select x and y which satisfy the exact equality (this still can happen since there are finitely many computer numbers, but their number is quite large!). So if f change continuously you may need the condition |f(x,y) - c| epsilon for some epsilon 0. Regards, Moshe. --- Arun Kumar Saha [EMAIL PROTECTED] wrote: Here I am in a simulation study where I want to find different values of x and y such that f(x,y)=c (some known constant) w.r.t. x, y 0, y=x and x=c1 (another known constant). Can anyone please tell me how to do it efficiently in R. One way I thought that I will draw different random numbers from uniform dist according to that constraints and pick those which satisfy f(x,y)=c. However it is not I think computationally efficient. Can anyone here suggest me any other efficient approach? Regards, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] generic question - Genomics with R
Hi everybody, I am trying to make my mind about the use of R for Computational and Statistical Approaches to Genomics. I know this is a vaste field: this is the main reason why I am sending this message to this always useful list! Any key/entry point to this field will be extremely welcome! Please, could you help me to go in the right direction? Thanks!!! Ricardo -- Ricardo Rodríguez Your XEN ICT Team __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] resolution (dpi) problem
To all those who helped with this problem (Ted, Jon, Marc and Prof. Ripley). When I submitted the postscript files to the journal, I had given them the extension .ps even though they were (of course) encapsulated postscript. I decided to simply rename the files with the .eps extension and resubmit. This time the images were accepted without question. It would appear to be a case of someone assuming that I had submitted postscript without bothering to check that it was encapsulated. Thanks again Chris [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Set of well distinguishable line types?
That's a nice set of line types! I'll use these now. I thought because there are so many sophisticated color schemes there might be some line style schemes as well. Thanks for your help Jim and Richard, Werner --- Richard Pearson [EMAIL PROTECTED] schrieb: I've used the following to get a few different line types. However, I'd be interested to hear from someone with expertise in creating line types that are maximally distinguishable by human eyes. ltys = c(22, 44, 13, 1343, 73, 2262, 12223242, F282, F4448444, 224282F2, F1) Best wishes Richard. Jim Lemon wrote: Werner Wernersen wrote: Hi, I am plotting several lines into one plot and would like them to be distinguishable in print later on as well. Thus, my question is: Is there a larger set of such line types available like the sets available for colors? Maybe somebody has already put in the work to define some additional good looking and distinguishable line types. Hi Werner, If you look at lty, there is an option for defining broken line types by strings of up to 8 hexadecimal digits, e.g. abline(h=1,lty=28f8) gives a line like the centerline used in mechanical drawing. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Richard D. Pearson [EMAIL PROTECTED] School of Computer Science, http://www.cs.man.ac.uk/~pearsonr University of Manchester, Tel: +44 161 275 6178 Oxford Road, Mob: +44 7971 221181 Manchester M13 9PL, UK.Fax: +44 161 275 6204 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] generic question - Genomics with R
Hello, On 4/29/08, [Ricardo Rodriguez] Your XEN ICT Team [EMAIL PROTECTED] wrote: I am trying to make my mind about the use of R for Computational and Statistical Approaches to Genomics. [..] Please, could you help me to go in the right direction? I am not sure what pointers you are looking for, but checking the CRAN Task Views [1] may be a starting point. Liviu [1] http://cran.r-project.org/web/views/index.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] empirical null distribution
It's not really homework :) It's just an a little extra I want to explore. I allready compared the empirical null distribution and the theoritical null distribution by comparing their quantiles. The results are clear... But I just wondered if there isn't any way to make a graph of it...so you don't really need to compare numbers...that the image speaks for itself. I'm kind of a newbie in R...I did learn many things allready but this graphics stuff is kind of complex to me... -- View this message in context: http://www.nabble.com/empirical-null-distribution-tp16945981p16954788.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Variogram problem
Hello, I'm french and I have some difficulties in carry out the semiones under R with an aim to carry out an interpolation by krigeage. My goal is to obtain a chart of the distribution of precipitations/temperatures in Europe starting from 73 different stations (and, of course, distributed irregularly on the chart, where use of the krigeage). Here, I carried out this to test to obtain semivariogram spherical by groping: x-ts(rnorm(73)) cs1-corSpher(form=~x) y-Variogram(cs1,2628) #2628 corresponding to the distance described in l' helps, that is to say the number of station* (the number of station -1) /2. But there does not go it misses apparently much d' information. Having begun under R for approximately one month, I have not controlled all his language yet, I am completely lost. Thank you for your answers, your assistance would facilitate the task largely to me! -- View this message in context: http://www.nabble.com/Variogram-problem-tp16953929p16953929.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] generic question == mapping Longhurst biogeochemical ocean provinces in R
Hello all I am a newbie to R plotting maps. I am trying to plot over a world map a layer of Biogeochemical provinces (BGCP) by A.R. Longhurst. Each ocean region unfortunately are quite irregular in shape (not perfect squares). In GIS this layer of ocean provinces would be a layer of polygons, which I am assuming it cannot be plotted with R. I was wondering If anybody has encounter this problem before, to plot a GIS layer of polygons into a map in R. *Thanks a lot * -- ))):) ))):) ))):) ))):) ))):) ))):) ))):) ))):) Maria Jose Juan Jorda AZTI - Tecnalia / Unidad de Investigación Marina Herrera Kaia Portualde z/g 20110 Pasaia, Gipuzkoa, Spain Recursos Marinos y Pesquerias Depart. Biologia Animal, Vegetal y Ecologia Universidade A Coruña Campus A Zapateira s/n 15071, A Coruña, Spain Tel. Oficina +34-981167000 ext. 2204 Tel. Mobil + 34-671072900 Fax. +34981167065 [EMAIL PROTECTED] [EMAIL PROTECTED] -- ))):) ))):) ))):) ))):) ))):) ))):) ))):) ))):) Maria Jose Juan Jorda AZTI - Tecnalia / Unidad de Investigación Marina Herrera Kaia Portualde z/g 20110 Pasaia, Gipuzkoa, Spain Recursos Marinos y Pesquerias Depart. Biologia Animal, Vegetal y Ecologia Universidade A Coruña Campus A Zapateira s/n 15071, A Coruña, Spain Tel. Oficina +34-981167000 ext. 2204 Tel. Mobil + 34-671072900 Fax. +34981167065 [EMAIL PROTECTED] [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Using machine learning model to work on new data
---BeginMessage--- ---End Message--- 本信件可能包含工研院機密資訊,非指定之收件者,請勿使用或揭露本信件內容,並請銷毀此信件。 This email may contain confidential information. Please ...{{dropped:5}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 find the minimum
I am a new R user, and not very good at statistics and maths I find it difficult to find the minimum of this item: ((p*(b-1)-1)*(p+1)^(b-1)+1)/p^2 It seems that the method optim can find the minimum. I tried several times , but R constanly tells that failure to find b or p Would you please give some suggestions? Put down your copy of R, and step away from the computer! This is a reasonably straightforward calculus problem, and you'll likely get more insight solving it with pen and paper ...and if you can't differentiate, then now is as good a time to learn as any! Regards, Richie. Mathematical Sciences Unit HSL ATTENTION: This message contains privileged and confidential inform...{{dropped:20}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Variogram problem
Nicolas, I think you better have a look at the gstat package. install.packages(gstat) library(gstat) example(gstat) ?variogram ?krige HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Fritier Nicolas Verzonden: dinsdag 29 april 2008 9:53 Aan: r-help@r-project.org Onderwerp: [R] Variogram problem Hello, I'm french and I have some difficulties in carry out the semiones under R with an aim to carry out an interpolation by krigeage. My goal is to obtain a chart of the distribution of precipitations/temperatures in Europe starting from 73 different stations (and, of course, distributed irregularly on the chart, where use of the krigeage). Here, I carried out this to test to obtain semivariogram spherical by groping: x-ts(rnorm(73)) cs1-corSpher(form=~x) y-Variogram(cs1,2628) #2628 corresponding to the distance described in l' helps, that is to say the number of station* (the number of station -1) /2. But there does not go it misses apparently much d' information. Having begun under R for approximately one month, I have not controlled all his language yet, I am completely lost. Thank you for your answers, your assistance would facilitate the task largely to me! -- View this message in context: http://www.nabble.com/Variogram-problem-tp16953929p16953929.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R on X11 under Linux (newbie)
Em Seg 28 Abr 2008, Dumblauskas, Jerry escreveu: Thx I verified by typing in plot(1,1) at the R prompt -- sure enough an X window popped up on my desktop. Off to investigate Linux GUI front ends! Thx again Hi, at this moment the best IDE to use R on Linux in my opinion are in sequence: 1) emacs+ess 2) jgr 3 rgnome there are some others more complete GUI like Rcommander, pmg, rkward -- . _|_ .-' '-. / \ ^|^ | ejm97 \_/ -- Prof. Ronaldo Reis Júnior | .''`. UNIMONTES/Depto. Biologia Geral/Lab. de Biologia Computacional | : :' : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil | `- Fone: (38) 3229-8187 | [EMAIL PROTECTED] | [EMAIL PROTECTED] | http://www.ppgcb.unimontes.br/ | ICQ#: 5692561 | LinuxUser#: 205366 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] generic question - Genomics with R
I'd also suggest you check out http://www.bioconductor.org - Bioconductor is an open source and open development software project for the analysis and comprehension of genomic data Richard. Liviu Andronic wrote: Hello, On 4/29/08, [Ricardo Rodriguez] Your XEN ICT Team [EMAIL PROTECTED] wrote: I am trying to make my mind about the use of R for Computational and Statistical Approaches to Genomics. [..] Please, could you help me to go in the right direction? I am not sure what pointers you are looking for, but checking the CRAN Task Views [1] may be a starting point. Liviu [1] http://cran.r-project.org/web/views/index.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Richard D. Pearson [EMAIL PROTECTED] School of Computer Science,http://www.cs.man.ac.uk/~pearsonr University of Manchester, Tel: +44 161 275 6178 Oxford Road, Mob: +44 7971 221181 Manchester M13 9PL, UK.Fax: +44 161 275 6204 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] generic question - Genomics with R
I'm not sure what you are trying to do with R, but maybe you should take a look at the Task Views and see if there is something you can use at your field of work: http://www.stats.bris.ac.uk/R/web/views/ Bart Ricardo Rodríguez wrote: Hi everybody, I am trying to make my mind about the use of R for Computational and Statistical Approaches to Genomics. I know this is a vaste field: this is the main reason why I am sending this message to this always useful list! Any key/entry point to this field will be extremely welcome! Please, could you help me to go in the right direction? Thanks!!! Ricardo -- Ricardo Rodríguez Your XEN ICT Team __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/generic-question--%3E-Genomics-with-R-tp16954827p16955748.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] generic question == mapping Longhurst biogeochemical ocean provinces in R
*Hello all ** I am a newbie to R plotting maps. I am trying to plot over a world map a layer of Biogeochemical provinces (BGCP) by A.R. Longhurst. Each ocean region unfortunately are quite irregular in shape (not perfect squares). In GIS this layer of ocean provinces would be a layer of polygons, which I am assuming it cannot be plotted with R. I was wondering If anybody has encounter this problem before, to plot a GIS layer of polygons into a map in R. Thanks a lot * -- ))):) ))):) ))):) ))):) ))):) ))):) ))):) ))):) Maria Jose Juan Jorda AZTI - Tecnalia / Unidad de Investigación Marina Herrera Kaia Portualde z/g 20110 Pasaia, Gipuzkoa, Spain Recursos Marinos y Pesquerias Depart. Biologia Animal, Vegetal y Ecologia Universidade A Coruña Campus A Zapateira s/n 15071, A Coruña, Spain Tel. Oficina +34-981167000 ext. 2204 Tel. Mobil + 34-671072900 Fax. +34981167065 [EMAIL PROTECTED] [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Help with installing R on Red Hat linux 4
On Sun, 27-Apr-2008 at 10:52AM -0700, [EMAIL PROTECTED] wrote: | I am trying to install the rpm for R | I using Red Hat 4 ES on a 64bit machine | Kernel version is 2,6,9-67 | This is the error i get | Failed Dependencies libg2c.so () ()(64bit) is needed by | R-2.6.2-1.rh4.x86_64rpm | I have libf2c-3.4.6-9 installed on the box | any suggestions? Try this: yum provides libg2c* It will tell you what rpm you need. When you know what you need, use yum install compat-libf2cwhatever.rpm In any case, it doesn't take long to install from the source, and there are very simple instructions in the tgz file, and you'll have a newer release without having to wait until the 2.7.0 rpm is available.. HTH -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_Middle minds discuss events (:_~*~_:)Small minds discuss people (_)-(_) . Anon ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to plot wind direction and strength field
Dear R-help community, I have searched through the archives and not been able ot find any advice on how to plot a wind field with one arrow per grid square with the arrow pointing in the direction of the wind and it's size proportional to the wind strength. I have the wind speed data in arrays of [lon,lat,uwind] and [lon,lat,vwind] so it is broken down into u and v components. How do I plot it though?!?! Any suggestions very wecome indeed - I seem to have hit a brick wall. All the best, Jenny ~~ Jennifer Barnes PhD student: long range drought prediction Climate Extremes Group Department of Space and Climate Physics University College London Holmbury St Mary Dorking, Surrey, RH5 6NT Web: http://climate.mssl.ucl.ac.uk __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] generic question == mapping Longhurst biogeochemical ocean provinces in R
Maria Jose Juan Jorda mjuanjorda at gmail.com writes: Hello all I am a newbie to R plotting maps. I am trying to plot over a world map a layer of Biogeochemical provinces (BGCP) by A.R. Longhurst. Each ocean region unfortunately are quite irregular in shape (not perfect squares). In GIS this layer of ocean provinces would be a layer of polygons, which I am assuming it cannot be plotted with R. I was wondering If anybody has encounter this problem before, to plot a GIS layer of polygons into a map in R. The CRAN repository has a tab in the left navigation bar, Task Views. If you look there, you'll see many guides to subject areas - in your case, choose Spatial. You will find sections for reading spatial data - if your data can be represented as a shapefile, then reading them is not, in principle, a problem. So the recipe could be as simple as: library(rgdal) BGCP - readOGR(dsn=., layer=BGCP) # for the BGCP shapefile files (three or more files) in the working # directory spplot(BGCP, BGCP) # to plot the column named BGCP in the BGCP object with default # plotting arguments (spplot is in the sp package loaded with rgdal) Hope this helps, Roger __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] generic question - Genomics with R
Thank you so much. All the answers lead me to BioConductor and Task Views. Currently, I've not a precise task to solve, but I do need to draw a landscape about this topic. Your messages have helped a lot. I don't know why, but I don't reach BioConductor website by googling or searchmashing. Cheers, Ricardo. bartjoosen wrote: I'm not sure what you are trying to do with R, but maybe you should take a look at the Task Views and see if there is something you can use at your field of work: http://www.stats.bris.ac.uk/R/web/views/ Bart -- Ricardo Rodríguez Your XEN ICT Team __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R help
On 28/04/2008 9:47 PM, Debasish Roy wrote: I tried to read a dataset and then draw a histogram with a freqeuncy density curve fitted on the top of this. I used the command res - read.table(C:/Documents and Settings/db/Desktop/res.dat) and found res[1:5] V1 V2 V3 V4 V5 1 -0.4806 0.5075 0.0491 -0.7985 -0.666 Then I got the following when I troied to plot it hist(res) Error in hist.default(res) : 'x' must be numeric Even I tried hist(res[,2]) which is showing a blank plot. I'd guess it's not a blank plot, it's simply a histogram with one big bar taking up the whole of the plot. As others have mentioned, you only have one observation in each column. By the way, using a more informative subject line would be helpful. Most of the messages in the R-help mailing list are about R help. Duncan Murdoch My suspision is something is wrong in the way the data was read (with V1, V2, V3 etc). Can someone please help me how to get rid of this problem ? Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] empirical null distribution
On 29/04/2008 4:13 AM, mad_bassie wrote: It's not really homework :) It's just an a little extra I want to explore. I allready compared the empirical null distribution and the theoritical null distribution by comparing their quantiles. The results are clear... But I just wondered if there isn't any way to make a graph of it...so you don't really need to compare numbers...that the image speaks for itself. I'm kind of a newbie in R...I did learn many things allready but this graphics stuff is kind of complex to me... QQ plots are a natural way to compare distributions. You didn't say what statistic you are using, but if you are working with p-values, the theoretical null is probably uniform, so a simple histogram is useful. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] SOLVED error in summary.Design
Dear Frank and rest of list, please accept my apologies for not giving full details of my analysis in my previous email. I have been working on this problem and I think my error comes from the class of my variables and the way I defined the model, and I seemed to be able to solve it... d = datadist(VAR2,VAR3,VAR4,VAR5,VAR6,VAR7,VAR8) options(datadist=d) but then I called the model on factors mymodel = lrm(factor(VAR1)~VAR2+factor(VAR3)+ factor(VAR4)+factor(VAR5)+factor(VAR6)+factor(VAR7)+factor(VAR8), mydata, method=lrm.fit) Storing the variables in mydata as factors and recomputing d solves the mistake VAR1 = factor(mydata$VAR1) VAR3 = factor(mydata$VAR3) VAR4 = factor(mydata$VAR4) VAR5 = factor(mydata$VAR5) VAR6 = factor(mydata$VAR6) VAR7 = factor(mydata$VAR7) VAR8 = factor(mydata$VAR8) and VAR2 = mydata$VAR2 dd = datadist(VAR2, VAR3,VAR4,VAR5,VAR6,VAR7,VAR8) options(datadist=dd) mymodel2 = lrm(VAR1~VAR2+VAR3+VAR4+VAR5+VAR6+VAR7+VAR8, method=lrm.fit) This time, summary.Design() works Thanks for the useful comments David Frank E Harrell Jr [EMAIL PROTECTED] ha escrito: DAVID ARTETA GARCIA wrote: Dear list, after fitting an lrm with the Design package (stored as mymodel) I try running a summary, but I get the following error: dim(mydata) [1] 235 9 names(mydata) [1] id VAR1 VAR2 VAR3 VAR4 VAR5 VAR6 VAR7 VAR8 summary(mymodel) What is mymodel? Please read the posting guide by providing a full reproducible example. You can't expect people to help if you want to keep your code a secret. Error in `contrasts-`(`*tmp*`, value = contr.treatment) : contrasts can be applied only to factors with 2 or more levels but, VAR1 is my dependent nlevels(factor(VAR1)) [1] 2 This does not tell you about VAR1. It tells you about VAR1 after converting it to a factor variable. Frank VAR2 is continuous summary(VAR2) Min. 1st Qu. MedianMean 3rd Qu.Max. 0.906.058.40 10.99 13.15 59.70 and for the remaining variables... nlevels(factor(VAR3)) [1] 2 nlevels(factor(VAR4)) [1] 2 nlevels(factor(VAR5)) [1] 3 nlevels(factor(VAR6)) [1] 2 nlevels(factor(VAR7)) [1] 2 nlevels(factor(VAR8)) [1] 2 What I am missing? Thanks in advance, David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 plot wind direction and strength field
Jenny Barnes wrote: Dear R-help community, I have searched through the archives and not been able ot find any advice on how to plot a wind field with one arrow per grid square with the arrow pointing in the direction of the wind and it's size proportional to the wind strength. I have the wind speed data in arrays of [lon,lat,uwind] and [lon,lat,vwind] so it is broken down into u and v components. How do I plot it though?!?! Any suggestions very wecome indeed - I seem to have hit a brick wall. Hi Jenny, Some time ago, there was a request for a direction field plot. I programmed a basic function, but perhaps the person found another solution, for I never heard any more of it. However, this is not too hard to do in R, even adding the arrows to a geographical plot. Could you post some data and perhaps a link to an example of what output you would like? Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] I can not open R (UNCLASSIFIED)
Classification: UNCLASSIFIED Caveats: NONE Dear R users, I could not open R2.4.1 this morning with error messages Error in loadName space (name): There is no package called 'nlme' and Fatal error: unable to restore saved data in .Rdata under the information box. It had been working fine until yesterday. Appreciate your help. Kyong Classification: UNCLASSIFIED Caveats: NONE [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 plot wind direction and strength field
Hi Jim, I would like to plot something like figure 2 on this webpage: http://www.cnrfc.noaa.gov/storm_summaries/jan1997storms.php My data is very large - covering the whole globe at 2.5deg resolution so longitude=144 girds, latitude=73 grids and time=32 years - hard to give you that data..Would it help to give you a couple of grid squares worth of data for one year? Thanks, Jenny On Tue, 29 Apr 2008, Jim Lemon wrote: Jenny Barnes wrote: Dear R-help community, I have searched through the archives and not been able ot find any advice on how to plot a wind field with one arrow per grid square with the arrow pointing in the direction of the wind and it's size proportional to the wind strength. I have the wind speed data in arrays of [lon,lat,uwind] and [lon,lat,vwind] so it is broken down into u and v components. How do I plot it though?!?! Any suggestions very wecome indeed - I seem to have hit a brick wall. Hi Jenny, Some time ago, there was a request for a direction field plot. I programmed a basic function, but perhaps the person found another solution, for I never heard any more of it. However, this is not too hard to do in R, even adding the arrows to a geographical plot. Could you post some data and perhaps a link to an example of what output you would like? Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 plot wind direction and strength field
Jenny, Have a look at the R Newsletter Volume 3/2, October 2003 Regards, Sean Jenny Barnes wrote: Dear R-help community, I have searched through the archives and not been able ot find any advice on how to plot a wind field with one arrow per grid square with the arrow pointing in the direction of the wind and it's size proportional to the wind strength. I have the wind speed data in arrays of [lon,lat,uwind] and [lon,lat,vwind] so it is broken down into u and v components. How do I plot it though?!?! Any suggestions very wecome indeed - I seem to have hit a brick wall. All the best, Jenny ~~ Jennifer Barnes PhD student: long range drought prediction Climate Extremes Group Department of Space and Climate Physics University College London Holmbury St Mary Dorking, Surrey, RH5 6NT Web: http://climate.mssl.ucl.ac.uk __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/generic-question--%3E-Genomics-with-R-tp16954827p16958167.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Variogram problem
Thanks for your help, It is definitely that it is needed to me in finale, I therefore did not use the package check. I am going to try to understand step how is that now. Still thanks for your help! -- View this message in context: http://www.nabble.com/Variogram-problem-tp16953929p16958219.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Legend problem when exporting a plot to PDF
Hi list, When exporting to PDF a graph with a legend, in the final PDF, the text is going beyond the legend box. dev2bitmap(test.pdf, type=pdfwrite, h=6, w=6) The legend looks OK on the screen. I noticed that the size of the legend box depends on the size of the screen window, which is not the case for other graphical parts (text of the legend, title, axis text...) Any tip on how to deal with this? Another problem I encounter, which may be linked to this is: When I want to export PDFs to a given size with dev2bitmap (let's say h=3 and w=3), the size of the text of x-labels, y-labels and the x-axis annotations is not adjusted. The margins also keep the same size. Then if the size is too small, all the text fields overlap and the result is not nice. How to change this? I guess it's possible since the on the screen (x11) the margins are adjusted relative to the size of the plot. If you know one good tutorial to help creating ready-to-publish graphics, I would appreciate the reference. Thanks for your help Julien PS: R version 2.6.2 (2008-02-08) i386-apple-darwin8.10.1 -- Julien Roux, PhD student http://www.unil.ch/dee/page22707.html Department of Ecology and Evolution Biophore, University of Lausanne, 1015 Lausanne, Switzerland tel: +41 21 692 4221fax: +41 21 692 4165 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Running regression (lm, lrm) 100+ times and saving the results as matrix
An undergraduate here, so do not hesitate to let me know if you feel that I'm heading in a wrong direction. I have a data frame containing panel data across 10 years (hence 120 months). I want to be able to run regression separately for each month (or year). The below shows how I ran the regression for each month, but I need to know how I would combine the regression results together into a matrix possibly. Thank you! Mike --- m = max(data$TIME) # define regmatrix for(i in 1:m){ g=runreg(data, i) # attach g to regmatrix } runreg = function(data, index){ datainterim = subset(data, TIME==index) g = lrm(X ~ A + B, datainterim) return(g) } [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] (no subject)
Bonjour, Je travail sur R pour la modélisation des copules et j'ai utilisé le package fCopulae. Le problème est que j'ai pas les noms des copules utilisées:j'ai utilisé la list de 1 jusqu'au 22 et j'ai réussi à avoir les paramètres. S'il vous plaît, je demande votre aide là dessus. Dans l'attente de votre réponse, Merci d'avance. __ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Legend problem when exporting a plot to PDF
When exporting to PDF a graph with a legend, in the final PDF, the text is going beyond the legend box. dev2bitmap(test.pdf, type=pdfwrite, h=6, w=6) The legend looks OK on the screen. I noticed that the size of the legend box depends on the size of the screen window, As far as I remember, te problem has to do with different font handling in different devices. I'm sure someone more familiar wiht the internals will comment on this. The fix is easy: don't use dev2bitmap but open the desired target device before plotting. In your case: pdf(file='test.pdf', width=6, height=6) plot(...) legend(...) dev.off() cu Philipp -- Dr. Philipp Pagel Lehrstuhl für Genomorientierte Bioinformatik Technische Universität München Wissenschaftszentrum Weihenstephan 85350 Freising, Germany and Institut für Bioinformatik und Systembiologie / MIPS Helmholtz Zentrum München - Deutsches Forschungszentrum für Gesundheit und Umwelt Ingolstädter Landstrasse 1 85764 Neuherberg, Germany http://mips.gsf.de/staff/pagel __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] resolution (dpi) problem
Chris Walker wrote: To all those who helped with this problem (Ted, Jon, Marc and Prof. Ripley). When I submitted the postscript files to the journal, I had given them the extension .ps even though they were (of course) encapsulated postscript. I decided to simply rename the files with the .eps extension and resubmit. This time the images were accepted without question. It would appear to be a case of someone assuming that I had submitted postscript without bothering to check that it was encapsulated. It looks like the default extension on the 'Save as postscript' menu is '.ps'. That's both from the 'File' menu and the right click menu over the graphic device. I wonder if it might make sense to change that to '.eps', since the output is encapsulated postscript. Might help to avoid this in the future. Marc __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] empirical null distribution
I'm using F-distributions :) I allready found some things...I could plot the qqplot as you say and that gives me clear results. Allthough I still want a clear graphic and I 'll explain it as good as I can... I plotted 2 graphics plot(density(rf(1,2,49))) plot(density(disttest)) (the disttest is a distribution i simulated myself like this: for(i in 1:100){ X-rnorm(50,20,4) Y-rnorm(50,20,5) Z-rnorm(50,20,4) vector-c (X, Y, Z) vector2-rep(c('X','Y','Z'),c(50,50,50)) data1-data.frame(waarde=vector, soort = vector2) library(mvtnorm) library(multcomp) data1$soort-as.factor(data1$soort) disttest-c(disttest,summary(aov(waarde~soort,data=data1))[[1]][1,4]) } (I want to compare the theroretical F-distribution with a distribution where the variances are not equal...) Thos are 2 fine plots but I just can't figure out how to put them together in one graphic...is this possible in R...it would make things much clearer because the window setting are not really equal wich makes it difficult to compare... Thanks a lot allready! -- View this message in context: http://www.nabble.com/empirical-null-distribution-tp16945981p16959018.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Legend problem when exporting a plot to PDF
Copying between devices (as in dev2bitmap) is not a good way to produce high-quality graphs, and especially not if you change the size. What is wrong with pdf(test.pdf, width=6, height=6) re-run the plot commands dev.off() ? On Tue, 29 Apr 2008, Julien Roux wrote: Hi list, When exporting to PDF a graph with a legend, in the final PDF, the text is going beyond the legend box. dev2bitmap(test.pdf, type=pdfwrite, h=6, w=6) The legend looks OK on the screen. I noticed that the size of the legend box depends on the size of the screen window, which is not the case for other graphical parts (text of the legend, title, axis text...) Any tip on how to deal with this? Another problem I encounter, which may be linked to this is: When I want to export PDFs to a given size with dev2bitmap (let's say h=3 and w=3), the size of the text of x-labels, y-labels and the x-axis annotations is not adjusted. The margins also keep the same size. Then if the size is too small, all the text fields overlap and the result is not nice. How to change this? I guess it's possible since the on the screen (x11) the margins are adjusted relative to the size of the plot. If you know one good tutorial to help creating ready-to-publish graphics, I would appreciate the reference. Thanks for your help Julien PS: R version 2.6.2 (2008-02-08) i386-apple-darwin8.10.1 With R version 2.7.0 you have other possibilities, including dev.copy2pdf() and quartz(type=pdf). -- Julien Roux, PhD student http://www.unil.ch/dee/page22707.html Department of Ecology and Evolution Biophore, University of Lausanne, 1015 Lausanne, Switzerland tel: +41 21 692 4221fax: +41 21 692 4165 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 plot wind direction and strength field
Check out: http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=80 and RSiteSearch(quiver) On Tue, Apr 29, 2008 at 6:08 AM, Jenny Barnes [EMAIL PROTECTED] wrote: Dear R-help community, I have searched through the archives and not been able ot find any advice on how to plot a wind field with one arrow per grid square with the arrow pointing in the direction of the wind and it's size proportional to the wind strength. I have the wind speed data in arrays of [lon,lat,uwind] and [lon,lat,vwind] so it is broken down into u and v components. How do I plot it though?!?! Any suggestions very wecome indeed - I seem to have hit a brick wall. All the best, Jenny ~~ Jennifer Barnes PhD student: long range drought prediction Climate Extremes Group Department of Space and Climate Physics University College London Holmbury St Mary Dorking, Surrey, RH5 6NT Web: http://climate.mssl.ucl.ac.uk __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] randomForest and ordered factors
Hello R-user! I am running R 2.7.0 on a Power Book (Tiger). (I am still R and statistics beginner) I try to find the most important variables to divide my dataset as given in a categorical variable. code: Test.rf4-randomForest(Sex~.,na.action=na.roughfix, data=Subset4, importance=TRUE, proximity=TRUE, ntree=1, do.trace=1000, keep.forest=FALSE) My dataset contains also ordered factors classified as such. Is randomForest able to deal with it, does it change anything or is there no difference in using factors or ordered factors? Many thanks in advance B. Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] 175 Jahre UZH «staunen.erleben.begreifen. Naturwissenschaft zum Anfassen.» MNF-Jubiläumsevent für gross und klein. 19. April 2008, 10.00 Uhr bis 02.00 Uhr Campus Irchel, Winterthurerstrasse 190, 8057 Zürich Weitere Informationen http://www.175jahre.uzh.ch/naturwissenschaft __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] data management (subsetting and recombining)
This is an example of two months of data from a twenty four month data set that I would like to apply this too. These data are subsets of the same stations throught time, but differing ones were included on different sampling dates. I would like to subset these data and then put them together as a big matrix with the by column being RiverMile. What is the easiest way to proceed as this is a process that will be done on 96+ constituents? feb06 - structure(list(RiverMile = c(202L, 190L, 185L), X2.1.06 = c(285, NA, NA)), .Names = c(RiverMile, X2.1.06), row.names = c(29L, 31L, 32L), class = data.frame) may06 - structure(list(RiverMile = c(202L, 198L, 190L, 185L, 148L), X5.1.06 = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_)), .Names = c(RiverMile, X5.1.06), row.names = c(29L, 30L, 31L, 32L, 34L), class = data.frame) merge(feb06, may06, by=RiverMile) Error in fix.by(by.x, x) : 'by' must specify column(s) as numbers, names or logical #I have provided the column name. Is it because they are of differing lengths? thanks Stephen -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] NumDeriv - derivatives of covariance matrix
Hello R-help, I need to compute matrices of first derivatives of a covariance matrix C with entries given by c_ij=theta*exp(-0.5* sum(eta*(x[i,]-x[j,])^2)), wrt to elements of eta, a m-dimensional vector of parameters, given a n*m data matrix x. So far, I have been computing matrices for each parameter (given by par[index]) analytically, using the following kmatder- function(x, par, index) { ## x: n*m matrix ## par: vector of parameters, m=length(par)=ncol(x) ## compute matrix of partial derivatives wrt parameter par[index]: Cder = d C/d par[index] theta-1 eta-par n-nrow(x) Cder-matrix(0,n,n) for (i in 1:n) { for (j in i:n) { Cder[i,j]-(-0.5*((x[i,index]-x[j,index])^2))*theta*exp(-0.5* sum(eta*(x[i,]-x[j,])^2)) } } Cder-0.5*(Cder+t(Cder)) Cder } I was wondering whether it might be possible to speed up things using numDeriv (jacobian). If so, what would be the right way to implement a suitable method ? Cheers, Gao Daomeng [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] empirical null distribution
On 29/04/2008 8:09 AM, mad_bassie wrote: I'm using F-distributions :) I allready found some things...I could plot the qqplot as you say and that gives me clear results. Allthough I still want a clear graphic and I 'll explain it as good as I can... I plotted 2 graphics plot(density(rf(1,2,49))) plot(density(disttest)) (the disttest is a distribution i simulated myself like this: for(i in 1:100){ X-rnorm(50,20,4) Y-rnorm(50,20,5) Z-rnorm(50,20,4) vector-c (X, Y, Z) vector2-rep(c('X','Y','Z'),c(50,50,50)) data1-data.frame(waarde=vector, soort = vector2) library(mvtnorm) library(multcomp) data1$soort-as.factor(data1$soort) disttest-c(disttest,summary(aov(waarde~soort,data=data1))[[1]][1,4]) } (I want to compare the theroretical F-distribution with a distribution where the variances are not equal...) Thos are 2 fine plots but I just can't figure out how to put them together in one graphic...is this possible in R...it would make things much clearer because the window setting are not really equal wich makes it difficult to compare... You'd be better off comparing p-values than densities, but you can do what you're trying by using lines(density(disttest)) instead of calling plot() again. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 plot wind direction and strength field
Thanks Jim - here is some data: u - array(NA,c(5,8)) t - seq(from=0.5, to=0.11,length=15) t2 - seq(from=(-0.7),to=(-0.1),length=25) u[1:15] - t u[16:40] - t2 v - array(NA,c(5,8)) y - seq(from=(-0.9), to=(-0.01),length=40) v[1:40] - y I've made up the data but it's similar magnitude and the longitude direction is u and latitude direction is v as in the real data. I really appreciate your help! Jenny On Tue, 29 Apr 2008, Jim Lemon wrote: Jenny Barnes wrote: Hi Jim, I would like to plot something like figure 2 on this webpage: http://www.cnrfc.noaa.gov/storm_summaries/jan1997storms.php My data is very large - covering the whole globe at 2.5deg resolution so longitude=144 girds, latitude=73 grids and time=32 years - hard to give you that data..Would it help to give you a couple of grid squares worth of data for one year? Okay, Figures 2 and 3 look like 5 degree squares, and given a larger plot, 2.5 degree should be okay. Do you want curved arrows? That would take some programming as the standard arrows are straight. Also, the arrows in the figures all seem to be the same length. I can make the lengths proportional to wind speed. Yes, some data would be helpful, as getting the right plot usually involves trying out real data. Doesn't matter if it's faked as long as it has the same format and similar numbers to the real thing. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 plot wind direction and strength field
Hi Jim, I forgot to say that I don't want to create curved arrows, just straight - and I would like them to be proportional to the magnitude :o) Thanks again for your time! Jenny On Tue, 29 Apr 2008, Jenny Barnes wrote: Hi Jim, I would like to plot something like figure 2 on this webpage: http://www.cnrfc.noaa.gov/storm_summaries/jan1997storms.php My data is very large - covering the whole globe at 2.5deg resolution so longitude=144 girds, latitude=73 grids and time=32 years - hard to give you that data..Would it help to give you a couple of grid squares worth of data for one year? Thanks, Jenny On Tue, 29 Apr 2008, Jim Lemon wrote: Jenny Barnes wrote: Dear R-help community, I have searched through the archives and not been able ot find any advice on how to plot a wind field with one arrow per grid square with the arrow pointing in the direction of the wind and it's size proportional to the wind strength. I have the wind speed data in arrays of [lon,lat,uwind] and [lon,lat,vwind] so it is broken down into u and v components. How do I plot it though?!?! Any suggestions very wecome indeed - I seem to have hit a brick wall. Hi Jenny, Some time ago, there was a request for a direction field plot. I programmed a basic function, but perhaps the person found another solution, for I never heard any more of it. However, this is not too hard to do in R, even adding the arrows to a geographical plot. Could you post some data and perhaps a link to an example of what output you would like? Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How do you test for consecutivity?
I need to use R to model a large number of experiments (say, 1000). Each experiment involves the random selection of 5 numbers (without replacement) from a pool of numbers ranging between 1 and 30. What I need to know is what *proportion* of those experiments contains two or more numbers that are consecutive. So, for instance, an experiment that yielded the numbers 2, 28, 31, 4, 27 would be considered a consecutive = true experiment since 28 and 27 are two consecutive numbers, even though they are not side-by-side. I am quite new to R, so really am puzzled as to how to go about this. I've tried sorting each experiment, and then subtracting adjacent pairs of numbers to see if the difference is plus or minus 1. I'm also unsure about whether to use an array to store all the data first. Any assistance would be much appreciated. -- View this message in context: http://www.nabble.com/How-do-you-test-for-%22consecutivity%22--tp16959748p16959748.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] prediction in coxph
I have tried predict(coxout, newdata), it still gave me the fitted values only. Can anyone hlep me on how to do prediction for coxph? thank you very much! I would suggest first reading the manual page help(predict.coxph) There are several things one can predict from a Cox model. You need to tell us what you want to accomplish. Terry Therneau __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] resolution (dpi) problem
On 29-Apr-08 12:09:39, Marc Schwartz wrote: Chris Walker wrote: To all those who helped with this problem (Ted, Jon, Marc and Prof. Ripley). When I submitted the postscript files to the journal, I had given them the extension .ps even though they were (of course) encapsulated postscript. I decided to simply rename the files with the .eps extension and resubmit. This time the images were accepted without question. It would appear to be a case of someone assuming that I had submitted postscript without bothering to check that it was encapsulated. It looks like the default extension on the 'Save as postscript' menu is '.ps'. That's both from the 'File' menu and the right click menu over the graphic device. I wonder if it might make sense to change that to '.eps', since the output is encapsulated postscript. Might help to avoid this in the future. Marc I think it does make sense. Generally, someone will save a plot to PostScript for the purpose of including it in a document, and .eps will certainly help hapless editors to recognise it for what it is. ?postscript tells me: postscript(file = ifelse(onefile, Rplots.ps, Rplot%03d.ps), [etc.] so even if you invoke postscript() from the R command line you will get a default .ps extension. But here I think the danger is less, since I think most people will give an explicit (informative) filename when they save a plot, and can then choose to give it .eps. Perhaps the defaults here should read postscript(file = ifelse(onefile, Rplots.ps, Rplot%03d.eps), [etc] Certainly for Windows users, the suggested change could be wise, since Windows (for reasons best known to someone who should have known better) conceals the extension from the user, unless the user submits to cruel and unusual requirements such as (a) right-clicking on the file icon; (b) clicking on Properties! Possibly, on some Windows systems (I'm not a Windows user), hovering the mouse over the file pops up a little box which says PS file if the extension is .ps, and EPS file of the extension is .eps; and conceivably something like this may be the source of Chris's publisher's misapprehension. Certainly, the filename should not matter when it comes to actually importing the EPS into a document. For example, in 'groff' I can import as EPS a file which has any name and any extension whatever, just so long as it has a valid %%BoundingBox: line in it. But maybe, again, some software will only look at the extension in the first instance, and sulk if that is not .eps. Just some thoughts ... (And felicitations to Chris for getting his article through the door). Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 29-Apr-08 Time: 13:55:58 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How do you test for consecutivity?
Anthony28 wrote: I need to use R to model a large number of experiments (say, 1000). Each experiment involves the random selection of 5 numbers (without replacement) from a pool of numbers ranging between 1 and 30. What I need to know is what *proportion* of those experiments contains two or more numbers that are consecutive. So, for instance, an experiment that yielded the numbers 2, 28, 31, 4, 27 would be considered a consecutive = true experiment since 28 and 27 are two consecutive numbers, even though they are not side-by-side. I am quite new to R, so really am puzzled as to how to go about this. I've tried sorting each experiment, and then subtracting adjacent pairs of numbers to see if the difference is plus or minus 1. I'm also unsure about whether to use an array to store all the data first. Any assistance would be much appreciated. Vec - c(2, 28, 31, 4, 27) Vec [1] 2 28 31 4 27 # Sort the vector sort(Vec) [1] 2 4 27 28 31 # Get differences between sequential elements diff(sort(Vec)) [1] 2 23 1 3 # Are any differences == 1? any(diff(sort(Vec)) == 1) [1] TRUE See ?sort, ?diff and ?any for more information On your last question, if the data are all numeric and each experiment contains 30 elements from which you select five, then you can store the data in a N x 30 matrix, where N is the number of source data sets. The result could be stored in a N x 5 matrix. You can then run your test of sequential members as follows, presuming 'Res' contains the N x 5 result matrix: prop.table(table(apply(Res, 1, function(x) any(diff(sort(x)) == 1))) The output will be the proportion TRUE/FALSE of rows that have sequential elements. HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Simulation study in R
At 02:40 AM 4/29/2008, Arun Kumar Saha wrote: Here I am in a simulation study where I want to find different values of x and y such that f(x,y)=c (some known constant) w.r.t. x, y 0, y=x and x=c1 (another known constant). Can anyone please tell me how to do it efficiently in R. One way I thought that I will draw different random numbers from uniform dist according to that constraints and pick those which satisfy f(x,y)=c. However it is not I think computationally efficient. Can anyone here suggest me any other efficient approach? You have not specified the distributions proper for X and Y. Using a uniform distribution is only appropriate when it meets requirements. One obvious approach is to sample one of the variables, say X, and then solve your equation for Y. If you're going to draw a lot of samples, it would pay to develop y = g(x) first. But you need to know how to sample X in the first place. Is its distribution uniform, or something else? Robert A. LaBudde, PhD, PAS, Dpl. ACAFS e-mail: [EMAIL PROTECTED] Least Cost Formulations, Ltd.URL: http://lcfltd.com/ 824 Timberlake Drive Tel: 757-467-0954 Virginia Beach, VA 23464-3239Fax: 757-467-2947 Vere scire est per causas scire __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Legend problem when exporting a plot to PDF
On Tue, Apr 29, 2008 at 01:49:01PM +0200, Philipp Pagel wrote: When exporting to PDF a graph with a legend, in the final PDF, the text is going beyond the legend box. dev2bitmap(test.pdf, type=pdfwrite, h=6, w=6) The legend looks OK on the screen. I noticed that the size of the legend box depends on the size of the screen window, As far as I remember, te problem has to do with different font handling in different devices. I'm sure someone more familiar wiht the internals will comment on this. The fix is easy: don't use dev2bitmap but open the desired target device before plotting. In your case: pdf(file='test.pdf', width=6, height=6) plot(...) legend(...) dev.off() cu Philipp I'm not sure, whether this is the way to go. at least until recently the `pdf' device of R had a few rough edges which surfaced by an then. In my experience using `dev2bitmap(type=pdfwrite, ...)' -- and thus ghostscript for pdf generation resulted in cleaner/better pdf output (actually, `dev2bitmap' sort of postprocessess output from the `pdf' device a bit). concerning the original question: yes, the problem is there. I believe it is related simply to the fact that the same absolute font size used in the graphic window is used in the pdf output, too, which makes its _relative_ size dependent on the chosen size (widht/height) of the pdf output. my workaround is to ensure that the graphic windows size is exactly the same as that used in the `dev2bitmap` call. e.g. the X11() device has defaults of width = 7, height = 7 (but you can enforce other values by open a new one with, e.g., X11(width = 6, height = 9). thus, first plot to graphic window, make sure that no interactive resizing is necessary to get acceptable display on the monitor (otherwise close it and open new X11() with better width/height values). then call dev2bitmap() with the same width/height settings. that should lead essentially to WYSIWYG (modulo font substitution, maybe). joerg __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How do you test for consecutivity?
How about this result - numeric(10) for(i in 1:10){ x - sample(1:30, 5, replace = FALSE) x - sort(x) result[i] - any(diff(x) == 1) } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Anthony28 Sent: Tuesday, April 29, 2008 8:52 AM To: r-help@r-project.org Subject: [R] How do you test for consecutivity? I need to use R to model a large number of experiments (say, 1000). Each experiment involves the random selection of 5 numbers (without replacement) from a pool of numbers ranging between 1 and 30. What I need to know is what *proportion* of those experiments contains two or more numbers that are consecutive. So, for instance, an experiment that yielded the numbers 2, 28, 31, 4, 27 would be considered a consecutive = true experiment since 28 and 27 are two consecutive numbers, even though they are not side-by-side. I am quite new to R, so really am puzzled as to how to go about this. I've tried sorting each experiment, and then subtracting adjacent pairs of numbers to see if the difference is plus or minus 1. I'm also unsure about whether to use an array to store all the data first. Any assistance would be much appreciated. -- View this message in context: http://www.nabble.com/How-do-you-test-for-%22consecutivity%22- -tp16959748p16959748.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] function to generate weights for lm?
Hi, I would like to use a weighted lm model to reduce heteroscendasticity. I am wondering if the only way to generate the weights in R is through the laborious process of trial and error by hand. Does anyone know if R has a function that would automatically generate the weights need for lm? Thanks, -- Tom [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How do I specify a model with nested random terms?
Dear R-users, I have problems specifying a model with nested random terms. I want to reproduce a variance component model made in Mintab, the model specification in Minitab is: Response = Prod P Prod*P Sample(Prod P) Extract(Prod P Sample) Random Prod Sample Extract The dataset is balanced, and P is a fixed effect (treatment) while Prod, Sample and Extract are random effects. Sample is nested under the Prod*P interaction, and Extract is nested under Sample. I tried using the lme function with the following formula specification: lme(Response~Prod*P, Random=~1|Prod/P/Sample/Extract) but the results do not look right. I don't understand how to specify the fixed and random arguments correctly. Could someone explain these arguments to me? I have tried to read the help files and manuals but I still don't get it :-S Would it also be possible to use the aov function with Error() strata for this problem? Thank you and regards, Ingrid Måge [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] vioplot kernel smooth via density kernel smooth
posted mailed Johannes Graumann wrote: Vioplots have great appeal to me, as they manage to squeeze so much information into so little space ... Now some evaluation has made me suspicious about the implementation in the package vioplot and I would like to hear what you say about the appended results and the code going with it: library(vioplot) mydata - read.table(data) # file data attached plot(density(mydata[[1]])) # attached as densityplot.png vioplot(mydata[[1]]) # attached as vioplot.png Default settings for density seem to clearly indicate that the distribution is bimodal, while vioplot total misses that. Can vioplot be made to react more density-like or is there an alternative, more density-like implementation? Thanks for your imput, Joh As a quick hack I patched the vioplot function from the package of the same name as appended to use the default density function from base. The result when doing the same as described above (vioplot(mydata[[1]],sm_density=FALSE))is attached - much more what I would expect for this data set than what the original provides. Opinions? Ridicule? Joh vioplot - function (x, ..., range = 1.5, h = NULL, ylim = NULL, names = NULL, horizontal = FALSE, col = magenta, border = black, lty = 1, lwd = 1, rectCol = black, colMed = white, pchMed = 19, at, add = FALSE, wex = 1, drawRect = TRUE, sm_density=TRUE) { datas - list(x, ...) n - length(datas) if (missing(at)) at - 1:n upper - vector(mode = numeric, length = n) lower - vector(mode = numeric, length = n) q1 - vector(mode = numeric, length = n) q3 - vector(mode = numeric, length = n) med - vector(mode = numeric, length = n) base - vector(mode = list, length = n) height - vector(mode = list, length = n) baserange - c(Inf, -Inf) args - list(display = none) if (!(is.null(h))) args - c(args, h = h) for (i in 1:n) { data - datas[[i]] data.min - min(data) data.max - max(data) q1[i] - quantile(data, 0.25) q3[i] - quantile(data, 0.75) med[i] - median(data) iqd - q3[i] - q1[i] upper[i] - min(q3[i] + range * iqd, data.max) lower[i] - max(q1[i] - range * iqd, data.min) est.xlim - c(min(lower[i], data.min), max(upper[i], data.max)) if(sm.density==TRUE){ smout - do.call(sm.density, c(list(data, xlim = est.xlim), args)) } else { smout - do.call(density,list(data)) smout[[estimate]] - smout[[y]] smout[[eval.points]] - smout[[x]] } hscale - 0.4/max(smout$estimate) * wex base[[i]] - smout$eval.points height[[i]] - smout$estimate * hscale t - range(base[[i]]) baserange[1] - min(baserange[1], t[1]) baserange[2] - max(baserange[2], t[2]) } if (!add) { xlim - if (n == 1) at + c(-0.5, 0.5) else range(at) + min(diff(at))/2 * c(-1, 1) if (is.null(ylim)) { ylim - baserange } } if (is.null(names)) { label - 1:n } else { label - names } boxwidth - 0.05 * wex if (!add) plot.new() if (!horizontal) { if (!add) { plot.window(xlim = xlim, ylim = ylim) axis(2) axis(1, at = at, label = label) } box() for (i in 1:n) { polygon(c(at[i] - height[[i]], rev(at[i] + height[[i]])), c(base[[i]], rev(base[[i]])), col = col, border = border, lty = lty, lwd = lwd) if (drawRect) { lines(at[c(i, i)], c(lower[i], upper[i]), lwd = lwd, lty = lty) rect(at[i] - boxwidth/2, q1[i], at[i] + boxwidth/2, q3[i], col = rectCol) points(at[i], med[i], pch = pchMed, col = colMed) } } } else { if (!add) { plot.window(xlim = ylim, ylim = xlim) axis(1) axis(2, at = at, label = label) } box() for (i in 1:n) { polygon(c(base[[i]], rev(base[[i]])), c(at[i] - height[[i]], rev(at[i] + height[[i]])), col = col, border = border, lty = lty, lwd = lwd) if (drawRect) { lines(c(lower[i], upper[i]), at[c(i, i)], lwd = lwd, lty = lty) rect(q1[i], at[i] - boxwidth/2, q3[i], at[i] + boxwidth/2, col = rectCol) points(med[i], at[i], pch = pchMed, col = colMed) } } } invisible(list(upper = upper, lower = lower, median = med, q1 = q1, q3 = q3)) } Rplot.pdf Description: Adobe PDF document __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide
[R] XML write?
Is there any function to write a XML structure, after it was read using xmlTreeParse? Ex: library(XML) x - xmlTreeParse(Irpf2008/aplicacao/dados/12345678901/12345678901.xml) # write it... Alberto Monteiro PS: please, brazilians, don't be offended by my foul language! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Get inside a function the name of a variable called as argument?
Hi list, I created a function to plot my data: plot_function(vector) I want to write the name of the argument vector in the legend/title of the plot. For example if I call: plot_function(my_vector) I want my_vector to be written in the legend or title and so retrieve the name of this object as a string. Is it possible to achieve this? Thanks a lot for your help Julien -- Julien Roux, PhD student http://www.unil.ch/dee/page22707.html Department of Ecology and Evolution Biophore, University of Lausanne, 1015 Lausanne, Switzerland tel: +41 21 692 4221fax: +41 21 692 4165 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] ggplot2: setting global graphic parameters with png driver
You forgot to mention your version of R and your platform (and R has at least 3 separate png() devices). In 2.7.0, specify the size in inches and increase the resolution. In earlier versions, try bitmap(). From NEWS for 2.7.0 o Considerable efforts have been made to make the default output from graphics devices as similar as possible (and in particular close to that from postscript/pdf). Many devices were misinterpreting 'pointsize' in some way, for example as being in device units (pixels) rather than in points. On Tue, 29 Apr 2008, Xavier Chardon wrote: Hi all, I prepared a few charts with ggplot2, and was happy with the results as displayed on screen. I tried to draw them with a PNG driver instead. But I ran into several problems while trying to increase the resolution of the picture. Mainly, when I increased the picture size (e.g png(width=1024, height=768) ), the texts (title, labels, etc...) where too small. I tried to set the pointsize option of the driver. That did the trick, to some extent. But it seems limited, and I couldn't get big enough fonts for high resolution images. Also, I tried the resolution setting of the driver. But this has an effect on lots of things, e.g. the length of the lines in the legend, so I gave up this idea. I tried to change the font size of all elements, with e.g. grid.gedit(label, gp=gpar(cex=4) ). But the position of the labels does not change then, and with the bigger font, they are drawn on top of the axis or of its title. Another problem was that the line width is also too small in big images. I couldn't find a way to change it globally. So, is there a way to go easily from a plot that looks good on screen (X11 driver) to a similar png image? Or is it possible to change the default settings of ggplot2 (line size and font size in particular, which are not covered by the ggopt function) ? I guess people usually export their charts as image files, so hopefully there's an easy solution. Many thanks, Xavier __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] XML write?
By write, do you mean print? In that case using the basic.xml file that comes with the XML package: library(XML) basic.xml - system.file(exampleData, basic.xml, package = XML) # try this con - xmlTreeParse(basic.xml) root - xmlRoot(con) root # or if you are using internal nodes: con - xmlTreeParse(basic.xml, useInternalNodes = TRUE) root - xmlRoot(con) cat(saveXML(root), \n) On Tue, Apr 29, 2008 at 9:37 AM, Alberto Monteiro [EMAIL PROTECTED] wrote: Is there any function to write a XML structure, after it was read using xmlTreeParse? Ex: library(XML) x - xmlTreeParse(Irpf2008/aplicacao/dados/12345678901/12345678901.xml) # write it... Alberto Monteiro PS: please, brazilians, don't be offended by my foul language! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] XML write?
Alberto Monteiro wrote on 04/29/2008 08:37 AM: Is there any function to write a XML structure, after it was read using xmlTreeParse? Ex: library(XML) x - xmlTreeParse(Irpf2008/aplicacao/dados/12345678901/12345678901.xml) # write it... Calling: library(help=XML) # or help(package=XML) lists all the functions from the XML package, and saveXML seems to be what you want. I remember having difficulty finding these functions (for listing package contents) when I first learned R, and perusing the posting guide did mention them in relation to properly posting info about surprising behavior and bugs. Maybe a new list item can be added under Do your homework before posting, something like: * Do help(package=packageName) for a description and function list of the installed packageName, or read the package reference manual from CRAN (http://cran.r-project.org/web/packages/). Best, Jeff Alberto Monteiro PS: please, brazilians, don't be offended by my foul language! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] data management (subsetting and recombining)
s.d - structure(list(RiverMile = c(202L, 198L, 190L, 185L, 179L, 148L, 119L, 61L)), .Names = RiverMile, row.names = c(NA, -8L), class = data.frame) #s.d is all of the river miles that can occur in all of the data frames that I want to put together feb06 - structure(list(RiverMile = c(202L, 190L, 185L), X2.1.06 = c(285, NA, NA)), .Names = c(RiverMile, X2.1.06), row.names = c(29L, 31L, 32L), class = data.frame) may06 - structure(list(RiverMile = c(202L, 198L, 190L, 185L, 148L), X5.1.06 = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_)), .Names = c(RiverMile, X5.1.06), row.names = c(29L, 30L, 31L, 32L, 34L), class = data.frame) merge(s.d ,c(feb06, may06), all=TRUE, by.x=RiverMile) #I know they have different row numbers, but I can not figure out how to fill in the ones that don't have data with NA On Tue, Apr 29, 2008 at 8:37 AM, stephen sefick [EMAIL PROTECTED] wrote: This is an example of two months of data from a twenty four month data set that I would like to apply this too. These data are subsets of the same stations throught time, but differing ones were included on different sampling dates. I would like to subset these data and then put them together as a big matrix with the by column being RiverMile. What is the easiest way to proceed as this is a process that will be done on 96+ constituents? feb06 - structure(list(RiverMile = c(202L, 190L, 185L), X2.1.06 = c(285, NA, NA)), .Names = c(RiverMile, X2.1.06), row.names = c(29L, 31L, 32L), class = data.frame) may06 - structure(list(RiverMile = c(202L, 198L, 190L, 185L, 148L), X5.1.06 = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_)), .Names = c(RiverMile, X5.1.06), row.names = c(29L, 30L, 31L, 32L, 34L), class = data.frame) merge(feb06, may06, by=RiverMile) Error in fix.by(by.x, x) : 'by' must specify column(s) as numbers, names or logical #I have provided the column name. Is it because they are of differing lengths? thanks Stephen -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] XML write?
Gabor Grothendieck wrote: By write, do you mean print? No, I mean save to a file. I solved the problem with this: library(XML) x - xmlTreeParse(Irpf2008/aplicacao/dados/12345678901/12345678901.xml) sink(ihatetheirs.xls) print(x) sink() and then I can edit the saved file to cut some extra information not-xml related (and do what I want - again, sorry for the foul language). Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] XML write?
On Tue, Apr 29, 2008 at 10:20 AM, Alberto Monteiro [EMAIL PROTECTED] wrote: Gabor Grothendieck wrote: By write, do you mean print? No, I mean save to a file. I solved the problem with this: library(XML) x - xmlTreeParse(Irpf2008/aplicacao/dados/12345678901/12345678901.xml) sink(ihatetheirs.xls) print(x) sink() and then I can edit the saved file to cut some extra information not-xml related (and do what I want - again, sorry for the foul language). Alberto Monteiro Try saveXML: con - xmlTreeParse(basic.xml) root - xmlRoot(con) saveXML(root, myfile.xml) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] randomForest and ordered factors
If you are using the latest version (4.5-25), you will see in rfNews() that that's the problem I need to fix. The package was able to handle ordered factors, but some more stringent checks for factor levels consistency introduced in 4.5-23 broke the support for ordered factors in prediction. From the code you've shown, it looks like you are just growing the forest to evaluate variable importance or other things, instead of predicting other data (since you set keep.forest=FALSE). If that's the case, you should be fine, as the problem only happens when you try to call predict() with models that contain ordered factors as predictors. (Ordered factors are basically treated as numerics in RF: trees only make use of ranks for numeric variables, so there's basically no difference between ordered factors and numeric variables as predictors.) Andy From: Birgit Lemcke Hello R-user! I am running R 2.7.0 on a Power Book (Tiger). (I am still R and statistics beginner) I try to find the most important variables to divide my dataset as given in a categorical variable. code: Test.rf4-randomForest(Sex~.,na.action=na.roughfix, data=Subset4, importance=TRUE, proximity=TRUE, ntree=1, do.trace=1000, keep.forest=FALSE) My dataset contains also ordered factors classified as such. Is randomForest able to deal with it, does it change anything or is there no difference in using factors or ordered factors? Many thanks in advance B. Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] 175 Jahre UZH «staunen.erleben.begreifen. Naturwissenschaft zum Anfassen.» MNF-Jubiläumsevent für gross und klein. 19. April 2008, 10.00 Uhr bis 02.00 Uhr Campus Irchel, Winterthurerstrasse 190, 8057 Zürich Weitere Informationen http://www.175jahre.uzh.ch/naturwissenschaft __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Notice: This e-mail message, together with any attachme...{{dropped:11}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Get inside a function the name of a variable called as argument?
On 29/04/2008 9:53 AM, Julien Roux wrote: Hi list, I created a function to plot my data: plot_function(vector) I want to write the name of the argument vector in the legend/title of the plot. For example if I call: plot_function(my_vector) I want my_vector to be written in the legend or title and so retrieve the name of this object as a string. Is it possible to achieve this? Yes. If the argument name is arg in the function definition, then substitute(arg) gives the expression that was passed, and deparse(substitute(arg)) converts it into a string to use in a title. e.g. plot_function - function(arg) { + deparse(substitute(arg)) + } plot_function(my_vector) [1] my_vector Duncan Murdoch Thanks a lot for your help Julien __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] merging multiple data frames with different numbers of rows
merge can only merge two objects at a time- I would like to merge more than two objects at a time. s.d - structure(list(RiverMile = c(202L, 198L, 190L, 185L, 179L, 148L, 119L, 61L)), .Names = RiverMile, row.names = c(NA, -8L), class = data.frame) #s.d is all of the river miles that can occur in all of the data frames that I want to put together feb06 - structure(list(RiverMile = c(202L, 190L, 185L), X2.1.06 = c(285, NA, NA)), .Names = c(RiverMile, X2.1.06), row.names = c(29L, 31L, 32L), class = data.frame) may06 - structure(list(RiverMile = c(202L, 198L, 190L, 185L, 148L), X5.1.06 = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_)), .Names = c(RiverMile, X5.1.06), row.names = c(29L, 30L, 31L, 32L, 34L), class = data.frame) jun06 - structure(list(RiverMile = c(202L, 198L, 190L, 185L, 148L), X6.1.06 = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_)), .Names = c(RiverMile, X6.1.06), row.names = c(29L, 30L, 31L, 32L, 34L), class = data.frame) merge(s.d, feb06, all=T) RiverMile X2.1.06 161 NA 2 119 NA 3 148 NA 4 179 NA 5 185 NA 6 190 NA 7 198 NA 8 202 285 #this is what I want- is there a way to implement this over many data frames -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] randomForest and ordered factors
Hello Andy, thanks for your answer and sorry that I did not check the rfNews. You are right, presently I am only looking at variable importance and therefore I am very happy to hear that I won`t have problems using ordered factors. Since I just started to fiddle around with randomForest it might be that I will have some more questions later - let`see. But presently I am very grateful that you provide this package. Greets Birgit Am 29.04.2008 um 16:29 schrieb Liaw, Andy: If you are using the latest version (4.5-25), you will see in rfNews () that that's the problem I need to fix. The package was able to handle ordered factors, but some more stringent checks for factor levels consistency introduced in 4.5-23 broke the support for ordered factors in prediction. From the code you've shown, it looks like you are just growing the forest to evaluate variable importance or other things, instead of predicting other data (since you set keep.forest=FALSE). If that's the case, you should be fine, as the problem only happens when you try to call predict() with models that contain ordered factors as predictors. (Ordered factors are basically treated as numerics in RF: trees only make use of ranks for numeric variables, so there's basically no difference between ordered factors and numeric variables as predictors.) Andy From: Birgit Lemcke Hello R-user! I am running R 2.7.0 on a Power Book (Tiger). (I am still R and statistics beginner) I try to find the most important variables to divide my dataset as given in a categorical variable. code: Test.rf4-randomForest(Sex~.,na.action=na.roughfix, data=Subset4, importance=TRUE, proximity=TRUE, ntree=1, do.trace=1000, keep.forest=FALSE) My dataset contains also ordered factors classified as such. Is randomForest able to deal with it, does it change anything or is there no difference in using factors or ordered factors? Many thanks in advance B. Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] 175 Jahre UZH «staunen.erleben.begreifen. Naturwissenschaft zum Anfassen.» MNF-Jubiläumsevent für gross und klein. 19. April 2008, 10.00 Uhr bis 02.00 Uhr Campus Irchel, Winterthurerstrasse 190, 8057 Zürich Weitere Informationen http://www.175jahre.uzh.ch/naturwissenschaft __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Notice: This e-mail message, together with any attachments, contains information of Merck Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp Dohme or MSD and in Japan, as Banyu - direct contact information for affiliates is available at http://www.merck.com/ contact/contacts.html) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system. Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] 175 Jahre UZH «staunen.erleben.begreifen. Naturwissenschaft zum Anfassen.» MNF-Jubiläumsevent für gross und klein. 19. April 2008, 10.00 Uhr bis 02.00 Uhr Campus Irchel, Winterthurerstrasse 190, 8057 Zürich Weitere Informationen http://www.175jahre.uzh.ch/naturwissenschaft __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Get inside a function the name of a variable called as argument?
On Tue, Apr 29, 2008 at 03:53:02PM +0200, Julien Roux wrote: Hi list, I created a function to plot my data: plot_function(vector) I want to write the name of the argument vector in the legend/title of the plot. For example if I call: plot_function(my_vector) I want my_vector to be written in the legend or title and so retrieve the name of this object as a string. Is it possible to achieve this? While it might be possible, I think it would be better to use an extra argument for this: plot_function(my_vector, title = my_title) Functions should be general, and relying on the name of the variable makes your function less general. What if you in the future want to use plot_function with an anynmous vector created dynamically? e.g by combining two other vectors: plot_function(c(foo, bar)) -- Hans Ekbrand (http://sociologi.cjb.net) [EMAIL PROTECTED] GPG Fingerprint: 1408 C8D5 1E7D 4C9C C27E 014F 7C2C 872A 7050 614E signature.asc Description: Digital signature __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] merging multiple data frames with different numbers of rows
It appears that these are time series (i.e. there is only one value of River Mile in any one data frame) so if that's right you would be better off representing them as time series. Using zoo: library(zoo) feb06.z - zoo(feb06[,2], feb06[,1]) may06.z - zoo(may06[,2], may06[,1]) jun06.z - zoo(jun06[,2], jun06[,1]) merge(feb06.z, may06.z, jun06.z) feb06.z may06.z jun06.z 148 NA NA NA 185 NA NA NA 190 NA NA NA 198 NA NA NA 202 285 NA NA Alternately this also works: L - list(feb06 = feb06, may06 = may06, jun06 = jun06) do.call(merge, lapply(L, function(x) zoo(x[,2], x[,1]))) feb06 may06 jun06 148 NANANA 185 NANANA 190 NANANA 198 NANANA 202 285NANA Read the three vignettes that come with zoo and also ?merge.zoo On Tue, Apr 29, 2008 at 10:42 AM, stephen sefick [EMAIL PROTECTED] wrote: merge can only merge two objects at a time- I would like to merge more than two objects at a time. s.d - structure(list(RiverMile = c(202L, 198L, 190L, 185L, 179L, 148L, 119L, 61L)), .Names = RiverMile, row.names = c(NA, -8L), class = data.frame) #s.d is all of the river miles that can occur in all of the data frames that I want to put together feb06 - structure(list(RiverMile = c(202L, 190L, 185L), X2.1.06 = c(285, NA, NA)), .Names = c(RiverMile, X2.1.06), row.names = c(29L, 31L, 32L), class = data.frame) may06 - structure(list(RiverMile = c(202L, 198L, 190L, 185L, 148L), X5.1.06 = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_)), .Names = c(RiverMile, X5.1.06), row.names = c(29L, 30L, 31L, 32L, 34L), class = data.frame) jun06 - structure(list(RiverMile = c(202L, 198L, 190L, 185L, 148L), X6.1.06 = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_)), .Names = c(RiverMile, X6.1.06), row.names = c(29L, 30L, 31L, 32L, 34L), class = data.frame) merge(s.d, feb06, all=T) RiverMile X2.1.06 161 NA 2 119 NA 3 148 NA 4 179 NA 5 185 NA 6 190 NA 7 198 NA 8 202 285 #this is what I want- is there a way to implement this over many data frames -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] deleting variables
How can I automatically exclude one variable from being saved in the workspace when I quit an R session? The problem is I don't know how to erase a variable once it has been created. Background: I open a connection called con to a database server in my ~/.Rprofile. Obviously, the connection expires when quitting the R session. Unfortunately, the workspace is loaded after ~/.Rprofile is run. So con get overwritten by the old workspace. I thought of using .First() or .Last() but as these are functions I don't know how to modify global variables. Ralf __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to hide the warnings
Hi All, I want to hide all the system(R) generated warning messages and want only the messages from my script should be shown when i run myscript.R Can you please suggest how can I hide the warnings Thank you Vidhu [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] deleting variables
?rm Richard Ralf Goertz wrote: How can I automatically exclude one variable from being saved in the workspace when I quit an R session? The problem is I don't know how to erase a variable once it has been created. Background: I open a connection called con to a database server in my ~/.Rprofile. Obviously, the connection expires when quitting the R session. Unfortunately, the workspace is loaded after ~/.Rprofile is run. So con get overwritten by the old workspace. I thought of using .First() or .Last() but as these are functions I don't know how to modify global variables. Ralf __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Richard D. Pearson [EMAIL PROTECTED] School of Computer Science,http://www.cs.man.ac.uk/~pearsonr University of Manchester, Tel: +44 161 275 6178 Oxford Road, Mob: +44 7971 221181 Manchester M13 9PL, UK.Fax: +44 161 275 6204 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to solve a power series linear coefficient equation
Readers, I am having difficulty understanding how to enter commands into r. I have data arranged as: 100, 200, 300 5.6, 6.7, 7.8 8.9, 9.0, 0.1 1.2, 2.3, 3.4 The data is saved in csv format and I use the command 'read.table' to import into r. The values 5.6...3.4 are a function of values 100,...300, i.e. 100,...300 are independent variables (x). The function is a power series: y=a+bx+cx^2 How do I obtain the values of a,b,c by minimisation of the sum of squares of deviations? So far looking at the documentation 'r-intro' section 10, I tried the following: functionname-function(a,b,c){ + a-sum(a) + b-sum(b) + c-sum(c) + y-(a+bx+cx^2) + x-(x) + } The documentation states: ...using a call such as What does this mean? Yours, [EMAIL PROTECTED] gnu/linux mandriva 2008 r 251 (27-06-07) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Consecutive zeros in a vector
Suppose X is a long vector of integers (typically about 3 elements). Is there an efficient way to detect whether there are at least N consecutive zeros in X, and if yes, where does this occur? for example, suppose X is: 1 2 3 4 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 4 2 0 1 2 0 0 0 2 2 2 2 2 ... and N is 10. I would like a foo(X, 10) to return something like c(6,19) (start and end positions in X of at least 10 consecutive zeros). I can think of a number of slow and probably inefficient ways of doing it (nested loops..), but perhaps someone has a better idea.. Thanks in advance, Kenn [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Consecutive zeros in a vector
On 29/04/2008 11:39 AM, Kenn Konstabel wrote: Suppose X is a long vector of integers (typically about 3 elements). Is there an efficient way to detect whether there are at least N consecutive zeros in X, and if yes, where does this occur? for example, suppose X is: ... and N is 10. I would like a foo(X, 10) to return something like c(6,19) (start and end positions in X of at least 10 consecutive zeros). I can think of a number of slow and probably inefficient ways of doing it (nested loops..), but perhaps someone has a better idea.. Something based on rle() should be fairly easy. rle(x)$lengths 9 identifies the long runs, cumsum(rle(x)$lengths) identifies where runs end. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] F values from a Repeated Measures aov
Two things: 1. the + Sex term is superfluous 2. the variable Subject needs to be a Factor, not a vector (as I suspect it currently is). That is, add: mydata.tab$Subject=as.factor(mydata.tab$Subject) in the preamble before the aov call, and all should be fine. On 29-Apr-08, at 4:00 AM, [EMAIL PROTECTED] wrote: Hi Folks, I have repeated measures for data on association time (under 2 acoustic condtions) in male and female frogs as they grow to adulthood (6 timepoints). Thus, two within-subject variables (Acoustic Condition: 2 levels, Timepoint: 6 levels) and one between-subject variable (Sex:male or female). I am pretty sure my distributions depart from normality but I would first like to simply run a RM anova on the data. My problem is that when I do this I generate different values of F for my main effects and interaction when I do the analysis in [R] and SPSS - so I don't know which one to believe. Here is my code in R: mydata.tab=read.delim(mydata.txt, header=T) #read in my data mydata.tab$Timepoint=as.factor(mydata.tab$Timepoint)#col headings are factors so df are correct mydata.tab$Acx.Cond=as.factor(mydata.tab$Acx.Cond) mydata.tab$Sex=as.factor(mydata.tab$Sex) aov.F=aov(Targ.Assoc.Time~(Timepoint*Acx.Cond*Sex) + Error(Subject/ (Timepoint*Acx.Cond))+(Sex), data=mydata.tab) #run aov where i look at the main effects of Timepoint, Acoustic Condition and Sex as well as all the interactions therein on the amount of time a frog spends associating with the target sound. Include anything to do with Subject in the error term. Does this look right for a Repeated Measures ANOVA, or am I missing something to make it RM and that explains the large discrepancies in my F-values between [R] and SPSS? As soon as I get this canonical aov code figured out I want to derive my p-values by bootstrapping my F distributions, but first I need those canonical F's. Thanks -Alex -- Alexander T Baugh Section of Integrative Biology Univ. of Texas at Austin C0930 Austin, TX 78712 http://darktropic.blogspot.com/ -- Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html -Dr. John R. Vokey __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Concatenate variables and quoted text for output filenames
I am outputting some graphs from SpatStat using a for loop. I want the png files to include the i and j from the nested loops in their names. For example, I want the file names to look like i-j_plot.png. The code is below: ma - levels(marks(X)) n - length(ma) for(i in 1:n) for(j in 1:n) { png(filename=) plot(envelope(X, Kcross, i=ma[i], j=ma[j])) dev.off() } -- View this message in context: http://www.nabble.com/Concatenate-variables-and-quoted-text-for-output-filenames-tp16963770p16963770.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] deleting variables
Richard Pearson wrote: ?rm Richard Ralf Goertz wrote: How can I automatically exclude one variable from being saved in the workspace when I quit an R session? The problem is I don't know how to erase a variable once it has been created. [...] Ralf More on the use of rm. If you want to delete many variables in one go, x-runif(10) y-runif(10) z-runif(10) ls() #you check all the objects in your workspace #[1] x y z rm(list=your.list - ls()[2:3]) #you selected to delete all those objects whose indices are between 2 and 3. rm(your.list) #remove the temporary list with variable names ls() [1] x HTH Rubén __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How do you test for consecutivity?
This will work: my.list - c(2, 28, 31, 4, 27) sort(my.list) diff(sort(my.list)) any(diff(sort(my.list)) == 1) the middle two lines are only to illustrate what's going on. Best wishes! Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Anthony28 Sent: Tuesday, April 29, 2008 8:52 AM To: r-help@r-project.org Subject: [R] How do you test for consecutivity? I need to use R to model a large number of experiments (say, 1000). Each experiment involves the random selection of 5 numbers (without replacement) from a pool of numbers ranging between 1 and 30. What I need to know is what *proportion* of those experiments contains two or more numbers that are consecutive. So, for instance, an experiment that yielded the numbers 2, 28, 31, 4, 27 would be considered a consecutive = true experiment since 28 and 27 are two consecutive numbers, even though they are not side-by-side. I am quite new to R, so really am puzzled as to how to go about this. I've tried sorting each experiment, and then subtracting adjacent pairs of numbers to see if the difference is plus or minus 1. I'm also unsure about whether to use an array to store all the data first. Any assistance would be much appreciated. -- View this message in context: http://www.nabble.com/How-do-you-test-for-%22consecutivity%22--tp16959748p16 959748.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Concatenate variables and quoted text for output filenames
29/04/2008 17:04 trhermes a écrit I am outputting some graphs from SpatStat using a for loop. I want the png files to include the i and j from the nested loops in their names. For example, I want the file names to look like i-j_plot.png. The code is below: ma - levels(marks(X)) n - length(ma) for(i in 1:n) for(j in 1:n) { png(filename=) plot(envelope(X, Kcross, i=ma[i], j=ma[j])) dev.off() } png(filename=sprintf(%d-%d_plot.png, i, j)) -- Best wishes Wolfgang -- Wolfgang Huber EBI/EMBL Cambridge UK http://www.ebi.ac.uk/huber __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 hide the warnings
See help(warnings) and from there you'll also find help(warning). It is described there. /Henrik On Tue, Apr 29, 2008 at 5:14 PM, Vidhu Choudhary [EMAIL PROTECTED] wrote: Hi All, I want to hide all the system(R) generated warning messages and want only the messages from my script should be shown when i run myscript.R Can you please suggest how can I hide the warnings Thank you Vidhu [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How do you test for consecutivity?
Hey Anthony, There must be many ways to do this. This is one of them: #First, define a function to calculate the proportion of consecutive numbers in a vector. prop.diff=function(x){ d=diff(sort(x)) prop=(sum(d==1)+1)/length(x) return(prop)} #Note that I am counting both numbers in a consecutive pair. For example, the vector c(1,2,6,9,10) will contain 4 consecutive numbers. I think this is what you wanted do do, right? #Next, generate a matrix with 1000 columns (one for each experiment) and 5 rows (the five numbers in each experiment). Note the use of the 'replicate' function to generate multiple sets of random numbers selection=replicate(1000,sort(sample(1:30,5))) #Third, use the apply function to apply the function we defined above to each column of the matrix diffs=apply(selection,2,prop.diff) # This will give you a vector with the 1000 proportions of consecutive numbers Julian Anthony28 wrote: I need to use R to model a large number of experiments (say, 1000). Each experiment involves the random selection of 5 numbers (without replacement) from a pool of numbers ranging between 1 and 30. What I need to know is what *proportion* of those experiments contains two or more numbers that are consecutive. So, for instance, an experiment that yielded the numbers 2, 28, 31, 4, 27 would be considered a consecutive = true experiment since 28 and 27 are two consecutive numbers, even though they are not side-by-side. I am quite new to R, so really am puzzled as to how to go about this. I've tried sorting each experiment, and then subtracting adjacent pairs of numbers to see if the difference is plus or minus 1. I'm also unsure about whether to use an array to store all the data first. Any assistance would be much appreciated. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Calling R from C - part way there but need a push!
Dear All, I've read the manual on Writing R Extensions and in particular the part on calling R from C. (Most of the manual is about calling C from R, not the other way around.) The good news is that I can now call _some_ R from C, specifically the R functions which have C header files. However it isn't clear to me how to call R functions that are written in R. I imagine that there is a standard C function of the form Call_r_from_C(package name, Rfunction name as a string, arg1, arg2, ...); where arg1 etc are standardised ways of representing R data structures in C. However I haven't been able to find such a function prototype in the R include/*.h files. See footnote (1). Can you point me in the right direction please? Is there a set of examples somewhere that I can peruse? Does R keep any state when being called from C? Should I think of it as being a co-process, so I can make consecutive calls to it and expect it to remember previous calls? I'm thinking of a sequence of calls such as load library, load R code from a file of my own, set value of x, make a call and read the values back into my C program? Help is much appreciated. Regards, Max (1) The most likely include file is Rinterface.h and within that the most likely candidates seem to be: extern int (*ptr_R_ReadConsole)(const char *, unsigned char *, int, int); extern void (*ptr_R_WriteConsole)(const char *, int); extern void (*ptr_R_WriteConsoleEx)(const char *, int, int); but it turns out that they assume that R is running the terminal and these are requests to R to display or read from R's console. R isn't acting as the back end being given work and returning answers. (2) Googling calling r from c yields precisely five hits, most of which just point back at the R extensions document with vague It's in there somewhere's. I've looked! (3) Leads suggested by help.search(C) Foreign(base): Foreign Function Interface Functions to make calls to compiled code that has been loaded into R. .Internal(base) Call an Internal Function '.Internal' performs a call to an internal code which is built in to the R interpreter. Only true R wizards should even consider using this function, and only R developers can add to the list of internal functions. (Definitely not me!) .Primitive(base)Call a Primitive Internal Function The advantage of '.Primitive' over '.Internal' functions is the potential efficiency of argument passing. (4) R code that I have called successfully is that with prototypes defined in e.g. include/R_ext/Applic.h __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Combine Values into a Vector or List
Hi Richard, Thanks a lot! What I actually want to have A1 4 A2 2 . and so on! Is this possible? Thank you again :)! - Original Message From: [EMAIL PROTECTED] [EMAIL PROTECTED] To: Diego Culattoni [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, April 28, 2008 11:24:12 AM Subject: Re: [R] Combine Values into a Vector or List x1-paste(A, 1:6, sep = ) x2- round(rgamma(6,2,1)) x3-paste(B, 1:6, sep = ) x4- round(rgamma(6,2,1)) data1 - data.frame(x1,x2,x3,x4) I would like to get data2 - c(A1=4, A2=1, A3=0,...) Is there any standard for such a case? I presume that 4, 2, 0 are the first few values of x2. In which case, I think that what you want is simply this: names(x2) - x1 Regards, Richie. Mathematical Sciences Unit HSL ATTENTION: This message contains privileged and confidential inform...{{dropped:28}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] ggplot2: setting global graphic parameters with png driver
Sorry I forgot these informations. I'm using R 2.70, under Linux (Debian Etch). The png driver uses cairo, and the version of libcairo installed is 1.2.4 (which is not the latest, but more recent versions are not available is the debian stable repositories) I tried bitmap(), and it does not look good, because there is no antialiasing. I tried a lot of different settings with png(). Setting the size in inches and the resolution did not help. pointsize does help, but seems limited: increasing pointsize does not do anything after a certain value. It's like there's a maximum font size in pixels that I can achieve. Does that make any sense? This size is barely OK if I want an image of 1024x1024 pixels, which should be OK. However, there is still the problem of line width, wich are not affected by pointsize. Of course, I can modify the linewidth directly for every plot, but it would be easier with a global setting of ggplot ? Many thanks, Xavier Prof Brian Ripley a écrit : You forgot to mention your version of R and your platform (and R has at least 3 separate png() devices). In 2.7.0, specify the size in inches and increase the resolution. In earlier versions, try bitmap(). From NEWS for 2.7.0 oConsiderable efforts have been made to make the default output from graphics devices as similar as possible (and in particular close to that from postscript/pdf).Many devices were misinterpreting 'pointsize' in some way, for example as being in device units (pixels) rather than in points. On Tue, 29 Apr 2008, Xavier Chardon wrote: Hi all, I prepared a few charts with ggplot2, and was happy with the results as displayed on screen. I tried to draw them with a PNG driver instead. But I ran into several problems while trying to increase the resolution of the picture. Mainly, when I increased the picture size (e.g png(width=1024, height=768) ), the texts (title, labels, etc...) where too small. I tried to set the pointsize option of the driver. That did the trick, to some extent. But it seems limited, and I couldn't get big enough fonts for high resolution images. Also, I tried the resolution setting of the driver. But this has an effect on lots of things, e.g. the length of the lines in the legend, so I gave up this idea. I tried to change the font size of all elements, with e.g. grid.gedit(label, gp=gpar(cex=4) ). But the position of the labels does not change then, and with the bigger font, they are drawn on top of the axis or of its title. Another problem was that the line width is also too small in big images. I couldn't find a way to change it globally. So, is there a way to go easily from a plot that looks good on screen (X11 driver) to a similar png image? Or is it possible to change the default settings of ggplot2 (line size and font size in particular, which are not covered by the ggopt function) ? I guess people usually export their charts as image files, so hopefully there's an easy solution. Many thanks, Xavier __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Xavier Chardon Thésard Institut de l'élevage / INRA Projet ACTA modélisation environnementale des systèmes bovins et porcins [EMAIL PROTECTED] [EMAIL PROTECTED] 02 23 48 50 91 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How do you test for consecutivity?
On Tue, 29 Apr 2008, Anthony28 wrote: I need to use R to model a large number of experiments (say, 1000). Each experiment involves the random selection of 5 numbers (without replacement) from a pool of numbers ranging between 1 and 30. What I need to know is what *proportion* of those experiments contains two or more numbers that are consecutive. So, for instance, an experiment that yielded the numbers 2, 28, 31, 4, 27 would be considered a consecutive = true experiment since 28 and 27 are two consecutive numbers, even though they are not side-by-side. I am quite new to R, so really am puzzled as to how to go about this. I've tried sorting each experiment, and then subtracting adjacent pairs of numbers to see if the difference is plus or minus 1. I'm also unsure about whether to use an array to store all the data first. Any assistance would be much appreciated. Are the numbers 1:30 equiprobable?? If so, you can find the probability by direct enumeration. mat - combn(30,5) # each column happens to be in order tab - table( mat[2:5,]-mat[1:4,]==1, col(mat[1:4,]) ) table(tab[2,]) 0 1 2 3 4 65780 59800 15600 130026 prop.table( table(tab[2,] != 0 ) ) FALSE TRUE 0.4615946 0.5384054 If the numbers are not equiprobable, you will need to weight the values of tab[2,] according to the probability of each column of mat. HTH, Chuck -- View this message in context: http://www.nabble.com/How-do-you-test-for-%22consecutivity%22--tp16959748p16959748.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:[EMAIL PROTECTED] UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How do you test for consecutivity?
Hey Anthony, My previous function may not work in all cases. Say one of the experiments yields these numbers: 1,2,3,6,7 Would you say that the proportion of consecutive numbers is 100%? If so, this will work: prop.diff=function(x){ d=diff(sort(x)) prop=sum((c(0,d==1)+c(d==1,0))0) prop=prop/length(x) return(prop)} This function first identifies which numbers in your original vector are part of a sequence of consecutive numbers. Julian Julian Burgos wrote: Hey Anthony, There must be many ways to do this. This is one of them: #First, define a function to calculate the proportion of consecutive numbers in a vector. prop.diff=function(x){ d=diff(sort(x)) prop=(sum(d==1)+1)/length(x) return(prop)} #Note that I am counting both numbers in a consecutive pair. For example, the vector c(1,2,6,9,10) will contain 4 consecutive numbers. I think this is what you wanted do do, right? #Next, generate a matrix with 1000 columns (one for each experiment) and 5 rows (the five numbers in each experiment). Note the use of the 'replicate' function to generate multiple sets of random numbers selection=replicate(1000,sort(sample(1:30,5))) #Third, use the apply function to apply the function we defined above to each column of the matrix diffs=apply(selection,2,prop.diff) # This will give you a vector with the 1000 proportions of consecutive numbers Julian Anthony28 wrote: I need to use R to model a large number of experiments (say, 1000). Each experiment involves the random selection of 5 numbers (without replacement) from a pool of numbers ranging between 1 and 30. What I need to know is what *proportion* of those experiments contains two or more numbers that are consecutive. So, for instance, an experiment that yielded the numbers 2, 28, 31, 4, 27 would be considered a consecutive = true experiment since 28 and 27 are two consecutive numbers, even though they are not side-by-side. I am quite new to R, so really am puzzled as to how to go about this. I've tried sorting each experiment, and then subtracting adjacent pairs of numbers to see if the difference is plus or minus 1. I'm also unsure about whether to use an array to store all the data first. Any assistance would be much appreciated. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] function to generate weights for lm?
On Tue, Apr 29, 2008 at 6:20 AM, tom soyer [EMAIL PROTECTED] wrote: Hi, I would like to use a weighted lm model to reduce heteroscendasticity. I am wondering if the only way to generate the weights in R is through the laborious process of trial and error by hand. Does anyone know if R has a function that would automatically generate the weights need for lm? Hi Tom, The 'weights' argument to the 'gls' function in the nlme package provides a great deal of flexibility in estimate weighting parameters and model coefficients. For example, if you want to model monotonic heteroscedasticity by estimating the weights $E(Y)^{-2\alpha}$, you can use the varPower variance function class. E.g., something like f1 - gls(y ~ x1 + x2, data = your.data, weights = varPower()) will estimate the regression coefficients and alpha parameter together via maximum likelihood. (note that the usual specification for varPower is varPower(form = ~ your.formula), but by default the mean is used. See Ch 5 of the Pinheiro and Bates Mixed-effects Models book for details) Kingsford Jones __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] If(cond) statement
Why will this simple statement not work? I think I am following the documentation for if(cond) statements, and I have tried wrapping the cons.expr and alt.expr in {}, I get the same error. There is no example in the help file, and this is not covered in the Introduction to R, SimpleR or other tutorials I have looked into. mxx=max(cpx_list$nMV); mxy=max(trend_list$nMV); if (mxxmxy) mxy=mxx else mxx=mxy Error: unexpected 'else' in else Why does this error message have the first 'else' in single quote and second in double?? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R code for weighted Deming regression?
Hi, Any one has the code that I can borrow? Or any suggestions? Highly appreciate. Hongyan Du [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] panel.xyplot()
I am try to create a plot using xyplot(). I created a function panel.fun() wich generate segment, but I need use two columns from dataset2. library(lattice) panel.fun - function(x, y, minx, maxx, miny, maxy) { panel.xyplot(x,y) # since I don't know how to call dataset2 inside panel.fun(), so I hardcoded the data into function seq1 -c() seq2 -c() plotcols=rainbow(length(seq1)) for(i in 1:length(seq1)) { a - seq1[i] b - seq2[i] panel.segments(a,miny-rangey,a, maxy+rangey, col= plotcols[i],lty=4, lwd=2) panel.segments(b,miny-rangey,b, maxy+rangey, col= plotcols[i],lty=4, lwd=2) } } # after create panel.fun, I call xyplot() xyplot(a ~ b , data=dataset1, auto.key=TRUE, panel=function(x,y, minx, maxx, miny, maxy, seq){ panel.fun(x,y, min(na.omit(x)), max(na.omit(x)),min(na.omit(y)),max(na.omit(y))) }) Does anyone know how to solve this probelm? - [[elided Yahoo spam]] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Calling R from C - part way there but need a push!
On 29/04/2008 12:19 PM, Maximillian Murphy wrote: Dear All, I've read the manual on Writing R Extensions and in particular the part on calling R from C. (Most of the manual is about calling C from R, not the other way around.) The good news is that I can now call _some_ R from C, specifically the R functions which have C header files. However it isn't clear to me how to call R functions that are written in R. I imagine that there is a standard C function of the form Call_r_from_C(package name, Rfunction name as a string, arg1, arg2, ...); Not really. eval() is the main function to call from C. You construct an R expression, then evaluate it. where arg1 etc are standardised ways of representing R data structures in C. However I haven't been able to find such a function prototype in the R include/*.h files. See footnote (1). Can you point me in the right direction please? Is there a set of examples somewhere that I can peruse? Section 5.10 (Evaluating R expressions from C) of the Writing R Extensions manual gives a couple of examples. Does R keep any state when being called from C? Should I think of it as being a co-process, so I can make consecutive calls to it and expect it to remember previous calls? I'm thinking of a sequence of calls such as load library, load R code from a file of my own, set value of x, make a call and read the values back into my C program? The normal way to do it is to let R be in charge, and only occasionally call out to C: so then R keeps its state. What you are trying to do sounds more like writing a new front-end to R, which is much more involved: see Chapter 8 of that manual. Duncan Murdoch Help is much appreciated. Regards, Max (1) The most likely include file is Rinterface.h and within that the most likely candidates seem to be: extern int (*ptr_R_ReadConsole)(const char *, unsigned char *, int, int); extern void (*ptr_R_WriteConsole)(const char *, int); extern void (*ptr_R_WriteConsoleEx)(const char *, int, int); but it turns out that they assume that R is running the terminal and these are requests to R to display or read from R's console. R isn't acting as the back end being given work and returning answers. (2) Googling calling r from c yields precisely five hits, most of which just point back at the R extensions document with vague It's in there somewhere's. I've looked! (3) Leads suggested by help.search(C) Foreign(base): Foreign Function Interface Functions to make calls to compiled code that has been loaded into R. .Internal(base) Call an Internal Function '.Internal' performs a call to an internal code which is built in to the R interpreter. Only true R wizards should even consider using this function, and only R developers can add to the list of internal functions. (Definitely not me!) .Primitive(base)Call a Primitive Internal Function The advantage of '.Primitive' over '.Internal' functions is the potential efficiency of argument passing. (4) R code that I have called successfully is that with prototypes defined in e.g. include/R_ext/Applic.h __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Statistical Methods and Software for the Analysis of Occupational Exposure Data With Non-Detectable Values
FYI This is a nice package that is not on CRAN for some reason. You can get it at http://www.csm.ornl.gov/esh/statoed/ Tom -- View this message in context: http://www.nabble.com/Statistical-Methods-and-Software-for-the-Analysis-of-Occupational-Exposure-Data-With-Non-Detectable-Values-tp16966228p16966228.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] If(cond) statement
On 4/29/2008 1:21 PM, Beck, Kenneth (STP) wrote: Why will this simple statement not work? I think I am following the documentation for if(cond) statements, and I have tried wrapping the cons.expr and alt.expr in {}, I get the same error. There is no example in the help file, and this is not covered in the Introduction to R, SimpleR or other tutorials I have looked into. mxx=max(cpx_list$nMV); mxy=max(trend_list$nMV); if (mxxmxy) mxy=mxx else mxx=mxy Error: unexpected 'else' in else Why does this error message have the first 'else' in single quote and second in double?? Did you see this part of the help page? Note that it is a common mistake to forget to put braces ({ .. }) around your statements, e.g., after if(..) or for(). In particular, you should not have a newline between } and else to avoid a syntax error in entering a if ... else construct at the keyboard or via source. For that reason, one (somewhat extreme) attitude of defensive programming is to always use braces, e.g., for if clauses. Try this: if (mxx mxy) mxy - mxx else mxx - mxy Or this: {if (mxx mxy) mxy - mxx else mxx - mxy} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] If(cond) statement
Kenneth - See ?if in the Details section. Specifically this part (at least in R 2.7), In particular, you should not have a newline between '}' and 'else' to avoid a syntax error in entering a 'if ... else' construct at the keyboard or via 'source'. The R interpreter can't 'see ahead' that you have an else statement. Your program could validly end after your cons.expr, without the need for an 'else'. This is why you should put your else on the same line, possibly using {}s for clarity. Best, Erik Iverson Beck, Kenneth (STP) wrote: Why will this simple statement not work? I think I am following the documentation for if(cond) statements, and I have tried wrapping the cons.expr and alt.expr in {}, I get the same error. There is no example in the help file, and this is not covered in the Introduction to R, SimpleR or other tutorials I have looked into. mxx=max(cpx_list$nMV); mxy=max(trend_list$nMV); if (mxxmxy) mxy=mxx else mxx=mxy Error: unexpected 'else' in else Why does this error message have the first 'else' in single quote and second in double?? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 on extract paramters from fitted models
Hi, I have a question about how to extract paramters from a fitted model. I can extract coefficients and std, but from some other statistics, I dont know how to extract. Can anyone help? Here it is an example: coxout-coxph(Surv(t,t.censor)~x) coxout Call: coxph(formula = Surv(t, t.censor) ~ x) coef exp(coef) se(coef)zp x 0.349 1.420.257 1.36 0.17 Likelihood ratio test=1.84 on 1 df, p=0.175 n= 200 coxout$coef x 0.3490500 coxout$p NULL Any convienent way to extract the LRT and the p value? thank you! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Help on extract paramters from fitted models
See the source code of function: getS3method(print, coxph) is this block: tmp - cbind(coef, exp(coef), se, coef/se, signif(1 - pchisq((coef/se)^2, 1), digits - 1)) On 4/29/08, Lisa [EMAIL PROTECTED] wrote: Hi, I have a question about how to extract paramters from a fitted model. I can extract coefficients and std, but from some other statistics, I dont know how to extract. Can anyone help? Here it is an example: coxout-coxph(Surv(t,t.censor)~x) coxout Call: coxph(formula = Surv(t, t.censor) ~ x) coef exp(coef) se(coef)zp x 0.349 1.420.257 1.36 0.17 Likelihood ratio test=1.84 on 1 df, p=0.175 n= 200 coxout$coef x 0.3490500 coxout$p NULL Any convienent way to extract the LRT and the p value? thank you! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Combine Values into a Vector or List
Hi Diego, Try this: z-As[A1]+As[A2]; names(z)-z z 4 HTH, Jorge On Tue, Apr 29, 2008 at 2:57 PM, Diego Culattoni [EMAIL PROTECTED] wrote: Thank you Jorge, what I want to have is z - A1+A2 z 4 The problem is that A1, A2,... still unknown, so that I have the following error A1 object A1 not found Thank you in advance! - Original Message From: Jorge Ivan Velez [EMAIL PROTECTED] To: Diego Culattoni [EMAIL PROTECTED] Cc: R mailing list r-help@r-project.org Sent: Tuesday, April 29, 2008 7:38:41 PM Subject: Re: [R] Combine Values into a Vector or List Hi Diego, Is this what you want? # Data set set.seed(123) x1-paste(A, 1:6, sep = ) x2- round(rgamma(6,2,1)) x3-paste(B, 1:6, sep = ) x4- round(rgamma(6,2,1)) data1 - data.frame(x1,x2,x3,x4) data1 x1 x2 x3 x4 1 A1 1 B1 0 2 A2 3 B2 0 3 A3 0 B3 3 4 A4 2 B4 2 5 A5 4 B5 2 6 A6 2 B6 2 # A's As=as.numeric(t(data1[,1:2])[-1,]) names(As)=paste('A',1:length(As),sep=) As A1 A2 A3 A4 A5 A6 1 3 0 2 4 2 # B's Bs=as.numeric(t(data1[,3:4])[-1,]) names(Bs)=paste('B',1:length(Bs),sep=) Bs B1 B2 B3 B4 B5 B6 0 0 3 2 2 2 HTH, Jorge On Tue, Apr 29, 2008 at 1:20 PM, Diego Culattoni [EMAIL PROTECTED] wrote: Hi Richard, Thanks a lot! What I actually want to have A1 4 A2 2 .. and so on! Is this possible? Thank you again :)! - Original Message From: [EMAIL PROTECTED] [EMAIL PROTECTED] To: Diego Culattoni [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, April 28, 2008 11:24:12 AM Subject: Re: [R] Combine Values into a Vector or List x1-paste(A, 1:6, sep = ) x2- round(rgamma(6,2,1)) x3-paste(B, 1:6, sep = ) x4- round(rgamma(6,2,1)) data1 - data.frame(x1,x2,x3,x4) I would like to get data2 - c(A1=4, A2=1, A3=0,...) Is there any standard for such a case? I presume that 4, 2, 0 are the first few values of x2. In which case, I think that what you want is simply this: names(x2) - x1 Regards, Richie. Mathematical Sciences Unit HSL ATTENTION: This message contains privileged and confidential inform...{{dropped:28}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] tcltk
On an x86 machine operating under Gentoo Linux, I'm having trouble with tcltk in R-2.6.1 (the latest version available through Gentoo's emerge/portage system). The problem first came to my attention when install.packages(Rmetrics) produced the following error message: Loading required package: tcltk Error in firstlib(which.lib.loc, package) : Tcl/Tk support is not available on this system Error: package 'tcltk' could not be loaded Then I tried library(tcltk) and again got the last 3 lines shown above. Doing emerge --search tcl shows that dev-lang/tcl 8.4.18 and dev-tcltk/tcllib 1.6.1 are installed. I would be most grateful for suggestions for diagnosing and fixing this problem. Best regards, John -- John P. Burkett Department of Environmental and Natural Resource Economics and Department of Economics University of Rhode Island Kingston, RI 02881-0808 USA phone (401) 874-9195 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.