Re: [R] Polygons in Windows metafile
On 01/27/2010 10:58 AM, Steve Taylor wrote: Hi all, I'm producing some pie charts (Yes I know!) and plotting them into a Windows metafile. This is for insertion into a Word document. The circles come out rather jagged when you zoom in on them, the cause of which I have perhaps narrowed down to the way polygon() works in the metafile device. The polygon coordinates seem to be quantised to the pixels, which is odd for a vector graphics format. Try this to see what I mean: win.metafile('test.emf') par(mfrow=c(2,2)) for(i in 1:4) pie(sample(5,4,repl=TRUE)) dev.off() Is there a way to get a better quality EMF file of this output? PDF output looks great, but Word doesn't seem to understand inserting a PDF graphics file. Word also did something strange with EPS output. Hi Steve, I don't have Word here to test your code, but OpenOffice is free and it does a _much_ better job on things like this. Just a suggestion. 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] Apply a function on an array with the parameter as an array
Hi: On Tue, Jan 26, 2010 at 1:19 PM, jim holtman jholt...@gmail.com wrote: You can do something like this: lapply(1:nrow(X), function(.indx, param){ X[.indx,] * param[.indx] # apply param[i] to row i of X }, param=arrayOf Params) As a follow-up to Jim's reply, another solution to the problem where the rows of a matrix comprise the arguments of a function to be multiply applied is to use the mdply function in the plyr package, a nice convenience wrapper for the mapply() function. Here is a simple, reproducible example... f - function(a, b, c, x) a * x^2 + b * x + c df - data.frame(a = c(1, 2, 1, 2), b = c(0, 3, 2, 0), c = c(0, 2, 1, 3), x = c(1, 4, 5, 2)) df is a data frame whose columns contain the arguments of the function, in order of appearance. When executed in mdply, each row is input as argument to the function: library(plyr) mdply(df, f) # Arg 1: data frame of parameters; arg 2: function name My #$*% gmail editor won't let me type in the result without discarding everything else above it, but when you try it you'll see that it works. IMO, this is one of the hidden gems of the plyr package. HTH, Dennis [[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] Polygons in Windows metafile
Steve Taylor wrote: Hi all, I'm producing some pie charts (Yes I know!) and plotting them into a Windows metafile. This is for insertion into a Word document. The circles come out rather jagged when you zoom in on them, the cause of which I have perhaps narrowed down to the way polygon() works in the metafile device. The polygon coordinates seem to be quantised to the pixels, which is odd for a vector graphics format. Try this to see what I mean: win.metafile('test.emf') par(mfrow=c(2,2)) for(i in 1:4) pie(sample(5,4,repl=TRUE)) dev.off() Is there a way to get a better quality EMF file of this output? PDF output looks great, but Word doesn't seem to understand inserting a PDF graphics file. Word also did something strange with EPS output. You should be able to insert the PDF version into Word with 'Insert Object'. I don't know if it'll improve the look. Does setting pie(..., edges=1000) help? -Peter Ehlers cheers, Steve [[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. -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] RMySQL - Bulk loading data and creating FK links
I have a table (contact) with several fields and it's PK is an auto increment field. I'm bulk loading data to this table from files which if successful will be about 3.5million rows (approx 16000 rows per file). However, I have a linking table (an_contact) to resolve a m:m relationship between the an and contact tables. How can I retrieve the PK's for the data bulk loaded into contact so I can insert the relevant data into an_contact. I currently load the data into contact using: dbWriteTable(con, contact, dat, append=TRUE, row.names=FALSE) But I then need to get all the PK's which this dbWriteTable() appended to the contact table so I can load the data into my an_contact link table. I don't want to issue a separate INSERT query for each row in dat and then use MySQLs LAST_INSERT_ID() functionnot when I have 3.5million rows to insert! Any pointers welcome, Nathan -- Dr. Nathan S. Watson-Haigh OCE Post Doctoral Fellow CSIRO Livestock Industries University Drive Townsville, QLD 4810 Australia Tel: +61 (0)7 4753 8548 Fax: +61 (0)7 4753 8600 Web: http://www.csiro.au/people/Nathan.Watson-Haigh.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ordisymbol - changing symbols used in plotting factor levels
On Tue, 2010-01-26 at 19:59 -0400, Colin Curry wrote: Hello, I'm trying plot points in an NMDS according to a factor with two levels: fig-ordiplot(canod.sol, type=none,cex.axis=0.9,cex.lab=0.1,pty=m,tck=-0.01) ordisymbol(fig, y = hab, factor = habitat, rainbow = T,col = env, legend = F) This gets me part of the way - It produces a plot with blue triangles for the first factor level and red circles for the second level. What I want to do is change the symbols so they all plot as circles, then change the colours used to plot each factor level (e.g. I want blue circles and red circles). Any advice on how to do this? You can't, not with the way that function is currently implemented. It would have helped if you'd told us that this was in BiodiversityR --- originally I thought it was in vegan. You have to hack the code yourself. The example below, I think, will now do what you want: `Myordisymbol` - function(ordiplot,y,factor,col=1,rainbow=T,legend=T,...) { ordiscores - scores(ordiplot, display=sites) groups - table(y[,factor]) m - length(groups) if (m 25) { warning(Symbol size was kept constant as there were more than 25 categories ( number of symbols that are currently used in R)) rainbow - T } levels - names(groups) if (rainbow == T) {palette(rainbow(m))} for (i in 1:m) { subs - y[,factor]==levels[i] for (q in 1:length(subs)) { if(is.na(subs[q])) {subs[q]-F} } scores - ordiscores[subs,,drop=F] if (rainbow == T m 26) { ## Keep plotting char same for all groups ##points(scores[,1],scores[,2],pch=i,col=i,...) points(scores[,1],scores[,2],pch=1,col=i,...) } if (rainbow == T m 25) { points(scores[,1],scores[,2],pch=19,col=i,...) } if (rainbow == F) { ## Keep plotting char same for all groups ##points(scores[,1],scores[,2],pch=i,col=col,...) points(scores[,1],scores[,2],pch=1,col=col,...) } } if (legend==T) { if (rainbow==T m26) {legend(locator(1),legend=levels,pch=c(1:m),col=c(1:m))} if (rainbow==T m25) {legend(locator(1),legend=levels,pch=rep(19,m),col=c(1:m))} if (rainbow==F) {legend(locator(1),legend=levels,pch=c(1:m))} } palette(default) } But that isn't using your (nor was it ever if the call you show above is correct) setting of 'col' to 'env'. As you have rainbow = TRUE and m *is* 26 (m == 2 in your case), the colour used to plot is colour i = {1,...,m} using the rainbow palette. Anyway, HTH G Thanks, Colin Curry -- Colin Curry Ph.D. Candidate Canadian Rivers Institute Department of Biology University of New Brunswick, Fredericton [[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. -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] term.formula error when updating an nls object
Hi, I'm getting an error that I don't understand when updating an nls object. Here is a toy example. dd - structure(list(Contrast = c(0.00376, 0.03759, 0.12782, 0.25564, 0.50376, 1), Response = c(0.29915, 6.13248, 29.01709, 30.0641, 29.46581, 27.67094)), .Names = c(Contrast, Response), class = data.frame, row.names = c(NA, -6L)) m1 - nls(Response ~ Rm * Contrast^ex/(Contrast^ex + sig^ex), data = dd, start = list(Rm = 30, sig = 0.05, ex = 3)) m2 - update(m1, . ~ Rm * Contrast^ex/(Contrast^fx + sig^fx), start = list(Rm = 30, sig = 0.05, ex = 3, fx = 3.1)) Error in terms.formula(tmp, simplify = TRUE) : invalid power in formula but there is nothing wrong with fitting the second model directly with nls m2a - nls(Response ~ Rm * Contrast^ex/(Contrast^fx + sig^fx), data = dd, start = list(Rm = 30, sig = 0.05, ex = 3, fx = 3.1)) nor with fitting the model with the data transformed (though it is not necessarily the way I would like to fit the model in this case). m2b - update(m1, log(.) ~ log(.)) m3 - update(m2b, . ~ log(Rm * Contrast^ex/(Contrast^fx + sig^fx)), start = list(Rm = 30, sig = 0.05, ex = 3, fx = 3.1)) sessionInfo() R version 2.10.1 Patched (2010-01-25 r51051) i386-apple-darwin9.8.0 locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods [7] base Thanks, in advance, for any help. Ken -- Ken Knoblauch Inserm U846 Stem-cell and Brain Research Institute Department of Integrative Neurosciences 18 avenue du Doyen Lépine 69500 Bron France tel: +33 (0)4 72 91 34 77 fax: +33 (0)4 72 91 34 61 portable: +33 (0)6 84 10 64 10 http://www.sbri.fr/members/kenneth-knoblauch.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to change the tick character of x-axis ?
On 01/27/2010 04:08 PM, Jie TANG wrote: Hello, Now I draw a figure by boxplot ,but I am fail to add the tick information in the axis? How could I ? https://mail.google.com/mail/?ui=2ik=c88089ec0aview=attth=1266e2c8dff41fcbattid=0.1disp=attd now I want to add the tick information in the x-axis as Class1 ,Class2,Class3 instead of X5,X12,V3,V4,V5,V6 What can I do to achieve my goal?thanks Hi Jie, Try this: boxplot(count ~ spray, data = InsectSprays, col = lightgray,xaxt=n) axis(1,at=1:6,labels=paste(Class,1:6,sep=)) Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to sort data.frame
Dear R heleprs Suppose I have following data Scenarios combination_names series1 series2 Sc1 MAT2 GAU1 7.26554 8.409778 Sc2 MAT2 GAU2 7.438128 8.130275 Sc3 MAT3 GAU1 8.058422 8.06457 Sc4 MAT1 GAU2 8.179855 8.022071 Sc5 MAT3 GAU2 8.184033 8.191831 Sc6 MAT3 GAU2 7.50312 8.232425 Sc7 MAT1 GAU2 7.603291 8.200993 Sc8 MAT1 GAU1 8.221755 8.380097 Sc9 MAT3 GAU2 7.904908 8.088824 Sc10 MAT1 GAU3 7.67034 8.46376 I wish to sort thise data frame based on combination_names. Actually this is just an indicative data. I am deling with the data haveing 5000+ records. I just need to find out how to sort this data s.t, I will get say following result Scenarios combination_names series1 series2 Sc8 MAT1 GAU1 8.221755 8.380097 Sc4 MAT1 GAU2 8.179855 8.022071 Sc7 MAT1 GAU2 7.603291 8.200993 Sc10 MAT1 GAU3 7.67034 8.46376 and so I tried to understand the examples given in ?base::order but couldn't cracke it. Please guide Madhavi The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. [[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] plotting the coordinates versus dates
Hello! I have a dataset with the dates and positions - Lat and Long columns How do I make a scatter plot? Do I have to cbind to combine the Lat and Long columns? Any suggestions will be much appreciated! Thank you Julia [[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] add points to 3D plot using p3d {onion}
Hello Bradley I don't think there's an easy way to do what you want because the viewing angles are internal to p3d(). Frankly p3d() tries to be all things to all men (the arguments are a mess) and inevitably isn't as flexible as one might wish. I take it you want to do this: data(bunny) p3d(head(bunny,100),d0=2,theta=3) points(tail(bunny), col='blue') You'd want the call to points() to remember theta=3, and possibly d0=2 as well. Although I can see a hack I'd be very happy to help you offline. best wishes Robin Bradley Christoffersen wrote: Hi, Can anyone guide me as to how I can add points to a p3d() plot from the onion package? I want to plot points with different colors on the same 3D plot. Perhaps I can do this without adding points but somehow directing the 'h' parameter to give different color to points based on a factor I assign to them? FYI, I can do this using using scatterplot3d() and points3d(), but these plots lack perspective and hence it is hard to sense depth without the use of color. Thanks, Brad __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Robin K. S. Hankin Uncertainty Analyst University of Cambridge 19 Silver Street Cambridge CB3 9EP 01223-764877 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 attach chart to excel file?
Hi, How can I attach chart/plot to a excel file? I would like to create a plot in R eg. plot(1) and save it into a Excel file, eg. test.xls in a same working directory. Regrads, -J __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] RMySQL - Bulk loading data and creating FK links
Hi Nathan, I have a table (contact) with several fields and it's PK is an auto increment field. I'm bulk loading data to this table from files which if successful will be about 3.5million rows (approx 16000 rows per file). However, I have a linking table (an_contact) to resolve a m:m relationship between the an and contact tables. How can I retrieve the PK's for the data bulk loaded into contact so I can insert the relevant data into an_contact. I currently load the data into contact using: dbWriteTable(con, contact, dat, append=TRUE, row.names=FALSE) But I then need to get all the PK's which this dbWriteTable() appended to the contact table so I can load the data into my an_contact link table. I don't want to issue a separate INSERT query for each row in dat and then use MySQLs LAST_INSERT_ID() functionnot when I have 3.5million rows to insert! Any pointers welcome, Nathan It looks to me more like sql question. Why don't you use sql to write a query which will join all tables for you and then use RMySQL to retrieve relevant data? Of course, you could also dbGetQuery. Can you please explain a bit how you entity-relationship diagram looks like? Cheers, Olga __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plotting the coordinates versus dates
On 01/27/2010 08:31 PM, Julia Tchernova wrote: Hello! I have a dataset with the dates and positions - Lat and Long columns How do I make a scatter plot? Do I have to cbind to combine the Lat and Long columns? Any suggestions will be much appreciated! Hi Julia, I depends greatly on what you want to plot. Let's assume that you want to plot the dates at the geographical positions (named lat and lon), and that the dates are character strings. plot(lon,lat,main=Dates of the observations, xlab=Longitude,ylab=Latitude,type=n) text(lon,lat,dates) This assumes that you haven't got too many dates, and a fair bit of latitude (and longitude). It should give you an idea of one type of plot. 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] Microsoft SQL Server and R
Hi David, I have a client running Microsoft SQL Server. I am interested in ways of accessing data from this server using R. Why don't you try RMySQL package? It works fine for me. [[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 sort data.frame
Hi, Look at the sort_df function from the reshape package. cheers, Paul Madhavi Bhave wrote: Dear R heleprs Suppose I have following data Scenarios combination_names series1 series2 Sc1 MAT2 GAU1 7.26554 8.409778 Sc2 MAT2 GAU2 7.438128 8.130275 Sc3 MAT3 GAU1 8.058422 8.06457 Sc4 MAT1 GAU2 8.179855 8.022071 Sc5 MAT3 GAU2 8.184033 8.191831 Sc6 MAT3 GAU2 7.50312 8.232425 Sc7 MAT1 GAU2 7.603291 8.200993 Sc8 MAT1 GAU1 8.221755 8.380097 Sc9 MAT3 GAU2 7.904908 8.088824 Sc10 MAT1 GAU3 7.67034 8.46376 I wish to sort thise data frame based on combination_names. Actually this is just an indicative data. I am deling with the data haveing 5000+ records. I just need to find out how to sort this data s.t, I will get say following result Scenarios combination_names series1 series2 Sc8 MAT1 GAU1 8.221755 8.380097 Sc4 MAT1 GAU2 8.179855 8.022071 Sc7 MAT1 GAU2 7.603291 8.200993 Sc10 MAT1 GAU3 7.67034 8.46376 and so I tried to understand the examples given in ?base::order but couldn't cracke it. Please guide Madhavi The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. [[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. -- 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.
Re: [R] sp package coordinates and gridded problems with as.list()
Rhelp wanted wrote: Dear All I hope that someone can help. I am working with sp pakage and akima library(akima) library(sp) imagine lots of different dataframes, of row = 100 columns = 3 of x and y coordinates with z values I will call these data frames for the sake of this example akima akima-as.list(1:100) producing 100 dataframes dataframes of the form akima[[i]] I then wish to interp this list of coordinates: akima.li-as.list(1:100) for (i in 1:100) akima.li[[i]]-interp(akima[[i]]$x, akima[[i]]$y, akima [[i]]$z) so now I have 100 akima.li which I then transform into a dataframe of the akima.li values y-as.list(1:100) x-as.list(1:100) z-as.list(1:100) for (i in 1:endofrun){ y[[i]]= rep(akima.li[[i]]$x, each = length(akima.li[[i]]$y)) x[[i]] = rep(akima.li[[i]]$y, length(akima.li[[i]]$x)) z[[i]] = as.numeric(akima.li[[i]]$z) } abc-as.list(1:100) for (i in 1:endofrun){ abc[[i]]- data.frame(x[[i]], y[[i]], z[[i]]) abc[[i]][is.na(abc[[i]])] - 0} so now I have 100 dataframes with x and y columns and corresponding z values and any NAs are now 0. This is where my problem starts I wish to use sp to state which columns are coordinates of the form for (i in 1:100) coordinates(abc[[i]])= ~x+y and that all of the dataframes are a grid, such that. for (i in 1:100) gridded(abc[[i]]) = TRUE however I get error messeges such as: Error in function (classes, fdef, mtable) : unable to find an inherited method for function coordinates-, for signature integer the input to coordinates should be a data.frame, which abc[[i]] obviously isn't. Look at the meuse dataset from the sp-package for a sample of how such a data.frame should look like. cheers, Paul ps The r-sig-geo mailing list would be a better place to ask this question and I do not know what this means. I will then want to then go on to overlay such: datapoint = data.frame(x = 10, y = 20) coordinates(datapoint) = ~x+y gridded(datapoint)=TRUE value-as.list(1:100) for (i in 1:100) value [[i]]= abc[[...@data[overlay(abc[[i]], datapoint),] then I will have a list of 100 value for each original dataframe I would be appreciative if someone could tell me how I can allocate coordinate and grided systems to an dataframes which are as.list. I hope that is comprehendable and someone can help. I am very stuck many thanks Sylvestre [[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. -- 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] selecting significant predictors from ANOVA result
Dear all, I did ANOVA for many response variables (Var1, Var2, Var75000), and i got the result of p-value like below. Now, I want to select those predictors, which have pvalue less than or equal to 0.05 for each response variable. For example, X1, X2, X3, X4, X5 and X6 in case of Var1, and similarly, X1, X2...X5 in case of Var2, only X1 in case of Var3 and none of the predictors in case of Var4. predictors Var1 Var2 Var3 Var4 X1 0.5 0.001 0.05 0.36 X2 0.0001 0.001 0.09 0.37 X3 0.0002 0.005 0.13 0.38 X4 0.0003 0.01 0.17 0.39 X5 0.01 0.05 0.21 0.4 X6 0.05 0.0455 0.25 0.41 X7 0.038063 0.0562 0.29 0.42 X8 0.04605 0.0669 0.33 0.43 X9 0.054038 0.0776 0.37 0.44 X10 0.062025 0.0883 0.41 0.45 I have very large data sets (# of response variables = ~75,000). So, i need some kind of automated procedure. But i have no ideas. If i got help from some body, it will be great for me. Thanks in advance. Sincerely, Ram Kumar Basnet, Ph. D student Wageningen University, The Netherlands. [[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] GARCH (1,1) negative volatility???
Dear all, I am using GARCH (1,1) model to simulate volatility. But seems that I am missing something about how it works in R. The following code produces negative results, though vola cannot be. What is wrong here? library(fSeries) library(fGarch) spec = garchSpec(model = list(omega = 0.01, alpha = 0.13, beta = 0.86)) gat - garchSim(spec, n = 10) Thanks a lot! [[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] term.formula error when updating an nls object
Ken, You just need to wrap the rhs of your formula in I() to get around update()'s parsing of terms. m2 - update(m1, . ~ I(Rm * Contrast^ex/(Contrast^fx + sig^fx)), start = list(Rm = 30, sig = 0.05, ex = 3, fx = 3.1)) -Peter Ehlers Ken Knoblauch wrote: Hi, I'm getting an error that I don't understand when updating an nls object. Here is a toy example. dd - structure(list(Contrast = c(0.00376, 0.03759, 0.12782, 0.25564, 0.50376, 1), Response = c(0.29915, 6.13248, 29.01709, 30.0641, 29.46581, 27.67094)), .Names = c(Contrast, Response), class = data.frame, row.names = c(NA, -6L)) m1 - nls(Response ~ Rm * Contrast^ex/(Contrast^ex + sig^ex), data = dd, start = list(Rm = 30, sig = 0.05, ex = 3)) m2 - update(m1, . ~ Rm * Contrast^ex/(Contrast^fx + sig^fx), start = list(Rm = 30, sig = 0.05, ex = 3, fx = 3.1)) Error in terms.formula(tmp, simplify = TRUE) : invalid power in formula but there is nothing wrong with fitting the second model directly with nls m2a- nls(Response ~ Rm * Contrast^ex/(Contrast^fx + sig^fx), data = dd, start = list(Rm = 30, sig = 0.05, ex = 3, fx = 3.1)) nor with fitting the model with the data transformed (though it is not necessarily the way I would like to fit the model in this case). m2b - update(m1, log(.) ~ log(.)) m3 - update(m2b, . ~ log(Rm * Contrast^ex/(Contrast^fx + sig^fx)), start = list(Rm = 30, sig = 0.05, ex = 3, fx = 3.1)) sessionInfo() R version 2.10.1 Patched (2010-01-25 r51051) i386-apple-darwin9.8.0 locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods [7] base Thanks, in advance, for any help. Ken -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Edit a Sptial Lines Object
at the end of an object (attached) component (BP[1]). But Im not able to do so. I cant isolate the coordinates, if I use the �...@lines it turns into a list, but I need to keep the SpatialLines and S4 structure, then I will be able to transform the closed lines into polygons. So, How can I insert the coordinates that will close the BP[1] line into this object without changing the object properties. Any Ideas? Thank you in advance. - MSc. Rodrigo Aluizio mailto:r.alui...@gmail.com Centro de Estudos do Mar/UFPR Laboratório de Micropaleontologia __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] hdf files
hello, I have a problem to open an hdf file. i have downloaded the package 'hdf5' as it was advised on R seek. But when i try to load the file, the R console sends me an eror message: setwd(C:/Documents and Settings/Karine/Bureau/data/) #install.packages('hdf5') library(hdf5) sea_ice - hdf5load(asi-s6250-20090704-v5i.hdf, load = TRUE, verbosity = 3, tidy = FALSE) Grid_ice - hdf5load(LongitudeLatitudeGrid-s6250-Antarctic.hdf, load = TRUE, verbosity = 3, tidy = FALSE) sea_ice - hdf5load(asi-s6250-20090704-v5i.hdf, load = TRUE, verbosity = 3, tidy = FALSE) hdf5_global_verbosity=3 load=1 Erreur dans hdf5load(asi-s6250-20090704-v5i.hdf, load = TRUE, verbosity = 3, : unable to open HDF file: asi-s6250-20090704-v5i.hdf Grid_ice - hdf5load(LongitudeLatitudeGrid-s6250-Antarctic.hdf, load = TRUE, verbosity = 3, tidy = FALSE) hdf5_global_verbosity=3 load=1 Erreur dans hdf5load(LongitudeLatitudeGrid-s6250-Antarctic.hdf, load = TRUE, : unable to open HDF file: LongitudeLatitudeGrid-s6250-Antarctic.hdf Thanks a lot, Karine HEERAH Master 2 mention océanographie et environnements marins, parcours océanique 42 rue Salvador Allende 92000 Nanterre 06.61.50.97.47 Faites une bonne action avec Bing Solidaire ! C'est ici ! _ [[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] term.formula error when updating an nls object
Thanks, I hadn't thought of that. It works fine, now. I'll look out for that in the future. Ken Quoting Peter Ehlers ehl...@ucalgary.ca: Ken, You just need to wrap the rhs of your formula in I() to get around update()'s parsing of terms. m2 - update(m1, . ~ I(Rm * Contrast^ex/(Contrast^fx + sig^fx)), start = list(Rm = 30, sig = 0.05, ex = 3, fx = 3.1)) -Peter Ehlers Ken Knoblauch wrote: Hi, I'm getting an error that I don't understand when updating an nls object. Here is a toy example. dd - structure(list(Contrast = c(0.00376, 0.03759, 0.12782, 0.25564, 0.50376, 1), Response = c(0.29915, 6.13248, 29.01709, 30.0641, 29.46581, 27.67094)), .Names = c(Contrast, Response), class = data.frame, row.names = c(NA, -6L)) m1 - nls(Response ~ Rm * Contrast^ex/(Contrast^ex + sig^ex), data = dd, start = list(Rm = 30, sig = 0.05, ex = 3)) m2 - update(m1, . ~ Rm * Contrast^ex/(Contrast^fx + sig^fx), start = list(Rm = 30, sig = 0.05, ex = 3, fx = 3.1)) Error in terms.formula(tmp, simplify = TRUE) : invalid power in formula but there is nothing wrong with fitting the second model directly with nls m2a- nls(Response ~ Rm * Contrast^ex/(Contrast^fx + sig^fx), data = dd, start = list(Rm = 30, sig = 0.05, ex = 3, fx = 3.1)) nor with fitting the model with the data transformed (though it is not necessarily the way I would like to fit the model in this case). m2b - update(m1, log(.) ~ log(.)) m3 - update(m2b, . ~ log(Rm * Contrast^ex/(Contrast^fx + sig^fx)), start = list(Rm = 30, sig = 0.05, ex = 3, fx = 3.1)) sessionInfo() R version 2.10.1 Patched (2010-01-25 r51051) i386-apple-darwin9.8.0 locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods [7] base Thanks, in advance, for any help. Ken -- Peter Ehlers University of Calgary -- Ken Knoblauch Inserm U846 Stem-cell and Brain Research Institute Department of Integrative Neurosciences 18 avenue du Doyen Lépine 69500 Bron France tel: +33 (0)4 72 91 34 77 fax: +33 (0)4 72 91 34 61 portable: +33 (0)6 84 10 64 10 http://www.sbri.fr/members/kenneth-knoblauch.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to attach chart to excel file?
Try this: library(RDCOMClient) # from omegahat.org xl - COMCreate(Excel.Application) xl[[Visible]] - TRUE xl[[DisplayAlerts]] - FALSE wk - xl$Workbooks()$Add() tf - tempfile() png(tf) plot(rnorm(100), type = 'l') dev.off() wk$ActiveSheet()$Pictures()$Insert(tf) wk$SaveAs(gsub(/, , file.path(getwd(), test.xls))) wk$Close() xl$Quit() xl - NULL On Wed, Jan 27, 2010 at 8:21 AM, johannes rara johannesr...@gmail.com wrote: Hi, How can I attach chart/plot to a excel file? I would like to create a plot in R eg. plot(1) and save it into a Excel file, eg. test.xls in a same working directory. Regrads, -J __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 split a matrix into a few matrices?
Hi dear users, I try to split a matrix into a few matrices, for example, suppose that I have 1000X4 matrix from mvrnorm(1000,m,c) with m-matrix(c(0,0,0,2),4,1) and c-matrix(c(1.0,0.2,-0.5,0.3,0.2,1,0.2,-0.5,-0.5,0.2,1,0.2,0.3,-0.5,0.2,1),4,4,byrow=T) How to split the matrix into a. 2 matrices which the first one consists of the first 500 rows, and the second one consist of the last 500 rows b. split the matrix equally and sequentially (according to the order of the rows) into say 10 matrices with 100 x 4 dimension c. how to do (b) randomly, not following the order of the rows, but without any overlapping. So all the 10 matrices will consists of different values from the original matrix. Your help is very much appreciatedthank you ayu -- View this message in context: http://n4.nabble.com/How-to-split-a-matrix-into-a-few-matrices-tp1311535p1311535.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 split a matrix into a few matrices?
Try this: a - mvrnorm(100, m, c) On Wed, Jan 27, 2010 at 9:50 AM, ayu2008 ayuaz...@yahoo.com wrote: Hi dear users, I try to split a matrix into a few matrices, for example, suppose that I have 1000X4 matrix from mvrnorm(1000,m,c) with m-matrix(c(0,0,0,2),4,1) and c-matrix(c(1.0,0.2,-0.5,0.3,0.2,1,0.2,-0.5,-0.5,0.2,1,0.2,0.3,-0.5,0.2,1),4,4,byrow=T) How to split the matrix into a. 2 matrices which the first one consists of the first 500 rows, and the second one consist of the last 500 rows split(as.data.frame(a), rep(1:2, each = 500)) b. split the matrix equally and sequentially (according to the order of the rows) into say 10 matrices with 100 x 4 dimension split(as.data.frame(a), rep(1:100, each = 10)) c. how to do (b) randomly, not following the order of the rows, but without any overlapping. So all the 10 matrices will consists of different values from the original matrix. split(as.data.frame(a)[sample(1:nrow(a)),], rep(1:10, each = 10)) Your help is very much appreciatedthank you ayu -- View this message in context: http://n4.nabble.com/How-to-split-a-matrix-into-a-few-matrices-tp1311535p1311535.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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Retrieving an evaluated gradient value (UNCLASSIFIED)
Classification: UNCLASSIFIED Caveats: NONE I really appreciate Mr. Dallazuanna's quick reply for my question. See below. Kyong -Original Message- From: Henrique Dallazuanna [mailto:www...@gmail.com] Sent: Thursday, January 21, 2010 3:13 PM To: Park, Kyong H Mr CIV USA AMC Cc: r-help@r-project.org Subject: Re: [R] Retrieving an evaluated gradient value (UNCLASSIFIED) Try this: attr(junk1(k=0,b0=-14.0236,b1=2.44031), 'gradient') On Thu, Jan 21, 2010 at 6:05 PM, Park, Kyong H Mr CIV USA AMC kyong.ho.p...@us.army.mil wrote: Classification: UNCLASSIFIED Caveats: NONE Dear R users, How can I retrieve an evaluated gradient value from deriv function provided below? I want to retrieve b0 value. Appreciate your help. Kyong junk1-deriv(~(1/b1)*k-b0/b1,b0,c(k,b0,b1),formal=T) junk1(k=0,b0=-14.0236,b1=2.44031) [1] 5.746647 attr(, gradient): b0 [1,] -0.409784 Classification: UNCLASSIFIED Caveats: NONE [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O Classification: UNCLASSIFIED Caveats: NONE __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Polygons in Windows metafile
On Jan 27, 2010, at 3:05 AM, Jim Lemon wrote: On 01/27/2010 10:58 AM, Steve Taylor wrote: Hi all, I'm producing some pie charts (Yes I know!) and plotting them into a Windows metafile. This is for insertion into a Word document. The circles come out rather jagged when you zoom in on them, the cause of which I have perhaps narrowed down to the way polygon() works in the metafile device. The polygon coordinates seem to be quantised to the pixels, which is odd for a vector graphics format. Try this to see what I mean: win.metafile('test.emf') par(mfrow=c(2,2)) for(i in 1:4) pie(sample(5,4,repl=TRUE)) dev.off() Is there a way to get a better quality EMF file of this output? PDF output looks great, but Word doesn't seem to understand inserting a PDF graphics file. Word also did something strange with EPS output. Hi Steve, I don't have Word here to test your code, but OpenOffice is free and it does a _much_ better job on things like this. Just a suggestion. OO.o does not import pdf or eps files for me. I generally need to convert to tiff format to get importation into OO.o files. Am I missing an obvious (or obscure) method? I'm generally using a Mac so would not be using win.metafile(). -- David. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Replacing ' (apostrophe) with (two apostrophe)
On 27.01.2010 06:45, Steven Kang wrote: Hi all, I am trying to replace a string containing ' (apostrophe) with (two apostrophes not inverted commas). i.e *asdf'qwer* replaced to *asdfqwer* Is this feasible? gsub(', '', asdf'qwer) Uwe Ligges Thanks . __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] adding / modifiying functions in a site-library package ????
On 27.01.2010 03:40, David Lubbers wrote: I want to add just one more function to an already installed, locally developed site-library package. Is there a good tutorial on this laying about? From what I see the new function would touch several files and directories in the existing package. Tools to automate that ? Yes: 1. change in the source package, let's call it pkg 2. R CMD build pkg 3. R CMD INSTALL --library=yourLibrary pkg_version.tar.gz you might want to check the package in step 2a. Best wishes, Uwe Ligges __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] SSOAP XML-RPC
Hi, I'm trying to use the XML-RPC client in the SSOAP package to connect to a service that I have created. From other languages (Perl, Python, Ruby) this is not a problem but the SSOAP client gives the following error: Error in .XMLRPC(http://localhost:9000;, Cytoscape.test, .opts = list(verbose = TRUE)) : Failed to parse XML-RPC request: Content is not allowed in prolog. It looks like the SSOAP XML-RPC client is not creating the right type of XML-RPC message. Does anyone know how to fix this or has successfully used the SSOAP XML-RPC client? Thanks, Jan -- View this message in context: http://n4.nabble.com/SSOAP-XML-RPC-tp1311562p1311562.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] R Memory Problem
You were asked to provide details, but so far have not. -- David. On Jan 27, 2010, at 2:17 AM, prem_R wrote: Yes i think this is explanation of the problem faced .Could you please help me to solve this . -- View this message in context: http://n4.nabble.com/R-Memory-Problem-tp1289221p1311291.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] Microsoft SQL Server and R
RMySQL is for MySQL. MySQL is not MSSQL. There is not RMSSQL. So the best you have something to conneto MSSQL... RODBC or you may connect. Or as Jim point you use a java client to connect to MSSQL through RJDBC which you may use for example a free jDBC driver like jTDS. Caveman On Wed, Jan 27, 2010 at 12:44 PM, Olga Lyashevska o...@herenstraat.nl wrote: Hi David, I have a client running Microsoft SQL Server. I am interested in ways of accessing data from this server using R. Why don't you try RMySQL package? It works fine for me. [[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. -- OpenSource Software Consultant CENFOSS (www.cenfoss.co.mz) SP Tech (www.sptech.co.mz) email: orvaq...@cenfoss.co.mz cell: +258828810980 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] problem with odfWeave
Hi Joel, Can you paste a minimal example illustrating your problem? Thanks, Ista On Wed, Jan 27, 2010 at 6:19 AM, Joel GOMBIN joel.gom...@gmail.com wrote: Hello, thanks to Sarah for her help. That works fine, except for one thing. When I generate my reports, using odfWeave(), some cells in my tables are filled with the expression I put in the input file (/Sexpr(...)) instead of the result of its evalutation. I suspected there was a problem in the XML code ; indeed, when I look at the content.xml file of the input ODT file, there are some text:soft-page-break/ tags in the middle of cells. Is it any way of instructing OpenOffice not to put these tags, or do I have no other choice than removing them by hand in the content.xml file ? Thanks a lot in advance, Joel On Wed, Jan 6, 2010 at 7:12 PM, Sarah Goslee sarah.gos...@gmail.com wrote: Hi Joel, If you actually want to make a table, you need to use odfTable. There are examples in the help for that function. Same for odfCat, but instead of creating a table, that will print your output. eg to print your output: echo=FALSE= odfCat(some random normal data:, rnorm(5)) # from the help file @ or to make a table: echo=FALSE= x - matrix(1:12, ncol=3) colnames(x) - c(a, b, c) odfTable(x) odfTableCaption(A useless table) @ ODT files are actually compressed XML files. If you just print from within R, there are no XML tags around your output and OpenOffice has no idea what to do with it. The various odfSomething R functions wrap the R output in XML tags so OOo will understand it in the final output. Sarah On Wed, Jan 6, 2010 at 12:41 PM, Joel GOMBIN joel.gom...@gmail.com wrote: Hello, I have encountered problems using odfdWeave. I actually have the same error message as was reported in this message ( http://tolstoy.newcastle.edu.au/R/e6/help/09/01/0872.html), but I don't quite understand the answer made by Max Kuhn (You need to cat the results using odfCAt, otherwise you are just writing the output with no XML around it.). What I am supposed to do exactly ? What I'm trying to do is writing values I have computed earlier in the cells of a table in an ODT file. I'm very grateful in advance for any help... -- Sarah Goslee http://www.functionaldiversity.org [[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. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] date and time functions
Dear R community I would like to perform some statistical analysis on a data set containing the following items: date, time, index of observation and various covariates. The date and time are originally extracted in the following format: dd.mm. and hh:mm:ss respectively. R and more precisely the function read.table() seems to read the data properly. In a second step, I would like to sort and subset the data according to daytime, day of the week, month, season but I get into trouble when trying to use the built-in functions with this format. Which is the most convenient date and time format in R to perform such kind of work? Is there any specific, powerful and well documented package containing various date and time functions? Many thanks in advance Best regards ___ Robert M. Kalicki, MD Postdoctoral Fellow Department of Nephrology and Hypertension Inselspital University of Bern Switzerland Address: Klinik und Poliklinik für Nephrologie und Hypertonie KiKl G6 Freiburgstrasse 15 CH-3010 Inselspital Bern Tel +41(0)31 632 96 63 Fax+41(0)31 632 14 58 [[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] date and time functions
Read the article in R News 4/1. 2010/1/27 Robert Kalicki robert.kali...@mph.unibe.ch: Dear R community I would like to perform some statistical analysis on a data set containing the following items: date, time, index of observation and various covariates. The date and time are originally extracted in the following format: dd.mm. and hh:mm:ss respectively. R and more precisely the function read.table() seems to read the data properly. In a second step, I would like to sort and subset the data according to daytime, day of the week, month, season but I get into trouble when trying to use the built-in functions with this format. Which is the most convenient date and time format in R to perform such kind of work? Is there any specific, powerful and well documented package containing various date and time functions? Many thanks in advance Best regards ___ Robert M. Kalicki, MD Postdoctoral Fellow Department of Nephrology and Hypertension Inselspital University of Bern Switzerland Address: Klinik und Poliklinik für Nephrologie und Hypertonie KiKl G6 Freiburgstrasse 15 CH-3010 Inselspital Bern Tel +41(0)31 632 96 63 Fax +41(0)31 632 14 58 [[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] difference between ' and
Hi everybody, From my experience (which is limited), it seems to me that ' (apostrophe) and (quotation marks) are the same in R: they are both used for strings. The only difference would be taste. But I've recently read about the difference between = and - and I thought that there might be a difference here too in some cases. It might also depend on the operating system. Thanks for your input! Ivan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] problem with odfWeave
Hi, so to sum up, I'm making automated reports, in the form of tables. In each cell of the table is an expression like (e.g.) : \Sexpr{odfCat(round(summary(get(modele1))$coefficients[1,1],2))} For most cells, after I run odfWeave, the results are correctly put and formatted. But in some cells (always the same), the output.odt file has the original expression (e.g. \Sexpr{odfCat(round(summary(get(modele1))$coefficients[1,1],2))}) instead of the result of the evaluation of the expression. When I look at the content.xml code of the input file, I see that in these cells where the evaluation is not proprely run, I have something like : text:p text:style-name=P4 \Sexpr{odfCat(round(summary(get(modele1))$coefficients[2, text:soft-page-break/ 1],2))} /text:p instead of the regular text:p text:style-name=P4 \Sexpr{odfCat(round(summary(get(modele1))$coefficients[2,1],2))} /text:p So my question is : how can I get rid of these text:soft-page-break/ tags that appeared for no apparent reason ? Is there a way to configure OpenOffice Writer so that he won't put such tags ? Thanks a lot, Joel On Wed, Jan 27, 2010 at 1:54 PM, Ista Zahn istaz...@gmail.com wrote: Hi Joel, Can you paste a minimal example illustrating your problem? Thanks, Ista On Wed, Jan 27, 2010 at 6:19 AM, Joel GOMBIN joel.gom...@gmail.com wrote: Hello, thanks to Sarah for her help. That works fine, except for one thing. When I generate my reports, using odfWeave(), some cells in my tables are filled with the expression I put in the input file (/Sexpr(...)) instead of the result of its evalutation. I suspected there was a problem in the XML code ; indeed, when I look at the content.xml file of the input ODT file, there are some text:soft-page-break/ tags in the middle of cells. Is it any way of instructing OpenOffice not to put these tags, or do I have no other choice than removing them by hand in the content.xml file ? Thanks a lot in advance, Joel On Wed, Jan 6, 2010 at 7:12 PM, Sarah Goslee sarah.gos...@gmail.com wrote: Hi Joel, If you actually want to make a table, you need to use odfTable. There are examples in the help for that function. Same for odfCat, but instead of creating a table, that will print your output. eg to print your output: echo=FALSE= odfCat(some random normal data:, rnorm(5)) # from the help file @ or to make a table: echo=FALSE= x - matrix(1:12, ncol=3) colnames(x) - c(a, b, c) odfTable(x) odfTableCaption(A useless table) @ ODT files are actually compressed XML files. If you just print from within R, there are no XML tags around your output and OpenOffice has no idea what to do with it. The various odfSomething R functions wrap the R output in XML tags so OOo will understand it in the final output. Sarah On Wed, Jan 6, 2010 at 12:41 PM, Joel GOMBIN joel.gom...@gmail.com wrote: Hello, I have encountered problems using odfdWeave. I actually have the same error message as was reported in this message ( http://tolstoy.newcastle.edu.au/R/e6/help/09/01/0872.html), but I don't quite understand the answer made by Max Kuhn (You need to cat the results using odfCAt, otherwise you are just writing the output with no XML around it.). What I am supposed to do exactly ? What I'm trying to do is writing values I have computed earlier in the cells of a table in an ODT file. I'm very grateful in advance for any help... -- Sarah Goslee http://www.functionaldiversity.org [[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. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org [[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] href and Rd
Hello * is possible to have something like the LaTeX \href in Rd ? \url doesn't fit very well, and I didn't find much about. I have a long (external to the help system, a www one) url but i would like it to be hidden from a small word with the link. Please CC me! ;) thanks in advance Luca __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] href and Rd
On 27/01/2010 8:36 AM, Luca Braglia wrote: Hello * is possible to have something like the LaTeX \href in Rd ? \url doesn't fit very well, and I didn't find much about. I have a long (external to the help system, a www one) url but i would like it to be hidden from a small word with the link. No, \url is the only way to include a link outside the help system, and it displays the URL. If you really don't want to display it, you could use \link to a separate help page that contained a \url link, but it would not be very convenient. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] href and Rd
One approach would be to use one of the URL shortening services to define a shorter URL. The shorter URL would then appear rather than the long original one (although there would still be a URL shown so its not quite the functionality you asked for). For more info google for: url shortening On Wed, Jan 27, 2010 at 8:36 AM, Luca Braglia lbrag...@gmail.com wrote: Hello * is possible to have something like the LaTeX \href in Rd ? \url doesn't fit very well, and I didn't find much about. I have a long (external to the help system, a www one) url but i would like it to be hidden from a small word with the link. Please CC me! ;) thanks in advance Luca __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] control of scat1d tick color in plot.Predict?
Hi All, I have a quick question about using plot.Predict now that the rms package uses lattice. I'd like to add tick marks along the regression line, which is given by data=llist(variablename) in the plot call. The ticks show up fine, but I'd like to alter the color. I know the ticks are produced by scat1d, but after spending a fair bit of time going through documentation, it still isn't clear to me how to do this in the context of lattice. Guidance would be greatly appreciated. Thanks, Mike Babyak Duke University Medical Center My code using R 2.10.1/windows XP myx-c(1,2,3,4) myy-c(1,2,3,5) library(rms) d-datadist(myx) options(datadist=d) myfit-ols(myy~myx,x=T,y=T) p1-Predict(myfit,myx =.) library(lattice) #change line to black line - trellis.par.get(plot.line) line$col - 1 trellis.par.set(plot.line, line) plot(p1, data=llist(myx),col.fill=lightgray, lwd=1.5) [[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] Microsoft SQL Server and R
Yes, checking it now, I see you are absolutely right. Sorry for this confusion. Cheers, Olga On 27.01.2010, at 12:45, Orvalho Augusto wrote: RMySQL is for MySQL. MySQL is not MSSQL. There is not RMSSQL. So the best you have something to conneto MSSQL... RODBC or you may connect. Or as Jim point you use a java client to connect to MSSQL through RJDBC which you may use for example a free jDBC driver like jTDS. Caveman On Wed, Jan 27, 2010 at 12:44 PM, Olga Lyashevska o...@herenstraat.nl wrote: Hi David, I have a client running Microsoft SQL Server. I am interested in ways of accessing data from this server using R. Why don't you try RMySQL package? It works fine for me. [[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. -- OpenSource Software Consultant CENFOSS (www.cenfoss.co.mz) SP Tech (www.sptech.co.mz) email: orvaq...@cenfoss.co.mz cell: +258828810980 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] RMySQL - Bulk loading data and creating FK links
On Wed, Jan 27, 2010 at 8:56 AM, Matthew Dowle mdo...@mdowle.plus.com wrote: How many columns, and of what type are the columns ? As Olga asked too, it would be useful to know more about what you're really trying to do. 3.5m rows is not actually that many rows, even for 32bit R. Its depends on the columns and what you want to do with those columns. At the risk of suggesting something before we know the full facts, one possibility is to load the data from flat file into data.table. Use setkey() to set your keys. Use tables() to summarise your various tables. Then do your joins etc all-in-R. data.table has fast ways to do those sorts of joins (but we need more info about your task). Alternatively, you could check out the sqldf website. There is an sqlread.csv (or similar name) which can read your files directly into SQL read.csv.sql instead of going via R. Gabor has some nice examples there about that and its faster. You use some buzzwords which makes me think that SQL may not be appropriate for your task though. Can't say for sure (because we don't have enough information) but its possible you are struggling because SQL has no row ordering concept built in. That might be why you've created an increment In the SQLite database it automatically assigns a self incrementing hidden column called rowid to each row. e.g. using SQLite via the sqldf package on CRAN and the BOD data frame which is built into R we can display the rowid column explicitly by referring to it in our select statement: library(sqldf) BOD Time demand 118.3 22 10.3 33 19.0 44 16.0 55 15.6 67 19.8 sqldf(select rowid, * from BOD) rowid Time demand 1 118.3 2 22 10.3 3 33 19.0 4 44 16.0 5 55 15.6 6 67 19.8 field? Do your queries include order by incrementing field? SQL is not good at first and last type logic. An all-in-R solution may well be In SQLite you can get the top 3 values, say, like this (continuing the prior example): sqldf(select * from BOD order by Time desc limit 3) Time demand 17 19.8 25 15.6 34 16.0 better, since R is very good with ordered vectors. A 1GB data.table (or data.frame) for example, at 3.5m rows, could have 76 integer columns, or 38 double columns. 1GB is well within 32bit and allows some space for working copies, depending on what you want to do with the data. If you have 38 or less columns, or you have 64bit, then an all-in-R solution *might* get your task done quicker, depending on what your real goal is. If this sounds plausible, you could post more details and, if its appropriate, and luck is on your side, someone might even sketch out how to do an all-in-R solution. Nathan S. Watson-Haigh nathan.watson-ha...@csiro.au wrote in message news:4b5fde1b.10...@csiro.au... I have a table (contact) with several fields and it's PK is an auto increment field. I'm bulk loading data to this table from files which if successful will be about 3.5million rows (approx 16000 rows per file). However, I have a linking table (an_contact) to resolve a m:m relationship between the an and contact tables. How can I retrieve the PK's for the data bulk loaded into contact so I can insert the relevant data into an_contact. I currently load the data into contact using: dbWriteTable(con, contact, dat, append=TRUE, row.names=FALSE) But I then need to get all the PK's which this dbWriteTable() appended to the contact table so I can load the data into my an_contact link table. I don't want to issue a separate INSERT query for each row in dat and then use MySQLs LAST_INSERT_ID() functionnot when I have 3.5million rows to insert! Any pointers welcome, Nathan -- Dr. Nathan S. Watson-Haigh OCE Post Doctoral Fellow CSIRO Livestock Industries University Drive Townsville, QLD 4810 Australia Tel: +61 (0)7 4753 8548 Fax: +61 (0)7 4753 8600 Web: http://www.csiro.au/people/Nathan.Watson-Haigh.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] PNG resolution
Hello Matthew, I do not have a direct answer to your problem, but you could try saving it as an EPS and then rasterizing it using a graphics program (e.g., GIMP) to whatever resolution you wanted. Best luck finding a real solution. Joshua On Tue, Jan 26, 2010 at 9:05 AM, Matthew Walker matthew.walke...@ulaval.cawrote: Hi, I expect that if I change only the resolution of an image, although the image would have more pixels, if viewed in the same physical size, the elements in the image would have the same physical size but with more detail. However, when I use the res parameter of png() this is not what I see. Would someone show me how I can just increase the resolution without changing the physical sizes of elements in my plot? Maybe an example would help? Below are three images. I expect that if I print them out, let's say scaled to fit the page, then items such as the words Title Text would appear the same size. Instead (for the last two) it appears that the same number of pixels are being used, thus the text size appears smaller. What should I do to just increase the resolution? png(72dpi.png, width=6+2/3, height=6+2/3, units=in, res=72) plot(0,0, main=Title Text) dev.off() png(300dpi.png, width=6+2/3, height=6+2/3, units=in, res=300) plot(0,0, main=Title Text) dev.off() png(600dpi.png, width=6+2/3, height=6+2/3, units=in, res=600) plot(0,0, main=Title Text) dev.off() Thanks in advance, Matthew Walker __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Senior in Psychology University of California, Riverside http://www.joshuawiley.com/ [[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] problem with odfWeave
Joel, I still don't see an example. I think you're making things more difficult for yourself than you need to, but without an example I don't know what exactly you're doing. -Ista On Wed, Jan 27, 2010 at 8:34 AM, Joel GOMBIN joel.gom...@gmail.com wrote: Hi, so to sum up, I'm making automated reports, in the form of tables. In each cell of the table is an expression like (e.g.) : \Sexpr{odfCat(round(summary(get(modele1))$coefficients[1,1],2))} For most cells, after I run odfWeave, the results are correctly put and formatted. But in some cells (always the same), the output.odt file has the original expression (e.g. \Sexpr{odfCat(round(summary(get(modele1))$coefficients[1,1],2))}) instead of the result of the evaluation of the expression. When I look at the content.xml code of the input file, I see that in these cells where the evaluation is not proprely run, I have something like : text:p text:style-name=P4 \Sexpr{odfCat(round(summary(get(modele1))$coefficients[2, text:soft-page-break/ 1],2))} /text:p instead of the regular text:p text:style-name=P4 \Sexpr{odfCat(round(summary(get(modele1))$coefficients[2,1],2))} /text:p So my question is : how can I get rid of these text:soft-page-break/ tags that appeared for no apparent reason ? Is there a way to configure OpenOffice Writer so that he won't put such tags ? Thanks a lot, Joel On Wed, Jan 27, 2010 at 1:54 PM, Ista Zahn istaz...@gmail.com wrote: Hi Joel, Can you paste a minimal example illustrating your problem? Thanks, Ista On Wed, Jan 27, 2010 at 6:19 AM, Joel GOMBIN joel.gom...@gmail.com wrote: Hello, thanks to Sarah for her help. That works fine, except for one thing. When I generate my reports, using odfWeave(), some cells in my tables are filled with the expression I put in the input file (/Sexpr(...)) instead of the result of its evalutation. I suspected there was a problem in the XML code ; indeed, when I look at the content.xml file of the input ODT file, there are some text:soft-page-break/ tags in the middle of cells. Is it any way of instructing OpenOffice not to put these tags, or do I have no other choice than removing them by hand in the content.xml file ? Thanks a lot in advance, Joel On Wed, Jan 6, 2010 at 7:12 PM, Sarah Goslee sarah.gos...@gmail.com wrote: Hi Joel, If you actually want to make a table, you need to use odfTable. There are examples in the help for that function. Same for odfCat, but instead of creating a table, that will print your output. eg to print your output: echo=FALSE= odfCat(some random normal data:, rnorm(5)) # from the help file @ or to make a table: echo=FALSE= x - matrix(1:12, ncol=3) colnames(x) - c(a, b, c) odfTable(x) odfTableCaption(A useless table) @ ODT files are actually compressed XML files. If you just print from within R, there are no XML tags around your output and OpenOffice has no idea what to do with it. The various odfSomething R functions wrap the R output in XML tags so OOo will understand it in the final output. Sarah On Wed, Jan 6, 2010 at 12:41 PM, Joel GOMBIN joel.gom...@gmail.com wrote: Hello, I have encountered problems using odfdWeave. I actually have the same error message as was reported in this message ( http://tolstoy.newcastle.edu.au/R/e6/help/09/01/0872.html), but I don't quite understand the answer made by Max Kuhn (You need to cat the results using odfCAt, otherwise you are just writing the output with no XML around it.). What I am supposed to do exactly ? What I'm trying to do is writing values I have computed earlier in the cells of a table in an ODT file. I'm very grateful in advance for any help... -- Sarah Goslee http://www.functionaldiversity.org [[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. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Selective Plot Color
Is there a way (with a simple plot) to select all observations greater than a certain value and plot them with a different color than the rest of the observations in the plot? (i.e. for all observations greater than 10, I want to plot them in red, but the rest of the observations remain black. Where can I find how to do this? Patrick The information transmitted is intended only for the per...{{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] Selective Plot Color
On 1/27/2010 10:00 AM, Richardson, Patrick wrote: Is there a way (with a simple plot) to select all observations greater than a certain value and plot them with a different color than the rest of the observations in the plot? (i.e. for all observations greater than 10, I want to plot them in red, but the rest of the observations remain black. Where can I find how to do this? Patrick X - runif(30, min=5, max=15) Y - rnorm(30) plot(X, Y, col=ifelse(X 10, 'red', 'black'), pch=16) The information transmitted is intended only for the per...{{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. -- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] control of scat1d tick color in plot.Predict?
Mike Babyak wrote: Hi All, I have a quick question about using plot.Predict now that the rms package uses lattice. I'd like to add tick marks along the regression line, which is given by data=llist(variablename) in the plot call. The ticks show up fine, but I'd like to alter the color. I know the ticks are produced by scat1d, but after spending a fair bit of time going through documentation, it still isn't clear to me how to do this in the context of lattice. Guidance would be greatly appreciated. Thanks, Mike Babyak Duke University Medical Center My code using R 2.10.1/windows XP myx-c(1,2,3,4) myy-c(1,2,3,5) library(rms) d-datadist(myx) options(datadist=d) myfit-ols(myy~myx,x=T,y=T) p1-Predict(myfit,myx =.) library(lattice) #change line to black line - trellis.par.get(plot.line) line$col - 1 trellis.par.set(plot.line, line) plot(p1, data=llist(myx),col.fill=lightgray, lwd=1.5) That's a good request. I've added a new argument scat1d.opts to plot.Predict in rms. Default is list(frac=0.025, lwd=0.3) with col computed. If you specify col inside the list, it will be used. source('http://biostat.mc.vanderbilt.edu/tmp/plot.Predict.s') to get the new version. Frank -- Frank E Harrell Jr Professor and ChairmanSchool of Medicine Department of Biostatistics Vanderbilt University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] difference between ' and
On Wed, 27 Jan 2010 14:15:28 +0100 Ivan Calandra ivan.calan...@uni- hamburg.de wrote: From my experience (which is limited), it seems to me that ' (apostrophe) and (quotation marks) are the same in R: they are both used for strings. The only difference would be taste. But I've recently read about the difference between = and - and I thought that there might be a difference here too in some cases. Well, you can use ' but not inside (without escaping). Also, you can use but not ' inside '' (without escaping). -- Karl Ove Hufthammer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Writing Graphs to Files
Greetings, I am trying to write multiple .emf graphs to individual files. Our data is from agricultural laboratories where individual soil samples are tested for various plant nutrients, for example, ammonium nitrogen, phosphorus, and zinc. Basically, there are three important columns: the laboratory performing the tests, the type of test for each soil sample, and the results Lab_ID Anlysis_Soil Results 55001 AmmonumN_Soil15.3 55002 AmmoniumN_Soil2 5.4 55003 AmmoniumN_Soil3 8.8 55004 AmmoniumN_Soil4 6.9 55001 Phosphorus_ Soil1 15.3 55002 Phosphorus_ Soil2 25.8 55003 Phosphorus_ Soil3 37.8 55004 Phosphorus_ Soil4 46.9 55001 Zinc_ Soil11.3 55002 Zinc_ Soil21.4 55003 Zinc_ Soil3 1.8 55004 Zinc_ Soil4 1.9 Here is the introductory code: #Set the working directory setwd(C:\\Documents and Settings\\jfloren\\My Documents\\TestRSoil) napt - read.table(file = ./readin_all_for_2010_cert.csv , header = TRUE, sep = ,) attach(napt) ## Set up the subset for statistics and graphs -- myV cycles through Nitrogen_Soil1 to Zinc_Soil4. ## myVars - levels(Anlysis_Soil) for (myV in myVars) { rsubset - subset(napt, Anlysis_Soil %in% myV) if (nrow(rsubset) 8) { ### These are the start of the statistical results for each subset ### with more than 8 labs submitting results### attach(rsubset) count = length(Results) amed = median(Results) aMAD = mad(Results, constant ### Many more statistical results and a table is written. Then generate the graphs ### ## INSERT FOR GRAPHS NEW MATERIAL #Use par(mfrow= 3,1) to set up a report with 3 graphs in one columns (3 X 1 matrix) par(mfrow=c(3,1)) plot(Results,main=myV) # The following give lines at plus or minus 3 MAD units and + or – 15% from median abline(h=amed, lty=dashed) abline(h=m2aMAD) abline(h=p2aMAD) abline(h=m4aMAD, lty =dotted) abline(h=p4aMAD, lty =dotted) hist(Results) boxplot(Results, horizontal=TRUE) ### I see the graphs generated on the R GUI screen, but how do I get them into individual .emf files? ### I think I need something like the following, but how do I substitute myV instead of Graphs.emf into the file name? dev.copy(win.metafile, file = C:\\Documents and Settings\\jfloren\\My Documents\\TestRSoil\\Graphs.emf, width = 7, height = 10, pointsize = 12) dev.off() Thanks, Jerry Floren Minnesota Department of Agriculture -- View this message in context: http://n4.nabble.com/Writing-Graphs-to-Files-tp1311709p1311709.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] problem with odfWeave
Joel, The list strips off binary attachments. But Ista is correct - to diagnose your problem (one that I've never encountered), we need to see a short odfWeave input file (including data - random numbers are fine) that we can actually run, and see table cells that work and do not work. There's presumably something different about those cells, and nobody can tell you what it might be if we can't take a look. Sarah On Wed, Jan 27, 2010 at 10:01 AM, Joel GOMBIN joel.gom...@gmail.com wrote: Attached is the input file (modele_rapport.odt) and one example of output file (rapport_Abstention2.odt) (I run a loop with the same report generated for different datasets). I hope this is what you are looking for ? Joel -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] href and Rd
On 27/01/10 - 08:54, Gabor Grothendieck wrote: One approach would be to use one of the URL shortening services to define a shorter URL. The shorter URL would then appear rather than the long original one (although there would still be a URL shown so its not quite the functionality you asked for). For more info google for: url shortening yes, I've already used tinyurl, but it's not very smart anyway. BTW thanks all! Luca ps. it's time for a wishlist item __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] biplot from stats: 0.8 ?
Dear forum, I need to create biplot graphic. I took a look at the code of the biplot.default function from the stats package and I found that the arrows for the variables are multiplied by a coefficient of 0.8 before plotting: ... if (var.axes) arrows(0, 0, y[, 1L] * 0.8, y[, 2L] * 0.8, col = col[2L], length = arrow.len) ... I have no idea why this is done. Could somebody clarify? Thank you in advance. Regards, Martin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] selecting significant predictors from ANOVA result
Ram: You do not say how many cases (rows in your dataset) you have, but I suspect it may be small (a few hundred, say). In any case, what you describe is probably just a complicated way to generate random numbers -- it is **highly** unlikely that any meaningful, replicable scientific results would result from your proposed approach. Not surprising -- this appears to be a very difficult data analysis issue. It is obvious that you have only a minimal statistical background, so I would strongly recommend that you find a competent local statistician to help you with your work. Remote help from this list is wholly inadequate. Bert Gunter Genentech Nonclinical Statistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of ram basnet Sent: Wednesday, January 27, 2010 2:52 AM To: R help Subject: [R] selecting significant predictors from ANOVA result Dear all, I did ANOVA for many response variables (Var1, Var2, Var75000), and i got the result of p-value like below. Now, I want to select those predictors, which have pvalue less than or equal to 0.05 for each response variable. For example, X1, X2, X3, X4, X5 and X6 in case of Var1, and similarly, X1, X2...X5 in case of Var2, only X1 in case of Var3 and none of the predictors in case of Var4. predictors Var1 Var2 Var3 Var4 X1 0.5 0.001 0.05 0.36 X2 0.0001 0.001 0.09 0.37 X3 0.0002 0.005 0.13 0.38 X4 0.0003 0.01 0.17 0.39 X5 0.01 0.05 0.21 0.4 X6 0.05 0.0455 0.25 0.41 X7 0.038063 0.0562 0.29 0.42 X8 0.04605 0.0669 0.33 0.43 X9 0.054038 0.0776 0.37 0.44 X10 0.062025 0.0883 0.41 0.45 I have very large data sets (# of response variables = ~75,000). So, i need some kind of automated procedure. But i have no ideas. If i got help from some body, it will be great for me. Thanks in advance. Sincerely, Ram Kumar Basnet, Ph. D student Wageningen University, The Netherlands. [[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] biplot from stats: 0.8 ?
Probably so that the end of the arrow does not overplot the labels. Kevin On Wed, Jan 27, 2010 at 10:28 AM, Martin Ivanov tra...@abv.bg wrote: Dear forum, I need to create biplot graphic. I took a look at the code of the biplot.default function from the stats package and I found that the arrows for the variables are multiplied by a coefficient of 0.8 before plotting: ... if (var.axes) arrows(0, 0, y[, 1L] * 0.8, y[, 2L] * 0.8, col = col[2L], length = arrow.len) ... I have no idea why this is done. Could somebody clarify? Thank you in advance. Regards, Martin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Kevin Wright [[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] add points to 3D plot using p3d {onion}
Just as an aside, the scatterplot3d package does things like this very cleverly. Essentially, when you create a plot with scatterplot3d, the function actually returns functions with values set so that points3d(), for example, knows the axis scaling. Best, -- Wolfgang Viechtbauerhttp://www.wvbauer.com/ Department of Methodology and StatisticsTel: +31 (43) 388-2277 School for Public Health and Primary Care Office Location: Maastricht University, P.O. Box 616 Room B2.01 (second floor) 6200 MD Maastricht, The Netherlands Debyeplein 1 (Randwyck) Original Message From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Robin Hankin Sent: Wednesday, January 27, 2010 11:17 To: Bradley Christoffersen Cc: r-help@r-project.org Subject: Re: [R] add points to 3D plot using p3d {onion} Hello Bradley I don't think there's an easy way to do what you want because the viewing angles are internal to p3d(). Frankly p3d() tries to be all things to all men (the arguments are a mess) and inevitably isn't as flexible as one might wish. I take it you want to do this: data(bunny) p3d(head(bunny,100),d0=2,theta=3) points(tail(bunny), col='blue') You'd want the call to points() to remember theta=3, and possibly d0=2 as well. Although I can see a hack I'd be very happy to help you offline. best wishes Robin Bradley Christoffersen wrote: Hi, Can anyone guide me as to how I can add points to a p3d() plot from the onion package? I want to plot points with different colors on the same 3D plot. Perhaps I can do this without adding points but somehow directing the 'h' parameter to give different color to points based on a factor I assign to them? FYI, I can do this using using scatterplot3d() and points3d(), but these plots lack perspective and hence it is hard to sense depth without the use of color. Thanks, Brad __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Function for describing segements in sequential data
Dear R-users, Say that I have a sequence of zeroes and ones: x - c(1,1,1,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0) The sequences of ones represent segments and I want to report the starting and endpoints of these segments. For example, in 'x', the first segment starts at location 1 and ends at 3, and the second segment starts at location 8 and ends at location 10. Is there an efficient way of doing this in R without having to right a bunch of if-else conditions? I know the rle function will report the length of the segments but not the endpoints. Thanks in advance. Gregory Gentlemen __ [[elided Yahoo spam]] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] large integers in R
On 27/01/2010 10:50 AM, Blanford, Glenn wrote: Duncan, thanks. To the point, R supports -(2**31-1) to 2**31-1 or -2147483647 to +2147483647 -2147483648 is a valid signed integer but returns NA. Signed integers are -2147483648 to 2147483647 Yes, R uses the -2147483648 encoding to store the integer NA. Duncan Murdoch Glenn D Blanford, PhD NAIL lab, PM NSI, Fort Monmouth, NJ glenn.blanf...@us.army.mil Scientific Research Corporation gblanf...@scires.com From: Duncan Murdoch [murd...@stats.uwo.ca] Sent: Tuesday, January 26, 2010 4:09 PM To: Blanford, Glenn Cc: r-help@R-project.org Subject: Re: [R] large integers in R On 26/01/2010 3:25 PM, Blanford, Glenn wrote: Has there been any update on R's handling large integers greater than 10^9 (between 10^9 and 4x10^9) ? as.integer() in R 2.9.2 lists this as a restriction but doesnt list the actual limit or cause, nor if anyone was looking at fixing it. Integers in R are 4 byte signed integers, so the upper limit is 2^31-1. That's not likely to change soon. The double type in R can hold exact integer values up to around 2^52. So for example calculations like this work fine: x - 2^50 y - x + 1 y-x [1] 1 Just don't ask R to put those values into a 4 byte integer, they won't fit: as.integer(c(x,y)) [1] NA NA Warning message: NAs introduced by coercion Duncan Murdoch Glenn D Blanford, PhD mailto:glenn.blanf...@us.army.mil Scientific Research Corporation gblanf...@scires.commailto:gblanf...@scires.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Function for describing segements in sequential data
Hi, On Wed, Jan 27, 2010 at 12:31 PM, Gregory Gentlemen gregory_gentle...@yahoo.ca wrote: Dear R-users, Say that I have a sequence of zeroes and ones: x - c(1,1,1,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0) The sequences of ones represent segments and I want to report the starting and endpoints of these segments. For example, in 'x', the first segment starts at location 1 and ends at 3, and the second segment starts at location 8 and ends at location 10. Is there an efficient way of doing this in R without having to right a bunch of if-else conditions? How about something like this: start - which(diff(c(0,x)) == 1) ## Append first 0 for a bookend end - which(diff(x) == -1) start is: 1, 8, 15 end is: 3, 10, 17 -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] RMySQL - Bulk loading data and creating FK links
sqldf(select * from BOD order by Time desc limit 3) Exactly. SQL requires use of order by. It knows the order, but it isn't ordered. Thats not good, but might be fine, depending on what the real goal is. Gabor Grothendieck ggrothendi...@gmail.com wrote in message news:971536df1001270629w4795da89vb7d77af6e4e8b...@mail.gmail.com... On Wed, Jan 27, 2010 at 8:56 AM, Matthew Dowle mdo...@mdowle.plus.com wrote: How many columns, and of what type are the columns ? As Olga asked too, it would be useful to know more about what you're really trying to do. 3.5m rows is not actually that many rows, even for 32bit R. Its depends on the columns and what you want to do with those columns. At the risk of suggesting something before we know the full facts, one possibility is to load the data from flat file into data.table. Use setkey() to set your keys. Use tables() to summarise your various tables. Then do your joins etc all-in-R. data.table has fast ways to do those sorts of joins (but we need more info about your task). Alternatively, you could check out the sqldf website. There is an sqlread.csv (or similar name) which can read your files directly into SQL read.csv.sql instead of going via R. Gabor has some nice examples there about that and its faster. You use some buzzwords which makes me think that SQL may not be appropriate for your task though. Can't say for sure (because we don't have enough information) but its possible you are struggling because SQL has no row ordering concept built in. That might be why you've created an increment In the SQLite database it automatically assigns a self incrementing hidden column called rowid to each row. e.g. using SQLite via the sqldf package on CRAN and the BOD data frame which is built into R we can display the rowid column explicitly by referring to it in our select statement: library(sqldf) BOD Time demand 118.3 22 10.3 33 19.0 44 16.0 55 15.6 67 19.8 sqldf(select rowid, * from BOD) rowid Time demand 1 118.3 2 22 10.3 3 33 19.0 4 44 16.0 5 55 15.6 6 67 19.8 field? Do your queries include order by incrementing field? SQL is not good at first and last type logic. An all-in-R solution may well be In SQLite you can get the top 3 values, say, like this (continuing the prior example): sqldf(select * from BOD order by Time desc limit 3) Time demand 17 19.8 25 15.6 34 16.0 better, since R is very good with ordered vectors. A 1GB data.table (or data.frame) for example, at 3.5m rows, could have 76 integer columns, or 38 double columns. 1GB is well within 32bit and allows some space for working copies, depending on what you want to do with the data. If you have 38 or less columns, or you have 64bit, then an all-in-R solution *might* get your task done quicker, depending on what your real goal is. If this sounds plausible, you could post more details and, if its appropriate, and luck is on your side, someone might even sketch out how to do an all-in-R solution. Nathan S. Watson-Haigh nathan.watson-ha...@csiro.au wrote in message news:4b5fde1b.10...@csiro.au... I have a table (contact) with several fields and it's PK is an auto increment field. I'm bulk loading data to this table from files which if successful will be about 3.5million rows (approx 16000 rows per file). However, I have a linking table (an_contact) to resolve a m:m relationship between the an and contact tables. How can I retrieve the PK's for the data bulk loaded into contact so I can insert the relevant data into an_contact. I currently load the data into contact using: dbWriteTable(con, contact, dat, append=TRUE, row.names=FALSE) But I then need to get all the PK's which this dbWriteTable() appended to the contact table so I can load the data into my an_contact link table. I don't want to issue a separate INSERT query for each row in dat and then use MySQLs LAST_INSERT_ID() functionnot when I have 3.5million rows to insert! Any pointers welcome, Nathan -- Dr. Nathan S. Watson-Haigh OCE Post Doctoral Fellow CSIRO Livestock Industries University Drive Townsville, QLD 4810 Australia Tel: +61 (0)7 4753 8548 Fax: +61 (0)7 4753 8600 Web: http://www.csiro.au/people/Nathan.Watson-Haigh.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Function for describing segements in sequential data
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gregory Gentlemen Sent: Wednesday, January 27, 2010 9:31 AM To: r-help@r-project.org Subject: [R] Function for describing segements in sequential data Dear R-users, Say that I have a sequence of zeroes and ones: x - c(1,1,1,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0) The sequences of ones represent segments and I want to report the starting and endpoints of these segments. For example, in 'x', the first segment starts at location 1 and ends at 3, and the second segment starts at location 8 and ends at location 10. Is there an efficient way of doing this in R without having to right a bunch of if-else conditions? I know the rle function will report the length of the segments but not the endpoints. You can use expressions based on cumsum(rle(x)$lengths) or, more directly, on the following functions isFirstInRun - function(x)c(TRUE, x[-1]!=x[-length(x)]) isLastInRun - function(x)c(x[-1]!=x[-length(x)], TRUE) which do part of what rle() does. E.g., which(isFirstInRun(x) x==1) # starting positions of runs of 1's [1] 1 8 15 which(isLastInRun(x) x==1) # ending positions of runs of 1's [1] 3 10 17 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com Thanks in advance. Gregory Gentlemen __ [[elided Yahoo spam]] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] ask for help with this R quesiton
question like this: I have data tag and phi, when tag are the same, then phi are the same. like below, tag have value 1 2 3 4 and phi have value .9 .3 1 0. my question is, how can I get the result like tag=c(1,2,3,4) and corresponding phi=c(.9,.3,1,0) tag phi 2.3 1.9 2.3 31 2.3 1.9 31 40 1.9 2.3 tag=c(2,1,2,3,2,1,3,4,1,2) phi=c(.3,.9,.3,1,.3,.9,1,0,.9,.3) [[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] ask for help with this R quesiton
Try this: unique(cbind(tag, phi))[order(unique(tag)),] On Wed, Jan 27, 2010 at 4:13 PM, song song rprojecth...@gmail.com wrote: question like this: I have data tag and phi, when tag are the same, then phi are the same. like below, tag have value 1 2 3 4 and phi have value .9 .3 1 0. my question is, how can I get the result like tag=c(1,2,3,4) and corresponding phi=c(.9,.3,1,0) tag phi 2 .3 1 .9 2 .3 3 1 2 .3 1 .9 3 1 4 0 1 .9 2 .3 tag=c(2,1,2,3,2,1,3,4,1,2) phi=c(.3,.9,.3,1,.3,.9,1,0,.9,.3) [[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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Writing Graphs to Files
Thank you so much Eik. This is what I used, and it genereated 530 files of triple graphs in less than a minute. dev.copy(win.metafile, file = paste(myV,emf,sep=.), width = 7, height = 10, pointsize = 12) dev.off() Thanks again, Jerry Floren Minnesota Department of Agriculture -- View this message in context: http://n4.nabble.com/Writing-Graphs-to-Files-tp1311709p1311947.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] Rcmdr has stopped working
On my Mac (Snow Leopard and R64), I had been using Rcmdr nicely. But now when I do library(Rcmdr) the tk libraries load, but the Rcmdr window never appears. library(Rcmdr) Loading required package: tcltk Loading Tcl/Tk interface ... And if I try to do anything else, R goes to 100% cpu and hangs. How do I recover? Thanks, Jim Rome __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Alt carachters in R
Hi all, I am trying to use and place in a graph some alt characters such as *.. Could you help me? Thanks __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Step and AIC
Hello everybody, I would need some help from you. I am trying to fit a logistic model to some presence absence data of animals living on river islands. I have got 12 predictor variables and I am trying to use a stepwise forward method to fit the best logistic model to my data. I am using the function STEP (stats). I have a question for you. Can I use step function if my variables have a binomial distribution? Reading the explanations of the function, I have understood that step is more suitable for dealing with gaussian distributed variables. Is that right? I apologize in advance for this question, but I am just at the beginning of my long path to handle and know statistics and R. regards Francesca [[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] large integers in R
Duncan, thanks. To the point, R supports -(2**31-1) to 2**31-1 or -2147483647 to +2147483647 -2147483648 is a valid signed integer but returns NA. Signed integers are -2147483648 to 2147483647 Glenn D Blanford, PhD NAIL lab, PM NSI, Fort Monmouth, NJ glenn.blanf...@us.army.mil Scientific Research Corporation gblanf...@scires.com From: Duncan Murdoch [murd...@stats.uwo.ca] Sent: Tuesday, January 26, 2010 4:09 PM To: Blanford, Glenn Cc: r-help@R-project.org Subject: Re: [R] large integers in R On 26/01/2010 3:25 PM, Blanford, Glenn wrote: Has there been any update on R's handling large integers greater than 10^9 (between 10^9 and 4x10^9) ? as.integer() in R 2.9.2 lists this as a restriction but doesnt list the actual limit or cause, nor if anyone was looking at fixing it. Integers in R are 4 byte signed integers, so the upper limit is 2^31-1. That's not likely to change soon. The double type in R can hold exact integer values up to around 2^52. So for example calculations like this work fine: x - 2^50 y - x + 1 y-x [1] 1 Just don't ask R to put those values into a 4 byte integer, they won't fit: as.integer(c(x,y)) [1] NA NA Warning message: NAs introduced by coercion Duncan Murdoch Glenn D Blanford, PhD mailto:glenn.blanf...@us.army.mil Scientific Research Corporation gblanf...@scires.commailto:gblanf...@scires.com [[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] median of grouped data
Good morning, I would like to know if is possible somebody can help me with this please: I would like to calculate the median of grouped data, this is an example: IDPM adt_01 25.255 adt_01 225.36 adt_01 14.2325 adt_02 15 adt_02 12.3 adt_03 15.2 adt_03 148.3 adt_03 25.5 adt_03 14.25 I need the median of adt_01, 02 and 03 , I know that I have to split first my data and then ask for the median but the code I have is not working. Thank you very much if you can help me with the code maria __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] ask for help with this R quesiton
question like this: I have data tag and phi, when tag are the same, then phi are the same. like below, tag have value 1 2 3 4 and phi have value .9 .3 1 0. my question is, how can I get the result like tag=c(1,2,3,4) and corresponding phi=c(.9,.3,1,0) tag phi 2.3 1.9 2.3 31 2.3 1.9 31 40 1.9 2.3 tag=c(2,1,2,3,2,1,3,4,1,2) phi=c(.3,.9,.3,1,.3,.9,1,0,.9,.3) [[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] ask for help with this R quesiton
question like this: I have data tag and phi, when tag are the same, then phi are the same. like below, tag have value 1 2 3 4 and phi have value .9 .3 1 0. my question is, how can I get the result like tag=c(1,2,3,4) and corresponding phi=c(.9,.3,1,0) tag phi 2.3 1.9 2.3 31 2.3 1.9 31 40 1.9 2.3 tag=c(2,1,2,3,2,1,3,4,1,2) phi=c(.3,.9,.3,1,.3,.9,1,0,.9,.3) [[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] Executing a R-string
On 28/01/2010, at 2:59 AM, Joe Trubisz wrote: Hello... In other languages (e.g. php, perl), you have the ability to create a valid string and execute the string to get the result. For example (in pseudo-R): S-which(m==4) R-exec(S) I know this does not work, but was wondering if there was an equivalent mechanism that I cannot find in the docs anywhere to make it work. set.seed(42) m - sample(0:9,42,TRUE) S - which(m==4) eval(parse(text=S)) [1] 11 15 19 29 42 cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 a R-string
m - c(1,4,2,3,7,5) S - which(m==4) P - parse(text=S) R - eval(P) R Before you do this, see fortune(106) fortune(106) If the answer is parse() you should usually rethink the question. -- Thomas Lumley R-help (February 2005) On Wed, Jan 27, 2010 at 8:59 AM, Joe Trubisz jtrub...@mac.com wrote: Hello... In other languages (e.g. php, perl), you have the ability to create a valid string and execute the string to get the result. For example (in pseudo-R): S-which(m==4) R-exec(S) I know this does not work, but was wondering if there was an equivalent mechanism that I cannot find in the docs anywhere to make it work. Thanks, Joe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Step and AIC
Hi, On Wed, Jan 27, 2010 at 12:21 PM, francesca.ior...@googlemail.com wrote: Hello everybody, I would need some help from you. I am trying to fit a logistic model to some presence absence data of animals living on river islands. I have got 12 predictor variables and I am trying to use a stepwise forward method to fit the best logistic model to my data. I am using the function STEP (stats). I have a question for you. Can I use step function if my variables have a binomial distribution? Reading the explanations of the function, I have understood that step is more suitable for dealing with gaussian distributed variables. Is that right? I apologize in advance for this question, but I am just at the beginning of my long path to handle and know statistics and R. This isn't really answering your question at all, but instead of doing stepwise regression, could I recommend trying a regularized/penalized regression model, instead? The glmnet function in the glmnet package can fit the entire regularization path for lasso/elasticnet -regularized logistic regression model ... might be worth a try. -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] Indexes for Simplexes
I'm going to be manipulating some 3-rd and 4-th rank tensors in relatively high dimensions, and it would help a great deal to use only the unique entries instead of repeating every operation 6 or 24 times. Operations are tensor-matrix, tensor-vector, and tensor-tensor multiplication. Does anyone have some code where they've done this? I know it will take me days to work out all the kinks otherwise. Thanks John __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2 theme for custom point colors?
Hi, I remember asking a similar question some time ago, I don't know if the matter has evolved since then, http://groups.google.com/group/ggplot2/browse_frm/thread/a3df8a0d1ee335fb/e3bedd50fb9bd567?lnk=gstq=theme#e3bedd50fb9bd567 There's also set_default_scale, somewhat related to your question. baptiste 2010/1/27 Kevin Wright kw.s...@gmail.com: 1. Is it possible to set the point colors in a ggplot2 theme? For example, to default to these colors: scale_colour_manual(value = c(red, orange, yellow, green, blue) 2. Is it possible to set this theme in .Rprofile, similar to: my.lattice.colors = function () { ...etc.} options(lattice.theme=.mw.lattice.colors) -- Kevin Wright [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plotting the coordinates versus dates
Julia Tchernova wrote: Hello! I have a dataset with the dates and positions - Lat and Long columns How do I make a scatter plot? Do I have to cbind to combine the Lat and Long columns? Any suggestions will be much appreciated! Thank you Julia [[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. If you cast your data into the spatial classes for R provided by the sp-pacakge, you can easily make nice plots. After installing sp from CRAN: library(sp) data(meuse) meuse summary(meuse) coordinates(meuse) = ~x+y ?coordinates spplot(meuse, zinc) The r-sig-geo mailing list is more suitable for this kind of question. cheers, 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.
Re: [R] Rcmdr has stopped working
Dear Jim, The Rcmdr (version 1.5.4) works for me under R64 (R 2.10.1) and Snow Leopard. Without more information, it's hard to know what went wrong. Have you checked whether tcltk works? For example, try library(tcltk tk_choose.dir(getwd(), Choose folder) I hope this helps, John John Fox Senator William McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of James Rome Sent: January-27-10 1:50 PM To: r-help@r-project.org Subject: [R] Rcmdr has stopped working On my Mac (Snow Leopard and R64), I had been using Rcmdr nicely. But now when I do library(Rcmdr) the tk libraries load, but the Rcmdr window never appears. library(Rcmdr) Loading required package: tcltk Loading Tcl/Tk interface ... And if I try to do anything else, R goes to 100% cpu and hangs. How do I recover? Thanks, Jim Rome __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Rcmdr has stopped working
Apparently tcltk is the issue. That hung my R. How do I reinstall tcltk? On 1/27/10 3:06 PM, John Fox wrote: library(tcltk tk_choose.dir(getwd(), Choose folder) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] returning a list of functions
Lazy evaluation. Consider: funlist - list() for (i in 1:5)funlist[[i]]- eval(bquote(function(x)x^.(i))) str(funlist[[2]]) function (x) - attr(*, source)= chr function(x)x^.(i) funlist[[2]] function(x)x^.(i) ## But... body(funlist[[2]]) x^2L body(funlist[[3]]) x^3L funlist[[2]](2) [1] 4 funlist[[3]](2) [1] 8 ?bquote See Bill Venables's Programmer's Niche Column on Mind Your Language in the Vol 2/2, June 2002 R News for a fuller explanation. Note that bquote() is just a kind of macro-like version of substitute(). Bert Gunter Genentech Nonclinical Statistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Rajat Mukherjee Sent: Wednesday, January 27, 2010 7:37 AM To: r-h...@stat.math.ethz.ch Subject: [R] returning a list of functions Hi interested readers, I have a function that creates several functions within a loop and I would like them to be returned for further use as follows: Main.Function(df,...){ # df is a multivariate data funcList-list(NULL) for (i in 1:ncol(df)){ temp-logspline(df[,i],...) # logspline density estimate funcList[[i]]-function(x){expression(temp,x)} } return(funcList) } I have tried this, unfortunately can't figure out why all the functions returned are identical. Any help towards this will be much appreciated. Thanks. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Alt carachters in R
Tena koe Gepeto Not sure if the following helps since you have not been very specific in your question: plot(1:10) text(3,2,'*') text(5,2,'*5') text(4,2,'5*5') text(4,5,'17\n4') text(6,5,'17\\n4') Hei kona ra ... Peter Alspach -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of gepeto Sent: Thursday, 28 January 2010 4:59 a.m. To: r-help@r-project.org Subject: [R] Alt carachters in R Hi all, I am trying to use and place in a graph some alt characters such as *.. Could you help me? Thanks __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] median of grouped data
Tena koe Maria ?tapply Specifically: tapply(yourData$PM, yourData$ID, median) HTH Peter Alspach -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of María del Pilar Márquez Sent: Thursday, 28 January 2010 7:06 a.m. To: r-help@r-project.org Subject: [R] median of grouped data Good morning, I would like to know if is possible somebody can help me with this please: I would like to calculate the median of grouped data, this is an example: IDPM adt_01 25.255 adt_01 225.36 adt_01 14.2325 adt_02 15 adt_02 12.3 adt_03 15.2 adt_03 148.3 adt_03 25.5 adt_03 14.25 I need the median of adt_01, 02 and 03 , I know that I have to split first my data and then ask for the median but the code I have is not working. Thank you very much if you can help me with the code maria __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Rcmdr has stopped working
Dear James, The tcltk package is part of the standard R distribution. I'm not sure why it isn't working. You might try reinstalling R or posting a question to the R-SIG-Mac list about tcltk not working. If you do the latter, you'll probably get a more informative response if you provide the information requested in the posting guide, at http://www.r-project.org/posting-guide.html. I hope this helps, John -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of James Rome Sent: January-27-10 3:12 PM To: John Fox Cc: r-help@r-project.org Subject: Re: [R] Rcmdr has stopped working Apparently tcltk is the issue. That hung my R. How do I reinstall tcltk? On 1/27/10 3:06 PM, John Fox wrote: library(tcltk tk_choose.dir(getwd(), Choose folder) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] color matrix
Hi, Is it possible to create a heatmap for say a 3x3 matrix of data where every color is pre-assigned? I can easily create a matrix of hex colors but when I try to use that matrix as the parameter for the 'col' option it doesn't work. If it's possible to just display a matrix of hex colors that would work as well thanks -- View this message in context: http://n4.nabble.com/color-matrix-tp1312078p1312078.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] sort a data frame according to all the Columns
Hi, I have a data frame read from a .csv file, with columns V1,V2,V3...,V18, per say, and I want to sort this data frame according to V1, and then V2, then V3..., and so on. Is there any fast way to get around with this problem? Thanks. -JJ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] sort a data frame according to all the Columns
I think you want ?order Juanjuan Chai wrote: Hi, I have a data frame read from a .csv file, with columns V1,V2,V3...,V18, per say, and I want to sort this data frame according to V1, and then V2, then V3..., and so on. Is there any fast way to get around with this problem? Thanks. -JJ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 matrix
Hi, It's easy with ggplot2, cols = matrix(c(#F7FBFF, #DEEBF7, #C6DBEF, #9ECAE1, #6BAED6, #4292C6, #2171B5, #08519C ,#08306B), ncol=3) library(ggplot2) m = melt(cols) qplot(factor(X1),factor(X2),data=m, fill=value, geom=tile) + scale_fill_identity() HTH, baptiste 2010/1/27 evgeny55 evgen...@yahoo.com: Hi, Is it possible to create a heatmap for say a 3x3 matrix of data where every color is pre-assigned? I can easily create a matrix of hex colors but when I try to use that matrix as the parameter for the 'col' option it doesn't work. If it's possible to just display a matrix of hex colors that would work as well thanks -- View this message in context: http://n4.nabble.com/color-matrix-tp1312078p1312078.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Merge: sort=F not preserving order?
Hello, I have the following data1 (index are chars): index 1 008823 2 012689 3 004503 4 002991 5 012689 6 002845 7 012689 8 012395 9 012689 10 009302 11 002845 12 006669 13 008823 14 009302 15 025340 16 012689 and data2 in this format (index2 are chars): index2 tic 1 001003 ANTQ 2 001004 AIR 3 001009 ABSI 4 001011 ACSE etc I am attempting to merge them using the following: mergeddata - merge(data1,data2, by.x=index, by.y=index2, sort=FALSE) I want to preserve the order of data1 by setting sort=FALSE, however the output I get is: index tic 1 008823 PHM 2 008823 PHM 3 012689 KBH 4 012689 KBH 5 012689 KBH 6 012689 KBH 7 012689 KBH 8 004503 XOM 9 002991 CVX 10 002845 CTX 11 002845 CTX 12 012395 TOL 13 009302 RYL 14 009302 RYL 15 006669 LEN 16 025340 DHI which has not preserved the order of data1, and also does not have a clear relationship to the order of data2 that I can see. I also tried converting both index fields from chars to ints and got the same result. Any ideas of what is going on here? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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: sort=F not preserving order?
Why yes. If you keep reading the helpfile for merge, you come to this bit: Value: A data frame. The rows are by default lexicographically sorted on the common columns, but for ‘sort = FALSE’ are in an unspecified order. sort=FALSE doesn't preserve your order; instead it gives you an unspecified potentially random order. Sarah On Wed, Jan 27, 2010 at 5:13 PM, lol zino lolz...@gmail.com wrote: Hello, [...] I am attempting to merge them using the following: mergeddata - merge(data1,data2, by.x=index, by.y=index2, sort=FALSE) I want to preserve the order of data1 by setting sort=FALSE, however the output I get is: [...] which has not preserved the order of data1, and also does not have a clear relationship to the order of data2 that I can see. I also tried converting both index fields from chars to ints and got the same result. Any ideas of what is going on here? __ -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] problem with nls function
quote From: hammadi jbeli hammadi.jbeli_at_gmail.com Date: Tue, 26 Jan 2010 23:40:47 +0100 I have used R formulation style and I found this in some R documentations. /quote Sorry, that makes no sense. I would recommend you go back to your original dataset and pick a very small subset of it--with only 2 variables, for example. Then try running nls on that, so at least your code line will be a manageable size. Also, as people regularly remind me :-), post a *small* but reproducible data set so we can see what sort of stuff you're feeding into these functions. {like, say, L.minor.m1-nls(Y~a_1_1*D_1+a_1_2*(exp(-gamma_1_F*stdS*(s_F-c_1_F)), start=list(a_1_1=0.0593,a_2_1=-0.0822),trace=TRUE) } Tho' I tend to suspect an attempt to fit that many independent exp(gamma)'s is doomed to failure. If you can explain what the underlying data represent, there may be a better, and vectorized, way to find a fit function. Carl __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Installing R and modules on Unix OS
Hi: I have a question about installing R (and modules) on a Unix system (AIX). Can I just gunzip (or the equivalent) the installation files into my home directory or will I need someone with root access to install R? I am hoping that the answer is the former (I can unzip all files to a directory R that I create under my home directory and I can start using it). Could you please help me with this and any other instructions to install R and modules when you do not have root access? Thanks. Satish __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fwd: Re: Graph color
Finally I´m very near on the graph I want... The code is this (based on your guide): First I read this data on the M.txt file: Player TYr Dec Jose 20 14 Pepe 12 16 Andres 15 12 Guille 16 14 Pedro 18 19 Luis 14 19 Raul 18 15 Pepe 7 5 MC-read.table(MC.txt,header=T,sep=,dec=,) #I read the data attach(MC) par(bg=black) plot(x = MC$TYr, y = MC$Dec, xlab=Actual Goals, ylab=Last year Goals,col=white,col.axis=white) title(Goals on Game,font=4,col=white) lim-par(usr) rect(lim[1],lim[3],lim[2],lim[4],col=white,border=white) text(x = MC$TYr, y = MC$Dec, labels = MC$Player) grid() abline(1,1) WHAT IS MY PROBLEM? The main title and the axis names doesn´t appear I want to put them on white but the script doesn´t run. Can any one guide me? The other problem is that the border of the x and y axis doesn´t appears... Sorry about my silly questions... 2010/1/27 Jim Lemon j...@bitwrit.com.au On 01/27/2010 06:41 AM, narillosdesan...@gmail.com wrote: No mate, Sorry first of all about my indefinition (I´m Spanish, I´m improving everyday but a long road to the perfection). Sorry pleae. Second, also it is diffcoult sometimes to express what we try (sorry and many thanks just for reading of course for helping). Imagine you plot X=[2 4 6 8] front a Y=[6 5 8 7] When you plot it by default all is white what I want is to use par(br=gray) to make the graph gray but I want that the area (the imaginary square defined by the axis) not to be gray I want to deffine its colour by ie lightblue. So the image will be a square image outside gray and on the axis area (not the dots, points or bar plots) the area in lightblue. I don´t now if I have expressed well if not latter I will send an example, ok? Hi, You can make the background of the plot area a different color: # first set up the plot plot(X,Y,type=n,...) # get the coordinates of the edges of the plot xylim-par(usr) # then display a rectangle that fills it rect(xylim[1],xylim[3],xylim[2],xylim[4], col=lightblue,border=black) # then plot the points over the rectangle points(X,Y,type=b) Jim [[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] median of grouped data
Like this? d = read.table(textConnection(ID PM adt_01 25.255 adt_01 225.36 adt_01 14.2325 adt_02 15 adt_02 12.3 adt_03 15.2 adt_03 148.3 adt_03 25.5 adt_03 14.25),head=T) d d$PM - as.numeric(d$PM) ddply(d,.(ID),numcolwise(median)) Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA --- On Wed, 1/27/10, María del Pilar Márquez marquezvi...@wisc.edu wrote: From: María del Pilar Márquez marquezvi...@wisc.edu Subject: [R] median of grouped data To: r-help@r-project.org Date: Wednesday, January 27, 2010, 10:05 AM Good morning, I would like to know if is possible somebody can help me with this please: I would like to calculate the median of grouped data, this is an example: ID PM adt_01 25.255 adt_01 225.36 adt_01 14.2325 adt_02 15 adt_02 12.3 adt_03 15.2 adt_03 148.3 adt_03 25.5 adt_03 14.25 I need the median of adt_01, 02 and 03 , I know that I have to split first my data and then ask for the median but the code I have is not working. Thank you very much if you can help me with the code maria __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Randomly rearranging elements of sets
?sample On 28/01/2010, at 12:06 PM, jshort wrote: Hi I've recently been trying to solve some probability questions in R, but am having trouble. This is one question thats been causing some hair loss: Given the set of integers S = {1,2,3,4,5,6,7,8,9,10}, create a function F(S) that uniformly and randomly rearranges these integers. For example, in one instance, we might have F(S) = {2,3,9,7,5,6,1,8,10,4}. .. .. Here is what I've managed so far with regards to solving the above. The first part of my program is just the following (which is flawless): w = matrix(0, ncol = 10, nrow = 1, byrow = T) for( i in 1:1) { (m = runif(1,0,10)) for(j in 1:10) { if (j-1 m m j) w[1,i] = j } As you can see, I first define my output (called w) as 1 by 10 matrix. Afterwards, I randomly assign the first integer '1' to one of the positions on 1-10 (the function runif(1,0,10) lets me do this so that each position is equally likely). The next part of my program is where the difficulty lies. We need to randomly assign the remaining 9 integers. The program should look something like the following: for( i in 2:10) { (q = runif(1,0,10) { if(condition(i)) w[1,i] = xxx, else (repeat with new q-value untill condition(i) is met) } I know how to fill one of the details in the above. Clearly condition(i) should something like the following: for(e in 2:10) { if (e-1 q q e) (for(s in 1:i-1) { e != w[1,s] } w[1,i] = e The REAL issue is filling the exact details of the else condition. Clearly I want to tell R that I wish to repeat with a new random number q until condition(i) is met, but I don't know how to tell R this. Any help with this would be much appreciated. ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Randomly rearranging elements of sets
On Wed, Jan 27, 2010 at 11:11 PM, Rolf Turner r.tur...@auckland.ac.nz wrote: ?sample And/Or read Knuth. Does this sound like a homework problem? -- blog: http://geospaced.blogspot.com/ web: http://www.maths.lancs.ac.uk/~rowlings web: http://www.rowlingson.com/ twitter: http://twitter.com/geospacedman pics: http://www.flickr.com/photos/spacedman __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] SSOAP XML-RPC
Hi Jan Is .XMLRPC(http://localhost:9000;, Cytoscape.test, .opts = list(verbose = TRUE)) the command you used? If not, what did you use? Can you debug the .XMLRPC function (e.g. with options(error = recover)) and see what the XML that was sent to the server, i.e. the cmd variable in the .XMLRPC() function. Can you find out what the Perl, Python or Ruby modules send? It is easy to fix if we know what should be sent, but we do need more details. D. Jan Bot wrote: Hi, I'm trying to use the XML-RPC client in the SSOAP package to connect to a service that I have created. From other languages (Perl, Python, Ruby) this is not a problem but the SSOAP client gives the following error: Error in .XMLRPC(http://localhost:9000;, Cytoscape.test, .opts = list(verbose = TRUE)) : Failed to parse XML-RPC request: Content is not allowed in prolog. It looks like the SSOAP XML-RPC client is not creating the right type of XML-RPC message. Does anyone know how to fix this or has successfully used the SSOAP XML-RPC client? Thanks, Jan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] RMySQL - Bulk loading data and creating FK links
How it represents data internally should not be important as long as you can do what you want. SQL is declarative so you just specify what you want rather than how to get it and invisibly to the user it automatically draws up a query plan and then uses that plan to get the result. On Wed, Jan 27, 2010 at 12:48 PM, Matthew Dowle mdo...@mdowle.plus.com wrote: sqldf(select * from BOD order by Time desc limit 3) Exactly. SQL requires use of order by. It knows the order, but it isn't ordered. Thats not good, but might be fine, depending on what the real goal is. Gabor Grothendieck ggrothendi...@gmail.com wrote in message news:971536df1001270629w4795da89vb7d77af6e4e8b...@mail.gmail.com... On Wed, Jan 27, 2010 at 8:56 AM, Matthew Dowle mdo...@mdowle.plus.com wrote: How many columns, and of what type are the columns ? As Olga asked too, it would be useful to know more about what you're really trying to do. 3.5m rows is not actually that many rows, even for 32bit R. Its depends on the columns and what you want to do with those columns. At the risk of suggesting something before we know the full facts, one possibility is to load the data from flat file into data.table. Use setkey() to set your keys. Use tables() to summarise your various tables. Then do your joins etc all-in-R. data.table has fast ways to do those sorts of joins (but we need more info about your task). Alternatively, you could check out the sqldf website. There is an sqlread.csv (or similar name) which can read your files directly into SQL read.csv.sql instead of going via R. Gabor has some nice examples there about that and its faster. You use some buzzwords which makes me think that SQL may not be appropriate for your task though. Can't say for sure (because we don't have enough information) but its possible you are struggling because SQL has no row ordering concept built in. That might be why you've created an increment In the SQLite database it automatically assigns a self incrementing hidden column called rowid to each row. e.g. using SQLite via the sqldf package on CRAN and the BOD data frame which is built into R we can display the rowid column explicitly by referring to it in our select statement: library(sqldf) BOD Time demand 1 1 8.3 2 2 10.3 3 3 19.0 4 4 16.0 5 5 15.6 6 7 19.8 sqldf(select rowid, * from BOD) rowid Time demand 1 1 1 8.3 2 2 2 10.3 3 3 3 19.0 4 4 4 16.0 5 5 5 15.6 6 6 7 19.8 field? Do your queries include order by incrementing field? SQL is not good at first and last type logic. An all-in-R solution may well be In SQLite you can get the top 3 values, say, like this (continuing the prior example): sqldf(select * from BOD order by Time desc limit 3) Time demand 1 7 19.8 2 5 15.6 3 4 16.0 better, since R is very good with ordered vectors. A 1GB data.table (or data.frame) for example, at 3.5m rows, could have 76 integer columns, or 38 double columns. 1GB is well within 32bit and allows some space for working copies, depending on what you want to do with the data. If you have 38 or less columns, or you have 64bit, then an all-in-R solution *might* get your task done quicker, depending on what your real goal is. If this sounds plausible, you could post more details and, if its appropriate, and luck is on your side, someone might even sketch out how to do an all-in-R solution. Nathan S. Watson-Haigh nathan.watson-ha...@csiro.au wrote in message news:4b5fde1b.10...@csiro.au... I have a table (contact) with several fields and it's PK is an auto increment field. I'm bulk loading data to this table from files which if successful will be about 3.5million rows (approx 16000 rows per file). However, I have a linking table (an_contact) to resolve a m:m relationship between the an and contact tables. How can I retrieve the PK's for the data bulk loaded into contact so I can insert the relevant data into an_contact. I currently load the data into contact using: dbWriteTable(con, contact, dat, append=TRUE, row.names=FALSE) But I then need to get all the PK's which this dbWriteTable() appended to the contact table so I can load the data into my an_contact link table. I don't want to issue a separate INSERT query for each row in dat and then use MySQLs LAST_INSERT_ID() functionnot when I have 3.5million rows to insert! Any pointers welcome, Nathan -- Dr. Nathan S. Watson-Haigh OCE Post Doctoral Fellow CSIRO Livestock Industries University Drive Townsville, QLD 4810 Australia Tel: +61 (0)7 4753 8548 Fax: +61 (0)7 4753 8600 Web: http://www.csiro.au/people/Nathan.Watson-Haigh.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide
[R] quartz() and dpi
Hello all, I am using quartz (on OS X obviously) to produce PDFs and PNGs from my plots, for later inclusion in LaTeX. I am typically using something like: plot(0) dev.print(quartz, file=foo.pdf, width=5, height=3) dev.print(quartz, file=foo.png, width=5, height=3, dpi=72) I want the sizes of the PDF and PNG to be *equal* in *inches*, which works with dpi=72. However, when I increase the dpi parameter, instead of producing an image of the same size with increased resolution, it creates a larger image of resolution = 72. E.g. try dev.print(quartz, file=foo-72.png, width=5, height=3, dpi=72) dev.print(quartz, file=foo-300.png, width=5, height=3, dpi=300) system(open -a Preview.app foo-*.png) The inspector in Preview should show 72 dpi for both files. This is with: sessionInfo() R version 2.10.1 (2009-12-14) x86_64-apple-darwin9.8.0 Is this a know bug/limitation? Is a solution planned? Is there a workaround for now? As a final note, I am aware that PDF is superior to PNG, particularly in a LaTeX workflow; but for particularly complex plots, I sometimes fall back on high resolution PNGs. Currently it forces me to add a 'scale' argument to includegraphics in latex for those. I would rather leave the latex document alone, use extension-less file names includegraphics and decide from R wether to produce a pdf or a png. Thank you in advance, 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.
[R] exporting multidimensional matrix from R
Hi, I have a matrix of size 19x512x20 in R. I want to export this file into another format which can be imported into MATLAB. write.xls or write.table exports only one dimension. please send a code if possible. I am very new to R and have been struggling with this. Thanks ! Gopi [[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] Fwd: Re: Graph color
On 01/28/2010 09:52 AM, Jose Narillos de Santos wrote: Finally I´m very near on the graph I want... The code is this (based on your guide): First I read this data on the M.txt file: Player TYr Dec Jose20 14 Pepe12 16 Andres 15 12 Guille 16 14 Pedro 18 19 Luis14 19 Raul18 15 Pepe7 5 MC-read.table(MC.txt,header=T,sep=,dec=,) #I read the data attach(MC) par(bg=black) plot(x = MC$TYr, y = MC$Dec, xlab=Actual Goals, ylab=Last year Goals,col=white,col.axis=white) title(Goals on Game,font=4,col=white) lim-par(usr) rect(lim[1],lim[3],lim[2],lim[4],col=white,border=white) text(x = MC$TYr, y = MC$Dec, labels = MC$Player) grid() abline(1,1) WHAT IS MY PROBLEM? The main title and the axis names doesn´t appear I want to put them on white but the script doesn´t run. Can any one guide me? The other problem is that the border of the x and y axis doesn´t appears... Hi Jose, I think this will be close to what you want. The black outer background and the white inner background obscure almost everything, and so you may have to specify nearly everything in the plot, or keep changing par(fg) and par(bg) as you add bits. plot(x = MC$TYr, y = MC$Dec) lim-par(usr) rect(lim[1],lim[3],lim[2],lim[4],col=white,border=white) points(x = MC$TYr, y = MC$Dec,col=black) axis(1,col=white) mtext(Last year Goals,side=2,line=2,col=white) mtext(Actual Goals,side=1,line=2,col=white) mtext(seq(8,20,by=2),at=seq(8,20,by=2),side=1,line=1,col=white) axis(2,col=white) mtext(seq(6,18,by=2),at=seq(6,18,by=2),side=2,line=1,col=white) mtext(Goals on game,at=14,line=2,cex=1.5,col=white) grid() abline(1,1,col=black) box(col=white) 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.