[R] problem formula (newbe)
Dear R-users,  I am trying to run a function of the package âadabagâ (e.g. boosting.cv) in order to determine a proper number of cluster that I would specify later on my KMeans clustering. (I had this idea from: http://www.statsoft.com/TEXTBOOK/stcluan.html)  However, I do have a problem with the âformulaâ parameter of e.g. boosting.cv : I am not familiar with these formulas and my research in the R user guide did not really helped me:  I have 2 columns in my dataset corresponding to 2 âresponseâ variables (x = coordinates along PCA axis 1 and y = coordinates along PCA axis 2 of my raw dataset) and thatâs on these variables that I would like to run the boosting.cv, therefore I tried to define a formula with 2 response variables and no terms but itâs not really explained this way in the R-guide and Iâm not even sure itâs possible.  I also tried by making my KMeans clustering before, applying the cluster number to each row and using this number (recoded  as.character) as a term, but it does not work either.  A quick overview of code / error message if needed :  form - as.formula (COORDI_PCA1n2$Dim.1 + COORDI_PCA1n2$Dim.2 ~KMeans) boosting.cv(form, COORDI_PCA1n2) Error in `[.data.frame`(data, , as.character(formula[[2]])) :  undefined columns selected boosting.cv(form, COORDI_PCA1n2[, 1:2]) Error in `[.data.frame`(data, , as.character(formula[[2]])) :  undefined columns selected   If anyone has the time to indicate me where Iâm being wrong⦠ With regards [[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] Merge data frames but prefer values in one
Thanks for the post-processing ideas. But is there any way to do that in one step? On Thu, Sep 10, 2009 at 7:20 PM, Henrique Dallazuanna www...@gmail.com wrote: Try this: xy - merge(x, y, by = c(a,b),all = TRUE) xy$c - ifelse(rowSums(!is.na(.x - xy[, c('c.x', 'c.y')])) 1, .x[,1], rowSums(.x, na.rm = TRUE)) xy On Thu, Sep 10, 2009 at 12:21 PM, JiHO jo.li...@gmail.com wrote: JiHO --- http://maururu.net __ 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] Accumulating results from for loop in a list/array
Steven I think list() can help you ## indlist = list() for (i in 1:(dim(x)[2])) { indlist[[paste(ind, i, sep = )]] - which(x[ , i] == y) } accum = unlist(indlist) print(indlist$ind1) ### Schalk Heunis On Fri, Sep 11, 2009 at 7:52 AM, Steven Kang stochastick...@gmail.com wrote: Dear R users, I would like to accumulate objects generated from 'for' loop to a list or array. To illustrate the problem, arbitrary data set and script is shown below, x - data.frame(a = c(rep(n,3),rep(y,2),rep(n,3),rep(y,2)), b = c(rep(y,2),rep(n,4),rep(y,3),n), c = c(rep(n,7),rep(y,3)), d = c(y, rep(n,4), rep(y,2), rep(n,3))) for (i in 1:(dim(x)[2])) { assign(paste(ind, i, sep = ), which(x[ , i] == y)) accum - c(ind1, ind2, ind3, ind4) } ind1 [1] 4 5 9 10 ind2 [1] 1 2 7 8 9 ind3 [1] 8 9 10 ind4 [1] 1 6 7 accum [1] 4 5 9 10 1 2 7 8 9 8 9 10 1 6 7 Are there any alternative method where the highlighted statement above can be represented without typing individual objects manually? (as it can be very tedious with large number of objects; i.e ind1, ind2, ., ind100) Also, is there any way to extract individual objects ('ind1' etc) from 'accum'? accum[1:length(ind1)] [1] 4 5 9 10 gives 'ind1', but this may become messy for other objects (like 'ind10') Highly appreciate for sharing your expertise in solving this problem. [[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] Is there any month object like LETTERS ?
There is an object LETTERS which displays all letters from a to z. Is there any similar object whicg displays the months as well in chronological order? like jan, feb,...,dec Thanks, -- View this message in context: http://www.nabble.com/Is-there-any-%22month%22-object-like-%22LETTERS%22---tp25396125p25396125.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] Best R text editors?
On Fri, 11-Sep-2009 at 06:12AM +0200, Johannes Huesing wrote: | Martin Maechler maech...@stat.math.ethz.ch [Wed, Sep 02, 2009 at 09:17:42AM CEST]: | PaCo == p connolly p_conno...@slingshot.co.nz | on Wed, 02 Sep 2009 12:19:31 +1200 writes: | | PaCo On Mon, 31-Aug-2009 at 08:25PM +1000, Jim Lemon wrote: | PaCo [...] | [...] | PaCo | Emacs still | PaCo | has that annoying trait of being determinedly incompatible with anything | PaCo | else, even if the conventions are quite sensible. | | A lot of the keystrokes are the same as when you are using the bash. | | [...] | | well, actually, since Emacs 23, in its 'Options' Menu there's | now a check-box entry | | C-x/C-c/C-v Cut and Paste (CUA) | | ((which still is off by default ;-)) | | and in previous versions, you could always do M-x cua-mode for | the same effect. Talk about a well-hidden function mostly directed | at beginners ... Perhaps the thinking was that by the time they find it, they'll already have noticed that they can cut/copy and paste using only the mouse buttons and won't be bothered with such inefficient methods. Though this be madness, yet there is a method in't. :-) -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Average minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) . Eleanor Roosevelt ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. __ 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] Constructing variables conditional on two indicators
Dear R users I have a data frame that looks like this: m j X1 X2 1 1 1 2 1 ... 1 J 2 1 2 2 2 ... 2 J . . . M 1 M 2 M ... M J The data frame essentially looks like a panel: m and j are indicators where m is 1:M and j is 1:J (and M J); X1 and X2 are variables. I would like to construct and add new variables to the data frame that are m- and j- specific, e.g., compute X3 where X3 is the sum of X1 of all j in m, and this for each m. The new variable X3 is then added to the data frame (and is the same for all rows with the same m indicator). How can I program this efficiently without running loops? Thanks in advance Jo Reynaerts Ph.D. student LICOS Centre for Institutions and Economic Performance Katholieke Universiteit Leuven Debériotstraat 34/3511 B-3000 Leuven Belgium jo.reynae...@econ.kuleuven.bemailto:jo.reynae...@econ.kuleuven.be [[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] Constructing variables conditional on two indicators
have a look at ave() and/or tapply(). I hope it helps. Best, Dimitris Reynaerts, Jo wrote: Dear R users I have a data frame that looks like this: m j X1 X2 1 1 1 2 1 ... 1 J 2 1 2 2 2 ... 2 J . . . M 1 M 2 M ... M J The data frame essentially looks like a panel: m and j are indicators where m is 1:M and j is 1:J (and M J); X1 and X2 are variables. I would like to construct and add new variables to the data frame that are m- and j- specific, e.g., compute X3 where X3 is the sum of X1 of all j in m, and this for each m. The new variable X3 is then added to the data frame (and is the same for all rows with the same m indicator). How can I program this efficiently without running loops? Thanks in advance Jo Reynaerts Ph.D. student LICOS Centre for Institutions and Economic Performance Katholieke Universiteit Leuven Debériotstraat 34/3511 B-3000 Leuven Belgium jo.reynae...@econ.kuleuven.bemailto:jo.reynae...@econ.kuleuven.be [[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. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ 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] Linux R version: best?
On Thu, 10-Sep-2009 at 04:47PM -0400, S. Few wrote: | For my Redhat 5.2 Linux box, which version of R would be most stable? Redhat 5.2 is *very* old. That was around about the time of Windows98, IIRC. Or do you mean RHEL 5.2? | | I am doing forecasting, statistics, etc. | | | Thanks! | | Steve | | __ | 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. -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Average minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) . Eleanor Roosevelt ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. __ 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] executing rscript from VB
Maybe I'm missing something, but how about using the shell function? Bart Duncan Murdoch-2 wrote: On 9/10/2009 9:25 AM, H Rao wrote: Hi, I am looking to execute an R script from VB as below. The script runs fine but the redirection doesnt seem to happen. The redirection operator and the out file seem to be treated as arguments to the R script. Is there a way to get the operator working That's a VB question. You should ask Microsoft. Duncan Murdoch thanks, R System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = E:/R/bin/Rscript.exe; proc.StartInfo.Arguments = E:/R/bin/test.r test.out; proc.StartInfo.UseShellExecute = true; proc.Start(); __ 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. -- View this message in context: http://www.nabble.com/executing-rscript-from-VB-tp25383342p25396386.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] how to do this?
Hello R-users I have a situation like this x=c(1,3,2) y=data.frame(a=1:3, b=4:6, c=7:9)*2 So we have t(t(x)) [,1] [1,]1 [2,]3 [3,]2 And y a b c 1 2 8 14 2 4 10 16 3 6 12 18 I would like to obtain a vector with number taken from the data.frame: x is needed as row index With c(1,3,2), in this case the ouput should be 2 16 12 I've tried a little bit with apply, but unsuccessfully. Thank you __ 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] sppolot: fill below minimum legend value
emorway wrote: In the plot below, there are some grid cells that have values below 10, which is the lowest cut value I have specified. Is there a way, without adjusting the number of cuts, to tell R to fill in those cells with the lowest possible color (in this case greeen)? There is a white hole in the image about a quarter of the way in from the left side, this is what I would like to correct. Thanks...Eric The code: pts-list(sp.points,K.dat,pch=3,col=black) cuts-c(10,20,30,40,50,60,70,80,90,100,200,300,400,500,600,700,800,900,1000) spplot(lzm.krige.dir[var1.pred],at=cuts,colorkey=list(at=log10(cuts),at=log10(cuts),labels=as.character(cuts)),scales=list(draw=TRUE), xlab=Easting,ylab=Northing,key.space=right,cex=1.1,col.regions=terrain.colors(30),main=Hydraulic Conductivity of Layer 2,sp.layout=list(pts)) The image: http://www.nabble.com/file/p25392472/Image3.jpeg Hi Eric, As far as I know you need to set the lower value of cuts to the minimum of the dataset to prevent this white space from occuring. If you don't want to see this in the colorbar, you need to adjust it using the colorkey argument. And a non-technical note, you e-mail doesn't give a lot of background regarding your problem. spplot is a function that is only used by people working with geographic data, which is probably a small subset of the total community. See the posting guide for some hints about what kind of information is necessary in an e-mail to r-help, for example a reproducible example. In addition, there is a mailing list specifically meant for geographic data, r-sig-geo, where you are more likely to get the answers you are looking for. cheers and good luck, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ 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] ipred
Hello, I have a question about ipred package. I am working on a data set which contains 1000 individual swho came from 588 regions. I calculated misclassification error rate with cross validation and its smooted version bootstrap 632 for different sample sizes in LDF. I am doubting whether error rate and low variance are enough to explain my data. Thanks Meral [[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] call Fortran from R
Dear R users, I have to call fortran program from within R (R 2.8.1 on ubuntu 8.10 machine). Suppose I have a fortran code like this (this is only a toy model, my working model is far more complex, but input/output is similar) DOUBLE PRECISION FUNCTION model(times, alfa, beta) DOUBLE PRECISION alfa, beta, times model=beta*sin(times)+alfa*cos(times) END FUNCTION which is saved as model.f. I wrote a wapper like this (saved as wrapper.f) SUBROUTINE model_wrapper(times, alfa, beta, answer) DOUBLE PRECISION times, alfa, beta, answer EXTERNAL model answer = model(times, alfa, beta) END SUBROUTINE Then I compiled all this stuff g77 -fno-second-underscore -c -fPIC model.f g77 -fno-second-underscore -c -fPIC wrapper.f g77 -fno-second-underscore -shared -o model.so model.o wrapper.o From within R dyn.load('model.so') model - function(times, alfa, beta) { returned_data = .Fortran('model_wrapper', times=as.double(times), alfa=as.double(alfa), beta=as.double(beta), result=double(1)) return(returned_data) } # example run test_1-model(1.0,0.2,0.3) which gives test_1$times [1] 1.0 $alfa [1] 0.2 $beta [1] 0.3 $result [1] 147456887 where $result is clearly wrong. I suppose I made some mistake with the handling of data types, but I am not able to figure out where. Can someboby help me? Giacomo -- --- Giacomo Santini PhD Dipartimento di Biologia Evoluzionistica Leo Pardi Universita' degli Studi di Firenze Via Romana 17 I-50125 Firenze Italy Tel: +39 055 2288288 (DBE) - +39 0574 447727 (CESPRO) Fax: +39 055 2288289 www.dbe.unifi.it/santini __ 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)
Hello, I have a question about ipred package. I am working on a data set which contains 1000 individual swho came from 588 regions. I calculated misclassification error rate with cross validation and its smooted version bootstrap 632 for different sample sizes in LDF. I am doubting whether error rate and low variance are enough to explain my data. Thanks Meral [[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 to compare the result of GLM and GAM
Dear R users I have basic knowledge of R and unaware of many more. I am confused about how can I compare the result of two different models? Have count data of plant species and want to correlate with altitude, rri, pH, moisture, temperature etc. I have made some models using GLM of different orders and I found 2nd order GLM significant than others. Now, I wanted to check whether GAM is more robust than GLM. Is it possible to test this in R? If yes, What are the parameters to be focused for the comparison? Thanks in advance Dilli Rijal Central Department of Botany Biodiversity and environmental Management Kathmandu, Nepal [[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] R - box design-scatter plot für means/regres sion/lme?
Dear All! It's now weeks that I'm going crazy with R, and as I'm a new user I now ask for help (also because I still have only a few days to finish..)... So shortly I describe you my Experiment in which I was looking for the decomposition of herbivore dung under different treatments: I made a box design experiment which is structured in the following way: I collected dung from 2 species (Wildebeest and Giraffe) and put for each species 8 pellets in different pots. I used 2 water treatments for the pots: wet (by adding water) and dry and two shadow treatments: shadow and sun. So the design for 1 box was looking as follow: 1 Box (Sun or Shadow): 1 giraffe dung - wet 1 giraffe dung - dry 1 wildebeest dung - wet 1 wildebeest dung - dry -- total 10 Boxen (5 shadow, 5 sun) Now, for each treatment I took out 2 pellets which I then measured fr different variables. I did this at 3 time point: 0, 6 and 12 days after set up. So I have now following Data: Giraffe dung: wet/ dry treatment under shadow/sun condition, 3 collection times, always 5 Replikate Same for the Wildebeest dung. For the pellets I measured following variables: DW.P = dry weight pro pellet WL= water loss Ctot= total carbon Ntot=total nitrogen Now, for my statistics I used: lme(Y ~ Day*water.T*shadow.T*dung.T, random=~Day|Box/Pot) but apperently I have to fit a linear correlation for Day, so that Day is not seen as a Factor.. How have I to do that? Something Day - corr(Day*Y)? Then I also have to calculate the regressions for Ctot and Ntot to get the slopes. I tried with: slope - function(x) {-summary(lm(log(x)~c(1,6,12)))$coefficients[2,1]} Reg.Slopes - aggregate(DW.P, list(shadow.T=shadow.T, water.T=water.T,Species=Species,Pot=ID),slope) ...but it doesn't work... And finally to my plots. I need scatter plots of the means of the different measured variables with the sd bar. I found out there is a code plotmeans but I don't know how to use it with my data... And also how to put the Titles and Subtitles in the right way, as the x and y axes... I'm sorry for the long mail, but I'm really desperate! Thank you very very very much, Stefanie __ 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] call Fortran from R
On 11/09/2009 4:39 AM, Giacomo Santini wrote: Dear R users, I have to call fortran program from within R (R 2.8.1 on ubuntu 8.10 machine). Suppose I have a fortran code like this (this is only a toy model, my working model is far more complex, but input/output is similar) DOUBLE PRECISION FUNCTION model(times, alfa, beta) DOUBLE PRECISION alfa, beta, times model=beta*sin(times)+alfa*cos(times) END FUNCTION which is saved as model.f. I wrote a wapper like this (saved as wrapper.f) SUBROUTINE model_wrapper(times, alfa, beta, answer) DOUBLE PRECISION times, alfa, beta, answer EXTERNAL model answer = model(times, alfa, beta) END SUBROUTINE It's been a long time since I worked in Fortran, but don't you need to declare that model returns a double precision value in the wrapper? By default in ancient Fortran model would be an integer value. Since you compile the two functions separately, the wrapper code won't see the declaration in model.f. Then I compiled all this stuff g77 -fno-second-underscore -c -fPIC model.f g77 -fno-second-underscore -c -fPIC wrapper.f g77 -fno-second-underscore -shared -o model.so model.o wrapper.o I would use R CMD SHLIB model.f wrapper.f to be sure the options match what R is expecting. Duncan Murdoch From within R dyn.load('model.so') model - function(times, alfa, beta) { returned_data = .Fortran('model_wrapper', times=as.double(times), alfa=as.double(alfa), beta=as.double(beta), result=double(1)) return(returned_data) } # example run test_1-model(1.0,0.2,0.3) which gives test_1$times [1] 1.0 $alfa [1] 0.2 $beta [1] 0.3 $result [1] 147456887 where $result is clearly wrong. I suppose I made some mistake with the handling of data types, but I am not able to figure out where. Can someboby help me? Giacomo __ 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: how to do this?
Da: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Per conto di Luca Braglia Inviato: venerdì 11 settembre 2009 10.17 A: r-help@r-project.org Oggetto: [R] how to do this? in this case the ouput should be 2 16 12 Obviously this id.match = rep(0, nrow(y)) for (indice in 1:nrow(y)) { id.match[indice] - y[indice, x[indice]] } id.match ... works, but it's not that good solution (especially for big data.frame) Thank you __ 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] call Fortran from R
Thanks! now it works ! Giacomo Duncan Murdoch wrote: On 11/09/2009 4:39 AM, Giacomo Santini wrote: Dear R users, I have to call fortran program from within R (R 2.8.1 on ubuntu 8.10 machine). Suppose I have a fortran code like this (this is only a toy model, my working model is far more complex, but input/output is similar) DOUBLE PRECISION FUNCTION model(times, alfa, beta) DOUBLE PRECISION alfa, beta, times model=beta*sin(times)+alfa*cos(times) END FUNCTION which is saved as model.f. I wrote a wapper like this (saved as wrapper.f) SUBROUTINE model_wrapper(times, alfa, beta, answer) DOUBLE PRECISION times, alfa, beta, answer EXTERNAL model answer = model(times, alfa, beta) END SUBROUTINE It's been a long time since I worked in Fortran, but don't you need to declare that model returns a double precision value in the wrapper? By default in ancient Fortran model would be an integer value. Since you compile the two functions separately, the wrapper code won't see the declaration in model.f. Then I compiled all this stuff g77 -fno-second-underscore -c -fPIC model.f g77 -fno-second-underscore -c -fPIC wrapper.f g77 -fno-second-underscore -shared -o model.so model.o wrapper.o I would use R CMD SHLIB model.f wrapper.f to be sure the options match what R is expecting. Duncan Murdoch From within R dyn.load('model.so') model - function(times, alfa, beta) { returned_data = .Fortran('model_wrapper', times=as.double(times), alfa=as.double(alfa), beta=as.double(beta), result=double(1)) return(returned_data) } # example run test_1-model(1.0,0.2,0.3) which gives test_1$times [1] 1.0 $alfa [1] 0.2 $beta [1] 0.3 $result [1] 147456887 where $result is clearly wrong. I suppose I made some mistake with the handling of data types, but I am not able to figure out where. Can someboby help me? Giacomo -- --- Giacomo Santini PhD Dipartimento di Biologia Evoluzionistica Leo Pardi Universita' degli Studi di Firenze Via Romana 17 I-50125 Firenze Italy Tel: +39 055 2288288 (DBE) - +39 0574 447727 (CESPRO) Fax: +39 055 2288289 www.dbe.unifi.it/santini __ 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 do this?
Try this: y[matrix(c(seq_along(x), x), ncol = 2)] [1] 2 16 12 On Fri, Sep 11, 2009 at 4:17 PM, Luca Braglia brag...@poleis.eu wrote: Hello R-users I have a situation like this x=c(1,3,2) y=data.frame(a=1:3, b=4:6, c=7:9)*2 So we have t(t(x)) [,1] [1,] 1 [2,] 3 [3,] 2 And y a b c 1 2 8 14 2 4 10 16 3 6 12 18 I would like to obtain a vector with number taken from the data.frame: x is needed as row index With c(1,3,2), in this case the ouput should be 2 16 12 I've tried a little bit with apply, but unsuccessfully. Thank you __ 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] Multilevel models with sampling weights at both levels
Greetings, Is there a package in R that will run multilevel models (e.g. students nested in schools) where sampling weights can be employed at both levels? Thanks in advance. David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: dkaplan at education dot wisc dot edu homepage: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 __ 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: how to do this?
Da: Linlin Yan [mailto:yanlinli...@gmail.com] Inviato: venerdì 11 settembre 2009 11.19 A: Luca Braglia Cc: r-help@r-project.org Oggetto: Re: [R] how to do this? Try this: y[matrix(c(seq_along(x), x), ncol = 2)] [1] 2 16 12 Very interesting! So I can give as index to a data.frame a matrix (of index) too (not only vectors separated by commas). Thank you __ 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] Is there any month object like LETTERS ?
On Fri, Sep 11, 2009 at 8:13 AM, megh megh700...@yahoo.com wrote: There is an object LETTERS which displays all letters from a to z. Is there any similar object whicg displays the months as well in chronological order? like jan, feb,...,dec You could construct a vector of the first of the month for some year and then use months() or format() on it: months(ISOdatetime(1960,1:12,1,0,0,0)) [1] January February March April May June [7] July AugustSeptember October November December format(ISOdatetime(1960,1:12,1,0,0,0),%b) [1] Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Note these are locale-dependent, so les Francais will see something else. Probably Jan,Fev,Mar,Avr and so on... Barry __ 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 do rotation for polygon?
Hi, See if this helps, polygon.regular - # return a matrix of xy coordinates for a regular polygon centered about (0,0) function (sides = 5) { n - sides if (n 3) n - 3 if (n 8) n - 50 th - pi * 2/n costh - cos(th) sinth - sin(th) xx - yy - rep(0, n + 1) if (n%%2) { xx[1] - 0 yy[1] - 1 } else { xx[1] - -sin(th/2) yy[1] - cos(th/2) } for (i in 2:(n + 1)) { xl - xx[i - 1] yl - yy[i - 1] xx[i] - xl * costh - yl * sinth yy[i] - xl * sinth + yl * costh } xy - matrix(c(xx, yy), ncol = 2) return(xy) } pentagon - polygon.regular(5) / 10 # scale down rotate - function (xy, theta = 0) { matR - matrix(c(cos(theta), -sin(theta), sin(theta), cos(theta)), nrow = 2) t(matR %*% t(xy)) } all - do.call(rbind, lapply(seq(0, 2*pi, length=5), rotate, xy=pentagon)) large - pentagon * 2 # these will be the center positions all[, 1] - all[, 1] + rep(large[1:5, 1], each=nrow(pentagon)) # shift the polygons all[, 2] - all[, 2] + rep(large[1:5, 2], each=nrow(pentagon)) all - cbind(all, rep(1:5, each=nrow(pentagon))) # give them an ID grid.newpage() vp - viewport(1, 1, xscale=c(-1, 1), yscale=c(-1, 1)) pushViewport(vp) grid.polygon(all[, 1], all[, 2], id=all[, 3], gp=gpar(fill=1:5)) HTH, baptiste 2009/9/10 William Dunlap wdun...@tibco.com Try representing the pentagon as a set of complex numbers. Translate them by adding a complex number and multiply by exp(1i*angle) to rotate them around the origin. E.g. to rotate them around their center of gravity, mean(p), do p-complex(real=c(4,5,7,8,6), imag=c(5,3,3,5,7)) plot(p, xlim=c(0,10), ylim=c(0,10), type=n) for(k in 0:10)polygon(border=k, lwd=k+1, (p-mean(p))*exp(k*1i/10*pi)+mean(p)) Bill Dunlap TIBCO Software Inc - Spotfire Division wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Hemavathi Ramulu Sent: Thursday, September 10, 2009 1:44 AM To: Greg Snow Cc: r-help@r-project.org Subject: Re: [R] How to do rotation for polygon? Hi everyone, I still couldn't get the diagram as I mentioned before. I try Grey and Milton suggestion but it confusing. I hope anyone helped me. Thanks in advance. Regards, Hema. On Thu, Sep 3, 2009 at 11:39 PM, Greg Snow greg.s...@imail.org wrote: The my.symbols and ms.polygon functions in the TeachingDemos package may help. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Hemavathi Ramulu Sent: Wednesday, September 02, 2009 11:05 PM To: r-help@r-project.org Subject: [R] How to do rotation for polygon? Hi everyone, I have coding for repeating pentagon as below: plot(0:11,type=n) for (i in 1:10 )polygon(rep(c(4,5,7,8,6)), i*c(.5,.3,.3,.5,.7), bor=2) which are increasing vertically. Now, I want to know how to rotate the pentagon, so that I will get pattern like flower. Basicly, repeating pentagon in circle. Thanks alot for helping me to solve this problem. -- Hemavathi [[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. -- Hemavathi Ramulu [[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. -- _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK http://newton.ex.ac.uk/research/emag __ [[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] Best R text editors?
On 09/11/2009 05:15 PM, Patrick Connolly wrote: ... | and in previous versions, you could always do M-x cua-mode for | the same effect. Talk about a well-hidden function mostly directed | at beginners ... Perhaps the thinking was that by the time they find it, they'll already have noticed that they can cut/copy and paste using only the mouse buttons and won't be bothered with such inefficient methods. Though this be madness, yet there is a method in't. :-) Well, okay, let's look at it from the viewpoint of learning theory. We expect that if someone has learned a skill, they will prefer to engage in other behaviors where they can successfully use that skill. Upon this easily understood foundation rest the fortunes of many. Thus two of those entities, let us call them A and M for the purposes of discussion, spend a great deal of time and effort attempting to differentiate their interfaces from each other so that having trained their users, those users will be reluctant to switch to the competitor. However, they must remain similar enough so that the switch from the competitor is not impossible. Such is the dispiriting triumph of form over substance in interface design. Both have yet to abandon such atavists as myself who prefer to type rather than fiddle with a pointing device, though they try hard to convert us. A somewhat smaller organization that I will label G seems to have decided that it can build a user base by sticking to the arcane typoglyphics of the VT-100 era and enticing the largely amoral digirati with moral suasion. Now that's madness. 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] Simple time series questions
This script worked for me. Be sure to put in your correct link. link - C:\\R_Home\\Charts Graphs Blog\\R_Chart_Doc\\text_data.csv testdata- read.table(link, head = T, sep = ,,na.strings = na) test_date = as.Date(testdata$Date,%d-%m-%y) plot(test_date, testdata$Model, type=l, log=y) points(test_date, testdata$BaseDataA, type = l, col = red) points(test_date, testdata$BaseDataB, type = l, col = blue) You add 2nd and 3rd series with points command Hope this helps. Kelly http://chartsgraphs.wordpress.com http://chartsgraphs.wordpress.com gug wrote: I'm sure this is a really simple problem, but I've spent hours digging and I keep running into roadblocks. I'm trying to get a simple chart with three time series. Similar to the attached example http://www.nabble.com/file/p25398419/Excel%2Bchart%2Bexample.pdf Excel+chart+example.pdf , something that was quite easy to do in Excel, except that I need a log y-axis: something that R can do and Excel can't. The data is in the attached CSV file http://www.nabble.com/file/p25398419/test%2Bchart%2Bdata.csv test+chart+data.csv . I can read it in OK, and create separate charts: testdata- read.table(C:\\Files\\test chart data.csv, head = T, sep = ,,na.strings = na) test_date = as.Date(testdata$Date,%d-%m-%y) test_data_model = testdata$Model test_date_baseA = testdata$BaseDataA test_date_baseB = testdata$BaseDataB plot(test_date, test_data_model,type='l',log=y) plot(test_date, test_data_baseA,type='l',log=y) plot(test_date, test_data_baseB,type='l',log=y) grid() (Clearly at this point, each chart over-writes the previous one.) Next I try to get them onto a single chart, sharing the same y-axis. I'm sure I haven't done this very elegantly, but here goes: frame_model = data.frame(a=test_date,b=test_data_model) frame_A = data.frame(a=test_date,b=test_data_baseA) frame_B = data.frame(a=test_date,b=test_data_baseB) ts_model = ts(frame_model$b) ts_a = ts(frame_A$b) ts_b = ts(frame_B$b) ts.plot(ts_model,ts_a,ts_b,col=c(blue,red,green),log=y) The problem is that I no longer have the date along the y-axis. How can I get that back? Finally, when I plot the separate time series, the grid() function geneates a grid where the vertical lines are not lined up with the year tick marks. I interpreted the topic help as saying that by default they would match the tick marks. How can I achieve that? Thanks for any suggestions, Guy Green http://chartsgraphs.wordperss.com http://chartsgraphs.wordperss.com -- View this message in context: http://www.nabble.com/Simple-time-series-questions-tp25398419p25398863.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] Best R text editors?
On 11-Sep-09 10:41:21, Jim Lemon wrote: On 09/11/2009 05:15 PM, Patrick Connolly wrote: ... | and in previous versions, you could always do M-x cua-mode for | the same effect. Talk about a well-hidden function mostly directed | at beginners ... Perhaps the thinking was that by the time they find it, they'll already have noticed that they can cut/copy and paste using only the mouse buttons and won't be bothered with such inefficient methods. Though this be madness, yet there is a method in't. :-) Well, okay, let's look at it from the viewpoint of learning theory. We expect that if someone has learned a skill, they will prefer to engage in other behaviors where they can successfully use that skill. Upon this easily understood foundation rest the fortunes of many. Thus two of those entities, let us call them A and M for the purposes of discussion, spend a great deal of time and effort attempting to differentiate their interfaces from each other so that having trained their users, those users will be reluctant to switch to the competitor. However, they must remain similar enough so that the switch from the competitor is not impossible. Such is the dispiriting triumph of form over substance in interface design. Both have yet to abandon such atavists as myself who prefer to type rather than fiddle with a pointing device, though they try hard to convert us. A somewhat smaller organization that I will label G seems to have decided that it can build a user base by sticking to the arcane typoglyphics of the VT-100 era and enticing the largely amoral digirati with moral suasion. Now that's madness. Jim Once again, I cannot resist citing the immortal quote (from Charles Curran, of the UK Unix Users Group): I can touch-type, but I can't touch-mouse Originally posted on Wed Nov 17 13:48:14 2004, in the context of an extended discussion (still relevant to the present thread): http://finzi.psych.upenn.edu/R/Rhelp02/archive/41560.html Best wishes to all, Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 11-Sep-09 Time: 11:53:09 -- 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] Best R text editors?
On 11/09/2009 6:53 AM, (Ted Harding) wrote: On 11-Sep-09 10:41:21, Jim Lemon wrote: On 09/11/2009 05:15 PM, Patrick Connolly wrote: ... | and in previous versions, you could always do M-x cua-mode for | the same effect. Talk about a well-hidden function mostly directed | at beginners ... Perhaps the thinking was that by the time they find it, they'll already have noticed that they can cut/copy and paste using only the mouse buttons and won't be bothered with such inefficient methods. Though this be madness, yet there is a method in't. :-) Well, okay, let's look at it from the viewpoint of learning theory. We expect that if someone has learned a skill, they will prefer to engage in other behaviors where they can successfully use that skill. Upon this easily understood foundation rest the fortunes of many. Thus two of those entities, let us call them A and M for the purposes of discussion, spend a great deal of time and effort attempting to differentiate their interfaces from each other so that having trained their users, those users will be reluctant to switch to the competitor. However, they must remain similar enough so that the switch from the competitor is not impossible. Such is the dispiriting triumph of form over substance in interface design. Both have yet to abandon such atavists as myself who prefer to type rather than fiddle with a pointing device, though they try hard to convert us. A somewhat smaller organization that I will label G seems to have decided that it can build a user base by sticking to the arcane typoglyphics of the VT-100 era and enticing the largely amoral digirati with moral suasion. Now that's madness. Jim Once again, I cannot resist citing the immortal quote (from Charles Curran, of the UK Unix Users Group): I can touch-type, but I can't touch-mouse That's a strange disability. It took me several months to learn to touch-type (and years later I'm still not very good at the top-row numbers or the special symbols on them), but I memorized the location of the two buttons on my mouse in no time at all. Duncan Murdoch Originally posted on Wed Nov 17 13:48:14 2004, in the context of an extended discussion (still relevant to the present thread): http://finzi.psych.upenn.edu/R/Rhelp02/archive/41560.html Best wishes to all, Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 11-Sep-09 Time: 11:53:09 -- 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. __ 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] Is there any month object like LETTERS ?
See ?Constants On Fri, Sep 11, 2009 at 3:13 AM, megh megh700...@yahoo.com wrote: There is an object LETTERS which displays all letters from a to z. Is there any similar object whicg displays the months as well in chronological order? like jan, feb,...,dec Thanks, -- View this message in context: http://www.nabble.com/Is-there-any-%22month%22-object-like-%22LETTERS%22---tp25396125p25396125.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] Color index in image function
On Thu, 2009-09-10 at 05:27 -0700, FMH wrote: Thank you for the scripts, but the label and the values in the x and y-axis suddently dissapear even the 'axis' function is used as stated in the command below. Could you help on this? axis(1, at = seq(100, 800, by = 100)) axis(2, at = seq(100, 600, by = 100)) How could i add a tittle on top of color index? Thank you Fir Try this Brazilan.Pallete - colorRampPalette(c(green,yellow, blue)) require(fields) image.plot(volcano, col = Brazilan.Pallete(50), legend.lab=Scale) contour(volcano, levels = seq(90, 200, by = 5), add = TRUE) -- Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil __ 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 do this?
Try this: y[cbind(seq(length(x)), x)] On Fri, Sep 11, 2009 at 5:17 AM, Luca Braglia brag...@poleis.eu wrote: Hello R-users I have a situation like this x=c(1,3,2) y=data.frame(a=1:3, b=4:6, c=7:9)*2 So we have t(t(x)) [,1] [1,]1 [2,]3 [3,]2 And y a b c 1 2 8 14 2 4 10 16 3 6 12 18 I would like to obtain a vector with number taken from the data.frame: x is needed as row index With c(1,3,2), in this case the ouput should be 2 16 12 I've tried a little bit with apply, but unsuccessfully. Thank you __ 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] Merge data frames but prefer values in one
Maybe: do.call(rbind, lapply(with(xy - rbind(x, y), split(xy, list(a, b), drop = TRUE)), tail, 1)) On Fri, Sep 11, 2009 at 3:45 AM, jo jo.li...@gmail.com wrote: Thanks for the post-processing ideas. But is there any way to do that in one step? On Thu, Sep 10, 2009 at 7:20 PM, Henrique Dallazuanna www...@gmail.com wrote: Try this: xy - merge(x, y, by = c(a,b),all = TRUE) xy$c - ifelse(rowSums(!is.na(.x - xy[, c('c.x', 'c.y')])) 1, .x[,1], rowSums(.x, na.rm = TRUE)) xy On Thu, Sep 10, 2009 at 12:21 PM, JiHO jo.li...@gmail.com wrote: JiHO --- http://maururu.net -- 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.
[R] Graph visualization
Hello, I am working with graph and adjacency matrix, the package 'graph' seems to be appropriate for this. An example in the package mat - rbind(c(0, 0, 1, 1), + c(0, 0, 1, 1), + c(1, 1, 0, 1), + c(1, 1, 1, 0)) rownames(mat) - colnames(mat) - letters[1:4] graph1 - new(graphAM, adjMat=mat) graph1 A graphAM graph with undirected edges Number of Nodes = 4 Number of Edges = 5 how can I plot the object graph1? Thanks in advance Arber [[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] Plot area reduction
you can use the 'mar' parameter of 'par' to setup the margins of the graph and then use the height/width option when opening the graphic device to control the plotting area. On Thu, Sep 10, 2009 at 6:10 AM, rajesh j akshay.raj...@gmail.com wrote: Hi, I need my plot to occupy a thin strip-like area but the plot area in R is a square so when I save it and reduce its height to a strip in my document the font in the graph looks flattened. Is there someway i can do this in R itself?..so that my plot is a strip but the font looks normal -- Rajesh.J [[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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ 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] Searching 1st number within a ch. string
Hi all, Is there any process to conduct a search for a particular digit or letter in a ch. string? For example I want to make a search where 1st numeric figure appears in the string asd123. Here the answer should be 4 Thanks, -- View this message in context: http://www.nabble.com/Searching-1st-number-within-a-ch.-string-tp25400580p25400580.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] Searching 1st number within a ch. string
Try this: head(unlist(gregexpr([0-9], asd123)), 1) On Fri, Sep 11, 2009 at 10:02 AM, RON70 ron_michae...@yahoo.com wrote: Hi all, Is there any process to conduct a search for a particular digit or letter in a ch. string? For example I want to make a search where 1st numeric figure appears in the string asd123. Here the answer should be 4 Thanks, -- View this message in context: http://www.nabble.com/Searching-1st-number-within-a-ch.-string-tp25400580p25400580.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. -- 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] Simple time series questions
Try this script. I converted test_date to numeric decimal year link - C:\\R_Home\\Charts Graphs Blog\\R_Chart_Doc\\text_data.csv testdata- read.table(link, head = T, sep = ,,na.strings = na) test_date = as.Date(testdata$Date,%d-%m-%y) # Convert dates to decimal year my_yr - as.numeric(format(test_date,format=%Y)) my_mo - as.numeric(format(test_date, format=%m)) dec_yr - my_yr + (my_mo+0.5)/12 plot(dec_yr, testdata$Model, type=l, log=y, xaxs=i, yaxs=i, axes=T, xlim = c(2003, 2008)) points(dec_yr, testdata$BaseDataA, type = l, col = red) points(dec_yr, testdata$BaseDataB, type = l, col = blue) grid( col=grey,lty=1) box() Kelly http://chartsgraphs.wordpress.com http://chartsgraphs.wordpress.com gug wrote: Thanks - that works great. Do you have any suggestions about the grid() problem - i.e. that the vertical gridlines do not line up with the x-axis tickmarks (which are years)? I can't see on what basis the vertical gridlines are being positioned, but it doesn't look good that they are not lined up with anything. Thanks, Guy DKOD wrote: This script worked for me. Be sure to put in your correct link. link - C:\\R_Home\\Charts Graphs Blog\\R_Chart_Doc\\text_data.csv testdata- read.table(link, head = T, sep = ,,na.strings = na) test_date = as.Date(testdata$Date,%d-%m-%y) plot(test_date, testdata$Model, type=l, log=y) points(test_date, testdata$BaseDataA, type = l, col = red) points(test_date, testdata$BaseDataB, type = l, col = blue) You add 2nd and 3rd series with points command Hope this helps. Kelly http://chartsgraphs.wordpress.com http://chartsgraphs.wordpress.com -- View this message in context: http://www.nabble.com/Simple-time-series-questions-tp25398419p25400652.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] What determines the unit of POSIXct differences?
'-' calls 'difftime' which, if you don't specify the units, makes the following assumptions in the code: difftime function (time1, time2, tz = , units = c(auto, secs, mins, hours, days, weeks)) { time1 - as.POSIXct(time1, tz = tz) time2 - as.POSIXct(time2, tz = tz) z - unclass(time1) - unclass(time2) units - match.arg(units) if (units == auto) { if (all(is.na(z))) units - secs else { zz - min(abs(z), na.rm = TRUE) if (is.na(zz) || zz 60) units - secs else if (zz 3600) units - mins else if (zz 86400) units - hours else units - days } } switch(units, secs = structure(z, units = secs, class = difftime), mins = structure(z/60, units = mins, class = difftime), hours = structure(z/3600, units = hours, class = difftime), days = structure(z/86400, units = days, class = difftime), weeks = structure(z/(7 * 86400), units = weeks, class = difftime)) } You can use difftime explicitly so you can control the units. c(as.POSIXct('2009-09-01'), as.POSIXct('2009-10-11')) - as.POSIXct('2009-08-31') Time differences in days [1] 1 41 difftime(c(as.POSIXct('2009-09-01'), as.POSIXct('2009-10-11')), as.POSIXct('2009-08-31'), units='sec') Time differences in secs [1] 86400 3542400 On Fri, Sep 11, 2009 at 7:50 AM, Heinz Tuechler tuech...@gmx.at wrote: Dear All, what determines if a difference between POSIXct objects gets expressed in days or seconds? In the following example, it's sometimes seconds, sometimes days. as.POSIXct('2009-09-01') - as.POSIXct(NA) Time difference of NA secs c(as.POSIXct('2009-09-01'), as.POSIXct(NA)) - c(as.POSIXct('2009-09-01'), as.POSIXct('2009-08-31')) Time differences in secs [1] 0 NA c(as.POSIXct('2009-09-01'), as.POSIXct(NA)) - as.POSIXct('2009-08-31') Time differences in days [1] 1 NA Thanks, Heinz __ 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ 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] Searching 1st number within a ch. string
Try this: regexpr([0-9], asd123) [1] 4 attr(,match.length) [1] 1 On Fri, Sep 11, 2009 at 9:02 AM, RON70 ron_michae...@yahoo.com wrote: Hi all, Is there any process to conduct a search for a particular digit or letter in a ch. string? For example I want to make a search where 1st numeric figure appears in the string asd123. Here the answer should be 4 Thanks, -- View this message in context: http://www.nabble.com/Searching-1st-number-within-a-ch.-string-tp25400580p25400580.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] What determines the unit of POSIXct differences?
Jim - Thank you very much for this explanation and the hint to use difftime. Heinz At 15:09 11.09.2009, jim holtman wrote: '-' calls 'difftime' which, if you don't specify the units, makes the following assumptions in the code: difftime function (time1, time2, tz = , units = c(auto, secs, mins, hours, days, weeks)) { time1 - as.POSIXct(time1, tz = tz) time2 - as.POSIXct(time2, tz = tz) z - unclass(time1) - unclass(time2) units - match.arg(units) if (units == auto) { if (all(is.na(z))) units - secs else { zz - min(abs(z), na.rm = TRUE) if (is.na(zz) || zz 60) units - secs else if (zz 3600) units - mins else if (zz 86400) units - hours else units - days } } switch(units, secs = structure(z, units = secs, class = difftime), mins = structure(z/60, units = mins, class = difftime), hours = structure(z/3600, units = hours, class = difftime), days = structure(z/86400, units = days, class = difftime), weeks = structure(z/(7 * 86400), units = weeks, class = difftime)) } You can use difftime explicitly so you can control the units. c(as.POSIXct('2009-09-01'), as.POSIXct('2009-10-11')) - as.POSIXct('2009-08-31') Time differences in days [1] 1 41 difftime(c(as.POSIXct('2009-09-01'), as.POSIXct('2009-10-11')), as.POSIXct('2009-08-31'), units='sec') Time differences in secs [1] 86400 3542400 On Fri, Sep 11, 2009 at 7:50 AM, Heinz Tuechler tuech...@gmx.at wrote: Dear All, what determines if a difference between POSIXct objects gets expressed in days or seconds? In the following example, it's sometimes seconds, sometimes days. as.POSIXct('2009-09-01') - as.POSIXct(NA) Time difference of NA secs c(as.POSIXct('2009-09-01'), as.POSIXct(NA)) - c(as.POSIXct('2009-09-01'), as.POSIXct('2009-08-31')) Time differences in secs [1] 0 NA c(as.POSIXct('2009-09-01'), as.POSIXct(NA)) - as.POSIXct('2009-08-31') Time differences in days [1] 1 NA Thanks, Heinz __ 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ 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 wo read stability VAR plot?
I have made program code for Vector Auto Regressive in terms of completing my undergraduate program using R. I have an important question related to my project. If I have: data(Canada) var.2c - VAR(Canada, p = 2, type = const) var.2c.stabil - stability(var.2c, type = OLS-CUSUM) I want to get the value of plot(var.2c.stabil). Can you help me what should I do or write so the result can occur? It means if I have source code: data(Canada) x=acf(Canada) I will get the value of acf if I write x in R. Thanks in advance _ ry-edit.aspx [[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] Sorting
I have following object : date2 [,1] [,2] [1,] apr 1992 [2,] aug 1992 [3,] dec 1992 [4,] feb 1992 [5,] jan 1992 [6,] jul 1992 [7,] jun 1992 [8,] mar 1992 [9,] may 1992 [10,] nov 1992 [11,] oct 1992 [12,] sep 1992 [13,] apr 1993 [14,] aug 1993 [15,] dec 1993 [16,] feb 1993 [17,] jan 1993 [18,] jul 1993 [19,] jun 1993 [20,] mar 1993 [21,] may 1993 [22,] nov 1993 [23,] oct 1993 [24,] sep 1993 [25,] apr 1994 [26,] aug 1994 [27,] dec 1994 [28,] feb 1994 [29,] jan 1994 [30,] jul 1994 Now I want to sort the elements like below, and want to get the index numbers of date2 under following sorting scheme. jan 1992 feb 1992 mar 1992 dec 1992 jan 1993 feb 1993 mar 1993 dec 1993 jan 1994 feb 1994 mar 1994 dec 1994 Can anyone help me please? -- View this message in context: http://www.nabble.com/Sorting-tp25401249p25401249.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] Sorting
Try this: data2[order(data2[,2], match(data2[,1], tolower(month.abb))),] On Fri, Sep 11, 2009 at 10:46 AM, megh megh700...@yahoo.com wrote: I have following object : date2 [,1] [,2] [1,] apr 1992 [2,] aug 1992 [3,] dec 1992 [4,] feb 1992 [5,] jan 1992 [6,] jul 1992 [7,] jun 1992 [8,] mar 1992 [9,] may 1992 [10,] nov 1992 [11,] oct 1992 [12,] sep 1992 [13,] apr 1993 [14,] aug 1993 [15,] dec 1993 [16,] feb 1993 [17,] jan 1993 [18,] jul 1993 [19,] jun 1993 [20,] mar 1993 [21,] may 1993 [22,] nov 1993 [23,] oct 1993 [24,] sep 1993 [25,] apr 1994 [26,] aug 1994 [27,] dec 1994 [28,] feb 1994 [29,] jan 1994 [30,] jul 1994 Now I want to sort the elements like below, and want to get the index numbers of date2 under following sorting scheme. jan 1992 feb 1992 mar 1992 dec 1992 jan 1993 feb 1993 mar 1993 dec 1993 jan 1994 feb 1994 mar 1994 dec 1994 Can anyone help me please? -- View this message in context: http://www.nabble.com/Sorting-tp25401249p25401249.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. -- 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.
[R] Modify functions in base packages (needed for completion for proto objects)
Hello everyone, I am trying to implement completion for proto objects. Proto extends environment in a hierarchical way. Thus completion should list all the names in all it's parent environments. For normal classes defining names.class would do the job, but completion for environment is hard coded in utils:::specialCompletions by means of base::ls(). As result defining names.proto does not work. I tried to make ls generic and to do something like: environment(ls.default) - asNamespace('utils') environment(ls) - asNamespace('utils') environment(ls.proto) - asNamespace('utils') That does not work either. Is there a way to make utils:::specialCompletions use my ls instead of base::ls?? I know Deepayan Sarkar is working now on improving the completion system (potentially by introducing completion generic). That would definitely solve the problem. But for now, does a quick fix exist? Thanks a lot, Vitalie __ 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] Sorting
You might want to add a date column it you are planning to operate on the data with dates: a # your data X..1. X..2. 1apr 1992 2aug 1992 3dec 1992 4feb 1992 5jan 1992 6jul 1992 7jun 1992 8mar 1992 9may 1992 10 nov 1992 11 oct 1992 12 sep 1992 13 apr 1993 14 aug 1993 15 dec 1993 16 feb 1993 17 jan 1993 18 jul 1993 19 jun 1993 20 mar 1993 21 may 1993 22 nov 1993 23 oct 1993 24 sep 1993 25 apr 1994 26 aug 1994 27 dec 1994 28 feb 1994 29 jan 1994 30 jul 1994 # convert to date a$date - as.Date(paste('1', a[[1]], a[[2]]), %d %b %Y) a X..1. X..2. date 1apr 1992 1992-04-01 2aug 1992 1992-08-01 3dec 1992 1992-12-01 4feb 1992 1992-02-01 5jan 1992 1992-01-01 6jul 1992 1992-07-01 7jun 1992 1992-06-01 8mar 1992 1992-03-01 9may 1992 1992-05-01 10 nov 1992 1992-11-01 11 oct 1992 1992-10-01 12 sep 1992 1992-09-01 13 apr 1993 1993-04-01 14 aug 1993 1993-08-01 15 dec 1993 1993-12-01 16 feb 1993 1993-02-01 17 jan 1993 1993-01-01 18 jul 1993 1993-07-01 19 jun 1993 1993-06-01 20 mar 1993 1993-03-01 21 may 1993 1993-05-01 22 nov 1993 1993-11-01 23 oct 1993 1993-10-01 24 sep 1993 1993-09-01 25 apr 1994 1994-04-01 26 aug 1994 1994-08-01 27 dec 1994 1994-12-01 28 feb 1994 1994-02-01 29 jan 1994 1994-01-01 30 jul 1994 1994-07-01 a[order(a$date),] X..1. X..2. date 5jan 1992 1992-01-01 4feb 1992 1992-02-01 8mar 1992 1992-03-01 1apr 1992 1992-04-01 9may 1992 1992-05-01 7jun 1992 1992-06-01 6jul 1992 1992-07-01 2aug 1992 1992-08-01 12 sep 1992 1992-09-01 11 oct 1992 1992-10-01 10 nov 1992 1992-11-01 3dec 1992 1992-12-01 17 jan 1993 1993-01-01 16 feb 1993 1993-02-01 20 mar 1993 1993-03-01 13 apr 1993 1993-04-01 21 may 1993 1993-05-01 19 jun 1993 1993-06-01 18 jul 1993 1993-07-01 14 aug 1993 1993-08-01 24 sep 1993 1993-09-01 23 oct 1993 1993-10-01 22 nov 1993 1993-11-01 15 dec 1993 1993-12-01 29 jan 1994 1994-01-01 28 feb 1994 1994-02-01 25 apr 1994 1994-04-01 30 jul 1994 1994-07-01 26 aug 1994 1994-08-01 27 dec 1994 1994-12-01 On Fri, Sep 11, 2009 at 9:46 AM, megh megh700...@yahoo.com wrote: I have following object : date2 [,1] [,2] [1,] apr 1992 [2,] aug 1992 [3,] dec 1992 [4,] feb 1992 [5,] jan 1992 [6,] jul 1992 [7,] jun 1992 [8,] mar 1992 [9,] may 1992 [10,] nov 1992 [11,] oct 1992 [12,] sep 1992 [13,] apr 1993 [14,] aug 1993 [15,] dec 1993 [16,] feb 1993 [17,] jan 1993 [18,] jul 1993 [19,] jun 1993 [20,] mar 1993 [21,] may 1993 [22,] nov 1993 [23,] oct 1993 [24,] sep 1993 [25,] apr 1994 [26,] aug 1994 [27,] dec 1994 [28,] feb 1994 [29,] jan 1994 [30,] jul 1994 Now I want to sort the elements like below, and want to get the index numbers of date2 under following sorting scheme. jan 1992 feb 1992 mar 1992 dec 1992 jan 1993 feb 1993 mar 1993 dec 1993 jan 1994 feb 1994 mar 1994 dec 1994 Can anyone help me please? -- View this message in context: http://www.nabble.com/Sorting-tp25401249p25401249.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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ 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] Simple time series questions
Here it is using zoo and classic graphics. 1. Just paste this into your R session: library(zoo) URL - http://www.nabble.com/file/p25398419/test%2Bchart%2Bdata.csv; z - read.zoo(URL, header = TRUE, format = %d-%m-%y, sep = ,) cols - c(green, red, blue) plot(z, screen = 1, col = cols) # 2. Or try this fancier version using the same code # replacing the plot statement above with all this plot(z, screen = 1, col = cols, xaxt = n) legend(topleft, c(A, B, C), col = cols, lty = 1) # fancy X axis (code is from ?plot.zoo page) ym - as.yearmon(time(z)) mon - as.numeric(format(ym, %m)) yy - format(ym, %y) mm - substring(month.abb[mon], 1, 1) Axis(side = 1, at = time(z)[mon == 1], labels = yy[mon == 1], cex.axis = 0.7) Axis(side = 1, at = time(z)[mon 1], labels = mm[mon 1], cex.axis = 0.5, tcl = -0.3) abline(v = time(z)[mon == 1], col = grey(0.9)) abline(h = axTicks(2), col = grey(0.9)) On Fri, Sep 11, 2009 at 9:07 AM, DKOD ko...@processtrends.com wrote: Try this script. I converted test_date to numeric decimal year link - C:\\R_Home\\Charts Graphs Blog\\R_Chart_Doc\\text_data.csv testdata- read.table(link, head = T, sep = ,,na.strings = na) test_date = as.Date(testdata$Date,%d-%m-%y) # Convert dates to decimal year my_yr - as.numeric(format(test_date,format=%Y)) my_mo - as.numeric(format(test_date, format=%m)) dec_yr - my_yr + (my_mo+0.5)/12 plot(dec_yr, testdata$Model, type=l, log=y, xaxs=i, yaxs=i, axes=T, xlim = c(2003, 2008)) points(dec_yr, testdata$BaseDataA, type = l, col = red) points(dec_yr, testdata$BaseDataB, type = l, col = blue) grid( col=grey,lty=1) box() Kelly http://chartsgraphs.wordpress.com http://chartsgraphs.wordpress.com gug wrote: Thanks - that works great. Do you have any suggestions about the grid() problem - i.e. that the vertical gridlines do not line up with the x-axis tickmarks (which are years)? I can't see on what basis the vertical gridlines are being positioned, but it doesn't look good that they are not lined up with anything. Thanks, Guy DKOD wrote: This script worked for me. Be sure to put in your correct link. link - C:\\R_Home\\Charts Graphs Blog\\R_Chart_Doc\\text_data.csv testdata- read.table(link, head = T, sep = ,,na.strings = na) test_date = as.Date(testdata$Date,%d-%m-%y) plot(test_date, testdata$Model, type=l, log=y) points(test_date, testdata$BaseDataA, type = l, col = red) points(test_date, testdata$BaseDataB, type = l, col = blue) You add 2nd and 3rd series with points command Hope this helps. Kelly http://chartsgraphs.wordpress.com http://chartsgraphs.wordpress.com -- View this message in context: http://www.nabble.com/Simple-time-series-questions-tp25398419p25400652.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] Modify functions in base packages (needed for completion for proto objects)
See ?assignInNamespace On Fri, Sep 11, 2009 at 10:02 AM, Vitalie S. vitosm...@rambler.ru wrote: Hello everyone, I am trying to implement completion for proto objects. Proto extends environment in a hierarchical way. Thus completion should list all the names in all it's parent environments. For normal classes defining names.class would do the job, but completion for environment is hard coded in utils:::specialCompletions by means of base::ls(). As result defining names.proto does not work. I tried to make ls generic and to do something like: environment(ls.default) - asNamespace('utils') environment(ls) - asNamespace('utils') environment(ls.proto) - asNamespace('utils') That does not work either. Is there a way to make utils:::specialCompletions use my ls instead of base::ls?? I know Deepayan Sarkar is working now on improving the completion system (potentially by introducing completion generic). That would definitely solve the problem. But for now, does a quick fix exist? Thanks a lot, Vitalie __ 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] Graph visualization
Hi, On Sep 11, 2009, at 8:22 AM, Arber Ngjela wrote: Hello, I am working with graph and adjacency matrix, the package 'graph' seems to be appropriate for this. An example in the package mat - rbind(c(0, 0, 1, 1), + c(0, 0, 1, 1), + c(1, 1, 0, 1), + c(1, 1, 1, 0)) rownames(mat) - colnames(mat) - letters[1:4] graph1 - new(graphAM, adjMat=mat) graph1 A graphAM graph with undirected edges Number of Nodes = 4 Number of Edges = 5 how can I plot the object graph1? I haven't used the graph library, but I do use the igraph library a bit and it's quite good (highly recommended). There is a tkplot function implemented which not only plots your graph, but allows you to pull/push nodes around on the screen, select, etc (you'll need the tcl/tk stuff installed). Like so: library(igraph) mat - rbind(c(0, 0, 1, 1), c(0, 0, 1, 1), c(1, 1, 0, 1), c(1, 1, 1, 0)) dimnames(mat) - list(LETTERS[1:4], LETTERS[1:4]) graph - graph.adjacency(mat) tkplot(graph) (you can specify different layouts, too). HTH, -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ 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] Best R text editors?
On Fri, 11 Sep 2009, Duncan Murdoch wrote: On 11/09/2009 6:53 AM, (Ted Harding) wrote: On 11-Sep-09 10:41:21, Jim Lemon wrote: On 09/11/2009 05:15 PM, Patrick Connolly wrote: ... |and in previous versions, you could always do M-x cua-mode for |the same effect. Talk about a well-hidden function mostly |directed |at beginners ... Perhaps the thinking was that by the time they find it, they'll already have noticed that they can cut/copy and paste using only the mouse buttons and won't be bothered with such inefficient methods. Though this be madness, yet there is a method in't. :-) Well, okay, let's look at it from the viewpoint of learning theory. We expect that if someone has learned a skill, they will prefer to engage in other behaviors where they can successfully use that skill. Upon this easily understood foundation rest the fortunes of many. Thus two of those entities, let us call them A and M for the purposes of discussion, spend a great deal of time and effort attempting to differentiate their interfaces from each other so that having trained their users, those users will be reluctant to switch to the competitor. However, they must remain similar enough so that the switch from the competitor is not impossible. Such is the dispiriting triumph of form over substance in interface design. Both have yet to abandon such atavists as myself who prefer to type rather than fiddle with a pointing device, though they try hard to convert us. A somewhat smaller organization that I will label G seems to have decided that it can build a user base by sticking to the arcane typoglyphics of the VT-100 era and enticing the largely amoral digirati with moral suasion. Now that's madness. Jim Once again, I cannot resist citing the immortal quote (from Charles Curran, of the UK Unix Users Group): I can touch-type, but I can't touch-mouse That's a strange disability. It took me several months to learn to touch-type (and years later I'm still not very good at the top-row numbers or the special symbols on them), but I memorized the location of the two buttons on my mouse in no time at all. Duncan Murdoch Ahh, just Ted's point--mice have three buttons (unless they are connected to Apples). Clint Originally posted on Wed Nov 17 13:48:14 2004, in the context of an extended discussion (still relevant to the present thread): http://finzi.psych.upenn.edu/R/Rhelp02/archive/41560.html Best wishes to all, Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 11-Sep-09 Time: 11:53:09 -- 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. __ 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. -- Clint BowmanINTERNET: cl...@ecy.wa.gov Air Quality Modeler INTERNET: cl...@math.utah.edu Department of Ecology VOICE: (360) 407-6815 PO Box 47600FAX:(360) 407-7534 Olympia, WA 98504-7600 __ 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] voice recognition software
Hello all. Has anyone out there had experience using R with voice recognition software? I got this query from a student with nerve damage in her hand who wants to program in R. Thanks, Chris __ 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] Mapping factors to a new set of factors
Thanks Jorge, That is what I was looking for. Cheers, James From: Jorge Ivan Velez [mailto:jorgeivanve...@gmail.com] Sent: 08 September 2009 18:41 To: Arnold, James Cc: r-help@r-project.org Subject: Re: [R] Mapping factors to a new set of factors Hi James, Take a look at the recode function in the car package. It might be useful in this case. HTH, Jorge On Tue, Sep 8, 2009 at 12:01 PM, james.arn...@sssc.uk.com wrote: Hello, I am trying to map a factor variable within a data frame to a new variable whose entries are derived from the content of the original variable and there are fewer factors in the new variable. That is, I'm trying to set up a surjection. After first thinking that this would be a common operation and would have a quite simple interface, I can not seem to find one, nor any similar posts on this topic (please correct me if there is something). Therefore, I have written a function to perform this mapping. However, the function I have written doesn't seem to work with vectors greater than length 1, and as such is useless. Is there any way to ensure the function would work appropriately for each element of the vector input? mapLN - function(x) { Reg - levels(df$Var1) if (x==Reg[1] | x==Reg[2] | x==Reg[13] | x==Reg[17] | x==Reg[20] | x==Reg[23] | x==Reg[27]) {North} else if (x==Reg[3] | x==Reg[5] | x==Reg[7] | x==Reg[14] | x==Reg[15] | x==Reg[24] | x==Reg[30]) {East} else if (x==Reg[4] | x==Reg[6] | x==Reg[8] | x==Reg[9] | x==Reg[11] | x==Reg[16] | x==Reg[18] | x==Reg[21] | x==Reg[22] | x==Reg[25] | x==Reg[28] | x==Reg[29] | x==Reg[31]) {West} else if (x==Reg[10] | x==Reg[12] | x==Reg[19] | x==Reg[26] | x==Reg[32]) {South} else stop(Not in original set) } Many thanks, James This E-Mail is confidential and intended solely for the use of the individual to whom it is addressed. If you are not the addressee, any disclosure, reproduction, copying, distribution or other dissemination or use of this communication is strictly prohibited. If you have received this transmission in error please notify the sender immediately by replying to this e-mail, or telephone 01382 207 222, and then delete this e-mail. All outgoing messages are checked for viruses however no guarantee is given that this e-mail message, and any attachments, are free from viruses. You are strongly recommend to check for viruses using your own virus scanner. Neither SCRC or SSSC will accept responsibility for any damage caused as a result of virus infection. __ 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. This E-Mail is confidential and intended solely for the use of the individual to whom it is addressed. If you are not the addressee, any disclosure, reproduction, copying, distribution or other dissemination or use of this communication is strictly prohibited. If you have received this transmission in error please notify the sender immediately by replying to this e-mail, or telephone 01382 207 222, and then delete this e-mail. All outgoing messages are checked for viruses however no guarantee is given that this e-mail message, and any attachments, are free from viruses. You are strongly recommend to check for viruses using your own virus scanner. Neither SCRC or SSSC will accept responsibility for any damage caused as a result of virus infection. __ 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] Mantel test least square line
Thank you it is what I was looking for. -- View this message in context: http://www.nabble.com/Mantel-test-least-square-line-tp25235402p25401329.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] Reading gzip data from a non zero file offset
Dear R users, I have a file that contains a text header followed by a gzipped data chunk. I thought I would be able to read this by doing something like this. con-file('myfile','rb') header-readLines(con,10) gzf-gzcon(con) data-readBin(gzf,int,n=1e7) But what I find is that gzcon resets the original connection back to the beginning of the file rather than reading from its current location. Would anyone have any suggestions for how to handle this in R? Right now I am using system to call tail to copy the gzipped data into a temporary file, but that isn't portable. Many thanks for your help, Greg. -- Gregory Jefferis, PhD Division of Neurobiology MRC Laboratory of Molecular Biology, Hills Road, Cambridge, CB2 0QH, UK. http://www2.mrc-lmb.cam.ac.uk/NB/jefferis_g http://www.neuroscience.cam.ac.uk/directory/profile.php?gsxej2 http://flybrain.stanford.edu __ 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] Best R text editors?
On 11-Sep-09 14:16:44, Clint Bowman wrote: On Fri, 11 Sep 2009, Duncan Murdoch wrote: On 11/09/2009 6:53 AM, (Ted Harding) wrote: On 11-Sep-09 10:41:21, Jim Lemon wrote: On 09/11/2009 05:15 PM, Patrick Connolly wrote: ... |and in previous versions, you could always do M-x cua-mode |for |the same effect. Talk about a well-hidden function mostly |directed |at beginners ... Perhaps the thinking was that by the time they find it, they'll already have noticed that they can cut/copy and paste using only the mouse buttons and won't be bothered with such inefficient methods. Though this be madness, yet there is a method in't. :-) Well, okay, let's look at it from the viewpoint of learning theory. We expect that if someone has learned a skill, they will prefer to engage in other behaviors where they can successfully use that skill. Upon this easily understood foundation rest the fortunes of many. Thus two of those entities, let us call them A and M for the purposes of discussion, spend a great deal of time and effort attempting to differentiate their interfaces from each other so that having trained their users, those users will be reluctant to switch to the competitor. However, they must remain similar enough so that the switch from the competitor is not impossible. Such is the dispiriting triumph of form over substance in interface design. Both have yet to abandon such atavists as myself who prefer to type rather than fiddle with a pointing device, though they try hard to convert us. A somewhat smaller organization that I will label G seems to have decided that it can build a user base by sticking to the arcane typoglyphics of the VT-100 era and enticing the largely amoral digirati with moral suasion. Now that's madness. Jim Once again, I cannot resist citing the immortal quote (from Charles Curran, of the UK Unix Users Group): I can touch-type, but I can't touch-mouse That's a strange disability. It took me several months to learn to touch-type (and years later I'm still not very good at the top-row numbers or the special symbols on them), but I memorized the location of the two buttons on my mouse in no time at all. Duncan Murdoch Ahh, just Ted's point--mice have three buttons (unless they are connected to Apples). Clint Well, not really!! My point (and certainly Charles Curran's point) is that in touch-typing you know by proprioception and neuromuscular coordination where your fingers are relative to the keys on the keyboard, and what key you will press next, without looking; and you can accurately press several keys in rapid succession -- just as a pianist can play an arpeggio without looking. But touch-mousing isn't just knowing where the mouse itself is, nor the buttons. It would involve knowing from the sensations of moving the mouse where the mouse-pointer was on the screen, without looking, and also what graphic element (icon, on-screen button, tab in a drop-down menu) the mouse was over, also without looking. You can type accurately and rapidly withnout looking at the keyboard. You can't use a mouse with closely and accurately observing where the mouse-pointer is in the GUI. You can touch type. You can't touch-mouse. (Unless you have one of those accessibility add-ons for the visually impaired, where a SatNav voice tells you what the mouse is over, and what is written in the tab from the drop-down menu). Also, the ocasionnal misstake in typing is usually fairly harmless. Mistakes in mousing can be catastrophic. However, when one is typing program code then of course one needs to scrutinise it carefully. Even then, a typo usually results in an error message, rarely in a disaster. A mouso, however, will (almost by definition) result in the execution of a correctly coded procedure. Tough luck if it's the wrong one. Ted. Originally posted on Wed Nov 17 13:48:14 2004, in the context of an extended discussion (still relevant to the present thread): http://finzi.psych.upenn.edu/R/Rhelp02/archive/41560.html Best wishes to all, Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 11-Sep-09 Time: 11:53:09 -- 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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide
[R] format (?) problems with data imported from postgres
Good day, I read some data from a PostgreSQL database by a following script: library(Rdbi) library(RdbiPgSQL) # conn becomes an object which contains the DB connection: conn - dbConnect(PgSQL(), host=localhost, dbname=BVS, user=postgres, password = ***) query_duj_kal - dbSendQuery(conn, select zdroj as well, cas as date, fe2, fe3, mn, nh4, no2, no3, o2, teplota as temperature from analystats where zdroj like 'Dunaj Kalinkovo') watchem_duj_kal - dbGetResult(query_duj_kal) My intention with the data is to create a time series by a following script: date - (watchem_duj_kal$date) NO3 - (watchem_duj_kal$no3) NH4 - (watchem_duj_kal$nh4) maxy-max(NO3,NH4) miny-min(NO3[NO30],NH4[NH40]) date_p - as.POSIXct(date, CET) par(mfrow=c(2,1), ylog = TRUE, yaxp = c(0.01, 100, 3)) plot(date_p, NO3,log = y, type = l, col = darkred, main = NVZ-1, xlab = time, ylab = NO3- ) lines(date_p, NH4, col = darkblue, lty = dotted) plot(date_p, NH4, log = y, type = l, col = darkblue, main = NVZ-1, xlab = time, ylab = NH4+ ) The first problems comes with the definition maxy and miny (following a previous advice od Christian Poersching through this mailing list) what worked pretty well with data imported from a csv file by a read.table() function, but in this case I got NA output The next problem comes with the unambiguous format od the date field, which is in the database defined as -MM-DD, but in the resulting watchem_duj_kal dataset is strangely converted to DD-MM-, what is unambiguous for the as.POSIXct() function expecting -MM-DD. A function converting the format of the date should help, but I could not find untill now. I appreciate every advice/suggestion/help. Best regards Tomas __ 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] RPostgreSQL package and libpq.dll file
Dear all, I'd like to use the package RPostgreSQL. I'm using R version 2.8.1 and I've download the last version RPostgreSQL. When I load the package, I get something like the file LIBPQ.DLL is missing. Do you have any idea about what I'm suppose to do ? Thanks everyone. _ [[elided Hotmail 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] Mapping factors to a new set of factors
Thanks a lot Phil, Recode is exactly what I was looking for. I managed to get my old function working using sapply, but the performance was horrendously slow! One other thing was that the lvls vector can only seem to be set within the global scope of R, and local variables within a function do not seem to be able to be seen within the scope of a function that sets that variable and calls recode. Thanks, James -Original Message- From: Phil Spector [mailto:spec...@stat.berkeley.edu] Sent: 08 September 2009 22:25 To: Arnold, James Subject: Re: [R] Mapping factors to a new set of factors James - If you need to do something like this, I strongly recommend the recode function of the car package. You can use it like this: library(car) recode(x,'lvls[c(1,2,13,17,20,23,27)]=North; lvls[c(3,5,7,14,15,24,30)] =East; lvls[c(4,6,8,9,11,16,18,21,22,25,28,29,31)]=West; lvls[c(10,12,19,26,32)]=South; else=Not In Original Set') Including the as.factor=FALSE argument to recode will return a character vector -- by default it returns a factor. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Tue, 8 Sep 2009, james.arn...@sssc.uk.com wrote: Hello, I am trying to map a factor variable within a data frame to a new variable whose entries are derived from the content of the original variable and there are fewer factors in the new variable. That is, I'm trying to set up a surjection. After first thinking that this would be a common operation and would have a quite simple interface, I can not seem to find one, nor any similar posts on this topic (please correct me if there is something). Therefore, I have written a function to perform this mapping. However, the function I have written doesn't seem to work with vectors greater than length 1, and as such is useless. Is there any way to ensure the function would work appropriately for each element of the vector input? mapLN - function(x) { Reg - levels(df$Var1) if (x==Reg[1] | x==Reg[2] | x==Reg[13] | x==Reg[17] | x==Reg[20] | x==Reg[23] | x==Reg[27]) {North} else if (x==Reg[3] | x==Reg[5] | x==Reg[7] | x==Reg[14] | x==Reg[15] | x==Reg[24] | x==Reg[30]) {East} else if (x==Reg[4] | x==Reg[6] | x==Reg[8] | x==Reg[9] | x==Reg[11] | x==Reg[16] | x==Reg[18] | x==Reg[21] | x==Reg[22] | x==Reg[25] | x==Reg[28] | x==Reg[29] | x==Reg[31]) {West} else if (x==Reg[10] | x==Reg[12] | x==Reg[19] | x==Reg[26] | x==Reg[32]) {South} else stop(Not in original set) } Many thanks, James This E-Mail is confidential and intended solely for the use of the individual to whom it is addressed.? If you are not the addressee, any disclosure, reproduction, copying, distribution or other dissemination or use of this communication is strictly prohibited.? If you have received this transmission in error please notify the sender immediately by replying to this e-mail, or telephone 01382 207 222, and then delete this e-mail. All outgoing messages are checked for viruses however no guarantee is given that this e-mail message, and any attachments, are free from viruses. You are strongly recommend to check for viruses using your own virus scanner. Neither SCRC or SSSC will accept responsibility for any damage caused as a result of virus infection. This E-Mail is confidential and intended solely for the use of the individual to whom it is addressed. If you are not the addressee, any disclosure, reproduction, copying, distribution or other dissemination or use of this communication is strictly prohibited. If you have received this transmission in error please notify the sender immediately by replying to this e-mail, or telephone 01382 207 222, and then delete this e-mail. All outgoing messages are checked for viruses however no guarantee is given that this e-mail message, and any attachments, are free from viruses. You are strongly recommend to check for viruses using your own virus scanner. Neither SCRC or SSSC will accept responsibility for any damage caused as a result of virus infection. __ 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] Mapping factors to a new set of factors
Thanks Jim, I managed to get my function to work by putting it within an sapply. Unfortunately the performance was terrible, so I've gone with the suggestion of other posters to use recode in the car package. Cheers, James -Original Message- From: jim holtman [mailto:jholt...@gmail.com] Sent: 08 September 2009 18:37 To: Arnold, James Cc: r-help@r-project.org Subject: Re: [R] Mapping factors to a new set of factors use 'ifelse' # not tested; you supply data for the '%in%' map - function(x){ ifelse(x %in% c('a','b'), North, ifelse(x %in% c('c','d'), South, ifelse(x %in% c('e', 'f'), East, ifelse(x %in% c('g', 'h'), West, NA } On Tue, Sep 8, 2009 at 12:01 PM, james.arn...@sssc.uk.com wrote: Hello, I am trying to map a factor variable within a data frame to a new variable whose entries are derived from the content of the original variable and there are fewer factors in the new variable. That is, I'm trying to set up a surjection. After first thinking that this would be a common operation and would have a quite simple interface, I can not seem to find one, nor any similar posts on this topic (please correct me if there is something). Therefore, I have written a function to perform this mapping. However, the function I have written doesn't seem to work with vectors greater than length 1, and as such is useless. Is there any way to ensure the function would work appropriately for each element of the vector input? mapLN - function(x) { Reg - levels(df$Var1) if (x==Reg[1] | x==Reg[2] | x==Reg[13] | x==Reg[17] | x==Reg[20] | x==Reg[23] | x==Reg[27]) {North} else if (x==Reg[3] | x==Reg[5] | x==Reg[7] | x==Reg[14] | x==Reg[15] | x==Reg[24] | x==Reg[30]) {East} else if (x==Reg[4] | x==Reg[6] | x==Reg[8] | x==Reg[9] | x==Reg[11] | x==Reg[16] | x==Reg[18] | x==Reg[21] | x==Reg[22] | x==Reg[25] | x==Reg[28] | x==Reg[29] | x==Reg[31]) {West} else if (x==Reg[10] | x==Reg[12] | x==Reg[19] | x==Reg[26] | x==Reg[32]) {South} else stop(Not in original set) } Many thanks, James This E-Mail is confidential and intended solely for the use of the individual to whom it is addressed. If you are not the addressee, any disclosure, reproduction, copying, distribution or other dissemination or use of this communication is strictly prohibited. If you have received this transmission in error please notify the sender immediately by replying to this e-mail, or telephone 01382 207 222, and then delete this e-mail. All outgoing messages are checked for viruses however no guarantee is given that this e-mail message, and any attachments, are free from viruses. You are strongly recommend to check for viruses using your own virus scanner. Neither SCRC or SSSC will accept responsibility for any damage caused as a result of virus infection. __ 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? This E-Mail is confidential and intended solely for the use of the individual to whom it is addressed. If you are not the addressee, any disclosure, reproduction, copying, distribution or other dissemination or use of this communication is strictly prohibited. If you have received this transmission in error please notify the sender immediately by replying to this e-mail, or telephone 01382 207 222, and then delete this e-mail. All outgoing messages are checked for viruses however no guarantee is given that this e-mail message, and any attachments, are free from viruses. You are strongly recommend to check for viruses using your own virus scanner. Neither SCRC or SSSC will accept responsibility for any damage caused as a result of virus infection. __ 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] Best R text editors?
Ted, I think I share your feelings about mice (e.g., that is why I use window managers where the mouse is not needed or is actually discouraged) but ... On Fri, Sep 11, 2009 at 4:46 PM, Ted Harding ted.hard...@manchester.ac.uk wrote: On 11-Sep-09 14:16:44, Clint Bowman wrote: On Fri, 11 Sep 2009, Duncan Murdoch wrote: On 11/09/2009 6:53 AM, (Ted Harding) wrote: On 11-Sep-09 10:41:21, Jim Lemon wrote: On 09/11/2009 05:15 PM, Patrick Connolly wrote: ... | and in previous versions, you could always do M-x cua-mode | for | the same effect. Talk about a well-hidden function mostly | directed | at beginners ... Perhaps the thinking was that by the time they find it, they'll already have noticed that they can cut/copy and paste using only the mouse buttons and won't be bothered with such inefficient methods. Though this be madness, yet there is a method in't. :-) Well, okay, let's look at it from the viewpoint of learning theory. We expect that if someone has learned a skill, they will prefer to engage in other behaviors where they can successfully use that skill. Upon this easily understood foundation rest the fortunes of many. Thus two of those entities, let us call them A and M for the purposes of discussion, spend a great deal of time and effort attempting to differentiate their interfaces from each other so that having trained their users, those users will be reluctant to switch to the competitor. However, they must remain similar enough so that the switch from the competitor is not impossible. Such is the dispiriting triumph of form over substance in interface design. Both have yet to abandon such atavists as myself who prefer to type rather than fiddle with a pointing device, though they try hard to convert us. A somewhat smaller organization that I will label G seems to have decided that it can build a user base by sticking to the arcane typoglyphics of the VT-100 era and enticing the largely amoral digirati with moral suasion. Now that's madness. Jim Once again, I cannot resist citing the immortal quote (from Charles Curran, of the UK Unix Users Group): I can touch-type, but I can't touch-mouse That's a strange disability. It took me several months to learn to touch-type (and years later I'm still not very good at the top-row numbers or the special symbols on them), but I memorized the location of the two buttons on my mouse in no time at all. Duncan Murdoch Ahh, just Ted's point--mice have three buttons (unless they are connected to Apples). Clint Well, not really!! My point (and certainly Charles Curran's point) is that in touch-typing you know by proprioception and neuromuscular coordination where your fingers are relative to the keys on the keyboard, and what key you will press next, without looking; and you can accurately press several keys in rapid succession -- just as a pianist can play an arpeggio without looking. But touch-mousing isn't just knowing where the mouse itself is, nor the buttons. It would involve knowing from the sensations of moving the mouse where the mouse-pointer was on the screen, without looking, and also what graphic element (icon, on-screen button, tab in a drop-down menu) the mouse was over, also without looking. You can type accurately and rapidly withnout looking at the keyboard. You can't use a mouse with closely and accurately observing where the mouse-pointer is in the GUI. You can touch type. You can't It is here that I disagree: if the idea is typing without looking at the keyboard, then the correct analogy seems to me to be moving the mouse around without looking at the mouse. And the later is certainly doable. (OK, you can type without looking at the keyboard AND without looking at your monitor, such as when copying or translating, and that is not feasible with mice). touch-mouse. (Unless you have one of those accessibility add-ons for the visually impaired, where a SatNav voice tells you what the mouse is over, and what is written in the tab from the drop-down menu). Also, the ocasionnal misstake in typing is usually fairly harmless. Mistakes in mousing can be catastrophic. However, when one is typing Hummm... I am not sure that is a fair comparison either: certain mouse actions can be bound to some catastrophic actions. But I could have a command called er (e.g., ERase absolutely everything), which does something equally catastrophic and accidentally type that instead of df. The problem there is not in the mouse or the keyboard, but somewhere else. Best, R. program code then of course one needs to scrutinise it carefully. Even then, a typo usually results in an error message, rarely in a disaster. A mouso, however, will (almost by definition) result in the execution of a correctly coded procedure. Tough luck if it's the wrong
[R] State Space models in R
Hello everybody, I am writing a review paper about State Space models in R, and I would like to cover as many packages as I reasonably can. So far I am familiar with the following tools to deal with SS models: * StructTS, Kalman* (in stats) * packages dse[1-2] * package sspir * package dlm I would like to have some input from users who work with SS models: are there any other packages for SS models that I am missing?, which package do you use and why?, what do you think are advantages/ disadvantages of the package you use? Of course I do have my own preferences (biased, of course) and opinions about the different packages, but I would also like to summarize in my paper the feedback I get from the R community. Thank you in advance. Best, Giovanni Petris -- Giovanni Petris gpet...@uark.edu Associate Professor Department of Mathematical Sciences University of Arkansas - Fayetteville, AR 72701 Ph: (479) 575-6324, 575-8630 (fax) http://definetti.uark.edu/~gpetris/ __ 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] Is there any month object like LETTERS ?
On my R 2.9.2 installation, ?Constants just says No documentation I don't know why Gabor and I would have different results. However, ?LETTERS does provide the requested information. -Don At 7:30 AM -0400 9/11/09, Gabor Grothendieck wrote: See ?Constants On Fri, Sep 11, 2009 at 3:13 AM, megh megh700...@yahoo.com wrote: There is an object LETTERS which displays all letters from a to z. Is there any similar object whicg displays the months as well in chronological order? like jan, feb,...,dec Thanks, -- View this message in context: http://*www.*nabble.com/Is-there-any-%22month%22-object-like-%22LETTERS%22---tp25396125p25396125.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. -- -- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA 925-423-1062 __ 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] RPostgreSQL package and libpq.dll file
Lore M wrote: Dear all, I'd like to use the package RPostgreSQL. I'm using R version 2.8.1 and I've download the last version RPostgreSQL. When I load the package, I get something like the file LIBPQ.DLL is missing. Do you have any idea about what I'm suppose to do ? Thanks everyone. libpq.dll is the PostgreSQL client library. You should be able to get it here: http://www.postgresql.org/download/windows HTH Joe signature.asc Description: OpenPGP 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] Is there any month object like LETTERS ?
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Don MacQueen Sent: Friday, September 11, 2009 8:16 AM To: Gabor Grothendieck; megh Cc: r-help@r-project.org Subject: Re: [R] Is there any month object like LETTERS ? On my R 2.9.2 installation, ?Constants just says No documentation I don't know why Gabor and I would have different results. However, ?LETTERS does provide the requested information. In the upper left corner of the help for LETTERS is Constants(base) and usually that means that ?Constants would give you the same help file. All Rd files have one name entry and one or more alias entries. help() or ? looks in the list of alias entries, not the name, but most help files include the name in the aliases. src/library/base/man/Constants.Rd does not and probably should do that also. -Don At 7:30 AM -0400 9/11/09, Gabor Grothendieck wrote: See ?Constants On Fri, Sep 11, 2009 at 3:13 AM, megh megh700...@yahoo.com wrote: There is an object LETTERS which displays all letters from a to z. Is there any similar object whicg displays the months as well in chronological order? like jan, feb,...,dec Thanks, -- View this message in context: http://*www.*nabble.com/Is-there-any-%22month%22-object-like -%22LETTERS%22---tp25396125p25396125.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. -- -- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA 925-423-1062 __ 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] format (?) problems with data imported from postgres
Being more specific: On Fri, 2009-09-11 at 17:03 +0200, Tomas Lanczos wrote: Good day, I read some data from a PostgreSQL database by a following script: library(Rdbi) library(RdbiPgSQL) # conn becomes an object which contains the DB connection: conn - dbConnect(PgSQL(), host=localhost, dbname=BVS, user=postgres, password = ***) query_duj_kal - dbSendQuery(conn, select zdroj as well, cas as date, fe2, fe3, mn, nh4, no2, no3, o2, teplota as temperature from analystats where zdroj like 'Dunaj Kalinkovo') watchem_duj_kal - dbGetResult(query_duj_kal) My intention with the data is to create a time series by a following script: date - (watchem_duj_kal$date) NO3 - (watchem_duj_kal$no3) NH4 - (watchem_duj_kal$nh4) maxy-max(NO3,NH4) miny-min(NO3[NO30],NH4[NH40]) date_p - as.POSIXct(date, CET) par(mfrow=c(2,1), ylog = TRUE, yaxp = c(0.01, 100, 3)) plot(date_p, NO3,log = y, type = l, col = darkred, main = NVZ-1, xlab = time, ylab = NO3- ) lines(date_p, NH4, col = darkblue, lty = dotted) plot(date_p, NH4, log = y, type = l, col = darkblue, main = NVZ-1, xlab = time, ylab = NH4+ ) The first problems comes with the definition maxy and miny (following a previous advice od Christian Poersching through this mailing list) what worked pretty well with data imported from a csv file by a read.table() function, but in this case I got NA output The next problem comes with the unambiguous format od the date field, which is in the database defined as -MM-DD, but in the resulting watchem_duj_kal dataset is strangely converted to DD-MM-, what is unambiguous for the as.POSIXct() function expecting -MM-DD. A function converting the format of the date should help, but I could not find untill now. the resulting date field is imported into the dataset as character: date [1] 03-04-1991 07-04-1972 10-03-1997 02-12-1991 04-11-1997 [6] 11-03-1996 04-11-1975 08-31-1992 04-03-1991 10-10-1994 [11] 05-10-1992 03-28-1972 11-30-1992 03-20-1981 08-26-1991 [16] 03-08-1992 02-10-1991 09-05-1995 02-12-1975 03-12-1990 [21] 06-04-1992 01-14-1991 09-12-1971 06-11-1991 02-06-1975 [26] 02-09-1981 11-21-1980 02-09-1991 08-09-1997 02-10-1990 [31] 09-09-1996 11-19-1996 06-08-1990 08-11-1995 01-25-1994 [36] 02-06-1992 11-22-1994 07-17-1995 12-09-1994 09-05-1994 [41] 03-09-1990 04-22-1975 03-13-1995 11-08-1997 01-07-1991 [46] 07-14-1997 11-09-1995 01-17-1995 09-10-1974 08-19-1995 [51] 02-14-1995 05-27-1973 06-21-1994 07-15-1996 09-23-1975 [56] 02-12-1997 06-05-1991 04-03-1992 04-02-1975 05-11-1990 [61] 12-21-1980 05-10-1973 08-29-1980 03-06-1991 03-02-1992 [66] 04-05-1992 10-18-1995 06-02-1991 11-08-1975 10-21-1996 [71] 09-17-1973 06-01-1992 06-07-1992 12-04-1994 12-08-1996 [76] 07-20-1981 07-23-1973 10-20-1980 08-15-1994 05-06-1995 [81] 06-17-1996 02-06-1997 06-10-1997 03-31-1972 04-14-1997 [86] 02-23-1981 06-23-1975 02-17-1994 10-04-1995 05-12-1995 [91] 05-15-1981 10-16-1981 09-04-1996 03-12-1996 10-02-1997 [96] 11-24-1981 01-16-1996 05-21-1996 07-18-1994 03-22-1994 [101] 05-13-1997 I appreciate every advice/suggestion/help. Best regards Tomas __ 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 2.9.2 memory max - object vector size
At the risk of stating the obvious: - rm(.) # clears specific objects out of memory as soon as they're no longer needed in the routine. - sapply(ls(), function(x) object.size(get(x))) #lists all objects with the memory each is using. - rm(list=ls()) #clears out all objects, e.g. before the routine, to free up memory. Guy S. Few wrote: ## PROBLEM: I have memory limit problems. R and otherwise. My dataframes for merging or subsetting are about 300k to 900k records. I've had errors such as vector size too large. gc() was done.reset workspace, etc. -- View this message in context: http://www.nabble.com/R-2.9.2-memory-max---object-vector-size-tp25390745p25398830.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] Simple time series questions
Thanks - that works great. Do you have any suggestions about the grid() problem - i.e. that the vertical gridlines do not line up with the x-axis tickmarks (which are years)? I can't see on what basis the vertical gridlines are being positioned, but it doesn't look good that they are not lined up with anything. Thanks, Guy DKOD wrote: This script worked for me. Be sure to put in your correct link. link - C:\\R_Home\\Charts Graphs Blog\\R_Chart_Doc\\text_data.csv testdata- read.table(link, head = T, sep = ,,na.strings = na) test_date = as.Date(testdata$Date,%d-%m-%y) plot(test_date, testdata$Model, type=l, log=y) points(test_date, testdata$BaseDataA, type = l, col = red) points(test_date, testdata$BaseDataB, type = l, col = blue) You add 2nd and 3rd series with points command Hope this helps. Kelly http://chartsgraphs.wordpress.com http://chartsgraphs.wordpress.com -- View this message in context: http://www.nabble.com/Simple-time-series-questions-tp25398419p25399928.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] Rmetrics timeDate - business days between dates
Hi One of the most important calculation in applied finance is the number of days between dates. That kind of calculus become annoying when a specific calendar must be used. That is the case for the business days calculus. The package timeDate has a function isBizday to perform that kind of thing. The problem is that using this function to calculate the number of business days between dates has taken a very long time. An example of such an implementation is the function below. Has anyone an optimized function to to this counts? Clearly I have in mind to perform at least the basic analytics for a bond: Duration, internal rate of return , net present value, etc... That is not time feasible with a portfolio of bond using the function below. tks library(timeDate) BuziInDates - function(start, end, holidays){ #calculates the number of business days #between the dates start and end. if(class(start) != Date | class(end) != Date){ stop(Arguments must be of class Date.) } if(class(holidays) != function){ stop(holidays must be a function) } if(start end){ stop(start date must not be greater than end date.) } y1 - as.POSIXlt(start)$year + 1900 y2 - as.POSIXlt(end)$year + 1900 seqs - timeSequence(from = start, to = end, by = day) ndays - length(seqs) dts - NULL temp - NULL if( y1 == y2){ temp - window(holidays(y1), start = start, end = end) dts - seqs[isBizday(seqs,temp)] }else{ temp - holidays(y1) for(k in seq(from = y1+1, to = y2)){ temp - c(temp,holidays(k)) } temp - window(temp, start = start, end = end) dts- seqs[isBizday(seqs,temp)] } bdays - length(dts) return(bdays) } ### using the function... BuziInDates(as.Date('2009-09-11'), as.Date('2030-09-11') , holidayNYSE) [[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 wo read stability VAR plot?
I have made program code for Vector Auto Regressive in terms of completing my undergraduate program using R. I have an important question related to my project. If I have: data(Canada) var.2c - VAR(Canada, p = 2, type = const) var.2c.stabil - stability(var.2c, type = OLS-CUSUM) I want to get the value of plot(var.2c.stabil). Can you help me what should I do or write so the result can occur? Dear Arif, the stability function employs the package strucchange. Have a look at str(var.2c.stabil$stability) and then, for a particular equation (e.g. unemployment) str(var.2c.stabil$stability$U) the data for the process is contained in the list element process. HTH, Bernhard It means if I have source code: data(Canada) x=acf(Canada) I will get the value of acf if I write x in R. Thanks in advance _ ry-edit.aspx [[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. * Confidentiality Note: The information contained in this ...{{dropped:10}} __ 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] Graph visualization
Arber Ngjela wrote: Hello, I am working with graph and adjacency matrix, the package 'graph' seems to be appropriate for this. An example in the package mat - rbind(c(0, 0, 1, 1), + c(0, 0, 1, 1), + c(1, 1, 0, 1), + c(1, 1, 1, 0)) rownames(mat) - colnames(mat) - letters[1:4] graph1 - new(graphAM, adjMat=mat) graph1 A graphAM graph with undirected edges Number of Nodes = 4 Number of Edges = 5 how can I plot the object graph1? Hi Arber Rgraphviz http://bioconductor.org/packages/2.4/bioc/html/Rgraphviz.html is one option; it can be tricky to install on Windows / Mac where the version of graphviz installed on your system needs to be the same as the version used to build the package. See the README file in the package source distribution http://bioconductor.org/packages/2.4/bioc/src/contrib/Rgraphviz_1.22.1.tar.gz Martin Thanks in advance Arber [[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] Slow enumeration of vectors with restrictions
I have a vector T and a scalar m such that 1 = m = sum(T). I also have a vector U that satisfies three properties... 1. length(T)==length(U) 2. sum(U)==m 3. for (i in 1:length(T)) U[i]=T[i] The function nextu (given below) calculates the next vector subject to the same restrictions. The recursion A(T,m) is given below. It calculates the total number of different vectors there are for given T and m (in the example here it is 20). For example, if T - c(2,4,3,1) m - 4 #first I generate the first value of U #to be plugged into function nextu U.first - numeric(c) i-1 while(sum(U.first) m) { if(T[i] U.first[i]) { U.first[i]-(U.first[i]+1) } else { i-(i+1) } } #then I create a place to store the #vectors I will create with nextu np - A(T,m) c - length(T) mat - matrix(numeric(np*c),np,c) #then I run nextu starting with U.first #and store results in mat i - 1 U - U.first while (i = np) { for (j in 1:c) { mat[i,j] - U[j] } U - nextu(U) i - i+1 } In the example I gave above we get the following matrix... [,1] [,2] [,3] [,4] [1,]2200 [2,]1300 [3,]0400 [4,]2110 [5,]1210 [6,]0310 [7,]2020 [8,]1120 [9,]0220 [10,]1030 [11,]0130 [12,]2101 [13,]1201 [14,]0301 [15,]2011 [16,]1111 [17,]0211 [18,]1021 [19,]0121 [20,]0031 Although this works perfectly, it is way too slow to be useful in a program I am writing. I’m wondering if anyone has any ideas about how to speed up the process. If it helps, one can think of reversing the vectors and seeing them as numbers where addition is carried out in base T[i]+1 using carries from the (i-1) coordinate. #function nextu creates the next #sequential ordering of U that satisfies #the restrictions given by T and m nextu - function(U) { s - -1 i - 1 while (i = c) { if (U[i] == 0) { i - i+1 } else { s - s+U[i] i - i+1 break } } while (i =c) { if (U[i] == T[i]) { s - s+U[i] i - i+1 } else { k - i U[k] - (U[k] + 1) i - 1 break } } U[i] - min(s,T[i]) s - s-U[i] i - i+1 while (i k) { U[i] - min(s,T[i]) s - s-U[i] i - i+1 } U } #end of function nextu #function A implements a recursion to #get the total number of nextu calculations #needed #Thanks to Martin Morgan and Bill Dunlap for #help speeding A(T,m) up more than 1000 times! A - function(T, m) { C - function(lt, m) { if (lt == 1L) { R - as.numeric(0 = m m = T[1]) } else if (lt == 2L) { mu - m - (0:T[2L]) R - sum(mu = T[1L] 0L = mu) } else { R - 0 lt1 - lt-1L for (mu in m-(0:T[lt])) { if (is.na(memo[lt1, offset + mu])) memo[lt1, offset + mu] - C(lt1, mu) R - R + memo[lt1, offset + mu] } } R } T - rev(sort(T)) m - as.integer(m) offset - sum(T[-1]) - m + 1L nrow - length(T) - 1L memo - matrix(rep(NA_real_, nrow * (offset + m)), nrow=nrow) C(length(T), m) } #end of function A - Bryan Keller, Doctoral Student/Project Assistant Educational Psychology - Quantitative Methods The University of Wisconsin - Madison __ 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] State Space models in R
You might try: RSiteSearch(state space) and try the search engine at rseek.org On Fri, Sep 11, 2009 at 11:04 AM, Giovanni Petris gpet...@uark.edu wrote: Hello everybody, I am writing a review paper about State Space models in R, and I would like to cover as many packages as I reasonably can. So far I am familiar with the following tools to deal with SS models: * StructTS, Kalman* (in stats) * packages dse[1-2] * package sspir * package dlm I would like to have some input from users who work with SS models: are there any other packages for SS models that I am missing?, which package do you use and why?, what do you think are advantages/ disadvantages of the package you use? Of course I do have my own preferences (biased, of course) and opinions about the different packages, but I would also like to summarize in my paper the feedback I get from the R community. Thank you in advance. Best, Giovanni Petris -- Giovanni Petris gpet...@uark.edu Associate Professor Department of Mathematical Sciences University of Arkansas - Fayetteville, AR 72701 Ph: (479) 575-6324, 575-8630 (fax) http://definetti.uark.edu/~gpetris/ __ 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] State Space models in R
Hi, Giovanni: 1. I've used primarily sspir and dlm. There is apparently a new release of sspir, which I have not used. When I last tried sspir, it did NOT have a forecast function, while dlm did. The two packages have functions with the same name but incompatible code. It would be good if the two were compatible, but unfortunately, I'm not in a position to volunteer to make them so. 2. I'm very glad you are preparing such a review paper. To check your lit search, you might try something like the following: library(sos) ss - ???state space k - ???kalman sk - ss|k installPackages(sk) writeFindFn2xls(sk) When I did this just now, it identified 272 help pages in 92 packages matching either state space or kalman. In addition to the packages you mentioned, the following packages may also interest you: expsmooth, cts, KFAS, forecast, timsac, Stem, and deSolve; these all have at least 6 help pages matching one of these terms. The pomp package, with 5 matches, may also be of interest. The installPackages command above only installed packages with at least 6 help pages in this example. To extend this to 4, I used installPackages(sk, 4). Then I deleted the sk.xls file in getwd() and reran writeFindFn2xls(sk) to get more information about packages with 5 and 4 matches. To extend this search further, I added the following: dlm - ???dynamic linear model dlms - ???dynamic linear models dlsk - sk|dlm|dlms writeFindFn2xls(dlsk) This identified 320 help pages in 115 packages, but I don't know it added anything relevant to your question. I created the sos package with help from Sundar Dorai-Raj and Romain Francois largely to help with this kind of search. In seconds, it converted questions and insecurities about what relevant packages might be available into an embarrassment of riches. An anonymous referee (or some other future reader) will be less likely to complain about something you've missed. If it misses an important package, the package is either small or does not adequately match your search terms. Hope this helps. Spencer Giovanni Petris wrote: Hello everybody, I am writing a review paper about State Space models in R, and I would like to cover as many packages as I reasonably can. So far I am familiar with the following tools to deal with SS models: * StructTS, Kalman* (in stats) * packages dse[1-2] * package sspir * package dlm I would like to have some input from users who work with SS models: are there any other packages for SS models that I am missing?, which package do you use and why?, what do you think are advantages/ disadvantages of the package you use? Of course I do have my own preferences (biased, of course) and opinions about the different packages, but I would also like to summarize in my paper the feedback I get from the R community. Thank you in advance. Best, Giovanni Petris -- Spencer Graves, PE, PhD President and Chief Operating Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 __ 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] Is there any month object like LETTERS ?
month.abb should do the trick _ View your other email accounts from your Hotmail inbox. Add them now. __ 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] Simple time series questions
I'm sure this is a really simple problem, but I've spent hours digging and I keep running into roadblocks. I'm trying to get a simple chart with three time series. Similar to the attached example http://www.nabble.com/file/p25398419/Excel%2Bchart%2Bexample.pdf Excel+chart+example.pdf , something that was quite easy to do in Excel, except that I need a log y-axis: something that R can do and Excel can't. The data is in the attached CSV file http://www.nabble.com/file/p25398419/test%2Bchart%2Bdata.csv test+chart+data.csv . I can read it in OK, and create separate charts: testdata- read.table(C:\\Files\\test chart data.csv, head = T, sep = ,,na.strings = na) test_date = as.Date(testdata$Date,%d-%m-%y) test_data_model = testdata$Model test_date_baseA = testdata$BaseDataA test_date_baseB = testdata$BaseDataB plot(test_date, test_data_model,type='l',log=y) plot(test_date, test_data_baseA,type='l',log=y) plot(test_date, test_data_baseB,type='l',log=y) grid() (Clearly at this point, each chart over-writes the previous one.) Next I try to get them onto a single chart, sharing the same y-axis. I'm sure I haven't done this very elegantly, but here goes: frame_model = data.frame(a=test_date,b=test_data_model) frame_A = data.frame(a=test_date,b=test_data_baseA) frame_B = data.frame(a=test_date,b=test_data_baseB) ts_model = ts(frame_model$b) ts_a = ts(frame_A$b) ts_b = ts(frame_B$b) ts.plot(ts_model,ts_a,ts_b,col=c(blue,red,green),log=y) The problem is that I no longer have the date along the y-axis. How can I get that back? Finally, when I plot the separate time series, the grid() function geneates a grid where the vertical lines are not lined up with the year tick marks. I interpreted the topic help as saying that by default they would match the tick marks. How can I achieve that? Thanks for any suggestions, Guy Green -- View this message in context: http://www.nabble.com/Simple-time-series-questions-tp25398419p25398419.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] Completion for proto objects
On Fri, 11 Sep 2009 16:07:45 +0200, Gabor Grothendieck ggrothendi...@gmail.com wrote: See ?assignInNamespace thanks for the hint. It works to some extent. Functions are redefined in base but utils:::specialCompletions seems not to preform properly: ls.proto - function(x){ # function to complete .local - function(x){ if(is(x[[.super]], proto)) c(ls.default(x), Recall(x[[.super]])) else ls.default(x) } unlist(.local(x)) } ls1 - base::ls # cache ls ls.default1 - function(name, pos = -1, envir = as.environment(pos), all.names = FALSE, pattern){ UseMethod(ls) } assignInNamespace(ls.default, ls1 , 'base') assignInNamespace(ls, ls.default1 , 'base') assignInNamespace(ls.proto, ls.proto , 'base') environment(ls) - asNamespace('base') environment(ls.default) - asNamespace('base') environment(ls.proto) - asNamespace('base') p1 - proto(p1_abc=123) p2 - proto(.=p1, p2_abc=23423) ls(p2) [1] p2_abc p1_abc #works fine ls(p1) [1] p1_abc Completion for $ works fine with environments and everything else, but not with proto objects. also ls.str (which uses ls internally) gives an error. ls.str(p1) Error in ls(name, envir = envir, all.names = all.names, pattern = pattern) : argument name is missing, with no default What is going on?? My ls.proto works nicely in global env but does not when called from attached packages? Would really appreciate if someone can enlighten me. Thanks a lot. PS: I also tried to modify utils:::specialCompletions directly, did not wok either - it's something wrong with ls.proto above :(. On Fri, Sep 11, 2009 at 10:02 AM, Vitalie S. vitosm...@rambler.ru wrote: Hello everyone, I am trying to implement completion for proto objects. Proto extends environment in a hierarchical way. Thus completion should list all the names in all it's parent environments. For normal classes defining names.class would do the job, but completion for environment is hard coded in utils:::specialCompletions by means of base::ls(). As result defining names.proto does not work. I tried to make ls generic and to do something like: environment(ls.default) - asNamespace('utils') environment(ls) - asNamespace('utils') environment(ls.proto) - asNamespace('utils') That does not work either. Is there a way to make utils:::specialCompletions use my ls instead of base::ls?? I know Deepayan Sarkar is working now on improving the completion system (potentially by introducing completion generic). That would definitely solve the problem. But for now, does a quick fix exist? Thanks a lot, Vitalie __ 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] transposing a distance matrix in R
Hi Jeannine, I'm just forwarding this QA back to the r-help list, you'll get more eyes on it and other people might have better solutions. Answers inline: On Sep 11, 2009, at 12:25 PM, Jeannine Cavender-Bares wrote: Dear Steve, Greetings! You helped me earlier this summer with an R question in response to a message Brian McCarthy put out on the listserv. I was wondering if you happen to know the answer to the following question or if you can explain how I subscribe to the listserv. Can one just send a message to r-h...@r-project.org? You can subscribe to the listserv from here: https://stat.ethz.ch/mailman/listinfo/r-help Here goes: How does one convert a triangular distance matrix into a single column distance matrix?: e.g., traingular: A B C A na na na B 1 na na C 0 1 na single column: BA 1 CA 0 CB 1 Getting the distances from your matrix is pretty straightforward since they're all in the lower triangle of the matrix, see: ?lower.tri R m - matrix(c(NA,1,0,NA,NA,1,NA,NA,NA), 3) R dimnames(m) - list(c('A','B','C'), c('A','B','C')) R m[lower.tri(m)] [1] 1 0 1 Getting the names for the distances is a bit more tricky. I'm trying to do that with the expand.grid function, check it out to see how it works: ?expand.grid R who.vs.who - expand.grid(rownames(m), rownames(m)) R who.vs.who Var1 Var2 1AA 2BA 3CA 4AB 5BB 6CB 7AC 8BC 9CC We can use the same index generated by ``lower.tri(m)`` to get the names of the rows vs cols since R stores the elements of a matrix in column major order[1] (note that when I created the matrix ``m``, I used a vector that filled a matrix column by column). When you use a single integer to index into a matrix, it calculates which position to pull out in the same (column major) order, so: * ``m[1]`` is really element m[1,1] * ``m[2]`` is really element m[2,1], etc ... So now: R who.vs.who[lower.tri(m),] Var1 Var2 2BA 3CA 6CB ... almost there, no just put it together: R dist - m[lower.tri(m)] R who - who.vs.who[lower.tri(m),] R names(dist) - paste(who[,1], who[,2], sep=.vs.) R dist B.vs.A C.vs.A C.vs.B 1 0 1 HTH, -steve [1] Column major format: http://en.wikipedia.org/wiki/Row-major_order#Column-major_order -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ 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] Completion for proto objects
You might check the bugs section on the proto home page and if any of those seem to apply try the devel version of proto (or the workaround mentioned) as all known bugs are fixed in the devel version. If that does not help let me know offline and I will try to help you. See: http://r-proto.googlecode.com On Fri, Sep 11, 2009 at 12:39 PM, Vitalie S. vitosm...@rambler.ru wrote: On Fri, 11 Sep 2009 16:07:45 +0200, Gabor Grothendieck ggrothendi...@gmail.com wrote: See ?assignInNamespace thanks for the hint. It works to some extent. Functions are redefined in base but utils:::specialCompletions seems not to preform properly: ls.proto - function(x){ # function to complete .local - function(x){ if(is(x[[.super]], proto)) c(ls.default(x), Recall(x[[.super]])) else ls.default(x) } unlist(.local(x)) } ls1 - base::ls # cache ls ls.default1 - function(name, pos = -1, envir = as.environment(pos), all.names = FALSE, pattern){ UseMethod(ls) } assignInNamespace(ls.default, ls1 , 'base') assignInNamespace(ls, ls.default1 , 'base') assignInNamespace(ls.proto, ls.proto , 'base') environment(ls) - asNamespace('base') environment(ls.default) - asNamespace('base') environment(ls.proto) - asNamespace('base') p1 - proto(p1_abc=123) p2 - proto(.=p1, p2_abc=23423) ls(p2) [1] p2_abc p1_abc #works fine ls(p1) [1] p1_abc Completion for $ works fine with environments and everything else, but not with proto objects. also ls.str (which uses ls internally) gives an error. ls.str(p1) Error in ls(name, envir = envir, all.names = all.names, pattern = pattern) : argument name is missing, with no default What is going on?? My ls.proto works nicely in global env but does not when called from attached packages? Would really appreciate if someone can enlighten me. Thanks a lot. PS: I also tried to modify utils:::specialCompletions directly, did not wok either - it's something wrong with ls.proto above :(. On Fri, Sep 11, 2009 at 10:02 AM, Vitalie S. vitosm...@rambler.ru wrote: Hello everyone, I am trying to implement completion for proto objects. Proto extends environment in a hierarchical way. Thus completion should list all the names in all it's parent environments. For normal classes defining names.class would do the job, but completion for environment is hard coded in utils:::specialCompletions by means of base::ls(). As result defining names.proto does not work. I tried to make ls generic and to do something like: environment(ls.default) - asNamespace('utils') environment(ls) - asNamespace('utils') environment(ls.proto) - asNamespace('utils') That does not work either. Is there a way to make utils:::specialCompletions use my ls instead of base::ls?? I know Deepayan Sarkar is working now on improving the completion system (potentially by introducing completion generic). That would definitely solve the problem. But for now, does a quick fix exist? Thanks a lot, Vitalie __ 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. -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ __ 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 determine if a variable is already set?
Hi, It might be a primitive question but how it is possible to determine if a variable is initialized in an environment? Suppose that we start a R session and wants to run a script which use the variable i. Which function could evaluate if i is already initialized or not and if not, then ask interactively the user to set it? This is to avoid the error message: object i is not found. Regards, Carol [[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] Moving to Mac OS X
Hi all, I have been using R on Windows for a long time, but now I am ready to move to Mac OS X, but I was just wondering if R works better on Mac than on Windows. This is because I had some memory size issues in the past. Another question is if some of you know an R editor for Mac (just like Tinn-R). Thanks. Víctor Manuel García Guerrero Doctorado en Estudios de Población, CEDUA, COLMEX Camino al Ajusco N° 20, Pedregal de Sta. Teresa C.P.10740, Tlalpan, México, D.F. __ 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] Working with large matrix
Dear All, I have large matrix (46000 x 11250). I would like to do the linear regression for each row. I wrote a simple function that has lm() and used apply(mat,1,func). The issue is that it takes ages to load the file and also to finish the lm. I am using LINUX 64 bit with 32G mem. Is there an elegant and fast way of completing this task? Thanks in advance. Kind regards, Ezhil __ 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 determine if a variable is already set?
On Sep 11, 2009, at 12:15 PM, carol white wrote: Hi, It might be a primitive question but how it is possible to determine if a variable is initialized in an environment? Suppose that we start a R session and wants to run a script which use the variable i. Which function could evaluate if i is already initialized or not and if not, then ask interactively the user to set it? This is to avoid the error message: object i is not found. Regards, Carol See ?exists Note that this will tell you if the object exists, not if it contains a specifically desired initial value. You would have to check for the latter after determining that the object does indeed exist. 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.
[R] how to determine if a variable has already been initialized?
Hi, It might be a primitive question but how it is possible to determine if a variable is initialized in an environment? Suppose that we start a R session and wants to run a script which uses the variable i. Which function could evaluate if i exists already and has been initialized or not? The purpose is to avoid the message: error, object i is not found. Regards, Carol [[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] transposing a distance matrix in R
Try this also: subset(as.data.frame.table(m), !is.na(Freq)) On Fri, Sep 11, 2009 at 1:48 PM, Steve Lianoglou mailinglist.honey...@gmail.com wrote: Hi Jeannine, I'm just forwarding this QA back to the r-help list, you'll get more eyes on it and other people might have better solutions. Answers inline: On Sep 11, 2009, at 12:25 PM, Jeannine Cavender-Bares wrote: Dear Steve, Greetings! You helped me earlier this summer with an R question in response to a message Brian McCarthy put out on the listserv. I was wondering if you happen to know the answer to the following question or if you can explain how I subscribe to the listserv. Can one just send a message to r-h...@r-project.org? You can subscribe to the listserv from here: https://stat.ethz.ch/mailman/listinfo/r-help Here goes: How does one convert a triangular distance matrix into a single column distance matrix?: e.g., traingular: A B C A na na na B 1 na na C 0 1 na single column: BA 1 CA 0 CB 1 Getting the distances from your matrix is pretty straightforward since they're all in the lower triangle of the matrix, see: ?lower.tri R m - matrix(c(NA,1,0,NA,NA,1,NA,NA,NA), 3) R dimnames(m) - list(c('A','B','C'), c('A','B','C')) R m[lower.tri(m)] [1] 1 0 1 Getting the names for the distances is a bit more tricky. I'm trying to do that with the expand.grid function, check it out to see how it works: ?expand.grid R who.vs.who - expand.grid(rownames(m), rownames(m)) R who.vs.who Var1 Var2 1AA 2BA 3CA 4AB 5BB 6CB 7AC 8BC 9CC We can use the same index generated by ``lower.tri(m)`` to get the names of the rows vs cols since R stores the elements of a matrix in column major order[1] (note that when I created the matrix ``m``, I used a vector that filled a matrix column by column). When you use a single integer to index into a matrix, it calculates which position to pull out in the same (column major) order, so: * ``m[1]`` is really element m[1,1] * ``m[2]`` is really element m[2,1], etc ... So now: R who.vs.who[lower.tri(m),] Var1 Var2 2BA 3CA 6CB ... almost there, no just put it together: R dist - m[lower.tri(m)] R who - who.vs.who[lower.tri(m),] R names(dist) - paste(who[,1], who[,2], sep=.vs.) R dist B.vs.A C.vs.A C.vs.B 1 0 1 HTH, -steve [1] Column major format: http://en.wikipedia.org/wiki/Row-major_order#Column-major_order -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contacthttp://cbio.mskcc.org/%7Elianos/contact __ 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] AIC and goodness of prediction - was: Re: goodness of prediction using a model (lm, glm, gam, brt,
Hi Corrado, Not being familiar with your research goals or data I can't make recommendations, but I can suggest a couple of places to look for information: Frank Harrell's Regression Modeling Strategies and his Design library available on CRAN, and Hastie et al's The Elements of Statistical Learning. A couple more comments below.. On Thu, Sep 10, 2009 at 11:48 AM, Corrado ct...@york.ac.uk wrote: Dear Kingsford, I apologise for breaking the thread, but I thought there were some more people who would be interested. What you propose is what I am using at the moment: the sum of the squares of the residuals, plus variance / stdev. I am not really satisfied. I have also tried using R2, and it works well but some people go a bit wild eyed when they see a negative R2 (which is perfectly reasonable when you use R2 as a measure of goodness of fit on prediction on a dataset different from the training set). To get negative values I'm guessing you're using 1 - ((sum((obs - pred)^2)) / (sum((obs - mean(obs))^2))? If so a negative value indicates the model is a worse predictor than using a constant. Also note the formula is just a linear transform of the one mentioned in my last email. I was then wondering whether it would make sense to use AIC: the K in the formula will still be the number of parameters of the trained model, the sum of square residuals would be the (predicted - observed)^2, N would be the number of samples in the test dataset. I think it should work well. Generally, when assessing predictive ability one is not concerned with the number of parameters -- just how good the predictions are on data that is independent of the model selection and fitting process. Also, the general definition of AIC uses likelihoods not SS residuals. Also, using the SS resids you are once again back to a linear transormation of the MSE estimate... Kingsford What do you / other R list members think? Regards On Thursday 03 September 2009 15:06:14 Kingsford Jones wrote: There are many ways to measure prediction quality, and what you choose depends on the data and your goals. A common measure for a quantitative response is mean squared error (i.e. 1/n * sum((observed - predicted)^2)) which incorporates bias and variance. Common terms for what you are looking for are test error and generalization error. hth, Kingsford On Wed, Sep 2, 2009 at 11:56 PM, Corradoct...@york.ac.uk wrote: Dear R-friends, How do you test the goodness of prediction of a model, when you predict on a set of data DIFFERENT from the training set? I explain myself: you train your model M (e.g. glm,gam,regression tree, brt) on a set of data A with a response variable Y. You then predict the value of that same response variable Y on a different set of data B (e.g. predict.glm, predict.gam and so on). Dataset A and dataset B are different in the sense that they contain the same variable, for example temperature, measured in different sites, or on a different interval (e.g. B is a subinterval of A for interpolation, or a different interval for extrapolation). If you have the measured values for Y on the new interval, i.e. B, how do you measure how good is the prediction, that is how well model fits the Y on B (that is, how well does it predict)? In other words: Y~T,data=A for training Y~T,data=B for predicting I have devised a couple of method based around 1) standard deviation 2) R^2, but I am unhappy with them. Regards -- Corrado Topi Global Climate Change Biodiversity Indicators Area 18,Department of Biology University of York, York, YO10 5YW, UK Phone: + 44 (0) 1904 328645, E-mail: ct...@york.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. -- Corrado Topi Global Climate Change Biodiversity Indicators Area 18,Department of Biology University of York, York, YO10 5YW, UK Phone: + 44 (0) 1904 328645, E-mail: ct...@york.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] R/S Programmer Employment Opportunity - New York, NY
R / S Programmer - New York Description: Kaplan Test Prep Admissions is looking for a R / S Programmer to join their research based in New York City. We are looking for highly motivated individuals to work in a customer-focused environment. This is a unique opportunity to develop with a leading educational company with a diverse series of statistical applications in education/learning, operations, marketing, and finance. The Role * To provide ad-hoc programming services to customers * To create and deliver tailored software applications and libraries to internal clients * To participate in the design and implementation of cloud-based statistical high-performance computing applications Qualifications * Knowledge of statistical languages: S-PLUS or R, and SQL * Excellent communication skills * Experience of general software systems is an advantage (eg. Java, Ruby, Oracle, XML, HTML Offering * Opportunity to extend your technical knowledge while working in a dynamic environment with a diverse group of clients * Flexible working environment and working hours * Competitive salary depending on experience * Great benefits If you are interested in applying for this position please send a copy of your resume and cover letter to wesley.madi...@kaplan.com . Salary/Benefits: Salary commensurate with experience Full time employees enjoy these outstanding benefits: *401(k) plan *Comprehensive health, dental and short term disability long term disability plans *Business casual dress code *Sick days, personal days, holidays, and vacation days *A friendly, team oriented environment Company URL: http://www.kaplan.com http://www.kaplan.com Company Profile: Kaplan Test Prep and Admissions (www.kaptest.com), a division of Kaplan, Inc., is a premier provider of educational and career services for individuals, schools and businesses. Established in 1938, Kaplan Test Prep and Admissions is the world leader in the test prep industry and has served millions of students in nearly 70 years. With 3,000 classroom locations worldwide, a comprehensive menu of online offerings and a complete array of books and software, and private tutoring options, Kaplan offers preparation for more than 60 standardized tests in the U.S. and the U.K., including entrance exams for secondary school, college and graduate school, as well as English language and professional licensing exams. Kaplan also provides college and graduate admissions consulting services, as well as after-school learning programs for K-10 students through its SCORE! centers. Additionally, the division's K12 Learning Services unit is a leading nationwide provider of a broad range of academic intervention and support programs for school districts seeking to meet the demands of No Child Left Behind (NCLB). [[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] Moving to Mac OS X
On Sep 11, 2009, at 12:15 PM, Victor Manuel Garcia Guerrero wrote: Hi all, I have been using R on Windows for a long time, but now I am ready to move to Mac OS X, but I was just wondering if R works better on Mac than on Windows. This is because I had some memory size issues in the past. Another question is if some of you know an R editor for Mac (just like Tinn-R). Thanks. The notion of better is always in the eyes of the useR and will depend upon specific criteria. OSX can run R in both 32 bit and 64 bit modes and indeed the default OSX download for R provided by Simon installs and supports both. If you use the 32 bit version, then from a memory management standpoint, you will not see demonstrable gains over Windows. However, with the 64 bit version, you will avail yourself of a much larger memory address space as compared to running 32 bit R on Windows. That of course presumes that you have a lot of RAM in your Mac to actually take advantage of the larger address space. The 64 bit memory address space is also available via Linux, with appropriate hardware. You might want to review the R OSX FAQ: http://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html and also note that there is a OSX specific e-mail list: https://stat.ethz.ch/mailman/listinfo/r-sig-mac As far as editors, I am not familiar with the details of Tinn-R, but ESS/Emacs is available for OSX and this is what I use (continuing what I had been using on Linux for the past number of years). Others will likely be able to provide other recommendations and you might want to search the R-SIG-Mac list archives as no doubt there have been such discussions in the past. 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] Moving to Mac OS X
Hi, On Sep 11, 2009, at 1:15 PM, Victor Manuel Garcia Guerrero wrote: Hi all, I have been using R on Windows for a long time, but now I am ready to move to Mac OS X, but I was just wondering if R works better on Mac than on Windows. This is because I had some memory size issues in the past. 64bit R (from http://r.research.att.com/) works great on 64 bit macs w/ OS X ... my R sessions have chewed up all of the 8gb of ram on my cpu that were available if need be (and choked the rest of my system). Another question is if some of you know an R editor for Mac (just like Tinn-R). I'm not sure that there's a consensus. Here's a very recent thread: http://thread.gmane.org/gmane.comp.lang.r.general/161063/focus=161335 All the usual players: * Emacs w/ ESS * JGR * Eclipse + StatET plugin * I understand people are excited about an R plugin for jEdit that this guy is working on: http://romainfrancois.blog.free.fr/ I use TextMate .. there's an R.bundle for it which I don't really use aside from its syntax highlighting, though it does more (like sending commands to (some) R process). Works great w/ LaTeX+Sweave, too. It seems that's all I really need as I spend most of my time in the terminal then sourcing some file that has the functions I'm trying to refine anyway ... -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ 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 with plotting
HI all, raw_urine = read.table(Z:\\bruce.9.3.09.sample.stability.analysis\\urine\\mz.spot.sam.dat.new, header = TRUE ) pvalue = read.table(Z:\\bruce.9.3.09.sample.stability.analysis\\urine\\all.urine.features.t.test.result, header = TRUE ) library(compositions) p = function(a,b){ y = pvalue[,a] if(y0.01){ index = which(y, arr.ind=TRUE) day1 = raw_urine[index,3:7] day2 = raw_urine[index,b] graph = {matplot(raw_urine[index,1],day1,lwd = 3) matpoints(raw_urine[index,1],day2,lwd = 3, col=red)} print(graph) }} the above is my sample code in which i'm trying to output some graphs. but however, I can get return() to return value I want and all. But I just don't know if there's anything special I need to use to output graphs. I get this error msg: Warning message: In if (y 0.01) { : the condition has length 1 and only the first element will be used everything was fine until i put in graphing functions in the end. Thanks. -- Edward Chen Email: edche...@gmail.com Cell Phone: 510-371-4717 [[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] Barplot+Table
I am trying to automate a report that my company does every couple of years for the state of Maine. In the past we have used SPSS to run the data and then used complicated Excel template to make the tables/graphics which we then imported into Word. Since there are 256 tables/graphics for this report, this work flow is a little painful. I would like to automate the process and I think I can do so with odfWeave and R, but I've run into a problem. I can't seem to get the output from R to look like what we have used in the past. Here's an example of what I need it to look like (sorry for the long URL) http://1.bp.blogspot.com/_TRRvdLHNnE8/SqpP5gFG3DI/BgY/09x- LoLtfTI/s1600-h/example+graphic.png My boss is open to using another tool (R) to get the work done but my final output needs to look, more or less, like what we did last time. I can make a table and I can make a bar graph that, essentially gets me where I want to go (I can handle the tweaking) but I don't know how to put them together and make things line up, as in my example (URL). I have looked at iplot, ggplot, lattice, etc. I will confess that my knowledge of R's graphical capabilities leaves a lot to be desired (as I am proving today) but I really can not find an example or feature that seems to do what I am trying to do. I am more or less satisfied with the plot, but I really would like to line up the table with the graphics, which is why I don't just put a table under the graph via odfweave. Here's what I have thus far: ### # These numbers are just BS I made up. counties - c(County1,County2,County1,County2,County1,County2,County1,County2,County1,County2,County1,County2,County1,County2,County1,County2,County1,County2,County1,County2,County1,County2,County1,County2) gender - c(Male, Male,Male, Male, Male, Female,Female, Female,Male, Male,Male, Female,Male, Female,Male, Female,Male, Female,Female, Female,Male, Female,Male, Male) weight - c(1,2,1,2,1,2,2,1,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2) example.table-xtabs(weight~counties+gender) barplot(prop.table(example.table,1),beside=T) ### I am open to using any of the various graphics systems provided in R. I am willing/capable of learning and in fact, I want to learn how to do this but I can't even figure out which system I should spend my time learning more about and I don't have time to become an expert with all of them. Thank you. __ 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] Working with large matrix
Hi, On Sep 11, 2009, at 1:15 PM, A Ezhil wrote: Dear All, I have large matrix (46000 x 11250). I would like to do the linear regression for each row. I wrote a simple function that has lm() and used apply(mat,1,func). The issue is that it takes ages to load the file and also to finish the lm. I am using LINUX 64 bit with 32G mem. Is there an elegant and fast way of completing this task? Do bigmemory and biglm help? http://cran.r-project.org/web/packages/bigmemory http://cran.r-project.org/web/packages/biglm -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ 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 plotting
Hi Edward, On Sep 11, 2009, at 1:47 PM, Edward Chen wrote: HI all, raw_urine = read.table(Z:\\bruce.9.3.09.sample.stability.analysis\\urine\\mz.spot.sam.dat.new , header = TRUE ) pvalue = read.table(Z:\\bruce.9.3.09.sample.stability.analysis\\urine\\all.urine.features.t.test.result , header = TRUE ) library(compositions) p = function(a,b){ y = pvalue[,a] if(y0.01){ index = which(y, arr.ind=TRUE) day1 = raw_urine[index,3:7] day2 = raw_urine[index,b] graph = {matplot(raw_urine[index,1],day1,lwd = 3) matpoints(raw_urine[index,1],day2,lwd = 3, col=red)} print(graph) }} the above is my sample code in which i'm trying to output some graphs. but however, I can get return() to return value I want and all. I don't see a return() call. But I just don't know if there's anything special I need to use to output graphs. I get this error msg: Warning message: In if (y 0.01) { : the condition has length 1 and only the first element will be used That's not an error, but a warning -- your code runs, but might be doing something you don't expect it to be doing, since you're doing something a bit non-intuitive: R a - c(TRUE, FALSE, TRUE, TRUE) R if (a) cat(Hi\n) else cat(Bye\n) Hi Warning message: In if (a) cat(Hi\n) else cat(Bye\n) : the condition has length 1 and only the first element will be used You see how length(a) 1 -- what should ``if (a)`` evaluate to? R is telling you that it's just evaluating a[1]. So, maybe your data isn't what you expect it to be? -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ 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 block data across multiple columns?
Dear all, Does anyone have any suggestions on how to block multiple columns of data one at a time in the midst of an analysis, having specified the blocking variable? I am running a random effects model using lmer, and my data set has multiple columns. Individuals in the study are grouped into 60 families- which is the blocking factor. The random effects are markers (labeled Pxlyy below) that have two levels- 1 (presence) or 0 (absence). I need to estimate Variance Components for 'peg.no' (family wise, which is why this is the blocking factor), explained by each PxLyy, and by 'family' as well. I have managed to run the lmer model for the first marker column (P1L55), and have been able to block it according to 'family' as follows: vc-read.table(P:\\R\\Testvcomp10.txt,header=T) attach(vc) family-factor(family) colms-(vc)[4:13] ## these are the marker columns lapply(colms,factor) library(lme4) for (f in levels(family)) { print(Family) print(f) { t- vc [ family == f, ] try(lmer-fit(peg.no~1 + (1|P1L55) + (1|family), data=t, na.action=na.exclude)) print(summary(fit)) }} However I need to do this for 10 PxLyy columns simultaneously, so that I have 60 families * 10 markers= 600 runs of the model. To do this I tried, for (c in 1:length (colms)) { for (f in levels (family)) { print(Marker) print(c) print (Family) print(f) { t- vc[family == f,] ## this is where I lose the plot try(fit-lmer(peg.no~1 + (1|c)+ (1|family), data=t, na.action=na.exclude)) print(summary(fit)) }}} This however, doesn't run at all after the first two loops. I cannot figure out how to tell it to block each one of 10 columns in turn. This works for one marker, but not more in the same run. Any suggestions please? Thanks a lot, Aditi Data files at: http://www.4shared.com/file/131980362/460bdafe/Testvcomp10.html (excel) http://www.4shared.com/file/131980512/dc7308b/Testvcomp10.html (txt) - A Singh aditi.si...@bristol.ac.uk School of Biological Sciences University of Bristol __ 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] Barplot+Table
Try the textplot function in the gplots package: nf - layout(matrix(1:2), height = lcm(12)) par(mar = c(2, 8, 2, 2)) barplot(prop.table(example.table, 1), beside = TRUE) textplot(round(prop.table(example.table, 1), 2), halign = 'left', mar = c(0,0,0,0), show.colnames = FALSE, cex = 2, cmar = 5) On Fri, Sep 11, 2009 at 3:20 PM, Andy Choens andy.cho...@gmail.com wrote: I am trying to automate a report that my company does every couple of years for the state of Maine. In the past we have used SPSS to run the data and then used complicated Excel template to make the tables/graphics which we then imported into Word. Since there are 256 tables/graphics for this report, this work flow is a little painful. I would like to automate the process and I think I can do so with odfWeave and R, but I've run into a problem. I can't seem to get the output from R to look like what we have used in the past. Here's an example of what I need it to look like (sorry for the long URL) http://1.bp.blogspot.com/_TRRvdLHNnE8/SqpP5gFG3DI/BgY/09x- LoLtfTI/s1600-h/example+graphic.pnghttp://1.bp.blogspot.com/_TRRvdLHNnE8/SqpP5gFG3DI/BgY/09x-%0ALoLtfTI/s1600-h/example+graphic.png My boss is open to using another tool (R) to get the work done but my final output needs to look, more or less, like what we did last time. I can make a table and I can make a bar graph that, essentially gets me where I want to go (I can handle the tweaking) but I don't know how to put them together and make things line up, as in my example (URL). I have looked at iplot, ggplot, lattice, etc. I will confess that my knowledge of R's graphical capabilities leaves a lot to be desired (as I am proving today) but I really can not find an example or feature that seems to do what I am trying to do. I am more or less satisfied with the plot, but I really would like to line up the table with the graphics, which is why I don't just put a table under the graph via odfweave. Here's what I have thus far: ### # These numbers are just BS I made up. counties - c(County1,County2,County1,County2,County1,County2,County1,County2,County1,County2,County1,County2,County1,County2,County1,County2,County1,County2,County1,County2,County1,County2,County1,County2) gender - c(Male, Male,Male, Male, Male, Female,Female, Female,Male, Male,Male, Female,Male, Female,Male, Female,Male, Female,Female, Female,Male, Female,Male, Male) weight - c(1,2,1,2,1,2,2,1,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2) example.table-xtabs(weight~counties+gender) barplot(prop.table(example.table,1),beside=T) ### I am open to using any of the various graphics systems provided in R. I am willing/capable of learning and in fact, I want to learn how to do this but I can't even figure out which system I should spend my time learning more about and I don't have time to become an expert with all of them. Thank you. __ 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.
[R] R help:
Hi I have written a code to do some averaging of data over uneven intervals. The for loop keeps missing particular depths and I once got an error message reading: *** caught segfault *** address 0xc023, cause 'memory not mapped' Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace The portion of the code that is giving me problems is: if(length(which( interp.depth == highres.depth[i] )) 0 ) { print(paste(depth = ,highres.depth[i],sep=)) depth.tracker - c(highres.depth[i],depth.tracker) caco3.interp.vector - c(mean(caco3.interp),caco3.interp.vector) caco3.interp - numeric(0) } When the routine misses a depth, it returns a length of zero for (say) depth = 1.4, or highres.depth[141]. but when i type in the value 1.4, I get the proper answer. Any idea what is going on here? thanks Matt __ Matthew S. Fantle Assistant Professor Department of Geosciences Penn State University 212 Deike Bldg. University Park, PA 16802 Phone: 814-863-9968 mfan...@psu.edu Departmental Homepage http://www.geosc.psu.edu/people/faculty/personalpages/mfantle/index.html [[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 to Label Certain Lags for a PACF Graph
When I use the command for PACF, lags 5, 10, 15, and 20 are labeled. I would like to label lag 1. I would greatly appreciate if someone could tell me how to do this. Below is the command that I am using: pacf(data$R1,main=Series R1 Residuals) [[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] Matrix multiplication and random numbers
Hi Sorry I don't seem to have explained what I'm trying to do very clearly. The piece of code below multiplies the two matrices together a number of times based on the value in the matmult(InitialPop,1) term in this case one (year), this gives me the end population for the analysis. InitialPop-matrix(c(500,0,0,0,0,0,0)) matmult-function(InitialPop,N){ mat3-matrix(c(0,rnorm(1,0.6021,0.0987),0,0,0,0,0,0,0,rnorm(1,0.6021,0.0987),0,0,0,0,1.9,0,0,rnorm(1,0.6021,0.0987),0,0,0,4.8,0,0,0,rnorm(1,0.6021,0.0987),0,0,9.7,0,0,0,0,rnorm(1,0.6021,0.0987),0,18,0,0,0,0,0,rnorm(1,0.6021,0.0987),32.6,0,0,0,0,0,0),nrow=7) for (i in 1:N){ PVAmatrix-matrix(c(0,rnorm(1,0.6021,0.0987),0,0,0,0,0,0,0,rnorm(1,0.6021,0.0987),0,0,0,0,1.9,0,0,rnorm(1,0.6021,0.0987),0,0,0,4.8,0,0,0,rnorm(1,0.6021,0.0987),0,0,9.7,0,0,0,0,rnorm(1,0.6021,0.0987),0,18,0,0,0,0,0,rnorm(1,0.6021,0.0987),32.6,0,0,0,0,0,0),nrow=7) mat3-mat3%*%PVAmatrix } ans-mat3 %*% InitialPop return(ans) } matmult(InitialPop,1) The problem i have is to repeat this process say 1000 times and store this output in a format I can export easily whilst maintaining the randomness of the result, so that every end population is different. Any help would be brilliant Tom Chris Stubben wrote: RFish wrote: I new to using R and am struggling with some matrix multiplication. I'm not sure what you're trying to print, but you could place this vector in an expression mat3-expression(c(0,rnorm(1,0.6021,0.0987),0,0,0,0,0,0,0,rnorm(1,0.6021,0.0987),0,0,0,0,1.9,0,0,rnorm(1,0.6021,0.0987),0,0,0,4.8,0,0,0,rnorm(1,0.6021,0.0987),0,0,9.7,0,0,0,0,rnorm(1,0.6021,0.0987),0,18,0,0,0,0,0,rnorm(1,0.6021,0.0987),32.6,0,0,0,0,0,0)) # and then evaluate to get a new matrix each time matrix(eval(mat3), nrow=7) #I think this may be easier to follow. First create a matrix of zeros, stick in fertilities and then add random survival probabilities each time mat3-diag(0,7) #fertilities mat3[1,3:7]-c(1.9, 4.8, 9.7, 18, 32.6) # random survival on sub-diagonal mat3[row(mat3)==col(mat3)+1]-rnorm(6,0.6021,0.0987) # and if you want to project the population over 10 time steps in a loop ? n-matrix(c(500,0,0,0,0,0,0)) popsize - matrix(numeric(7 * 10), nrow = 7) for (i in 1:10) { popsize[, i] - n mat3[row(mat3)==col(mat3)+1]-rnorm(6,0.6021,0.0987) n - mat3 %*% n } [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 500 0. 0. 531.6256 709.89940 940.19337 1697.52862 3403.6610 [2,]0 352.5116 0. 0. 298.97874 424.71160 561.32525 1027.1605 [3,]0 0. 279.8029 0. 0.0 231.45988 316.83352 424.8883 [4,]0 0. 0. 147.8957 0.0 0.0 136.36804 220.7370 [5,]0 0. 0. 0. 96.92715 0.00.0 108.6551 [6,]0 0. 0. 0. 0.0 69.875270.0 0. [7,]0 0. 0. 0. 0.0 0.0 65.86229 0. Chris Stubben -- View this message in context: http://www.nabble.com/Matrix-multiplication-and-random-numbers-tp25365184p25403899.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] NLME
I am trying to use one of the variance function classes (e.g., varClasses -varConstPower or varPower) When I run the model under default conditions or specify varIdent explicitly I do not have any problems. If I try to use anything else I get error messages of the form Error in na.fail.default(list(USUBJID = c(1636L, 1636L, 1636L, 1636L, : missing values in object I have simplified my data to the bare minimum, I am positive there are no missing records, and my initial parameter estimates are in a range where the model happily converges otherwise. I am a bit unsure as to what is going on. Does anyone have anything to suggest for diagnosing this problem? Thanks -- View this message in context: http://www.nabble.com/NLME-tp25405582p25405582.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] How to Label Certain Lags for a PACF Graph
Hi Stephanie, Take a look at the xaxt argument under ?par as well as ?axis. Here is an example modified from ?pacf : acf(lh, xaxt = n) axis(1, 0:16, 0:16, cex.axis = 0.8) HTH, Jorge On Fri, Sep 11, 2009 at 12:02 PM, Stephanie Cooke cooke.stepha...@gmail.com wrote: When I use the command for PACF, lags 5, 10, 15, and 20 are labeled. I would like to label lag 1. I would greatly appreciate if someone could tell me how to do this. Below is the command that I am using: pacf(data$R1,main=Series R1 Residuals) [[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. [[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 Label Certain Lags for a PACF Graph
Try this: pacf(data$R1, main = Series R1 Residuals, xaxt = 'n') axis(1, c(1, axTicks(1))) On Fri, Sep 11, 2009 at 1:02 PM, Stephanie Cooke cooke.stepha...@gmail.comwrote: When I use the command for PACF, lags 5, 10, 15, and 20 are labeled. I would like to label lag 1. I would greatly appreciate if someone could tell me how to do this. Below is the command that I am using: pacf(data$R1,main=Series R1 Residuals) [[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] Moving to Mac OS X
Hi, I'm a daily user of both mac and Linux so wanted to offer some thoughts: 1) R runs great on a Mac. There is a standard install from the cran website that has a nice GUI built into it. You can do things like drag files to the console and it will fill in the path name. 2) I like using BBedit for all my programming needs. IMHO BBedit is the most powerful editor I've seen in my many years of programming. There is a small plugin that understands the R language. My general workflow is to write code in BBedit and then run it in R using the source function. 3) I purposefully chose NOT to install 64bit R. I have a dual-core machine. With the 32 bit version, R will happily keep one core running at 100%, but then I have other core free for my regular work. -- N On 9/11/09 10:32 AM, Marc Schwartz wrote: On Sep 11, 2009, at 12:15 PM, Victor Manuel Garcia Guerrero wrote: Hi all, I have been using R on Windows for a long time, but now I am ready to move to Mac OS X, but I was just wondering if R works better on Mac than on Windows. This is because I had some memory size issues in the past. Another question is if some of you know an R editor for Mac (just like Tinn-R). Thanks. The notion of better is always in the eyes of the useR and will depend upon specific criteria. OSX can run R in both 32 bit and 64 bit modes and indeed the default OSX download for R provided by Simon installs and supports both. If you use the 32 bit version, then from a memory management standpoint, you will not see demonstrable gains over Windows. However, with the 64 bit version, you will avail yourself of a much larger memory address space as compared to running 32 bit R on Windows. That of course presumes that you have a lot of RAM in your Mac to actually take advantage of the larger address space. The 64 bit memory address space is also available via Linux, with appropriate hardware. You might want to review the R OSX FAQ: http://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html and also note that there is a OSX specific e-mail list: https://stat.ethz.ch/mailman/listinfo/r-sig-mac As far as editors, I am not familiar with the details of Tinn-R, but ESS/Emacs is available for OSX and this is what I use (continuing what I had been using on Linux for the past number of years). Others will likely be able to provide other recommendations and you might want to search the R-SIG-Mac list archives as no doubt there have been such discussions in the past. 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. __ 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.