[R] Using ts and timeSeries
Hello. I have been working on a project which involves random number generation and unit root test. After I generate the numbers (I am generating stock returns using rnorm(1000,0,0.25), I want to check if the series has a unit root or not. But before I should modify the data to time series. My question is which of the functions ts or timeSeries more appropriate to test unit root using Augmented Dickey Fuller test? Thank you. -- View this message in context: http://r.789695.n4.nabble.com/Using-ts-and-timeSeries-tp3598693p3598693.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] Pointers in R
One thing to keep in mind is the no side effects rule in R. Almost all variables are copied on assignment/modification. Of course, there's also lazy instantiation, so the copy isn't actually constructed unless it needs to be, but this can impact the expected performance of more complicated data structures built in pure R. Jamie Olson School of Computer Science Carnegie Mellon University 5000 Forbes Ave. Pittsburgh, PA 15213 jfol...@cs.cmu.edu On Sun, Jun 12, 2011 at 7:36 PM, Jeff Newmiller jdnew...@dcn.davis.ca.uswrote: Lists are recursive and heterogenous in R. Just assign the values to elements in lists and assign those lists to elements in other lists to build your tree. --- Jeff Newmiller The . . Go Live... DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Jaimin Dave davejaim...@gmail.com wrote: Hello Everyone, I am new to R and would like to create a quad tree in R. However the problem is that I don't think R has pointers. Is there any way to create a tree in R? Thanks [[alternative HTML version deleted]] _ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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 can I write methods for 'as()'?
Since nobody else has respond, I thought I'd take a stab. Maybe if I'm wrong enough somebody will correct me, but my understanding is that that kind of situation, ie the pain of getting the correct method called when there is a dependency on the type of more than one argument is part of the motivation behind the S4 classes. So maybe it really just is that kludgy for s3 classes. Jamie Olson School of Computer Science Carnegie Mellon University 5000 Forbes Ave. Pittsburgh, PA 15213 jfol...@cs.cmu.edu On Mon, Jun 6, 2011 at 12:19 PM, Janko Thyson janko.thyson.rst...@googlemail.com wrote: Okay, I found something that is working, but it looks and feels pretty awkward as the method def and method lookup takes place in one function ;-) setRefClass(A, fields=list(X=numeric)) setRefClass(B, contains=A, fields=list(Y=character)) mySetAs - function( from, to ){ if(!existsMethod(f=coerce, signature=c(from=class(from), to=to))){ setAs(from=class(from), to=to, def=function(from, to){ out - getRefClass(to)$new(X=from) return(out) } ) } mthd - selectMethod(coerce, signature=c(from=class(from), to=to), useInherited= c(from=TRUE, to=TRUE)) out - mthd(from=from, to=to) return(out) } a - mySetAs(from=1:5, to=A) a$X b - mySetAs(from=1:5, to=B) b$X I'm sure there are much better ways. I'd appreciate any comments whatsoever. Best regards, Janko On 06.06.2011 17:46, Janko Thyson wrote: Somehow I don't see my own postings in the list, so sorry for replying to my own message and not the one that went out to the list. I got a little further and I think I found exactly the thing that is bothering me: how to get extended method dispatch going in 'setAs()': setRefClass(A, fields=list(X=numeric)) setRefClass(B, contains=A, fields=list(Y=character)) setAs(from=numeric, to=A, def=function(from,to){ out - getRefClass(to)$new(X=from) return(out) } ) a - as(1:5, A) a$X b - as(1:5, B) My problem is the last statement (b - as(1:5, B) which fails. I want to get around having to write new 'setAs' methods for all classes extending class 'A'. If 'B' inherits from 'A', shouldn't it then be possible to tell 'setAs' to look for the next suitable method, i.e. the method defined for 'A'? I tried 'NextMethod()' inside the body of 'setAs' but that didn't work out. Thanks a lot, Janko On 06.06.2011 17:15, Janko Thyson wrote: Dear list, I wonder how to write methods for the function 'as' in the sense that I can call 'as(object, Class, strict=TRUE, ext)' and let method dispatch figure out the correct method. AFAIU, there is a difference between, e.g. 'as.data.frame' and the methods of 'as()' as stated above since the former depends on arg 'x' instead of 'object', 'Class' etc.? methods(as) as.data.frame I have to admit that I'm not really familiar with the S3 style of defining methods as I have been coding in S4 a lot, but my first attempt was to write something like this: as.myClass - function(x, ...){ if(is(x, data.frame){ x - as.list(x) } if(is(x, character){ x - as.list(x) } ... out - getRefClass(myClass)$new(X=x) return(out) } But that way I'd have to explicitly call 'as.myClass(x)' whereas I'd simply like to type 'as(x, myClass)'. Also, how is it possible to have method dispatch recognize two signature arguments in S3? I.e., how can I define something like 'as.data.frame.character' in order to have explicit sub methods for all the data types of 'x' so I wouldn't have to process them all in the definition of 'as.myClass' as I did above? Thanks for your help, Janko [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Traversing KD-tree (or equivalent) for radius-based search
There aren't a whole lot of more complex data structures available as R packages. My impression is that pure R implementation offers dissatisfactory performance and native (or e.g. java) implementations end up inconsistent with R's no side effects principles. I'd suggest building an R interface to whatever spatial data structures you want, e.g. k-d or r(+/*)-trees. Jamie Olson School of Computer Science Carnegie Mellon University 5000 Forbes Ave. Pittsburgh, PA 15213 jfol...@cs.cmu.edu On Thu, Jun 2, 2011 at 8:43 PM, Andrea Taverna a.t...@libero.it wrote: Hi, I'm trying to implement the DBSCAN algorithm to get O(N*LogN) complexity and I'd need a spatial tree of some sort (kd,r,bd..), or a function that computes radius-based search on spatial data, i.e. given a radius eps finds ALL the points which fall in the corresponding hypersphere centered on the current examined point. Is there a package with this features? So far I found RANN and other packages whose name I can't remember (I don't have them with me a.t.m.), and they all seemed to offer a nearest-neighbour search, which asks for an upper limit to the number of points to be found, but no direct access to the spatial tree they used . The algorithms they provide are built around that limit and setting it to large values makes their execution impractical. OTOH, as far as I have understood, DBSCAN needs to know all the points in the eps-neighbourhood, or will create too many clusters, especially if there are really high-density region, as it happened when I used RANN's nn2 function in my implementation. thanks in advance, Andrea Taverna __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Standard deviation and Mean
On 14.06.2011 22:29, Daniel Malter wrote: Hi, pick up any introductory manual of which there are many online. It so happens that the functions for mean and sd are called mean() and sd(). If you want to know how to use them type ?mean or ?sd in the R-prompt and hit enter. ... and some rants back. Can you please 1. also reply to the original sender who may not be subscribed to the list and hence never receives the answer 2. quote the messages you are referring to, mailing list readers of this R-help *mailing list* won't see it otherwise Uwe Ligges Daniel -- View this message in context: http://r.789695.n4.nabble.com/Standard-deviation-and-Mean-tp3597521p3597734.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] How to generate bivariate exponential distribution?
On Tue, Jun 14, 2011 at 08:40:00AM -0700, xuyongdeng wrote: Any one know is there any package or function to generate bivariate exponential distribution? I gusee there should be three parameters, two rate parameters and one correlation parameter. I just did not find any function available on R. Any suggestion is appreciated. Do you have a specific bivariate exponential distribution in mind? If not, then try the following n - 1000 lambda1 - 2 lambda2 - 3 common - 1 x1 - rexp(n, rate=lambda1-common) x2 - rexp(n, rate=lambda2-common) z - rexp(n, rate=common) y1 - pmin(x1, z) y2 - pmin(x2, z) The variables y1, y2 have exponential distribution with rates lambda1, lambda2 and they are positively correlated, if 0 common min(lambda1, lambda2) The correlation increases with increasing common. Petr Savicky. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Side by side scatter plots with specified regression lines
Dear Sigrid, This is very easy with the ggplot2 package install.packages(ggplot2) library(ggplot2) ggplot(data = Your.Data.Frame, aes(x = YEAR, y = YIELD, colour = TREATMENT)) + geom_point() + geom_smooth(method = lm) + facet_wrap(~Country) Best regards, Thierry -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Sigrid Verzonden: zondag 12 juni 2011 21:47 Aan: r-help@r-project.org Onderwerp: [R] Side by side scatter plots with specified regression lines I am new and self taught in R, so please bear with me. I want to create two scatter plots side by side. The data set includes measurements from two different countries with 7 treatments over a timeline (x-axis). Problem 1 I want to have each plot to include the data from one of the countries with 7 regression lines of the treatments, but I do no know how to divide the data between them. This is how I created one plot with all the data. plot(YEAR,YIELD,col=red,xlab=Year,ylab=Yield,xlim=c(1,4),ylim=c( 1,150)) Problem 2 The models I've found to describe the regression lines of the treatments seems to be different than the default ablines that R creates. I have the values of the exact values of intercepts and slopes, but does not know how to add them to the graph. This is what I got so far. abline(lm(YIELD[TREATMENT==A]~YEAR[TREATMENT==A]),lty=2,col=1) I hope this is enough to give me some pointers, otherwise I will try to elaborate. Thank you for your help. -- View this message in context: http://r.789695.n4.nabble.com/Side-by-side- scatter-plots-with-specified-regression-lines-tp3592473p3592473.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] Odp: problems with plots in loop (corrected Email)
Hi r-help-boun...@r-project.org napsal dne 14.06.2011 18:28:42: Andreas Betz ab...@portola.com Odeslal: r-help-boun...@r-project.org 14.06.2011 18:28 Komu r-help@r-project.org Kopie Předmět [R] problems with plots in loop (corrected Email) Dear helpers, In an attempt to use a loop to generate graphs in a for loop in run into a problem. The plan is to fill each page with eight graphs (mfrow = c(4,2)) in to two columns. Only the buttom graphs ( meaning every fourth graph) have tick labels on the x axis to preserve space. I used an if Else statement to achieve that. The problem is that the first eight graphs are skipped when I run the loop, the other graphs are fine. However, all graphs can be generated individually. This indicates that the data sets are fine. Pulling the results from a nonlinear regression to more than 90 data sets from a list (resultslist[[i]]) Generating the first derivative and multiply it by 100 to adjust for the scale. Here is the code. pdf('F:/diffnormal_16001a.pdf') par(mfcol = c(4,2)) for(i in 1: 92){ fit - NULL der - NULL Zeit - NULL Zeit - seq(0,300) try(guess - predict(resultslist_1600[[i]]) ) if(class(guess) == try-error) {next} fit - smooth.spline(Zeit, guess) der - 100*(predict(fit, Zeit, deriv = 1))$y if((i/4)%%1 ==0){par(mar =c(4,4,0, 0) + 0.1)} else{par(mar =c(0,4,0, 0) + 0.1)} Maybe the else just moved due to mailer but it shall be on the same line as if statement to be executed. But in that case you would obtain error message. However when I get rid of all I do not have from your code pdf(test.pdf) par(mfcol = c(4,2)) for(i in 1: 8){ fit - NULL der - NULL Zeit - NULL Zeit - seq(0,300) if((i/4)%%1 ==0){par(mar =c(4,4,0, 0) + 0.1)} else{par(mar =c(0,4,0, 0) + 0.1)} leg = paste(Data_, i,sep = ) plot(Zeit, Zeit, pch = 19, cex=3, ylab = Signal, axes = F) if((i/4)%%1 ==0){axis(1, at = seq(0, 360, length = 6), label = c(), font = 2)} mtext(side = 3, leg, line = -2)} dev.off() It seems to me that plotting works as expected. Regards Petr leg = paste(Data_, i,sep = ) plot(resultslist_1600[[i]], type = all, pch = ., ylab = Signal, log = , axes = F) lines(Zeit, der) if((i/4)%%1 ==0){axis(1, at = seq(0, 360, length = 6), label = c(), font = 2)} axis(2, at = pretty(na.omit(eval(parse(text=paste(bleeder1600[,,i,],sep =), label = c()) mtext(side = 3, leg, line = -2)} I understand, that I am supposed to submit working code. However, I deal with a fairly comprehensive data set and I have to generate a large list using another R package. Thus I explain what it does: Generate time points(Zeit - seq(0,300) Pulling the results from a nonlinear regression to more than 90 data sets from a list (resultslist_1600[[i]]) Test if prediction can be done try(guess - predict(resultslist_1600[[i]]) ) if(class(guess) == try-error) {next} (it turned out it can be done for all data set, as I am able to generate the graphs for each data set from the command line individually. Generating the first derivative and multiply it by 100 to adjust for the scale. fit - smooth.spline(Zeit, guess) der - 100*(predict(fit, Zeit, deriv = 1))$y The problem appears to be hidden in the mfrow statement. I spent quite a bit of time on this problem, thus any help or new ideas would be very much appreciated. Thank you Andreas Betz Scientist andreasbetz@ Dear helpers, In an attempt to use a loop to generate graphs in a for loop in run into a problem. The plan is to fill each page with eight graphs (mfrow = c(4,2)) in to two columns. Only the buttom graphs ( meaning every fourth graph) have tick labels on the x axis to preserve space. I used an if Else statement to achieve that. The problem is that the first eight graphs are skipped when I run the loop, the other graphs are fine. However, all graphs can be generated individually. This indicates that the data sets are fine. Pulling the results from a nonlinear regression to more than 90 data sets from a list (resultslist[[i]]) Generating the first derivative and multiply it by 100 to adjust for the scale. Here is the code. pdf('F:/diffnormal_16001a.pdf') par(mfcol = c(4,2)) for(i in 1: 92){ fit - NULL der - NULL Zeit - NULL Zeit - seq(0,300) try(guess - predict(resultslist_1600[[i]]) ) if(class(guess) == try-error) {next} fit - smooth.spline(Zeit, guess) der - 100*(predict(fit, Zeit, deriv = 1))$y if((i/4)%%1 ==0){par(mar =c(4,4,0, 0) + 0.1)} else{par(mar =c(0,4,0, 0) + 0.1)} leg = paste(Data_, i,sep = ) plot(resultslist_1600[[i]], type = all, pch = ., ylab = Signal, log = , axes = F) lines(Zeit, der) if((i/4)%%1 ==0){axis(1, at = seq(0, 360, length = 6), label = c(), font = 2)}
Re: [R] plotting on an image
Thanks Greg, Using rasterImage and the steps you described works fine! I agree with the distraction! But my purpose is to superimpose a heat map of eye tracking data on the original picture... Thanks! - original message Subject: RE: [R] plotting on an image Sent: Wed, 15 Jun 2011 From: Greg Snowgreg.s...@imail.org If you are willing to prepend a step then you could: 1. Create an empty plot using your data and type='n' (or just plot the data, the points will be overwritten), you may want to set the asp argument, or explicitly do the xlim and ylim arguments. 2. Add the graphic using the rasterImage function 3. Use functions such as points or lines (or others that add to existing plots) to plot you data on top of the image. If you need certain points within the image to correspond to certain coordinates then the locator and updateusr (TeachingDemos package) may be of help. But in all of this, make sure that you really want to do this, often (but not always) putting an image in the background is chartjunk that distracts more than helps. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Johann Kim Sent: Monday, June 13, 2011 12:33 PM To: r-help@r-project.org Subject: [R] plotting on an image Hello all, has someone please a few hints about how to 1.st: draw an image (preferrably a jpg) and then 2nd: plot() on that image I am using a mac - and after searching and trying different ways (I have installed EBImage) I now would like to ask for help... Thanks! Johann __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. --- original message end __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Reshaping data with xtabs reorders my rows
Dear, I have a data frame melted from a list of matrices (melt from reshape package), then I impute some missing values and then want to tabulate the data again to the array (or list, doesn't matter) of matrices form. However when using xtabs function it orders my rows alphabetically and apparently doesn't take reorder = FALSE option or anything like it. Is there anything I can do to stop it from doing so? Relevant parts of code: matrices.m - melt(combined_list) matrices.m_i[is.na(matrices.m_i$value),]$value - predictions matrices - xtabs(value ~ location + variable + week, data = matrices.m_i) -- while(!succeed) { try(); } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] heatmap with values
On 06/14/2011 08:53 PM, Agustin Lobo wrote: Hi! I'm displaying a contingency table with heatmap(): svm.predPix.tabla svm.predPix CC DD LL NN NN2 CC 22 0 3 8 3 DD 0 27 0 1 0 LL 1 1 90 3 7 NN 2 0 1 11 4 NN2 0 0 5 1 20 heatmap(svm.predPix.tabla[5:1,], Rowv=NA, Colv=NA,col = rev(heat.colors(32)), scale=column, margins=c(5,10)) and I'm happy with the plot except that I would like to have the actual values displayed within each cell. Any help on how to achieve this? Data in https://sites.google.com/site/openfiles2/home/svm.predPix.tabla.rda Hi Agustin, I was going to send the code from color2D.matplot to display the values, but it required so much modification that I would suggest: library(plotrix) color2D.matplot(svm.predPix.tabla,show.values=TRUE,axes=FALSE, xlab=,ylab=) axis(1,at=0.5:4.5,labels=rownames(svm.predPix.tabla)) axis(2,at=4.5:0.5,labels=colnames(svm.predPix.tabla)) 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] Fitting a choice model (Bradley-Terry generalization)
I have some data I would like to model which involves choice of food by dung beetles. There are a number of experiments where in each case, there are five choices. Overall there are more than 5 different foods being compared (including a placebo) and different experiments use different comparisons. The problem is a generalization of Bradley-Terry but it differs from some generalizations in that the comparisons are not pairwise, and they don't produce a full ordering, just that one is preferred to the other four possibilities. I have had a look at the BradleyTerry2, eba, pmr and MLCM packages, none of which appear to provide the required functionality. I have also looked at a number of papers (Hunter, 2004; Firth, 2005; Huang Weng and Lin, 2006; and Fujimoto, Hino and Murata 2011). I think fitting using maximum likelihood should be possible, but would welcome any pointers to useful code, relevant ideas, or similar analyses. David Scott __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Fitting a choice model (Bradley-Terry generalization)
On Wed, 15 Jun 2011, David Scott wrote: I have some data I would like to model which involves choice of food by dung beetles. There are a number of experiments where in each case, there are five choices. Overall there are more than 5 different foods being compared (including a placebo) and different experiments use different comparisons. The problem is a generalization of Bradley-Terry but it differs from some generalizations in that the comparisons are not pairwise, and they don't produce a full ordering, just that one is preferred to the other four possibilities. In some cases such comparisons are coded with undecided for those comparisons that are not fully ranked. Alternatively, sometimes they are also coded with NAs. For example, if A is preferred over B and C, this may be coded as: A B, A C, B = C or A B, A C, NA. I have had a look at the BradleyTerry2, eba, pmr and MLCM packages, none of which appear to provide the required functionality. That depends what you think the required functionality is. If it is dealing with NAs, then some certainly have the functionality. Similarly, dealing with undecided is provided in several implementations. Additionally, to the packages above, the prefmod package provides a Bradley-Terry models as well as pattern models which might be interesting for you. The VGAM package can estimate Bradley-Terry models, see http://www.jstatsoft.org/v32/i10/. Finally, the psychotree package provides a class paircomp for representing paired comparison data, to estimate Bradley-Terry models, and in particular to assess the influence of covariates on such a model by recursive partitioning (see example(bttree, package = psychotree)). hth, Z I have also looked at a number of papers (Hunter, 2004; Firth, 2005; Huang Weng and Lin, 2006; and Fujimoto, Hino and Murata 2011). I think fitting using maximum likelihood should be possible, but would welcome any pointers to useful code, relevant ideas, or similar analyses. David Scott __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Query regarding auto arima
I am using AUTO ARIMA for forecasting. But it is not detecting 'seasonality term' of its own for any data. Is there any other method by which we can detect seasonality and its frequency for any data? Is there any method through which seasonality and its frequency can be automatically detected from ACF plot? -- Siddharth Arun, 4th Year Undergraduate student Industrial Engineering and Management, IIT Kharagpur [[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] Legend in lattice
Dear all, I have been working in a plot based on figure 5.6 of the Lattice book (http://lmdvr.r-forge.r-project.org/figures/figures.html). I have already modified it to include the size of the circles as another variable, but I would like to modify the legend to show it (like they do it in http://www.jstatsoft.org/v15/i05/paper). I have divided my variable in intervals: DATA$s_Shape_2 - cut(x=DATA$Shape_inde,breaks=c(0.999,1.2,1.4,1.7,2.1,5)) I will use the index of the categories as the radius of the circles. Now, following the aforementioned figure 5.6, I have the following code: NDVI.breaks - do.breaks(range(DATA.ord$NDVI), 50) xyplot(Y_Center_P~X_Center_P|Level,data=DATA.ord,col = black,aspect = iso, fill.color = DATA.ord$c_RNDVI, cex = DATA$s_Shape_2, panel = function(x, y, fill.color, cex,..., subscripts) { fill - fill.color[subscripts] cex - cex[subscripts] panel.grid(h = -1, v = -1) panel.xyplot(x, y, pch = 21, fill = fill, cex = cex,...) }, legend = list(right = list(fun = draw.colorkey, args = list(key = list(col = rainbow, at = NDVI.breaks), draw = FALSE))) ) How can I add the categories with circles of their respective sizes to the legend? I hope this is enough information to have some help. If not, let me know. Regards. Julio. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Count occurances in integers (or strings)
Hi, I have a dataframe column from which I want to calculate the number of 1's in each entry. Some column values could, for example, be 0001001000 and 111. To get the number of occurrences from a string I use this: sum(unlist(strsplit(mydata[,my_column], )) == 1) However, as my data is not in string form.. How do I convert it? l tried: lapply(mydata[,my_column],toString) but I do not seem to get it right (or at least I do not understand the output format). Also, are there other options? Can I easily calculate the occurrences directly from the integers? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Find values from one dataframe between certain values in another dataframe
Hi all, I have a 2 files, one with a series of beginning and end times of animal dives in (lets call it dives). The other file is readings from a time-depth recorder, there is a datetime reading for every second, a temperature and light level reading (lets call it tdr). Now I want to say from the file dives, using the start and end time of the dives, go to the tdr file and find me the temperature values that falls inbetween the times of the start and end times. So this is what I have written: dives-read.csv(file)#table with begin and end times of dives tdr-read.csv(file2)#table with every second readings of temp and light level dat-{} #just create empty thing for (i in 1:nrow(dives)){ st-x[i,1] # start datetime value for dive[i]. Column one is the start of dive datetime value ed-x[i,4] # end datetime value for dive[i] Column 4 is the end of the dive datetime value f-which(tdr[,2]=st tdr[,2]=ed) # find row numbers where tdr datetimes is between start #end times of dive[i]. Column 2 is the datetime value z1-tdr[f,5] # extract temperature values maxtemp-max(z1) #out of those values find the max value dat-rbind(dat,maxtemp) #add that row onto a dat } The problem is when I just want to check wat f is it keeps telling me interger(0). It says that there are no values in tdr that falls between the start and end of the dives. But there is, I have checked. I reckoned that it has to do with the format of the datetime values. I couldnt find how to convert it to a numeric value. At the moment my datetime values are in a POSIXct format defined as follows as.POSIXct(strptime((dive$begindive),'%Y/%m/%d %H:%M:%S'),tz=GMT) I have also tried to sort the tdr data first in ascending order tdr - tdr[order(tdr$datetime),] #sort z according to dtime I have even tried to convert to numeric format in excell (all three datetime values) and then use those numerics in R but it still doesnt want to work. The problem lies in the f-which(tdr[,2]=st tdr[,2]=ed) line. It doenst find any values from tdr that are between st and ed. But there definately is, I have done a manual check. Any help is appreciated, thank you. Mia -- View this message in context: http://r.789695.n4.nabble.com/Find-values-from-one-dataframe-between-certain-values-in-another-dataframe-tp3599033p3599033.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] Query regarding auto arima
On Wed, 15 Jun 2011, siddharth arun wrote: I am using AUTO ARIMA for forecasting. I assume you mean function auto.arima() from package forecast. But it is not detecting 'seasonality term' of its own for any data. Yes, it does so, if you supply a time series object with a frequency 1. Is there any other method by which we can detect seasonality and its frequency for any data? Is there any method through which seasonality and its frequency can be automatically detected from ACF plot? Usually you _know_ the frequency (i.e., 12 for monthly and 4 for quarterly data etc.). For example for the famous monthly AirPassengers series: library(forecast) auto.arima(AirPassengers) which returns a seasonal ARIMA model. See ?auto.arima for tweaking its arguments as well as the accompanying paper http://www.jstatsoft.org/v27/i03/ for more details. Z -- Siddharth Arun, 4th Year Undergraduate student Industrial Engineering and Management, IIT Kharagpur [[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] Rmpi installation
Hi there I am trying to install Rmpi (version 0.5-4) on our 8-core SUSE Linux Enterprise Server 11 SP1. I read all I could find about Rmpi installation but still cannot get it working. Here the last command that I used: R CMD INSTALL --configure.args=--with-Rmpi-include=/usr/lib64/mpi/gcc/openmpi/include \ --with-Rmpi-libpath=/usr/lib64/mpi/gcc/openmpi/lib64 \ --with-Rmpi-type=OPENMPI Rmpi_0.5-4.tar.gz Resulting in the following: zytosrv01dmi:/home/unger/R_projects/OS # R CMD INSTALL --configure-args=--with-Rmpi-include=/usr/lib64/mpi/gcc/openmpi/include \--with-Rmpi-libpath=/usr/lib64/mpi/gcc/openmpi/lib64 \ --with-Rmpi-type=OPENMPI Rmpi_0.5-4.tar.gz * installing to library Œ/usr/local/lib64/R/library¹ * installing *source* package ŒRmpi¹ ... checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking mpi.h usability... no checking mpi.h presence... no checking for mpi.h... no Try to find libmpi or libmpich ... checking for main in -lmpi... no libmpi not found. exiting... ERROR: configuration failed for package ŒRmpi¹ * removing Œ/usr/local/lib64/R/library/Rmpi¹ So obviously libmpi is not found. Doing a locate search for libmpi (straight after updatedb) shows: zytosrv01dmi:/home/unger/R_projects/OS # locate libmpi /opt/mpich/ch-p4/lib64/libmpich.a /opt/mpich/ch-p4/lib64/libmpichf90.a /opt/mpich/ch-p4/lib64/libmpichf90nc.a /opt/mpich/ch-p4/lib64/libmpichfarg.a /opt/mpich/ch-p4/lib64/libmpichfsup.a /opt/mpich/ch-p4mpd/lib64/libmpich.a /opt/mpich/ch-p4mpd/lib64/libmpichf90.a /opt/mpich/ch-p4mpd/lib64/libmpichf90nc.a /opt/mpich/ch-p4mpd/lib64/libmpichfarg.a /opt/mpich/ch-p4mpd/lib64/libmpichfsup.a /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_cxx.la /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_cxx.so /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_cxx.so.0 /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_cxx.so.0.0.0 /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_f77.la /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_f77.so /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_f77.so.0 /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_f77.so.0.0.0 /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_f90.la /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_f90.so /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_f90.so.0 /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_f90.so.0.0.0 /usr/lib64/mpi/gcc/openmpi/lib64/libmpi.la /usr/lib64/mpi/gcc/openmpi/lib64/libmpi.so /usr/lib64/mpi/gcc/openmpi/lib64/libmpi.so.0 /usr/lib64/mpi/gcc/openmpi/lib64/libmpi.so.0.0.0 What lets me assume that the path to libmpi is /usr/lib64/mpi/gcc/openmpi/lib64 which I already included in the options... How can I get this working? I would highly appreciate any help on this! Best wishes Kristian Dr. Kristian Unger Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Helmholtz Zentrum München Deutsches Forschungszentrum für Gesundheit und Umwelt (GmbH) Ingolstädter Landstr. 1 85764 Neuherberg www.helmholtz-muenchen.de Aufsichtsratsvorsitzende: MinDir´in Bärbel Brumme-Bothe Geschäftsführer: Prof. Dr. Günther Wess und Dr. Nikolaus Blum Registergericht: Amtsgericht München HRB 6466 USt-IdNr: DE 129521671 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Still have problems with tcltk in R 64 bit
I agree that this is a really outdated source but I did not find the way to tell R using correctly the tcl version included (at least for the 64 bit version). If I remove the environment variables, things work for R 32 bit (it uses the tcl version included), but it does not work in R 64 bit. Where are the configuration files used to define the path to each tcl version ? Arnaud 2011/6/14 Uwe Ligges lig...@statistik.tu-dortmund.de: On 14.06.2011 22:01, Arnaud Mosnier wrote: I achieve to make tcltk work on R 64 installing Active tcltk8.5 64bit version then setting windows environment variables as in http://www.sciviews.org/_rgui/tcltk/InstallRTclTk.html. Don't read outdated sources but the manuals. The R binary distribution comes with tcltk under Windows (in ${R_HOME}/tcl) for both 32-bit and 64-bit and will user a different tcl if you set environment variables. Hence the easiest thing is just to tell R not to use your otehrwise set environment variabes and use its own tcl version. Uwe Ligges But now, it uses only this 64 bit version and thus do not work anymore in R 32 bit ! In my case, it solves my problem as I will probably use only R 64bit but I do not like to end with an half solution. Arnaud 2011/6/14 Peter Langfelderpeter.langfel...@gmail.com: On Tue, Jun 14, 2011 at 12:47 PM, Adrienne Woottenamwoo...@ncsu.edu wrote: Taking a quick look for it, it seems that they have replaced it with tcltk2. I just did the installation with the same version in windows and it auto loaded the tcltk package and I never installed that package to begin with. I would try it with tcltk2 and see if you get the package to install appropriately. I'm not sure why tcltk isn't on CRAN anymore, it makes no sense not to have both tcltk and tcltk2, but here's hoping this helps you out. A FWIF, tcltk still exists but is now part of the standard R distribution (core packages is the term I think?) and as such is installed automatically when you install R. Therefore it is not available from CRAN. Peter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Rmpi installation
Hmm, looks like there was a trailing blank after the backslash and before end of line, resulting in --with-Rmpi-libpath possibly not recognised: \--with-Rmpi-libpath=/usr/lib64/mpi/gcc/openmpi/lib64 \ I also doubt there is real need to escape newlines within a string. But another possible problem source is that according to R CMD INSTALL --help, the parameter is called --configure-args, not configure.args. $ R CMD INSTALL --configure-args=--with-Rmpi-include=/usr/lib64/mpi/gcc/openmpi/include --with-Rmpi-libpath=/usr/lib64/mpi/gcc/openmpi/lib64 -- with-Rmpi-type=OPENMPI Rmpi_0.5-4.tar.gz Best On Wednesday 15 June 2011 14:25:46 Unger, Kristian, Dr. wrote: Hi there I am trying to install Rmpi (version 0.5-4) on our 8-core SUSE Linux Enterprise Server 11 SP1. I read all I could find about Rmpi installation but still cannot get it working. Here the last command that I used: R CMD INSTALL --configure.args=--with-Rmpi-include=/usr/lib64/mpi/gcc/openmpi/include \ --with-Rmpi-libpath=/usr/lib64/mpi/gcc/openmpi/lib64 \ --with-Rmpi-type=OPENMPI Rmpi_0.5-4.tar.gz Resulting in the following: zytosrv01dmi:/home/unger/R_projects/OS # R CMD INSTALL --configure-args=--with-Rmpi-include=/usr/lib64/mpi/gcc/openmpi/include \--with-Rmpi-libpath=/usr/lib64/mpi/gcc/openmpi/lib64 \ --with-Rmpi-type=OPENMPI Rmpi_0.5-4.tar.gz * installing to library Œ/usr/local/lib64/R/library¹ * installing *source* package ŒRmpi¹ ... checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking mpi.h usability... no checking mpi.h presence... no checking for mpi.h... no Try to find libmpi or libmpich ... checking for main in -lmpi... no libmpi not found. exiting... ERROR: configuration failed for package ŒRmpi¹ * removing Œ/usr/local/lib64/R/library/Rmpi¹ So obviously libmpi is not found. Doing a locate search for libmpi (straight after updatedb) shows: zytosrv01dmi:/home/unger/R_projects/OS # locate libmpi /opt/mpich/ch-p4/lib64/libmpich.a /opt/mpich/ch-p4/lib64/libmpichf90.a /opt/mpich/ch-p4/lib64/libmpichf90nc.a /opt/mpich/ch-p4/lib64/libmpichfarg.a /opt/mpich/ch-p4/lib64/libmpichfsup.a /opt/mpich/ch-p4mpd/lib64/libmpich.a /opt/mpich/ch-p4mpd/lib64/libmpichf90.a /opt/mpich/ch-p4mpd/lib64/libmpichf90nc.a /opt/mpich/ch-p4mpd/lib64/libmpichfarg.a /opt/mpich/ch-p4mpd/lib64/libmpichfsup.a /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_cxx.la /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_cxx.so /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_cxx.so.0 /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_cxx.so.0.0.0 /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_f77.la /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_f77.so /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_f77.so.0 /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_f77.so.0.0.0 /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_f90.la /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_f90.so /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_f90.so.0 /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_f90.so.0.0.0 /usr/lib64/mpi/gcc/openmpi/lib64/libmpi.la /usr/lib64/mpi/gcc/openmpi/lib64/libmpi.so /usr/lib64/mpi/gcc/openmpi/lib64/libmpi.so.0 /usr/lib64/mpi/gcc/openmpi/lib64/libmpi.so.0.0.0 What lets me assume that the path to libmpi is /usr/lib64/mpi/gcc/openmpi/lib64 which I already included in the options... How can I get this working? I would highly appreciate any help on this! Best wishes Kristian Dr. Kristian Unger Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Helmholtz Zentrum München Deutsches Forschungszentrum für Gesundheit und Umwelt (GmbH) Ingolstädter Landstr. 1 85764 Neuherberg www.helmholtz-muenchen.de Aufsichtsratsvorsitzende: MinDir´in Bärbel Brumme-Bothe Geschäftsführer: Prof. Dr. Günther Wess und Dr. Nikolaus Blum Registergericht: Amtsgericht München HRB 6466 USt-IdNr: DE 129521671 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide
Re: [R] Heatmap in R and/or ggplot2
On Tue, Jun 14, 2011 at 19:56, idris idris.r...@gmail.com wrote: Follow up question: My data contains x, y, height, and day. I want to create the heatmap for each day, keeping the color coding consistent. I've created an example with 2 days, and you can see the charts below. Notice that the legend changes from day 1 to day 2. How can I make the legend consistent? Also, my real data contains hundreds of days. Is there a way to create a 'movie' or a sequence of the heatmaps in chronological order of days? The way my code works now is obviously very naive as it just repeats the same code for day 1 and day 2. Is there a better way to do this? legend: use the limit argument of scale_fill_gradientn and set it to the max and min of height across all days movie: there is no way to do that in R alone (that I know of). you can: 1- use the jpeg or png device with a name including a special code which increases every time a new plot is produced (this is the default) 2- plot the successive plots in a for loop 3- turn the sequence of images into a movie using specialized software. For step 3 you could use guicktime on Mac OS X or mencoder on Linux/OS X. I don't know about Windows. Since mencoder works on the command line, you can call it from R and I have code to ease that: https://gitorious.org/r/r-utils/blobs/master/lib_movie.R but you should get familiar with mencoder a little bit before trying to read/understand it. JiHO --- http://maururu.net __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rmpi installation
Thank you very much Hugo. Using the command as suggested results exactly the same error: # R CMD INSTALL --configure-args=--with-Rmpi-include=/usr/lib64/mpi/gcc/openmpi/include --with-Rmpi-libpath=/usr/lib64/mpi/gcc/openmpi/lib64 --with-Rmpi-type=OPENMPI Rmpi_0.5-4.tar.gz * installing to library ‘/usr/local/lib64/R/library’ * installing *source* package ‘Rmpi’ ... checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking mpi.h usability... no checking mpi.h presence... no checking for mpi.h... no Try to find libmpi or libmpich ... checking for main in -lmpi... no libmpi not found. exiting... ERROR: configuration failed for package ‘Rmpi’ * removing ‘/usr/local/lib64/R/library/Rmpi’ Best wishes Kristian Dr. Kristian Unger Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Tel.: +49-89-3187-3515 Mob.: +49-160-90641879 Am 15.06.11 15:12 schrieb Hugo Mildenberger unter hugo.mildenber...@web.de: Hmm, looks like there was a trailing blank after the backslash and before end of line, resulting in --with-Rmpi-libpath possibly not recognised: \--with-Rmpi-libpath=/usr/lib64/mpi/gcc/openmpi/lib64 \ I also doubt there is real need to escape newlines within a string. But another possible problem source is that according to R CMD INSTALL --help, the parameter is called --configure-args, not configure.args. $ R CMD INSTALL --configure-args=--with-Rmpi-include=/usr/lib64/mpi/gcc/openmpi/include --with-Rmpi-libpath=/usr/lib64/mpi/gcc/openmpi/lib64 -- with-Rmpi-type=OPENMPI Rmpi_0.5-4.tar.gz Best On Wednesday 15 June 2011 14:25:46 Unger, Kristian, Dr. wrote: Hi there I am trying to install Rmpi (version 0.5-4) on our 8-core SUSE Linux Enterprise Server 11 SP1. I read all I could find about Rmpi installation but still cannot get it working. Here the last command that I used: R CMD INSTALL --configure.args=--with-Rmpi-include=/usr/lib64/mpi/gcc/openmpi/include \ --with-Rmpi-libpath=/usr/lib64/mpi/gcc/openmpi/lib64 \ --with-Rmpi-type=OPENMPI Rmpi_0.5-4.tar.gz Resulting in the following: zytosrv01dmi:/home/unger/R_projects/OS # R CMD INSTALL --configure-args=--with-Rmpi-include=/usr/lib64/mpi/gcc/openmpi/include \--with-Rmpi-libpath=/usr/lib64/mpi/gcc/openmpi/lib64 \ --with-Rmpi-type=OPENMPI Rmpi_0.5-4.tar.gz * installing to library Œ/usr/local/lib64/R/library¹ * installing *source* package ŒRmpi¹ ... checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking mpi.h usability... no checking mpi.h presence... no checking for mpi.h... no Try to find libmpi or libmpich ... checking for main in -lmpi... no libmpi not found. exiting... ERROR: configuration failed for package ŒRmpi¹ * removing Œ/usr/local/lib64/R/library/Rmpi¹ So obviously libmpi is not found. Doing a locate search for libmpi (straight after updatedb) shows: zytosrv01dmi:/home/unger/R_projects/OS # locate libmpi /opt/mpich/ch-p4/lib64/libmpich.a /opt/mpich/ch-p4/lib64/libmpichf90.a /opt/mpich/ch-p4/lib64/libmpichf90nc.a /opt/mpich/ch-p4/lib64/libmpichfarg.a /opt/mpich/ch-p4/lib64/libmpichfsup.a /opt/mpich/ch-p4mpd/lib64/libmpich.a /opt/mpich/ch-p4mpd/lib64/libmpichf90.a /opt/mpich/ch-p4mpd/lib64/libmpichf90nc.a
Re: [R] Still have problems with tcltk in R 64 bit
Well, the R code in package tcltk for startup under Windows is, as you could have found out yourself easily: .onLoad - function(lib, pkg) { packageStartupMessage(Loading Tcl/Tk interface ..., domain = R-tcltk, appendLF = FALSE) if(!nzchar(tclbin - Sys.getenv(MY_TCLTK))) { tclbin - file.path(R.home(), Tcl, if(.Machine$sizeof.pointer == 8) bin64 else bin) if(!file.exists(tclbin)) stop(Tcl/Tk support files were not installed, call.=FALSE) if(.Machine$sizeof.pointer == 8) { lib64 - gsub(\\, /, file.path(R.home(), Tcl, lib64), fixed=TRUE) Sys.setenv(TCLLIBPATH = lib64) } } library.dynam(tcltk, pkg, lib, DLLpath = tclbin) .C(tcltk_start, PACKAGE=tcltk) addTclPath(system.file(exec, package = tcltk)) packageStartupMessage( , done, domain = R-tcltk) invisible() } This tells us that if you do not have MY_TCLTK defined on startup of R, you probably forgot to select the tcltk files for 64 bit from the installer when installing your version of R. Uwe Ligges On 15.06.2011 14:28, Arnaud Mosnier wrote: I agree that this is a really outdated source but I did not find the way to tell R using correctly the tcl version included (at least for the 64 bit version). If I remove the environment variables, things work for R 32 bit (it uses the tcl version included), but it does not work in R 64 bit. Where are the configuration files used to define the path to each tcl version ? Arnaud 2011/6/14 Uwe Liggeslig...@statistik.tu-dortmund.de: On 14.06.2011 22:01, Arnaud Mosnier wrote: I achieve to make tcltk work on R 64 installing Active tcltk8.5 64bit version then setting windows environment variables as in http://www.sciviews.org/_rgui/tcltk/InstallRTclTk.html. Don't read outdated sources but the manuals. The R binary distribution comes with tcltk under Windows (in ${R_HOME}/tcl) for both 32-bit and 64-bit and will user a different tcl if you set environment variables. Hence the easiest thing is just to tell R not to use your otehrwise set environment variabes and use its own tcl version. Uwe Ligges But now, it uses only this 64 bit version and thus do not work anymore in R 32 bit ! In my case, it solves my problem as I will probably use only R 64bit but I do not like to end with an half solution. Arnaud 2011/6/14 Peter Langfelderpeter.langfel...@gmail.com: On Tue, Jun 14, 2011 at 12:47 PM, Adrienne Woottenamwoo...@ncsu.edu wrote: Taking a quick look for it, it seems that they have replaced it with tcltk2. I just did the installation with the same version in windows and it auto loaded the tcltk package and I never installed that package to begin with. I would try it with tcltk2 and see if you get the package to install appropriately. I'm not sure why tcltk isn't on CRAN anymore, it makes no sense not to have both tcltk and tcltk2, but here's hoping this helps you out. A FWIF, tcltk still exists but is now part of the standard R distribution (core packages is the term I think?) and as such is installed automatically when you install R. Therefore it is not available from CRAN. Peter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Standard deviation and Mean
I post my replies through nabble. The second one, I can do. However, I would assume that subscribers would not only see my reply, but also the original reply, since the forum and email programs/platforms provide threaded msg-ing these days, or not? The first seems to be an either/or option in nabble, either private msg or for everyone to see, but not both. Da. Uwe Ligges-3 wrote: On 14.06.2011 22:29, Daniel Malter wrote: Hi, pick up any introductory manual of which there are many online. It so happens that the functions for mean and sd are called mean() and sd(). If you want to know how to use them type ?mean or ?sd in the R-prompt and hit enter. ... and some rants back. Can you please 1. also reply to the original sender who may not be subscribed to the list and hence never receives the answer 2. quote the messages you are referring to, mailing list readers of this R-help *mailing list* won't see it otherwise Uwe Ligges Daniel -- View this message in context: http://r.789695.n4.nabble.com/Standard-deviation-and-Mean-tp3597521p3597734.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. -- View this message in context: http://r.789695.n4.nabble.com/Standard-deviation-and-Mean-tp3597521p3599404.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Legend in lattice
Júlio, Your code is not reproducible, you doesn't provide any data. So I did a minimal code that illustrates a possible procedure is the following n - 30 da - data.frame(x=runif(n), y=runif(n), z=runif(n)) da$z - cut(da$z, seq(0,1,0.25)) require(lattice) xyplot(y~x, da, cex=as.numeric(da$z), col=1, key=list(points=list(cex=1:4, pch=1), text=list(levels(da$z)), columns=4)) Bests, Walmes. == Walmes Marques Zeviani LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W) Departamento de Estatística - Universidade Federal do Paraná fone: (+55) 41 3361 3573 VoIP: (3361 3600) 1053 1173 e-mail: wal...@ufpr.br twitter: @walmeszeviani homepage: http://www.leg.ufpr.br/~walmes linux user number: 531218 == [[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] Using MLE Method to Estimate Regression Coefficients
The error msg puts it quite clearly -- the initial parameters 1,1,1,1 are inadmissible for your function. You need to have valid initial parameters for the variable metric method (option BFGS). This is one of the main problems users have with any optimization method. It is ALWAYS a good idea to actually evaluate your function outside of the optimizer i.e., simply put in the initial parameters and find out what function value you get. It should also be noted (as the package optimx does) that the VM and CG based methods really don't do very well without analytic gradients. JN On 06/15/2011 06:00 AM, r-help-requ...@r-project.org wrote: Message: 46 Date: Tue, 14 Jun 2011 13:04:55 -0400 (GMT-04:00) From: boyla...@earthlink.net To: r-help@r-project.org Subject: [R] Using MLE Method to Estimate Regression Coefficients Message-ID: 11895593.1308071096125.javamail.r...@mswamui-andean.atl.sa.earthlink.net Content-Type: text/plain; charset=utf-8 Good Afternoon, I am relatively new to R and have been trying to figure out how to estimate regression coefficients using the MLE method. Some background: I am trying to examine scenarios in which certain estimators might be preferred to others, starting with MLE. I understand that MLE will (should) produce the same results as Ordinary Least Squares if the assumption of normality holds. That said, in the following code (my apologies up front for any lack of elegance) I use the data from the printing press study (commonly used in the QE and stats literature) to develop first and second order models using OLS. Then, using some code I found online, I tried to use MLE to do the same thing. However, I cannot get it to work, as I get an error in my attempt to use the optim function. I have been studying the optim function in R; I have also explored the use of MLE in the R documentation via the stats4, MASS, and a few other packages but to little avail. My questions are as follows: 1) Is there a particular error in the MLE code below that I am just not seeing? 2) Is there a simpler, more direct, or otherwise better way to approach it? 3) Which package should I use for MLE regression? Sorry for the length and thanks in advance for any assistance someone might have; I know your time is valuable. I have pasted my code below but have also attached as a .txt file. v/r, Greg Doctoral Student, Dept. of Industrial Eng, Clemson University [snip] # Now let's use the above function to estimate the model. model - optim(c(1,1,1,1), llik.regress, method=BFGS, control=list(fnscale=-1), hessian=TRUE) Error in optim(c(1, 1, 1, 1), llik.regress, method = BFGS, control = list(fnscale = -1), : initial value in 'vmmin' is not finite -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Rmpi installation
Kristian, I just tried that particular command here on a Gentoo system with openmpi-1.5.3 installed, because I wondered why the Rmpi configure script tests for main function in a shared library ... But I got a completly different output from configure. While the linker succeeds here, the package load test does not. However, on your system, may be the openmpi installation really is a kinda private one of gcc? I heard gcc makes use of openmpi internally. So is openmpi really installed? I just recognize that you are trying to use Rmpi_0.5-4.tar.gz while current version on CRAN is Rmpi_0.5-9.tar.gz. Best Hugo R CMD INSTALL --configure-args=--with-Rmpi-include=/usr/include --with-Rmpi-libpath=/usr/lib64/openmpi --with-Rmpi-type=OPENMPI Rmpi_0.5-9.tar.gz * installing to library ‘/home/hm/R/x86_64-pc-linux-gnu-library/2.13’ * installing *source* package ‘Rmpi’ ... checking for openpty in -lutil... no checking for main in -lpthread... no configure: creating ./config.status config.status: creating src/Makevars ** libs ** libs x86_64-pc-linux-gnu-gcc -std=gnu99 -I/usr/lib64/R/include -DPACKAGE_NAME=\\ -DPACKAGE_TARNAME=\\ -DPACKAGE_VERSION=\\ - DPACKAGE_STRING=\\ -DPACKAGE_BUGREPORT=\\ -I/usr/include -DMPI2 -DOPENMPI -I/usr/local/include-fpic -O3 -pipe -march=core2 - mtune=core2 -ggdb -c RegQuery.c -o RegQuery.o x86_64-pc-linux-gnu-gcc -std=gnu99 -I/usr/lib64/R/include -DPACKAGE_NAME=\\ -DPACKAGE_TARNAME=\\ -DPACKAGE_VERSION=\\ - DPACKAGE_STRING=\\ -DPACKAGE_BUGREPORT=\\ -I/usr/include -DMPI2 -DOPENMPI -I/usr/local/include-fpic -O3 -pipe -march=core2 - mtune=core2 -ggdb -c Rmpi.c -o Rmpi.o x86_64-pc-linux-gnu-gcc -std=gnu99 -I/usr/lib64/R/include -DPACKAGE_NAME=\\ -DPACKAGE_TARNAME=\\ -DPACKAGE_VERSION=\\ - DPACKAGE_STRING=\\ -DPACKAGE_BUGREPORT=\\ -I/usr/include -DMPI2 -DOPENMPI -I/usr/local/include-fpic -O3 -pipe -march=core2 - mtune=core2 -ggdb -c conversion.c -o conversion.o x86_64-pc-linux-gnu-gcc -std=gnu99 -I/usr/lib64/R/include -DPACKAGE_NAME=\\ -DPACKAGE_TARNAME=\\ -DPACKAGE_VERSION=\\ - DPACKAGE_STRING=\\ -DPACKAGE_BUGREPORT=\\ -I/usr/include -DMPI2 -DOPENMPI -I/usr/local/include-fpic -O3 -pipe -march=core2 - mtune=core2 -ggdb -c internal.c -o internal.o x86_64-pc-linux-gnu-gcc -std=gnu99 -shared -Wl,-O1 -Wl,--as-needed -o Rmpi.so RegQuery.o Rmpi.o conversion.o internal.o -L/usr/lib64/openmpi -lmpi -L/usr/lib64/R/lib -lR installiert nach /home/hm/R/x86_64-pc-linux-gnu-library/2.13/Rmpi/libs [...] ompi_mpi_init: orte_init failed -- Returned Not found (-13) instead of Success (0) On Wednesday 15 June 2011 15:19:22 Unger, Kristian, Dr. wrote: Thank you very much Hugo. Using the command as suggested results exactly the same error: # R CMD INSTALL --configure-args=--with-Rmpi-include=/usr/lib64/mpi/gcc/openmpi/include --with-Rmpi-libpath=/usr/lib64/mpi/gcc/openmpi/lib64 --with-Rmpi-type=OPENMPI Rmpi_0.5-4.tar.gz * installing to library ‘/usr/local/lib64/R/library’ * installing *source* package ‘Rmpi’ ... checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking mpi.h usability... no checking mpi.h presence... no checking for mpi.h... no Try to find libmpi or libmpich ... checking for main in -lmpi... no libmpi not found. exiting... ERROR: configuration failed for package ‘Rmpi’ * removing ‘/usr/local/lib64/R/library/Rmpi’ Best wishes Kristian Dr. Kristian Unger Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Tel.: +49-89-3187-3515 Mob.: +49-160-90641879 Am 15.06.11 15:12 schrieb Hugo Mildenberger unter hugo.mildenber...@web.de: Hmm, looks like there was a trailing blank after the backslash and before end of line, resulting in --with-Rmpi-libpath possibly not recognised: \--with-Rmpi-libpath=/usr/lib64/mpi/gcc/openmpi/lib64 \ I also doubt there is real need to escape newlines within a string. But another possible problem source is that according to R CMD INSTALL --help, the parameter is called
Re: [R] Rmpi installation
Thanks Hugo. I am pretty sure openmpi is installed: # zypper se openmpi Loading repository data... Reading installed packages... S | Name | Summary | Type --+---+-+--- i | openmpi | A powerful implementaion of MPI | package | openmpi | A powerful implementaion of MPI | srcpackage i | openmpi-devel | A powerful implementaion of MPI | package I got the same error message with the latest version available. The reason why I took the somewhat older version is that I wanted to make sure that it is not related to any libraries used by the newest version. Best wishes Kristian Dr. Kristian Unger Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Tel.: +49-89-3187-3515 Mob.: +49-160-90641879 Am 15.06.11 16:16 schrieb Hugo Mildenberger unter hugo.mildenber...@web.de: Kristian, I just tried that particular command here on a Gentoo system with openmpi-1.5.3 installed, because I wondered why the Rmpi configure script tests for main function in a shared library ... But I got a completly different output from configure. While the linker succeeds here, the package load test does not. However, on your system, may be the openmpi installation really is a kinda private one of gcc? I heard gcc makes use of openmpi internally. So is openmpi really installed? I just recognize that you are trying to use Rmpi_0.5-4.tar.gz while current version on CRAN is Rmpi_0.5-9.tar.gz. Best Hugo R CMD INSTALL --configure-args=--with-Rmpi-include=/usr/include --with-Rmpi-libpath=/usr/lib64/openmpi --with-Rmpi-type=OPENMPI Rmpi_0.5-9.tar.gz * installing to library ‘/home/hm/R/x86_64-pc-linux-gnu-library/2.13’ * installing *source* package ‘Rmpi’ ... checking for openpty in -lutil... no checking for main in -lpthread... no configure: creating ./config.status config.status: creating src/Makevars ** libs ** libs x86_64-pc-linux-gnu-gcc -std=gnu99 -I/usr/lib64/R/include -DPACKAGE_NAME=\\ -DPACKAGE_TARNAME=\\ -DPACKAGE_VERSION=\\ - DPACKAGE_STRING=\\ -DPACKAGE_BUGREPORT=\\ -I/usr/include -DMPI2 -DOPENMPI -I/usr/local/include-fpic -O3 -pipe -march=core2 - mtune=core2 -ggdb -c RegQuery.c -o RegQuery.o x86_64-pc-linux-gnu-gcc -std=gnu99 -I/usr/lib64/R/include -DPACKAGE_NAME=\\ -DPACKAGE_TARNAME=\\ -DPACKAGE_VERSION=\\ - DPACKAGE_STRING=\\ -DPACKAGE_BUGREPORT=\\ -I/usr/include -DMPI2 -DOPENMPI -I/usr/local/include-fpic -O3 -pipe -march=core2 - mtune=core2 -ggdb -c Rmpi.c -o Rmpi.o x86_64-pc-linux-gnu-gcc -std=gnu99 -I/usr/lib64/R/include -DPACKAGE_NAME=\\ -DPACKAGE_TARNAME=\\ -DPACKAGE_VERSION=\\ - DPACKAGE_STRING=\\ -DPACKAGE_BUGREPORT=\\ -I/usr/include -DMPI2 -DOPENMPI -I/usr/local/include-fpic -O3 -pipe -march=core2 - mtune=core2 -ggdb -c conversion.c -o conversion.o x86_64-pc-linux-gnu-gcc -std=gnu99 -I/usr/lib64/R/include -DPACKAGE_NAME=\\ -DPACKAGE_TARNAME=\\ -DPACKAGE_VERSION=\\ - DPACKAGE_STRING=\\ -DPACKAGE_BUGREPORT=\\ -I/usr/include -DMPI2 -DOPENMPI -I/usr/local/include-fpic -O3 -pipe -march=core2 - mtune=core2 -ggdb -c internal.c -o internal.o x86_64-pc-linux-gnu-gcc -std=gnu99 -shared -Wl,-O1 -Wl,--as-needed -o Rmpi.so RegQuery.o Rmpi.o conversion.o internal.o -L/usr/lib64/openmpi -lmpi -L/usr/lib64/R/lib -lR installiert nach /home/hm/R/x86_64-pc-linux-gnu-library/2.13/Rmpi/libs [...] ompi_mpi_init: orte_init failed -- Returned Not found (-13) instead of Success (0) On Wednesday 15 June 2011 15:19:22 Unger, Kristian, Dr. wrote: Thank you very much Hugo. Using the command as suggested results exactly the same error: # R CMD INSTALL --configure-args=--with-Rmpi-include=/usr/lib64/mpi/gcc/openmpi/include --with-Rmpi-libpath=/usr/lib64/mpi/gcc/openmpi/lib64 --with-Rmpi-type=OPENMPI Rmpi_0.5-4.tar.gz * installing to library ‘/usr/local/lib64/R/library’ * installing *source* package ‘Rmpi’ ... checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking mpi.h usability... no checking mpi.h presence... no checking for
Re: [R] Still have problems with tcltk in R 64 bit
I was pretty sure to have installed tcltk files for 64 bit from the installer, but to be sure ... - I removed previously created Environment variables (MY_TCLTK) - I reinstalled R one more time ... this time with the full installation option and ... it does not work (still works with R 32bit) ! - I also tried to define directly the path to the tcl version included with R ... as the code you provided does ... thus MY_TCLTK = C:\Program Files\R\R-2.13.0\Tcl\bin64 ... still the same error in R 64 bit, and if I want to load tcltk in R 32, it gives me the following error (normal ... it tried to load a 64 bit application in a 32 bit environment). Loading Tcl/Tk interface ...Error : .onLoad failed in loadNamespace() for 'tcltk', details: call: inDL(x, as.logical(local), as.logical(now), ...) error: unable to load shared object 'C:/Program Files/R/R-2.13.0/library/tcltk/libs/i386/tcltk.dll': LoadLibrary failure: %1 is not a valid Win32 application. Error: package/namespace load failed for 'tcltk' I believe that the problem may come from the tcltk.dll file but I do not understand how it can be broken each time when I installed other versions ... Arnaud 2011/6/15 Uwe Ligges lig...@statistik.tu-dortmund.de: Well, the R code in package tcltk for startup under Windows is, as you could have found out yourself easily: .onLoad - function(lib, pkg) { packageStartupMessage(Loading Tcl/Tk interface ..., domain = R-tcltk, appendLF = FALSE) if(!nzchar(tclbin - Sys.getenv(MY_TCLTK))) { tclbin - file.path(R.home(), Tcl, if(.Machine$sizeof.pointer == 8) bin64 else bin) if(!file.exists(tclbin)) stop(Tcl/Tk support files were not installed, call.=FALSE) if(.Machine$sizeof.pointer == 8) { lib64 - gsub(\\, /, file.path(R.home(), Tcl, lib64), fixed=TRUE) Sys.setenv(TCLLIBPATH = lib64) } } library.dynam(tcltk, pkg, lib, DLLpath = tclbin) .C(tcltk_start, PACKAGE=tcltk) addTclPath(system.file(exec, package = tcltk)) packageStartupMessage( , done, domain = R-tcltk) invisible() } This tells us that if you do not have MY_TCLTK defined on startup of R, you probably forgot to select the tcltk files for 64 bit from the installer when installing your version of R. Uwe Ligges On 15.06.2011 14:28, Arnaud Mosnier wrote: I agree that this is a really outdated source but I did not find the way to tell R using correctly the tcl version included (at least for the 64 bit version). If I remove the environment variables, things work for R 32 bit (it uses the tcl version included), but it does not work in R 64 bit. Where are the configuration files used to define the path to each tcl version ? Arnaud 2011/6/14 Uwe Liggeslig...@statistik.tu-dortmund.de: On 14.06.2011 22:01, Arnaud Mosnier wrote: I achieve to make tcltk work on R 64 installing Active tcltk8.5 64bit version then setting windows environment variables as in http://www.sciviews.org/_rgui/tcltk/InstallRTclTk.html. Don't read outdated sources but the manuals. The R binary distribution comes with tcltk under Windows (in ${R_HOME}/tcl) for both 32-bit and 64-bit and will user a different tcl if you set environment variables. Hence the easiest thing is just to tell R not to use your otehrwise set environment variabes and use its own tcl version. Uwe Ligges But now, it uses only this 64 bit version and thus do not work anymore in R 32 bit ! In my case, it solves my problem as I will probably use only R 64bit but I do not like to end with an half solution. Arnaud 2011/6/14 Peter Langfelderpeter.langfel...@gmail.com: On Tue, Jun 14, 2011 at 12:47 PM, Adrienne Woottenamwoo...@ncsu.edu wrote: Taking a quick look for it, it seems that they have replaced it with tcltk2. I just did the installation with the same version in windows and it auto loaded the tcltk package and I never installed that package to begin with. I would try it with tcltk2 and see if you get the package to install appropriately. I'm not sure why tcltk isn't on CRAN anymore, it makes no sense not to have both tcltk and tcltk2, but here's hoping this helps you out. A FWIF, tcltk still exists but is now part of the standard R distribution (core packages is the term I think?) and as such is installed automatically when you install R. Therefore it is not available from CRAN. Peter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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
Re: [R] Obtaining OLAP cubes using R
Ho Saravana, I did have nearly the same issue some months ago -- you will find below a good starting point. I am quite sure there is a better way to achieve it or with better code, but this should work! Kind regards, Eric - generateCube - function(x,simplify=TRUE,onlyComb=FALSE,...){ stopifnot(require(gtools)) xdf=as.data.frame(x) out=vector(length=ncol(xdf),mode=list) for (i in 1:ncol(xdf)){ # dimensions of the cube icomb - combinations(length(colnames(xdf)),i,colnames(xdf)) out[[i]] - vector(length=nrow(icomb),mode=list) for (j in 1:nrow(icomb)){ ijargs - icomb[j,] names(out[[i]])[j] - paste(ijargs,collapse=*) tmp - with( xdf, eval(parse(text= paste(table(,paste(ijargs,collapse=,),),sep=) )) ) if (simplify i1) tmp-as.data.frame(ftable(tmp)) out[[i]][[j]] - tmp } } return(out) } M=diag(3) M[1,2]=2 M - rbind(M,M[1,]) colnames(M) - paste(V,1:ncol(M),sep=) out=generateCube(M) out2=generateCube(M,simplify=FALSE) out[[2]][[V1*V3]] out2[[2]][[V1*V3]][0,1] - On 14 June 2011 14:59, Saravanan saravanan.thirumuruganat...@gmail.comwrote: Hello All, I have a dataset and I wish to obtain all possible data cuboids from it using R . For eg if my data frame is : ABC 111 121 221 The output intended is : A=1 A=2 B=1 B=2 C=1 A=1,B=1 A=1,B=2 A=2,B=2 A=1,C=1 A=2,C=1 B=1,C=1 B=2,C=1 A=1,B=1,C=1 A=1,B=2,C=1 A=2,B=2,C=1 Are there any function(s) to do this in R ? I tried a combination of expand.grid and combn but the resulting code was very ugly and needed lot of hacks to make it work. I also tried to check the code for arules (which constructs similar itemsets) but unfortunately its code is in C and I am not very familiar in writing R extensions. Any pointers to functions will be much appreciated. Regards, Saravanan __ R-help@r-project.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. -- Eric Lecoutre Consultant - Business Decision Business Intelligence Customer Intelligence [[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] Column of numbers added to dataframe when saving with read.csv
I have a dataframe object having the following structure FinalOutput[1:3,] GasDays 2011-03-31 2010-09-30 2010-10-31 2010-11-30 2010-12-31 2011-01-31 2011-02-28 1 2006-10-01 217303553 221205033 222824639 217016511 216093460 216477468 216834021 2 2006-10-02 231158527 234565250 236004109 231467851 230100639 230079907 230734064 3 2006-10-03 282062314 285427832 286372163 282532055 280930498 281155966 281124614 After using write.table(FinalOutput, paste(ModelComparison.csv, sep = ''), sep = ',') the out put I get on the csv is GasDays 31/03/2011 30/09/2010 31/10/2010 30/11/2010 31/12/201031/01/2011 28/02/2011 31/03/2011 1 01/10/2006 217303553.3 221205032.6 222824638.7 217016510.8 216093460 216477467.9 216834021217303553.3 2 02/10/2006 231158527.1 234565249.7 236004108.7 231467850.7 230100639.1 230079907.4 230734064.4 231158527.1 3 03/10/2006 282062314.5 285427831.6 286372163 282532055.2 280930497.7 281155966 281124613.8 282062314.5 so essentially one column full of 1,2,3, ... is added to the file when saving it. Can someone pelase help me to get rid of it? Thanks Paolo On 14 June 2011 13:59, Saravanan saravanan.thirumuruganat...@gmail.comwrote: Hello All, I have a dataset and I wish to obtain all possible data cuboids from it using R . For eg if my data frame is : ABC 111 121 221 The output intended is : A=1 A=2 B=1 B=2 C=1 A=1,B=1 A=1,B=2 A=2,B=2 A=1,C=1 A=2,C=1 B=1,C=1 B=2,C=1 A=1,B=1,C=1 A=1,B=2,C=1 A=2,B=2,C=1 Are there any function(s) to do this in R ? I tried a combination of expand.grid and combn but the resulting code was very ugly and needed lot of hacks to make it work. I also tried to check the code for arules (which constructs similar itemsets) but unfortunately its code is in C and I am not very familiar in writing R extensions. Any pointers to functions will be much appreciated. Regards, Saravanan __ R-help@r-project.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. [[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] Column of numbers added to dataframe when saving with read.csv
Reading the helpfile (as the posting guide asks you to do) of write.table will solve your problem. -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Paolo Rossi Verzonden: woensdag 15 juni 2011 16:52 Aan: r-help@r-project.org Onderwerp: [R] Column of numbers added to dataframe when saving with read.csv I have a dataframe object having the following structure FinalOutput[1:3,] GasDays 2011-03-31 2010-09-30 2010-10-31 2010-11-30 2010-12-31 2011-01-31 2011-02-28 1 2006-10-01 217303553 221205033 222824639 217016511 216093460 216477468 216834021 2 2006-10-02 231158527 234565250 236004109 231467851 230100639 230079907 230734064 3 2006-10-03 282062314 285427832 286372163 282532055 280930498 281155966 281124614 After using write.table(FinalOutput, paste(ModelComparison.csv, sep = ''), sep = ',') the out put I get on the csv is GasDays 31/03/2011 30/09/2010 31/10/2010 30/11/2010 31/12/201031/01/2011 28/02/2011 31/03/2011 1 01/10/2006 217303553.3 221205032.6 222824638.7 217016510.8 216093460 216477467.9 216834021217303553.3 2 02/10/2006 231158527.1 234565249.7 236004108.7 231467850.7 230100639.1 230079907.4 230734064.4 231158527.1 3 03/10/2006 282062314.5 285427831.6 286372163 282532055.2 280930497.7 281155966 281124613.8 282062314.5 so essentially one column full of 1,2,3, ... is added to the file when saving it. Can someone pelase help me to get rid of it? Thanks Paolo On 14 June 2011 13:59, Saravanan saravanan.thirumuruganat...@gmail.comwrote: Hello All, I have a dataset and I wish to obtain all possible data cuboids from it using R . For eg if my data frame is : ABC 111 121 221 The output intended is : A=1 A=2 B=1 B=2 C=1 A=1,B=1 A=1,B=2 A=2,B=2 A=1,C=1 A=2,C=1 B=1,C=1 B=2,C=1 A=1,B=1,C=1 A=1,B=2,C=1 A=2,B=2,C=1 Are there any function(s) to do this in R ? I tried a combination of expand.grid and combn but the resulting code was very ugly and needed lot of hacks to make it work. I also tried to check the code for arules (which constructs similar itemsets) but unfortunately its code is in C and I am not very familiar in writing R extensions. Any pointers to functions will be much appreciated. Regards, Saravanan __ R-help@r-project.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/p osting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Column of numbers added to dataframe when saving with read.csv
You need to add row.names=FALSE to your write.table() statement. This and other useful options are documented in the help. And you'll notice that that first column of row names appears in your R output as well. Sarah On Wed, Jun 15, 2011 at 10:51 AM, Paolo Rossi statmailingli...@googlemail.com wrote: I have a dataframe object having the following structure FinalOutput[1:3,] GasDays 2011-03-31 2010-09-30 2010-10-31 2010-11-30 2010-12-31 2011-01-31 2011-02-28 1 2006-10-01 217303553 221205033 222824639 217016511 216093460 216477468 216834021 2 2006-10-02 231158527 234565250 236004109 231467851 230100639 230079907 230734064 3 2006-10-03 282062314 285427832 286372163 282532055 280930498 281155966 281124614 After using write.table(FinalOutput, paste(ModelComparison.csv, sep = ''), sep = ',') the out put I get on the csv is GasDays 31/03/2011 30/09/2010 31/10/2010 30/11/2010 31/12/2010 31/01/2011 28/02/2011 31/03/2011 1 01/10/2006 217303553.3 221205032.6 222824638.7 217016510.8 216093460 216477467.9 216834021 217303553.3 2 02/10/2006 231158527.1 234565249.7 236004108.7 231467850.7 230100639.1 230079907.4 230734064.4 231158527.1 3 03/10/2006 282062314.5 285427831.6 286372163 282532055.2 280930497.7 281155966 281124613.8 282062314.5 so essentially one column full of 1,2,3, ... is added to the file when saving it. Can someone pelase help me to get rid of it? Thanks Paolo -- 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] Column of numbers added to dataframe when saving with read.csv
Hi Paolo, Not sure to understand you well, but try with row.names=FALSE in your call to write.table() HTH, Ivan Le 6/15/2011 16:51, Paolo Rossi a écrit : I have a dataframe object having the following structure FinalOutput[1:3,] GasDays 2011-03-31 2010-09-30 2010-10-31 2010-11-30 2010-12-31 2011-01-31 2011-02-28 1 2006-10-01 217303553 221205033 222824639 217016511 216093460 216477468 216834021 2 2006-10-02 231158527 234565250 236004109 231467851 230100639 230079907 230734064 3 2006-10-03 282062314 285427832 286372163 282532055 280930498 281155966 281124614 After using write.table(FinalOutput, paste(ModelComparison.csv, sep = ''), sep = ',') the out put I get on the csv is GasDays 31/03/2011 30/09/2010 31/10/2010 30/11/2010 31/12/201031/01/2011 28/02/2011 31/03/2011 1 01/10/2006 217303553.3 221205032.6 222824638.7 217016510.8 216093460 216477467.9 216834021217303553.3 2 02/10/2006 231158527.1 234565249.7 236004108.7 231467850.7 230100639.1 230079907.4 230734064.4 231158527.1 3 03/10/2006 282062314.5 285427831.6 286372163 282532055.2 280930497.7 281155966 281124613.8 282062314.5 so essentially one column full of 1,2,3, ... is added to the file when saving it. Can someone pelase help me to get rid of it? Thanks Paolo On 14 June 2011 13:59, Saravanansaravanan.thirumuruganat...@gmail.comwrote: Hello All, I have a dataset and I wish to obtain all possible data cuboids from it using R . For eg if my data frame is : ABC 111 121 221 The output intended is : A=1 A=2 B=1 B=2 C=1 A=1,B=1 A=1,B=2 A=2,B=2 A=1,C=1 A=2,C=1 B=1,C=1 B=2,C=1 A=1,B=1,C=1 A=1,B=2,C=1 A=2,B=2,C=1 Are there any function(s) to do this in R ? I tried a combination of expand.grid and combn but the resulting code was very ugly and needed lot of hacks to make it work. I also tried to check the code for arules (which constructs similar itemsets) but unfortunately its code is in C and I am not very familiar in writing R extensions. Any pointers to functions will be much appreciated. Regards, Saravanan __ R-help@r-project.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. [[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. -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Dept. Mammalogy Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Column of numbers added to dataframe when saving with read.csv
Sarah, That is correct - thanks a lot for this to everyone who replied Paolo On 15 June 2011 16:03, Sarah Goslee sarah.gos...@gmail.com wrote: You need to add row.names=FALSE to your write.table() statement. This and other useful options are documented in the help. And you'll notice that that first column of row names appears in your R output as well. Sarah On Wed, Jun 15, 2011 at 10:51 AM, Paolo Rossi statmailingli...@googlemail.com wrote: I have a dataframe object having the following structure FinalOutput[1:3,] GasDays 2011-03-31 2010-09-30 2010-10-31 2010-11-30 2010-12-31 2011-01-31 2011-02-28 1 2006-10-01 217303553 221205033 222824639 217016511 216093460 216477468 216834021 2 2006-10-02 231158527 234565250 236004109 231467851 230100639 230079907 230734064 3 2006-10-03 282062314 285427832 286372163 282532055 280930498 281155966 281124614 After using write.table(FinalOutput, paste(ModelComparison.csv, sep = ''), sep = ',') the out put I get on the csv is GasDays 31/03/2011 30/09/2010 31/10/2010 30/11/2010 31/12/201031/01/2011 28/02/2011 31/03/2011 1 01/10/2006 217303553.3 221205032.6 222824638.7 217016510.8 216093460 216477467.9 216834021217303553.3 2 02/10/2006 231158527.1 234565249.7 236004108.7 231467850.7 230100639.1 230079907.4 230734064.4 231158527.1 3 03/10/2006 282062314.5 285427831.6 286372163 282532055.2 280930497.7 281155966 281124613.8 282062314.5 so essentially one column full of 1,2,3, ... is added to the file when saving it. Can someone pelase help me to get rid of it? Thanks Paolo -- 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.
Re: [R] Rmpi installation
Kristian, these are the usual problems with binary distributions. Regarding --with-Rmpi-include=/usr/lib64/mpi/gcc/openmpi/include and configure output checking for mpi.h... no ... so does /usr/lib64/mpi/gcc/openmpi/include really exist? At least, that appears to be a very unusual place to look for mpi.h (normally to be found in /usr/include ). And if you try to compile link the attached demo program: does the link phase succeed? Compile link using $ mpicc mtest.c -o mtest Presumably you have already tried to run install.packages(Rmpi). Kind regards Hugo On Wednesday 15 June 2011 16:22:07 Unger, Kristian, Dr. wrote: Thanks Hugo. I am pretty sure openmpi is installed: # zypper se openmpi Loading repository data... Reading installed packages... S | Name | Summary | Type --+---+-+--- i | openmpi | A powerful implementaion of MPI | package | openmpi | A powerful implementaion of MPI | srcpackage i | openmpi-devel | A powerful implementaion of MPI | package I got the same error message with the latest version available. The reason why I took the somewhat older version is that I wanted to make sure that it is not related to any libraries used by the newest version. Best wishes Kristian Dr. Kristian Unger Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Tel.: +49-89-3187-3515 Mob.: +49-160-90641879 Am 15.06.11 16:16 schrieb Hugo Mildenberger unter hugo.mildenber...@web.de: Kristian, I just tried that particular command here on a Gentoo system with openmpi-1.5.3 installed, because I wondered why the Rmpi configure script tests for main function in a shared library ... But I got a completly different output from configure. While the linker succeeds here, the package load test does not. However, on your system, may be the openmpi installation really is a kinda private one of gcc? I heard gcc makes use of openmpi internally. So is openmpi really installed? I just recognize that you are trying to use Rmpi_0.5-4.tar.gz while current version on CRAN is Rmpi_0.5-9.tar.gz. Best Hugo R CMD INSTALL --configure-args=--with-Rmpi-include=/usr/include --with-Rmpi-libpath=/usr/lib64/openmpi --with-Rmpi-type=OPENMPI Rmpi_0.5-9.tar.gz * installing to library ‘/home/hm/R/x86_64-pc-linux-gnu-library/2.13’ * installing *source* package ‘Rmpi’ ... checking for openpty in -lutil... no checking for main in -lpthread... no configure: creating ./config.status config.status: creating src/Makevars ** libs ** libs x86_64-pc-linux-gnu-gcc -std=gnu99 -I/usr/lib64/R/include -DPACKAGE_NAME=\\ -DPACKAGE_TARNAME=\\ -DPACKAGE_VERSION=\\ - DPACKAGE_STRING=\\ -DPACKAGE_BUGREPORT=\\ -I/usr/include -DMPI2 -DOPENMPI -I/usr/local/include-fpic -O3 -pipe -march=core2 - mtune=core2 -ggdb -c RegQuery.c -o RegQuery.o x86_64-pc-linux-gnu-gcc -std=gnu99 -I/usr/lib64/R/include -DPACKAGE_NAME=\\ -DPACKAGE_TARNAME=\\ -DPACKAGE_VERSION=\\ - DPACKAGE_STRING=\\ -DPACKAGE_BUGREPORT=\\ -I/usr/include -DMPI2 -DOPENMPI -I/usr/local/include-fpic -O3 -pipe -march=core2 - mtune=core2 -ggdb -c Rmpi.c -o Rmpi.o x86_64-pc-linux-gnu-gcc -std=gnu99 -I/usr/lib64/R/include -DPACKAGE_NAME=\\ -DPACKAGE_TARNAME=\\ -DPACKAGE_VERSION=\\ - DPACKAGE_STRING=\\ -DPACKAGE_BUGREPORT=\\ -I/usr/include -DMPI2 -DOPENMPI -I/usr/local/include-fpic -O3 -pipe -march=core2 - mtune=core2 -ggdb -c conversion.c -o conversion.o x86_64-pc-linux-gnu-gcc -std=gnu99 -I/usr/lib64/R/include -DPACKAGE_NAME=\\ -DPACKAGE_TARNAME=\\ -DPACKAGE_VERSION=\\ - DPACKAGE_STRING=\\ -DPACKAGE_BUGREPORT=\\ -I/usr/include -DMPI2 -DOPENMPI -I/usr/local/include-fpic -O3 -pipe -march=core2 - mtune=core2 -ggdb -c internal.c -o internal.o x86_64-pc-linux-gnu-gcc -std=gnu99 -shared -Wl,-O1 -Wl,--as-needed -o Rmpi.so RegQuery.o Rmpi.o conversion.o internal.o -L/usr/lib64/openmpi -lmpi -L/usr/lib64/R/lib -lR installiert nach /home/hm/R/x86_64-pc-linux-gnu-library/2.13/Rmpi/libs [...] ompi_mpi_init: orte_init failed -- Returned Not found (-13) instead of Success (0) On Wednesday 15 June 2011 15:19:22 Unger, Kristian, Dr. wrote: Thank you very much Hugo. Using the command as suggested results exactly the same error: # R CMD INSTALL --configure-args=--with-Rmpi-include=/usr/lib64/mpi/gcc/openmpi/include --with-Rmpi-libpath=/usr/lib64/mpi/gcc/openmpi/lib64 --with-Rmpi-type=OPENMPI Rmpi_0.5-4.tar.gz * installing to library ‘/usr/local/lib64/R/library’ * installing *source* package ‘Rmpi’ ... checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no
[R] Problem auto.arima() in R
I am using auto.arima() for forecasting.When I am using any in built data such as AirPassangers it is capturing seasonality. But, If I am entering data in any other format(in vector form or from an excel sheet) it is not detecting seasonality. Is there any specific format in which it detects seasonality or I am doing some thing wrong? Does data have to be entered in a specific format? -- Siddharth Arun, 4th Year Undergraduate student Industrial Engineering and Management, IIT Kharagpur [[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] Rmpi installation
Dear Hugo I ran the command with the verbose switch and get the following output: mpicc mtest.c -ov mtest mtest: In function `_start': /usr/src/packages/BUILD/glibc-2.11.1/csu/../sysdeps/x86_64/elf/start.S:65: multiple definition of `_start' /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../lib64/crt1.o:/usr/src/pack ages/BUILD/glibc-2.11.1/csu/../sysdeps/x86_64/elf/start.S:65: first defined here mtest: In function `_fini': (.fini+0x0): multiple definition of `_fini' /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../lib64/crti.o:initfini.c:(. fini+0x0): first defined here mtest:(.rodata+0x0): multiple definition of `_IO_stdin_used' /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../lib64/crt1.o:(.rodata.cst4 +0x0): first defined here mtest: In function `__data_start': (.data+0x0): multiple definition of `__data_start' /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../lib64/crt1.o:(.data+0x0): first defined here mtest: In function `main': (.text+0xec): multiple definition of `main' /tmp/ccUyk8e9.o:mtest.c:(.text+0x0): first defined here mtest: In function `_init': (.init+0x0): multiple definition of `_init' /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../lib64/crti.o:initfini.c:(. init+0x0): first defined here /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: error in mtest(.eh_frame); no .eh_frame_hdr table will be created. collect2: ld returned 1 exit status Not sure if this makes any sense? Best wishes Kristian Dr. Kristian Unger Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Tel.: +49-89-3187-3515 Mob.: +49-160-90641879 Am 15.06.11 17:25 schrieb Hugo Mildenberger unter hugo.mildenber...@web.de: Kristian, these are the usual problems with binary distributions. Regarding --with-Rmpi-include=/usr/lib64/mpi/gcc/openmpi/include and configure output checking for mpi.h... no ... so does /usr/lib64/mpi/gcc/openmpi/include really exist? At least, that appears to be a very unusual place to look for mpi.h (normally to be found in /usr/include ). And if you try to compile link the attached demo program: does the link phase succeed? Compile link using $ mpicc mtest.c -o mtest Presumably you have already tried to run install.packages(Rmpi). Kind regards Hugo On Wednesday 15 June 2011 16:22:07 Unger, Kristian, Dr. wrote: Thanks Hugo. I am pretty sure openmpi is installed: # zypper se openmpi Loading repository data... Reading installed packages... S | Name | Summary | Type --+---+-+--- i | openmpi | A powerful implementaion of MPI | package | openmpi | A powerful implementaion of MPI | srcpackage i | openmpi-devel | A powerful implementaion of MPI | package I got the same error message with the latest version available. The reason why I took the somewhat older version is that I wanted to make sure that it is not related to any libraries used by the newest version. Best wishes Kristian Dr. Kristian Unger Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Tel.: +49-89-3187-3515 Mob.: +49-160-90641879 Am 15.06.11 16:16 schrieb Hugo Mildenberger unter hugo.mildenber...@web.de: Kristian, I just tried that particular command here on a Gentoo system with openmpi-1.5.3 installed, because I wondered why the Rmpi configure script tests for main function in a shared library ... But I got a completly different output from configure. While the linker succeeds here, the package load test does not. However, on your system, may be the openmpi installation really is a kinda private one of gcc? I heard gcc makes use of openmpi internally. So is openmpi really installed? I just recognize that you are trying to use Rmpi_0.5-4.tar.gz while current version on CRAN is Rmpi_0.5-9.tar.gz. Best Hugo R CMD INSTALL --configure-args=--with-Rmpi-include=/usr/include --with-Rmpi-libpath=/usr/lib64/openmpi --with-Rmpi-type=OPENMPI Rmpi_0.5-9.tar.gz * installing to library ‘/home/hm/R/x86_64-pc-linux-gnu-library/2.13’ * installing *source* package ‘Rmpi’ ... checking for openpty in -lutil... no checking for main in -lpthread... no configure: creating ./config.status config.status: creating src/Makevars ** libs ** libs x86_64-pc-linux-gnu-gcc -std=gnu99 -I/usr/lib64/R/include -DPACKAGE_NAME=\\ -DPACKAGE_TARNAME=\\ -DPACKAGE_VERSION=\\ - DPACKAGE_STRING=\\ -DPACKAGE_BUGREPORT=\\ -I/usr/include -DMPI2 -DOPENMPI -I/usr/local/include-fpic -O3 -pipe -march=core2 - mtune=core2 -ggdb -c RegQuery.c -o RegQuery.o x86_64-pc-linux-gnu-gcc -std=gnu99 -I/usr/lib64/R/include -DPACKAGE_NAME=\\
Re: [R] Obtaining OLAP cubes using R
Hi Eric, Your solution looks very close to my own. I also use expand.grid to get the cross product though. If I find an alternate way, I will send out my solution. Thanks a lot for your suggestion ! Regards, Saravanan On 06/15/2011 09:34 AM, Eric Lecoutre wrote: Ho Saravana, I did have nearly the same issue some months ago -- you will find below a good starting point. I am quite sure there is a better way to achieve it or with better code, but this should work! Kind regards, Eric - generateCube - function(x,simplify=TRUE,onlyComb=FALSE,...){ stopifnot(require(gtools)) xdf=as.data.frame(x) out=vector(length=ncol(xdf),mode=list) for (i in 1:ncol(xdf)){ # dimensions of the cube icomb - combinations(length(colnames(xdf)),i,colnames(xdf)) out[[i]] - vector(length=nrow(icomb),mode=list) for (j in 1:nrow(icomb)){ ijargs - icomb[j,] names(out[[i]])[j] - paste(ijargs,collapse=*) tmp - with( xdf, eval(parse(text= paste(table(,paste(ijargs,collapse=,),),sep=) )) ) if (simplify i1) tmp-as.data.frame(ftable(tmp)) out[[i]][[j]] - tmp } } return(out) } M=diag(3) M[1,2]=2 M - rbind(M,M[1,]) colnames(M) - paste(V,1:ncol(M),sep=) out=generateCube(M) out2=generateCube(M,simplify=FALSE) out[[2]][[V1*V3]] out2[[2]][[V1*V3]][0,1] - On 14 June 2011 14:59, Saravanan saravanan.thirumuruganat...@gmail.com mailto:saravanan.thirumuruganat...@gmail.com wrote: Hello All, I have a dataset and I wish to obtain all possible data cuboids from it using R . For eg if my data frame is : ABC 111 121 221 The output intended is : A=1 A=2 B=1 B=2 C=1 A=1,B=1 A=1,B=2 A=2,B=2 A=1,C=1 A=2,C=1 B=1,C=1 B=2,C=1 A=1,B=1,C=1 A=1,B=2,C=1 A=2,B=2,C=1 Are there any function(s) to do this in R ? I tried a combination of expand.grid and combn but the resulting code was very ugly and needed lot of hacks to make it work. I also tried to check the code for arules (which constructs similar itemsets) but unfortunately its code is in C and I am not very familiar in writing R extensions. Any pointers to functions will be much appreciated. Regards, Saravanan __ R-help@r-project.org mailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html http://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Eric Lecoutre Consultant - Business Decision Business Intelligence Customer Intelligence [[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] non-numeric argument to binary operator
Write yourself an alternative function to table, for example like this: tableOfGivenLevels = function(x, levels) { n = length(levels) counts = rep(0, n); names(counts) = levels tab = table(x); counts[match(names(tab), levels)] = tab; counts; } x = sample(c(1:4), 20, replace = TRUE) tableOfGivenLevels(x, c(0:6)) Then run your old code, the one with habs=t(apply(habs, 1, table))/b but replace table by tableOfGivenLevels. Peter On Tue, Jun 14, 2011 at 10:43 PM, the_big_kowalski bkowal...@csumb.edu wrote: Most likely reason is that the number of unique values in the rows of habs is not the same. Yes, I think that is the problem, thank you. How would I write the code to include 0s in the matrix, ie, I want to have a record of when 1, 2, or 3 does not get sampled, to come up with a frequency of each value for each nn (which in this case is 5) I tried 'factor' but what ends up happening is that the matrix gets reduced to zero after a couple of iterations. habs=t(apply(habs, 1, function(x) table(factor(x, levels = 1:3 -- View this message in context: http://r.789695.n4.nabble.com/non-numeric-argument-to-binary-operator-tp3598160p3598563.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. -- Sent from my Linux computer. Way better than iPad :) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Rmpi installation
Dear Kristian, please run exactly mpicc mtest.c -o mtest If you really need it, add -v separately. mpicc is nothing but a compiler wrapper. The -o switch specifies the outfile name, which has to follow immediately after -o, with or without a blank character in between. I'm not sure about what happens with -ov mtest. Probably an output file named v is produced on disk, in addition to the file mtest stemming from a previous with -o mtest Depending on mpicc's, gcc's and ld's version, gcc may instruct the linker to link the previously produced executable mtest with the object newly compiled from mtest.c plus several implicit libraries and startup objects, and output the result to v. ld would then be faced with duplicate defined symbols and output a list of these doublets. My proposal was meant as a test for an else correct openmpi installation, perhaps I should have said this. On successful completion, no message should be printed, but an executable named mtest should have been produced, which could then be run typing ./mtest. If the link process failed, then the openmpi installation was inconsistent. Kind regards Hugo On Wednesday 15 June 2011 17:45:41 Unger, Kristian, Dr. wrote: Dear Hugo I ran the command with the verbose switch and get the following output: mpicc mtest.c -ov mtest mtest: In function `_start': /usr/src/packages/BUILD/glibc-2.11.1/csu/../sysdeps/x86_64/elf/start.S:65: multiple definition of `_start' /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../lib64/crt1.o:/usr/src/pack ages/BUILD/glibc-2.11.1/csu/../sysdeps/x86_64/elf/start.S:65: first defined here mtest: In function `_fini': (.fini+0x0): multiple definition of `_fini' /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../lib64/crti.o:initfini.c:(. fini+0x0): first defined here mtest:(.rodata+0x0): multiple definition of `_IO_stdin_used' /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../lib64/crt1.o:(.rodata.cst4 +0x0): first defined here mtest: In function `__data_start': (.data+0x0): multiple definition of `__data_start' /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../lib64/crt1.o:(.data+0x0): first defined here mtest: In function `main': (.text+0xec): multiple definition of `main' /tmp/ccUyk8e9.o:mtest.c:(.text+0x0): first defined here mtest: In function `_init': (.init+0x0): multiple definition of `_init' /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../lib64/crti.o:initfini.c:(. init+0x0): first defined here /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: error in mtest(.eh_frame); no .eh_frame_hdr table will be created. collect2: ld returned 1 exit status Not sure if this makes any sense? Best wishes Kristian Dr. Kristian Unger Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Tel.: +49-89-3187-3515 Mob.: +49-160-90641879 Am 15.06.11 17:25 schrieb Hugo Mildenberger unter hugo.mildenber...@web.de: Kristian, these are the usual problems with binary distributions. Regarding --with-Rmpi-include=/usr/lib64/mpi/gcc/openmpi/include and configure output checking for mpi.h... no ... so does /usr/lib64/mpi/gcc/openmpi/include really exist? At least, that appears to be a very unusual place to look for mpi.h (normally to be found in /usr/include ). And if you try to compile link the attached demo program: does the link phase succeed? Compile link using $ mpicc mtest.c -o mtest Presumably you have already tried to run install.packages(Rmpi). Kind regards Hugo On Wednesday 15 June 2011 16:22:07 Unger, Kristian, Dr. wrote: Thanks Hugo. I am pretty sure openmpi is installed: # zypper se openmpi Loading repository data... Reading installed packages... S | Name | Summary | Type --+---+-+--- i | openmpi | A powerful implementaion of MPI | package | openmpi | A powerful implementaion of MPI | srcpackage i | openmpi-devel | A powerful implementaion of MPI | package I got the same error message with the latest version available. The reason why I took the somewhat older version is that I wanted to make sure that it is not related to any libraries used by the newest version. Best wishes Kristian Dr. Kristian Unger Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Tel.: +49-89-3187-3515 Mob.: +49-160-90641879 Am 15.06.11 16:16 schrieb Hugo Mildenberger unter hugo.mildenber...@web.de: Kristian, I just tried that particular command here on
Re: [R] BIZARRE results from wilcox.test()
I did not intend to bully you but rather tried to speak narrowly to the core of the issue. In a sense the point was that the example you used to illustrate the problem created part of the problem and that in a sensical dataset you would not obtain nonsensical results. Secondly, my reply talked to the solution of your problem by pointing out that the test uses the normal approximation by standard, which is exactly that: an approximation, implying that avoiding the approximation may solve the issue. This is what exact=T does, as you figured out. Daniel genecleaner wrote: Dear Daniel and Sarah, Thanks you for your rude replies . The script that I provided was only an example and to illustrate the problem. It makes perfectly sense to use the Wilcoxon test on my datasets. However, you replies were nonsensical, since you could not solve the problem but rather just bullied me. Anyway, this is the solution to the problem: the exact=TRUE statement should be added w - wilcox.test(c(1:50),(c(1:50)+100)) w$p.value [1] 7.066072e-18 w - wilcox.test(c(1:50),(c(1:50)+100), exact=TRUE) w$p.value [1] 1.982331e-29 Best regards, genecleaner -- View this message in context: http://r.789695.n4.nabble.com/BIZARRE-results-from-wilcox-test-tp3597818p3600158.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] Rmpi installation
Hi Hugo One step closer! I added the path to libmpi to ld.so.conf and ran ldconfig (see http://www.linuxforums.org/forum/programming-scripting/80405-linking-shared -libraries.html). Compiling the code you sent me works but running the file gets stuck with the following message: ./mtest librdmacm: couldn't read ABI version. librdmacm: assuming: 4 libibverbs: Fatal: couldn't read uverbs ABI version. CMA: unable to open /dev/infiniband/rdma_cm -- WARNING: Failed to open OpenIB-cma [DAT_INTERNAL_ERROR:]. This may be a real error or it may be an invalid entry in the uDAPL Registry which is contained in the dat.conf file. Contact your local System Administrator to confirm the availability of the interfaces in the dat.conf file. -- Any suggestions? Best wishes Kristian Dr. Kristian Unger Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Tel.: +49-89-3187-3515 Mob.: +49-160-90641879 Am 15.06.11 19:25 schrieb Hugo Mildenberger unter hugo.mildenber...@web.de: Dear Kristian, please run exactly mpicc mtest.c -o mtest If you really need it, add -v separately. mpicc is nothing but a compiler wrapper. The -o switch specifies the outfile name, which has to follow immediately after -o, with or without a blank character in between. I'm not sure about what happens with -ov mtest. Probably an output file named v is produced on disk, in addition to the file mtest stemming from a previous with -o mtest Depending on mpicc's, gcc's and ld's version, gcc may instruct the linker to link the previously produced executable mtest with the object newly compiled from mtest.c plus several implicit libraries and startup objects, and output the result to v. ld would then be faced with duplicate defined symbols and output a list of these doublets. My proposal was meant as a test for an else correct openmpi installation, perhaps I should have said this. On successful completion, no message should be printed, but an executable named mtest should have been produced, which could then be run typing ./mtest. If the link process failed, then the openmpi installation was inconsistent. Kind regards Hugo On Wednesday 15 June 2011 17:45:41 Unger, Kristian, Dr. wrote: Dear Hugo I ran the command with the verbose switch and get the following output: mpicc mtest.c -ov mtest mtest: In function `_start': /usr/src/packages/BUILD/glibc-2.11.1/csu/../sysdeps/x86_64/elf/start.S:65 : multiple definition of `_start' /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../lib64/crt1.o:/usr/src/pa ck ages/BUILD/glibc-2.11.1/csu/../sysdeps/x86_64/elf/start.S:65: first defined here mtest: In function `_fini': (.fini+0x0): multiple definition of `_fini' /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../lib64/crti.o:initfini.c: (. fini+0x0): first defined here mtest:(.rodata+0x0): multiple definition of `_IO_stdin_used' /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../lib64/crt1.o:(.rodata.cs t4 +0x0): first defined here mtest: In function `__data_start': (.data+0x0): multiple definition of `__data_start' /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../lib64/crt1.o:(.data+0x0) : first defined here mtest: In function `main': (.text+0xec): multiple definition of `main' /tmp/ccUyk8e9.o:mtest.c:(.text+0x0): first defined here mtest: In function `_init': (.init+0x0): multiple definition of `_init' /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../lib64/crti.o:initfini.c: (. init+0x0): first defined here /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld : error in mtest(.eh_frame); no .eh_frame_hdr table will be created. collect2: ld returned 1 exit status Not sure if this makes any sense? Best wishes Kristian Dr. Kristian Unger Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Tel.: +49-89-3187-3515 Mob.: +49-160-90641879 Am 15.06.11 17:25 schrieb Hugo Mildenberger unter hugo.mildenber...@web.de: Kristian, these are the usual problems with binary distributions. Regarding --with-Rmpi-include=/usr/lib64/mpi/gcc/openmpi/include and configure output checking for mpi.h... no ... so does /usr/lib64/mpi/gcc/openmpi/include really exist? At least, that appears to be a very unusual place to look for mpi.h (normally to be found in /usr/include ). And if you try to compile link the attached demo program: does the link phase succeed? Compile link using $ mpicc mtest.c -o mtest Presumably you have already tried to run install.packages(Rmpi). Kind regards
Re: [R] Problem auto.arima() in R
siddharth arun sid.arun91 at gmail.com writes: I am using auto.arima() for forecasting.When I am using any in built data such as AirPassangers it is capturing seasonality. But, If I am entering data in any other format(in vector form or from an excel sheet) it is not detecting seasonality. Is there any specific format in which it detects seasonality or I am doing some thing wrong? Does data have to be entered in a specific format? Unfortunately, this is far too vague a question for us to answer. Please read the posting guide and give us some more details about what you are trying to do, preferably as a small reproducible example. Also, be aware that auto.arima() is a function in the contributed 'forecast' package: this would be useful information to include. Ben Bolker __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Year cost optimisation
Hi, I have a data file with all our purchases from last year, it contains the unit price, count, and total dollars spend. Now I'm looking for some way to classify all our purchases to find out which purchases are the best ones to find cheaper alternatives. for example: if we only buy 1 item of a product which costs 5 dollar, we maybe can find a cheaper product of 4.5 dollar, but this won't make it on our year budget. On the other hand, there may be some products of 2.5 dollar, but we purchased 1000ths of them, so 2.3 dollar/product can be a significant saving. Instead of searching for each of our products a cheaper alternative (takes a awfull lot of time), I would like to concentrate on a top 20 for example. Maybe calculate the pct contribution to the total budget, and take the top 20? Any other ideas for an approach? Here an example dataframe: dat - data.frame(item=1:160, unit_price=round(c(runif(80,0,100), runif(80,250,1000)),2), count=round(c(runif(40, 1,10), runif(40,20,1000),runif(40, 1,10), runif(40,20,1000)),0), total=0) dat$total = dat$count*dat$unit_price Bart -- View this message in context: http://r.789695.n4.nabble.com/Year-cost-optimisation-tp3599538p3599538.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] Error bars
Hi, Can anyone help with plotting vertical error bars on a bar graph. I have tried following examples online and in the big R book and writing my own function but I have been unsuccessful and donât really have an understanding of what it is I am doing. I have calculated my standard errors so basically just need to draw the bars on the graph but just donât have a clue!!! I donât even know what information people will need to help me.. The code for my graph is: barplot(tapply(Sporangia,list(Host,Isolate),mean),xlab=Isolate,ylab=Mean Sporangia per Needle,col=c(grey39,grey64,grey89),beside=T) col=c(grey39,grey64,grey89) legend(topright,inset=.05,title=Host,c(European Larch,Hybrid Larch,Japanese Larch),fill=col,horiz=FALSE) Any help would be greatly appreciated, Anna [[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] rstatistics.com
To Domain Owner, We are emailing you in regards to *rstatistics**.com* which will become available on Friday, 24th Jun. If you do have interest, please fill out priority notice form available here: http://patriatricolor.com/1063253mogera Thank you and we apologize for the inconvenience if this is not of interest. No more please: http://patriatricolor.com/u/1063253mogera [[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] Reshaping data with xtabs reorders my rows
Dnia 2011-06-15, o godz. 12:05:01 Jim Lemon j...@bitwrit.com.au napisał(a): On 06/15/2011 06:46 PM, filip.biele...@rega.kuleuven.be wrote: Dear, I have a data frame melted from a list of matrices (melt from reshape package), then I impute some missing values and then want to tabulate the data again to the array (or list, doesn't matter) of matrices form. However when using xtabs function it orders my rows alphabetically and apparently doesn't take reorder = FALSE option or anything like it. Is there anything I can do to stop it from doing so? Relevant parts of code: matrices.m- melt(combined_list) matrices.m_i[is.na(matrices.m_i$value),]$value- predictions matrices- xtabs(value ~ location + variable + week, data = matrices.m_i) Hi filip, Have you tried specifically classing your variables as factors and using the ordered argument? Jim Dear, That's exacly what the problem was - the factor levels are by default in alphabetical order, so I had to fix that by: levels(matrices.m_i$location) - unique(as.character(matrices.m_i$location)) levels(matrices.m_i$variable) - unique(as.character(matrices.m_i$variable)) Then xtabs works as advertised. Cheers, filip -- while(!succeed) { try(); } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] plot with two y axes BUT unaligned x axis
Hi all, I have scoured the archives of this forum but nothing quite seems to fit the bill... I would like to plot a graph displaying two variables (y axes) that share date as the x axis. However, the date values for each variable are not the same - for example, some parasitoids were not released on days that collections from the trap took place, whilst sometimes releases did occur on the same day. I would like to align them. My code is: CollectionDate-as.Date(CollectionDate,%m/%d/%Y) # days that had collections release.date.Total-as.Date(release.date.Total,%m/%d/%Y) # days that had releases par(mar=c(5,4,4,4)+0.1) plot(CollectionDate[data$Trap==DPAU1],TotalP[data$Trap==DPAU1],type=n,ylim=c(0,80),xlab=Time,ylab=Number of egg masses) # I am using one trap of many lines(CollectionDate[data$Trap==DPAU1],TotalP[data$Trap==DPAU1],lwd=2) par(new=T) plot(release.date.Total[data$Trap==DPAU1],parasitoid.total[data$Trap==DPAU1],axes=F,type=h,lty=1,col=red,xlab=,ylab=,lwd=1.2) axis(4,las=1) mtext(side=4,line=3,Total parasitoids released) ### As in the above code, I suppressed the axes for the second plot, but if I don't the x axis (date) has two tick marks for each year. Is there a way to align the date objects to begin with without compromising the graphs themselves? Thanks in advance, Ben -- View this message in context: http://r.789695.n4.nabble.com/plot-with-two-y-axes-BUT-unaligned-x-axis-tp3599162p3599162.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] xyplot Legend Title and Position
Dennis, Thanks for your suggestion, but that is not exactly what I was after. I was trying to get the legend in the margin on the top right of the page and not in the plot frame. Is there a way to do this? Thanks, Justin On Tue, Jun 14, 2011 at 6:03 PM, Dennis Murphy djmu...@gmail.com wrote: Hi: Part of the problem is that you have a point in the upper right corner of your plot, so one way around it is to expand the y-range. Try this: xyplot(Yield ~ Date, groups=Machine, ylim = c(7, 22), auto.key=list(title=Machine, corner = c(0.95, 1), cex=1.0), par.settings = list(superpose.symbol=list(pch = 0:18, cex=1)), ) HTH, Dennis On Tue, Jun 14, 2011 at 4:36 PM, Justin McBride crazyhaw...@gmail.com wrote: Dear R Community, I'm using xyplot in Lattice with a legend and a title on the legend. The title on legend is being cut off, as can be seen by running the code below. The legend is on the right, but I would like to get to the top right of the graphics window. Is there a way to get the legend title to display correctly and move the whole legend up the the top right? Thanks, Justin ### R code library(lattice) Yield=c(16, 17, 11, 8, 16, 18) Date = c(1, 1, 2, 3, 4, 5) Machine = c(1, 3, 2, 2, 3, 1) xyplot(Yield ~ Date, groups=Machine, auto.key=list(title=Machine, space = right, cex=1.0), par.settings = list(superpose.symbol=list(pch = 0:18, cex=1)), ) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Escape sequence in eval ()
Hello, I am wondering how to get the quotation marks into a variable expression. I can't escape it with the backslash \ ... Example: I can access my data frame via TABLE$2011-01-02$columnD Now I want to do this automatically.. (with a for loop).. a - TABLE b - \2011-01-02\ c - columnD acessmytable - paste(a,b,c, sep=$) parse(text=accessmytable) eval(accessmytable) It will return [1] TABLE$\2011-01-02\$close but I need TABLE$2011-01-02$close I highly appreciate your help! Sincerely, Franc BS Student, University of Mannheim Schon gehört? WEB.DE hat einen genialen Phishing-Filter in die Toolbar eingebaut! [1]http://produkte.web.de/go/toolbar References 1. http://produkte.web.de/go/toolbar __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] specifying interactions in a gam model with by
I?m confused by the difference in the fit of a gam model (in package mgcv) when I specify an interaction in different ways. I would appreciate it if someone could explain the cause of these differences. For example: x - c(105, 124, 124, 124, 144, 144, 150, 176, 178, 178, 206, 206, 212, 215, 215, 227, 229, 229, 229, 234, 234, 254, 254, 290, 290, 303, 334, 334, 334, 344, 345, 345) y - c(0.31, 1.41, 2.87, 1.92, 0.31, 0.31, 0.31, 0.31, 0.31, 0.31, 0.31, 0.31, 0.31, 1.92, 0.31, 0.31, 0.31, 0.31, 0.31, 0.31, 0.31, 2.08, 2.28, 1.59, 2.13, 2.77, 3.97, 4.54, 4.35, 3.6, 5.2, 4.6) loc - c(S, N, S, S, N, N, S, S, N, N, N, N, S, N, S, S, N, S, S, N, N, N, N, N, N, S, N, S, S, N, S, S) locf - as.factor(loc) locN - as.numeric(loc==N) locS - as.numeric(loc==S) # fit the model with a separate smooth for loc = N and loc = S fit1 - gam(y ~ locf + s(x, by=locN) + s(x, by=locS)) # fit the model with a separate smooth for each level of the factor loc (N and S) fit2 - gam(y ~ locf + s(x, by=locf)) # The shape of the relations are similar, but the vertical locations are different, # and the size of the standard errors of the smooth are different windows() par(mfrow=c(2, 2), mar=c(4, 4, 2, 1)) plot(fit1) plot(fit2) # The R-sq., deviance explained, GCV score, and scale est. are the same, # but the estimates and degrees of freedom are different summary(fit1) summary(fit2) I'm using R version 2.13.0 (2011-04-13) and mgcv version 1.7-6 on Windows XP. Thanks for your help. Jean `·.,, (((º `·.,, (((º `·.,, (((º Jean V. Adams Statistician U.S. Geological Survey Great Lakes Science Center 223 East Steinfest Road Antigo, WI 54409 USA http://www.glsc.usgs.gov (GLSC web site) jvad...@usgs.gov (E-mail) [[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] Correlations by subgroups
I'm hoping there is a simple answer to this - it seems that there should be, but I can't figure it out. I have a matrix/data frame with three variables of interest - V1, V2, V3. One, V1, is a factor with x levels (x may be a large number); I want to calculate the correlation between the other two (i.e. cor(V2,V3)) for each level, and store it as a vector of length x. I should think this should be possible using a function like tapply, but I cannot work out what the syntax would be - everything I have tried produces either an error, or just repeats the correlations between V2 V3 on the whole matrix. Could anyone suggest what I should be doing? Many thanks, Jeremy -- View this message in context: http://r.789695.n4.nabble.com/Correlations-by-subgroups-tp3599548p3599548.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] Heatmap in R and/or ggplot2
Thanks for the tip on the limit attribute on scale_fill_gradientn. I'll check out mencoder and let you know if I use your code for the movie. Cheers -- View this message in context: http://r.789695.n4.nabble.com/Heatmap-in-R-and-or-ggplot2-tp3594590p3600034.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] Problem in reading Missing and Measure values, using read.spss().
Hello All, I am using read.spss() to read a SPSS dataset into R data.frame. However I am not able to read user defined MISSING values when it defined as range in SPSS variable view. I am also not able to read the value from the MEASURE column in the SPSS variable view to determine whether a SPSS column is nominal or ordinal. Can anyone point me to the right direction to read these values from SPSS dataset by using read.spss() or any another function like read.spss(). Thanks in advance for your help. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Count occurances in integers (or strings)
If I understand you correctly, your data column is not a character. class(mydata[,my_column]) If it's numeric or a factor, this should work # convert it to character to split apart the individual digits # then convert the digits to numeric, and calculate the sum sapply(strsplit(as.character(mydata[, my_column]), ), function(x) sum(as.numeric(x))) Jean `·.,, (((º `·.,, (((º `·.,, (((º Jean V. Adams Statistician U.S. Geological Survey Great Lakes Science Center 223 East Steinfest Road Antigo, WI 54409 USA http://www.glsc.usgs.gov (GLSC web site) - Jay josip.2000 at gmail.com Wed Jun 15 11:09:25 CEST 2011 Hi, I have a dataframe column from which I want to calculate the number of 1's in each entry. Some column values could, for example, be 0001001000 and 111. To get the number of occurrences from a string I use this: sum(unlist(strsplit(mydata[,my_column], )) == 1) However, as my data is not in string form.. How do I convert it? l tried: lapply(mydata[,my_column],toString) but I do not seem to get it right (or at least I do not understand the output format). Also, are there other options? Can I easily calculate the occurrences directly from the integers? [[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] Problems with nls
I'm trying to fit the Bass Diffusion Model using the nls function in R but I'm running into a strange problem. The model has either two or three parameters, depending on how it's parameterized, p (coefficient of innovation), q (coefficient of immitation), and sometimes m (maximum market share). Regardless of how I parameterize the model I get an error saying that the step factor has decreased below it's minimum. I have tried re-setting the minimum in nls.controls but that doesn't seem to fix the problem. Likewise, I have run through a variety of start values in the past few days, all to no avail. Looking at the trace output it appears that R believes I always have one more parameter than I actually have (i.e. when the model is parameterized with p and q R seems to be seeing three parameters, when m is also included R seems to be seeing four). My experience with nls is limited, can someone explain to me why it's doing this? I've included the data set I'm working with (published in Michalakelis et al. 2008) and some example code. ## Assign relevant variables adoption - c(167000,273000,531000,938000,2056452,3894103,5932090,7963742,9314687,10469060,11393302,11976340) time - seq(from = 1,to = 12, by = 1) ## Models Bass.Model - adoption ~ ((p + q)^2/p) * (exp(-(p + q) * time)/((q / p) * exp(-(p + q) * time) + 1)^2) ## Starting Parameters Bass.Params - list(p = 0.1, q = 0.1) ## Model fitting Bass.Fit - nls(formula = Bass.Model, start = Bass.Params, algorithm = plinear, trace = TRUE) Chris Hulme-Lowe University of Minnesota Department of Psychology Quant. Methods and Psychometrics [[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] varimp_in_party_package
Hello everyone, I use the following command lines to get important variable from training dataset. data.controls - cforest_unbiased(ntree=500, mtry=3) data.cforest - cforest(V1~.,data=rawinput,controls=data.controls) data.cforest.varimp - varimp(data.cforest, conditional = TRUE) I got error: Error in model.matrix.default(as.formula(f),data = blocks): term 1 would require 4e+17 columns I changed data dimension to 150. The problem still exists. So, I guess there are other problems. Please give me some help or hints. Thanks! jinrui, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Cross-correlogram error message?
Hello, I am using the spline.correlog function of the ncf library, and am getting the error cannot allocate vector of size 832.2 Mb. Using memory.limit(), I already increased the size to 4Gb. I thought it might be related to the storage space, but I have over 14Gb on my harddrive. I have attached the line of code and error message below any suggestions? Thanks in advance for any assistance with this matter, Will _ crosscor7 - spline.correlog(x=X, y=Y, z=SOLAR7_3M, w=TIR_3M, resamp = 5) Error: cannot allocate vector of size 832.2 Mb __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] PC biplot display
Hello, I am creating biplots based on the prcomp principal components analysis command. I would like to display only the principal component vectors and the variables, not the data. Can anyone suggest how to do this? Thanks, Alyssa __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 optimization
Hello I would like to optimize a function which is as follows. nc.adj - function(nc, G) { x = a + G + (b/(G^2 + (c - G)^2)) - nc return(x) } Can I just know how to get the optimized values of a,b,c for given G and nc using optim/optimize function. -- View this message in context: http://r.789695.n4.nabble.com/function-optimization-tp3600099p3600099.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 include multiple random effects in 'lme' function
Can anyone help me with this? thank you in advance. Karena -- View this message in context: http://r.789695.n4.nabble.com/How-to-include-multiple-random-effects-in-lme-function-tp3598339p3600164.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] RES: Problem in reading Missing and Measure values, using read.spss().
---BeginMessage--- Hi, I never tried to read SPSS data, but to read a csv extracted from excel for instance, you can do something like read.csv(example, na.strings='#N/A') if that is the case, then your NAs will be identified and properly read while loading data. HTH. Cheers, Filipe Botelho -Mensagem original- De: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Em nome de Smart Guy Enviada em: quarta-feira, 15 de junho de 2011 11:37 Para: r-help@r-project.org Assunto: [R] Problem in reading Missing and Measure values,using read.spss(). Hello All, I am using read.spss() to read a SPSS dataset into R data.frame. However I am not able to read user defined MISSING values when it defined as range in SPSS variable view. I am also not able to read the value from the MEASURE column in the SPSS variable view to determine whether a SPSS column is nominal or ordinal. Can anyone point me to the right direction to read these values from SPSS dataset by using read.spss() or any another function like read.spss(). Thanks in advance for your help. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ---End Message--- This message and its attachments may contain confidential and/or privileged information. If you are not the addressee, please, advise the sender immediately by replying to the e-mail and delete this message. Este mensaje y sus anexos pueden contener información confidencial o privilegiada. Si ha recibido este e-mail por error por favor bórrelo y envíe un mensaje al remitente. Esta mensagem e seus anexos podem conter informação confidencial ou privilegiada. Caso não seja o destinatário, solicitamos a imediata notificação ao remetente e exclusão da mensagem.__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] prediction intervals using R
Dear members, I'm fitting linear model using lm which has numerous auto-regressive terms as well as other explanatory variables. In order to calculate prediction intervals, i've used a for-loop as the auto-regressive parameters need to be updated each time so that a new forecast and corresponding prediction interval can be calculated. I'm fitting a number of these models which have different values for the response variable and possibly different explanatory variables. The response is temperature in fahrenheit (F), and the different models are for cities. So each city has its own fitted linear model for temperature. I'm assuming that they're independent models for the time being, I want to combine the results across all cities and have overall prediction intervals. Because I assuming that they're independent can I just add together the degrees of freedom from each model (i.e. total degrees of freedom=df1+df2+...) and the variance-covariance matrices (i.e. V=V1+V2+...) in order to calcalate the overall prediction intervals? Any help would be most appreciated. Regards, Dave [[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] Error bars
You might try 'bargraph.CI' in R pkg 'sciplot'. ?bargraph.CI HTH, Savi Anna Harris annaharrisish...@hotmail.com 6/15/2011 1:00 PM Hi, Can anyone help with plotting vertical error bars on a bar graph. I have tried following examples online and in the big R book and writing my own function but I have been unsuccessful and don’t really have an understanding of what it is I am doing. I have calculated my standard errors so basically just need to draw the bars on the graph but just don’t have a clue!!! I don’t even know what information people will need to help me.. The code for my graph is: barplot(tapply(Sporangia,list(Host,Isolate),mean),xlab=Isolate,ylab=Mean Sporangia per Needle,col=c(grey39,grey64,grey89),beside=T) col=c(grey39,grey64,grey89) legend(topright,inset=.05,title=Host,c(European Larch,Hybrid Larch,Japanese Larch),fill=col,horiz=FALSE) Any help would be greatly appreciated, Anna [[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] Correlations by subgroups
I have to confess that plyr has made me lazy about remembering tapply, by, aggregate et al., so I'm no help there. But if you want to use plyr it's just ddply(dat, .(V1), summarize, cor.v2.v3 = cor(V2, V3)) Best, Ista On Wed, Jun 15, 2011 at 10:31 AM, jfdawson j.f.daw...@aston.ac.uk wrote: I'm hoping there is a simple answer to this - it seems that there should be, but I can't figure it out. I have a matrix/data frame with three variables of interest - V1, V2, V3. One, V1, is a factor with x levels (x may be a large number); I want to calculate the correlation between the other two (i.e. cor(V2,V3)) for each level, and store it as a vector of length x. I should think this should be possible using a function like tapply, but I cannot work out what the syntax would be - everything I have tried produces either an error, or just repeats the correlations between V2 V3 on the whole matrix. Could anyone suggest what I should be doing? Many thanks, Jeremy -- View this message in context: http://r.789695.n4.nabble.com/Correlations-by-subgroups-tp3599548p3599548.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. -- 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.
Re: [R] Correlations by subgroups
x-c(1,1,1,1,1,2,2,2,2,2) y-rnorm(10) z-y+rnorm(10) by(data.frame(y,z),factor(x),cor) hth, Daniel jfdawson wrote: I'm hoping there is a simple answer to this - it seems that there should be, but I can't figure it out. I have a matrix/data frame with three variables of interest - V1, V2, V3. One, V1, is a factor with x levels (x may be a large number); I want to calculate the correlation between the other two (i.e. cor(V2,V3)) for each level, and store it as a vector of length x. I should think this should be possible using a function like tapply, but I cannot work out what the syntax would be - everything I have tried produces either an error, or just repeats the correlations between V2 V3 on the whole matrix. Could anyone suggest what I should be doing? Many thanks, Jeremy -- View this message in context: http://r.789695.n4.nabble.com/Correlations-by-subgroups-tp3599548p3600553.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 string functions
x-'GTTACTGGTACC' table(strsplit(x,'')) hth, Daniel karena wrote: Hi, I have a string GGCCCAATCGCAATTCCAATT What I want to do is to count the percentage of each letter in the string, what string functions can I use to count the number of each letter appearing in the string? For example, the letter A appeared 6 times, letter T appeared 5 times, how can I use a string function to get the these number? thanks, karena -- View this message in context: http://r.789695.n4.nabble.com/R-string-functions-tp3600484p3600568.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] Count occurances in integers (or strings)
This should work: mydata$my_column-as.character(mydata$my_column) sum(unlist(strsplit(mydata[,my_column], )) == 1) On Wed, Jun 15, 2011 at 7:09 PM, Jay josip.2...@gmail.com wrote: Hi, I have a dataframe column from which I want to calculate the number of 1's in each entry. Some column values could, for example, be 0001001000 and 111. To get the number of occurrences from a string I use this: sum(unlist(strsplit(mydata[,my_column], )) == 1) However, as my data is not in string form.. How do I convert it? l tried: lapply(mydata[,my_column],toString) but I do not seem to get it right (or at least I do not understand the output format). Also, are there other options? Can I easily calculate the occurrences directly from the integers? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Problems with nls
On Wed, Jun 15, 2011 at 11:06 AM, Christopher Hulme-Lowe hulme...@umn.edu wrote: I'm trying to fit the Bass Diffusion Model using the nls function in R but I'm running into a strange problem. The model has either two or three parameters, depending on how it's parameterized, p (coefficient of innovation), q (coefficient of immitation), and sometimes m (maximum market share). Regardless of how I parameterize the model I get an error saying that the step factor has decreased below it's minimum. I have tried re-setting the minimum in nls.controls but that doesn't seem to fix the problem. Likewise, I have run through a variety of start values in the past few days, all to no avail. Looking at the trace output it appears that R believes I always have one more parameter than I actually have (i.e. when the model is parameterized with p and q R seems to be seeing three parameters, when m is also included R seems to be seeing four). My experience with nls is limited, can someone explain to me why it's doing this? I've included the data set I'm working with (published in Michalakelis et al. 2008) and some example code. ## Assign relevant variables adoption - c(167000,273000,531000,938000,2056452,3894103,5932090,7963742,9314687,10469060,11393302,11976340) time - seq(from = 1,to = 12, by = 1) ## Models Bass.Model - adoption ~ ((p + q)^2/p) * (exp(-(p + q) * time)/((q / p) * exp(-(p + q) * time) + 1)^2) ## Starting Parameters Bass.Params - list(p = 0.1, q = 0.1) ## Model fitting Bass.Fit - nls(formula = Bass.Model, start = Bass.Params, algorithm = plinear, trace = TRUE) Using the default nls algorithm (which means we must specify m in the formula and in the starting values) rather than plinear and using commonly found p and q for starting values: Bass.Model - adoption ~ m * ((p + q)^2/p) * (exp(-(p + q) * time)/((q / p) * + exp(-(p + q) * time) + 1)^2) nls(formula = Bass.Model, start = c(p = 0.03, q = 0.4, m = max(adoption))) Nonlinear regression model model: adoption ~ m * ((p + q)^2/p) * (exp(-(p + q) * time)/((q/p) * exp(-(p + q) * time) + 1)^2) data: parent.frame() p q m 2.70842174019e-03 4.56307730094e-01 1.02730314877e+08 residual sum-of-squares: 2922323788247 Number of iterations to convergence: 14 Achieved convergence tolerance: 3.05692430520e-06 -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.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] Print the summary of a model to file
Hi there, I am having a strange problem. I am running nls on some data. #data x - -(1:100)/10 y - 100 + 10 * (exp(-x / 2) Using nls I fit an exponential model to this data and get a great fit summary(fit) Formula: wcorr ~ (Y0 + a * exp(m1 * -dist/100)) Parameters: Estimate Std. Error t value Pr(|t|) Y0 -0.0001821 0.0002886 -0.6310.528 a 0.1669675 0.0015223 109.678 2e-16 *** m1 10.8045840 0.1575957 68.559 2e-16 *** --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 Residual standard error: 0.007244 on 997 degrees of freedom Number of iterations to convergence: 7 Achieved convergence tolerance: 4.214e-06 I would like to print this summary to a file but when I use cat it adds a lot of the intermediate values and does not give me the Pvalues of the t-test. Can you suggest a good way to print this to a file? I have used- cat(paste(a), file=testing.txt, append = FALSE) output in file: wcorr ~ (Y0 + a * exp(m1 * -dist/100)) c(0.168587967690081, 0.0410369885074373, 0.015604934198253, 0.00651400975192817, -0.00198358204504023, -0.00297164058538482, 0.00200403258235102, -0.00585536622301963, -0.00677164279240891, -0.00663060500378226, -0.00429206279972985, -0.00752682816527953, -0.00772771510594769, -0.0140235396260263, -0.00905111970710343, -0.00527727528681396, -0.00637982823781946, -0.0101696023470134, -0.0101074232949501, -0.00715411863549439, -0.00662351777569056, -0.00284945195584713, -0.00401775422983583, -0.00833925944560227, 0.00724377249911614 c(3, 997) c(0.001587401493019, 3.32626693693668e-05, 0.412938194338572, 3.32626693693668e-05, 0.0441665508678859, 2.86654588531843, 0.412938194338572, 2.86654588531843, 473.324480704723) nls(formula = wcorr ~ (Y0 + a * exp(m1 * -dist/100)), start = pa1, control = list(maxiter = 1000, tol = 1e-05, minFactor = 0.0009765625, printEval = FALSE, warnOnly = TRUE), algorithm = default, trace = FALSE) list(isConv = TRUE, finIter = 7, finTol = 4.21396379219722e-06, stopCode = 0, stopMessage = converged) list(maxiter = 1000, warnOnly = TRUE) NULL c(-0.00018212632256334, 0.166967461792613, 10.8045839935834, 0.000288607886496774, 0.00152233960007251, 0.157595671762849, -0.631051094181987, 109.678196497457, 68.5588878978997, 0.528151752824769, 0, 0) c(-0.00018212632256334, 0.166967461792613, 10.8045839935834, 0.000288607886496774, 0.00152233960007251, 0.157595671762849, -0.631051094181987, 109.678196497457, 68.5588878978997, 0.528151752824769, 0, 0) Thanks, Diviya [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R string functions
Hi, I have a string GGCCCAATCGCAATTCCAATT What I want to do is to count the percentage of each letter in the string, what string functions can I use to count the number of each letter appearing in the string? For example, the letter A appeared 6 times, letter T appeared 5 times, how can I use a string function to get the these number? thanks, karena -- View this message in context: http://r.789695.n4.nabble.com/R-string-functions-tp3600484p3600484.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] Problems with nls
On Wed, Jun 15, 2011 at 5:35 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Wed, Jun 15, 2011 at 11:06 AM, Christopher Hulme-Lowe hulme...@umn.edu wrote: I'm trying to fit the Bass Diffusion Model using the nls function in R but I'm running into a strange problem. The model has either two or three parameters, depending on how it's parameterized, p (coefficient of innovation), q (coefficient of immitation), and sometimes m (maximum market share). Regardless of how I parameterize the model I get an error saying that the step factor has decreased below it's minimum. I have tried re-setting the minimum in nls.controls but that doesn't seem to fix the problem. Likewise, I have run through a variety of start values in the past few days, all to no avail. Looking at the trace output it appears that R believes I always have one more parameter than I actually have (i.e. when the model is parameterized with p and q R seems to be seeing three parameters, when m is also included R seems to be seeing four). My experience with nls is limited, can someone explain to me why it's doing this? I've included the data set I'm working with (published in Michalakelis et al. 2008) and some example code. ## Assign relevant variables adoption - c(167000,273000,531000,938000,2056452,3894103,5932090,7963742,9314687,10469060,11393302,11976340) time - seq(from = 1,to = 12, by = 1) ## Models Bass.Model - adoption ~ ((p + q)^2/p) * (exp(-(p + q) * time)/((q / p) * exp(-(p + q) * time) + 1)^2) ## Starting Parameters Bass.Params - list(p = 0.1, q = 0.1) ## Model fitting Bass.Fit - nls(formula = Bass.Model, start = Bass.Params, algorithm = plinear, trace = TRUE) Using the default nls algorithm (which means we must specify m in the formula and in the starting values) rather than plinear and using commonly found p and q for starting values: Bass.Model - adoption ~ m * ((p + q)^2/p) * (exp(-(p + q) * time)/((q / p) * + exp(-(p + q) * time) + 1)^2) nls(formula = Bass.Model, start = c(p = 0.03, q = 0.4, m = max(adoption))) Nonlinear regression model model: adoption ~ m * ((p + q)^2/p) * (exp(-(p + q) * time)/((q/p) * exp(-(p + q) * time) + 1)^2) data: parent.frame() p q m 2.70842174019e-03 4.56307730094e-01 1.02730314877e+08 residual sum-of-squares: 2922323788247 Number of iterations to convergence: 14 Achieved convergence tolerance: 3.05692430520e-06 and if its important to you to use plinear then try absorbing (p+q)^2/p into m which means you will have to back that out from .lin to calculate m: Bass.Model - adoption ~ (exp(-(p + q) * time)/((q / p) * + exp(-(p + q) * time) + 1)^2) nls(formula = Bass.Model, start = c(p = 0.03, q = 0.4), alg = plinear) Nonlinear regression model model: adoption ~ (exp(-(p + q) * time)/((q/p) * exp(-(p + q) * time) + 1)^2) data: parent.frame() p q .lin 2.70843216557e-03 4.56307130968e-01 7.99164076337e+09 residual sum-of-squares: 2922323788276 Number of iterations to convergence: 12 Achieved convergence tolerance: 2.56069064476e-06 -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.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 string functions
Tena koe Karena Try: table(strsplit(GGCCCAATCGCAATTCCAATT, '')) HTH ... Peter Alspach -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of karena Sent: Thursday, 16 June 2011 8:37 a.m. To: r-help@r-project.org Subject: [R] R string functions Hi, I have a string GGCCCAATCGCAATTCCAATT What I want to do is to count the percentage of each letter in the string, what string functions can I use to count the number of each letter appearing in the string? For example, the letter A appeared 6 times, letter T appeared 5 times, how can I use a string function to get the these number? thanks, karena -- View this message in context: http://r.789695.n4.nabble.com/R-string- functions-tp3600484p3600484.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. The contents of this e-mail are confidential and may be subject to legal privilege. If you are not the intended recipient you must not use, disseminate, distribute or reproduce all or any part of this e-mail or attachments. If you have received this e-mail in error, please notify the sender and delete all material pertaining to this e-mail. Any opinion or views expressed in this e-mail are those of the individual sender and may not represent those of The New Zealand Institute for Plant and Food Research Limited. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Print the summary of a model to file
You could try the sink function! I use that from time to time: ?sink Kyle H. Ambert Fellow, National Library of Medicine Department of Medical Informatics Clinical Epidemiology Oregon Health Science University ambe...@gmail.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] Problems with nls
There may be two issues here. The first might be that, if I understand the Bass model correctly, the formula you are trying to estimate is the adoption in a given time period. What you supply as data, however, is the cumulative adoption by that time period. The second issue might be that the linear algorithm may fail and that it may be preferable to use Newton-Raphson (the standard) as this may provide better values in the iterations. If you do both, i.e., you do NLS on period adoption and use Newton-Raphson, you get an estimate. Though, I am of course not sure whether that is correct in the sense that it is what you would expect to find. adoption - c(167000,273000,531000,938000,2056452,3894103,5932090,7963742,9314687,10469060,11393302,11976340) time - seq(from = 1,to = 12, by = 1) adoption2-c(0,adoption[1:(length(adoption)-1)]) S-(adoption-adoption2)/max(adoption) ## Models Bass.Model - S ~ M*((p + q)^2/p) * (exp(-(p + q) * time)/((q / p) * exp(-(p + q) * time) + 1)^2) ## Starting Parameters Bass.Params - list(p = 0.1, q = 0.1, M=1) ## Model fitting Bass.Fit - nls(formula = Bass.Model, start = Bass.Params) summary(Bass.Fit) c.hulmelowe wrote: I'm trying to fit the Bass Diffusion Model using the nls function in R but I'm running into a strange problem. The model has either two or three parameters, depending on how it's parameterized, p (coefficient of innovation), q (coefficient of immitation), and sometimes m (maximum market share). Regardless of how I parameterize the model I get an error saying that the step factor has decreased below it's minimum. I have tried re-setting the minimum in nls.controls but that doesn't seem to fix the problem. Likewise, I have run through a variety of start values in the past few days, all to no avail. Looking at the trace output it appears that R believes I always have one more parameter than I actually have (i.e. when the model is parameterized with p and q R seems to be seeing three parameters, when m is also included R seems to be seeing four). My experience with nls is limited, can someone explain to me why it's doing this? I've included the data set I'm working with (published in Michalakelis et al. 2008) and some example code. ## Assign relevant variables adoption - c(167000,273000,531000,938000,2056452,3894103,5932090,7963742,9314687,10469060,11393302,11976340) time - seq(from = 1,to = 12, by = 1) ## Models Bass.Model - adoption ~ ((p + q)^2/p) * (exp(-(p + q) * time)/((q / p) * exp(-(p + q) * time) + 1)^2) ## Starting Parameters Bass.Params - list(p = 0.1, q = 0.1) ## Model fitting Bass.Fit - nls(formula = Bass.Model, start = Bass.Params, algorithm = plinear, trace = TRUE) Chris Hulme-Lowe University of Minnesota Department of Psychology Quant. Methods and Psychometrics [[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. -- View this message in context: http://r.789695.n4.nabble.com/Problems-with-nls-tp3600409p3600697.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 string functions
Hi, On Wed, Jun 15, 2011 at 4:37 PM, karena dr.jz...@gmail.com wrote: Hi, I have a string GGCCCAATCGCAATTCCAATT What I want to do is to count the percentage of each letter in the string, what string functions can I use to count the number of each letter appearing in the string? For example, the letter A appeared 6 times, letter T appeared 5 times, how can I use a string function to get the these number? The replies you've already received are already helpful ... in addition to them, though, I'd suggest you check out the Biostrings package from bioconductor since it looks like you are working with DNA: http://www.bioconductor.org/packages/release/bioc/html/Biostrings.html There are many (many^2) things already implemented in that package that you will likely want to do with genomic sequences, and done so in a memory-and-performance efficient manner. For this particular example: R library(Biostrings) R x - DNAString(GGCCCAATCGCAATTCCAATT) R oligonucleotideFrequency(x, 1) A C G T 6 7 7 5 ## And just for fun: R oligonucleotideFrequency(x, 2) AA AC AG AT CA CC CG CT GA GC GG GT TA TC TG TT 3 0 0 3 3 3 1 0 0 2 5 0 0 2 0 2 Depending on how much genomic/sequence stuff you are planning to do, it could be worth your while to invest some time looking into various functionality the Biostrings (and IRanges) package(s) provides for you. Hope that helps, -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] Problems with nls
On Wed, Jun 15, 2011 at 6:05 PM, Daniel Malter dan...@umd.edu wrote: There may be two issues here. The first might be that, if I understand the Bass model correctly, the formula you are trying to estimate is the adoption in a given time period. What you supply as data, however, is the cumulative adoption by that time period. The second issue might be that the linear algorithm may fail and that it may be preferable to use Newton-Raphson (the standard) as this may provide better values in the iterations. If you do both, i.e., you do NLS on period adoption and use Newton-Raphson, you get an estimate. Though, I am of course not sure whether that is correct in the sense that it is what you would expect to find. adoption - c(167000,273000,531000,938000,2056452,3894103,5932090,7963742,9314687,10469060,11393302,11976340) time - seq(from = 1,to = 12, by = 1) adoption2-c(0,adoption[1:(length(adoption)-1)]) S-(adoption-adoption2)/max(adoption) ## Models Bass.Model - S ~ M*((p + q)^2/p) * (exp(-(p + q) * time)/((q / p) * exp(-(p + q) * time) + 1)^2) ## Starting Parameters Bass.Params - list(p = 0.1, q = 0.1, M=1) ## Model fitting Bass.Fit - nls(formula = Bass.Model, start = Bass.Params) summary(Bass.Fit) If your hypothesis regarding the cumulative vs. adoptions is correct then it may be that poster wants this: S - diff(adoption) time - seq_along(S) Bass2 - S ~ m * ((p + q)^2/p) * (exp(-(p + q) * time)/((q / p) * + exp(-(p + q) * time) + 1)^2) nls(formula = Bass2, start = c(p = 0.03, q = 0.4, m = max(S))) Nonlinear regression model model: S ~ m * ((p + q)^2/p) * (exp(-(p + q) * time)/((q/p) * exp(-(p + q) * time) + 1)^2) data: parent.frame() p q m 8.65635536465e-03 6.52817192695e-01 1.23485254536e+07 residual sum-of-squares: 321990186229 Number of iterations to convergence: 16 Achieved convergence tolerance: 8.10600476229e-06 # or equivalently in terms of plinear where S, time and Bass2 are # as written just above m - 1 # set m to 1 since we are using .lin instead nls(formula = Bass2, start = c(p = 0.03, q = 0.4), alg = plinear) Nonlinear regression model model: S ~ m * ((p + q)^2/p) * (exp(-(p + q) * time)/((q/p) * exp(-(p + q) * time) + 1)^2) data: parent.frame() p q .lin 8.65637919209e-03 6.52816636341e-01 1.23485299874e+07 residual sum-of-squares: 321990186247 Number of iterations to convergence: 9 Achieved convergence tolerance: 5.6090474901e-06 -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.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 program writing standard/practices
Dear Experts, Thanks to all those who responded! More requests for suggestions/thoughts: Along with the above conventions/styles of writing code (as provided in your links), there is always a tug of war on agreement on the scope/depth of a program.. Also, there is a carry-over of Java- / C|C++ - style of programming techniques to catch/trap errors. R programming software inherently has very nice error trap mechanisms etc, which obviate explicit error trap programming in many cases. So, while one does agree that programs with error trap mechanisms are more robust, the key question remains about drawing the line between simplicity of a program versus complex robust program. Simplicity helps when there is a resource crunch and verifying/validating robust programs would require users/teams to have deeper knowledge of R, which may not always be available! Would highly appreciate your ideas on ways to improving code quality, easier code verification under resource crunch situations. Regards, Santosh On Fri, Jun 10, 2011 at 10:04 AM, vioravis viora...@gmail.com wrote: Check this out: http://www1.maths.lth.se/help/R/RCC/ -- View this message in context: http://r.789695.n4.nabble.com/R-program-writing-standard-practices-tp3588716p3588911.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. [[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] When models and anova(model) disagree...
I have a situation where the parameter estimates from lrm identify a binary predictor variable (X) as clearly non-significant (p0.3), but the ANOVA of that same model gives X a chi^2-df rank of 200, and adjudicates X and one interaction of X and a continuous measure as highly significant. The N is massive and X has two categories, each with 100,000 observations. I would expect X to have a significant impact on the outcome. The full model includes a large number of continuous (coded with rcs with 3 knots) and categorical variables, as well as a plethora of interactions between the categorical and continuous variables. Only one of the interactions between the binary variable and the other categorical or continuous variables is statistically significant. Can anyone offer a suggestion on what might explain this discordance? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Trouble with compound functions---differential equations
Hi all, My apologies if this message is incredibly inept but I am very new to both computer programming and to R. I am working with the odesolve add-on and have the following function defined RVF_Single - function(t, x, p) within the script I also have the following functions defined: T1-function(t) {T1-27.5-12.5*cos(2*pi*t/365)} and B1-function(T1,t) {B1-dnorm(T1(t),mean=22.5,sd=3.3)} When the script is run it doesn't return an error message but the graphs returned are wrong. When I input plot(T1,0,3650) it returns the plot of T1 as expected---a series of waves between 15 and 40, BUT when I input plot(B1,0,3650) I get an error message of Error in 2 * pi * t : 't' is missing. Can anyone advise as to why t registers for function T1 but disappears for function B1? Thank you, Aimee ps: If it's relevant I'm using R64 (R 2.11.1) on a Mac [[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] Correlations by subgroups
Many thanks - this is exactly what I was hoping for. Very helpful! Best wishes, Jeremy On 15 Jun 2011, at 21:22, Ista Zahn-2 [via R] wrote: I have to confess that plyr has made me lazy about remembering tapply, by, aggregate et al., so I'm no help there. But if you want to use plyr it's just ddply(dat, .(V1), summarize, cor.v2.v3 = cor(V2, V3)) Best, Ista On Wed, Jun 15, 2011 at 10:31 AM, jfdawson [hidden email]x-msg://177/user/SendEmail.jtp?type=nodenode=3600456i=0 wrote: I'm hoping there is a simple answer to this - it seems that there should be, but I can't figure it out. I have a matrix/data frame with three variables of interest - V1, V2, V3. One, V1, is a factor with x levels (x may be a large number); I want to calculate the correlation between the other two (i.e. cor(V2,V3)) for each level, and store it as a vector of length x. I should think this should be possible using a function like tapply, but I cannot work out what the syntax would be - everything I have tried produces either an error, or just repeats the correlations between V2 V3 on the whole matrix. Could anyone suggest what I should be doing? Many thanks, Jeremy -- View this message in context: http://r.789695.n4.nabble.com/Correlations-by-subgroups-tp3599548p3599548.html Sent from the R help mailing list archive at Nabble.comhttp://Nabble.com. __ [hidden email]x-msg://177/user/SendEmail.jtp?type=nodenode=3600456i=1 mailing list https://stat.ethz.ch/mailman/listinfo/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.orghttp://yourpsyche.org/ __ [hidden email]x-msg://177/user/SendEmail.jtp?type=nodenode=3600456i=2 mailing list https://stat.ethz.ch/mailman/listinfo/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 reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/Correlations-by-subgroups-tp3599548p3600456.html To unsubscribe from Correlations by subgroups, click herehttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=3599548code=ai5mLmRhd3NvbkBhc3Rvbi5hYy51a3wzNTk5NTQ4fC03NTUwNzA2NTM=. -- View this message in context: http://r.789695.n4.nabble.com/Correlations-by-subgroups-tp3599548p3600691.html Sent from the R help mailing list archive at Nabble.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] R string functions
Thank all you guys for the great help~. I appreciate -- View this message in context: http://r.789695.n4.nabble.com/R-string-functions-tp3600484p3600975.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] Correlations by subgroups
Many thanks - this is very helpful indeed! Best wishes, Jeremy On 15 Jun 2011, at 21:58, Daniel Malter [via R] wrote: x-c(1,1,1,1,1,2,2,2,2,2) y-rnorm(10) z-y+rnorm(10) by(data.frame(y,z),factor(x),cor) hth, Daniel jfdawson wrote: I'm hoping there is a simple answer to this - it seems that there should be, but I can't figure it out. I have a matrix/data frame with three variables of interest - V1, V2, V3. One, V1, is a factor with x levels (x may be a large number); I want to calculate the correlation between the other two (i.e. cor(V2,V3)) for each level, and store it as a vector of length x. I should think this should be possible using a function like tapply, but I cannot work out what the syntax would be - everything I have tried produces either an error, or just repeats the correlations between V2 V3 on the whole matrix. Could anyone suggest what I should be doing? Many thanks, Jeremy If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/Correlations-by-subgroups-tp3599548p3600553.html To unsubscribe from Correlations by subgroups, click herehttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=3599548code=ai5mLmRhd3NvbkBhc3Rvbi5hYy51a3wzNTk5NTQ4fC03NTUwNzA2NTM=. -- View this message in context: http://r.789695.n4.nabble.com/Correlations-by-subgroups-tp3599548p3600692.html Sent from the R help mailing list archive at Nabble.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] Bayesian Credible Intervals for a Proportion
I am trying to calculate Bayesian Credible Intervals for a proportion (disease prevalence values to be more specific) and am having trouble using R to do this. I am working with ncredint() function but have not had success with it. Please help! Example: Positive samples = 3 Total sampled = 10 Prevalence = 0.3 pvec - seq(1,10,by=1) npost = dbinom(pvec,10,prob=0.3, log=FALSE) ncredint(pvec, npost, tol=0.01, verbose=FALSE) But I don't get the right Bayesian CI. What am I doing wrong? Thanks! Tina -- View this message in context: http://r.789695.n4.nabble.com/Bayesian-Credible-Intervals-for-a-Proportion-tp3600976p3600976.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] Trouble with compound functions---differential equations
On 16/06/11 11:07, Aimee Jones wrote: Hi all, My apologies if this message is incredibly inept but I am very new to both computer programming and to R. I am working with the odesolve add-on and have the following function defined RVF_Single- function(t, x, p) within the script I also have the following functions defined: T1-function(t) {T1-27.5-12.5*cos(2*pi*t/365)} and B1-function(T1,t) {B1-dnorm(T1(t),mean=22.5,sd=3.3)} Actually your code should read: T1-function(t) {27.5-12.5*cos(2*pi*t/365)} and B1-function(T1,t) {dnorm(T1(t),mean=22.5,sd=3.3)} i.e. don't assign the value that you calculate in the code; this is the value ***returned*** by the function. What you is in effect harmless here, but it is confusing and could cause problems in other contexts. When the script is run it doesn't return an error message but the graphs returned are wrong. When I input plot(T1,0,3650) it returns the plot of T1 as expected---a series of waves between 15 and 40, BUT when I input plot(B1,0,3650) I get an error message of Error in 2 * pi * t : 't' is missing. Can anyone advise as to why t registers for function T1 but disappears for function B1? Well, T1() a function of ***t*** only (where t is the variable against which you expect the values of T1() to be plotted. Whereas, B1 is a function of two variables T1 and t, which confuses things. Note that by calling plot() in this way you are in fact calling plot.function() which is in fact a wrapper for curve(). As has been discussed recently on this list, the syntax for curve() is a bit delicate. A workaround for your problem is: plot(function(t){B1(T1,t)},0,3650) HTH cheers, Rolf Turner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Trouble with compound functions---differential equations
Aimee Jones wrote: Hi all, My apologies if this message is incredibly inept but I am very new to both computer programming and to R. I am working with the odesolve add-on and have the following function defined RVF_Single - function(t, x, p) within the script I also have the following functions defined: T1-function(t) {T1-27.5-12.5*cos(2*pi*t/365)} and B1-function(T1,t) {B1-dnorm(T1(t),mean=22.5,sd=3.3)} When the script is run it doesn't return an error message but the graphs returned are wrong. When I input plot(T1,0,3650) it returns the plot of T1 as expected---a series of waves between 15 and 40, BUT when I input plot(B1,0,3650) I get an error message of Error in 2 * pi * t : 't' is missing. Can anyone advise as to why t registers for function T1 but disappears for function B1? Because B1 is a function with 2 arguments. plot calls B1 with 1 argument, which will be argument T1. So t is missing since it hasn't received a value. Redefine B1 as B1-function(t) {B1-dnorm(T1(t),mean=22.5,sd=3.3)} and you will get your plot. Berend -- View this message in context: http://r.789695.n4.nabble.com/Trouble-with-compound-functions-differential-equations-tp3601070p3601403.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] When models and anova(model) disagree...
The individual tests on coefficients in logistic regression are generally based on a Wald test statistic. Unfortunately there is a bit of a paradox possible in this case where the coefficient is highly significant, but due to a flattening of the likelihood the standard error is overestimated and the p-value ends up non-significant. The anova function uses the likelihood ratio test which is not affected by this and is the more trustworthy statistic to use. I assume that you are using the lrm function from the rms package, the book that that package goes along with gives more detail (including the name of the paradox which I don't remember at the moment (and my copy of the book is currently 40 miles away)). -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Rob James Sent: Wednesday, June 15, 2011 4:18 PM To: r-help@r-project.org Subject: [R] When models and anova(model) disagree... I have a situation where the parameter estimates from lrm identify a binary predictor variable (X) as clearly non-significant (p0.3), but the ANOVA of that same model gives X a chi^2-df rank of 200, and adjudicates X and one interaction of X and a continuous measure as highly significant. The N is massive and X has two categories, each with 100,000 observations. I would expect X to have a significant impact on the outcome. The full model includes a large number of continuous (coded with rcs with 3 knots) and categorical variables, as well as a plethora of interactions between the categorical and continuous variables. Only one of the interactions between the binary variable and the other categorical or continuous variables is statistically significant. Can anyone offer a suggestion on what might explain this discordance? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Bayesian Credible Intervals for a Proportion
It would help us to help you if you told us which package ncredint is in (it is not in any of the packages that is installed on the computer I am presently using, but could be in multiple others). Does this interval match what you are expecting? library(TeachingDemos) hpd(qbeta, shape1=4, shape2=8) [1] 0.09337233 0.58795256 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of tinazilla Sent: Wednesday, June 15, 2011 6:42 PM To: r-help@r-project.org Subject: [R] Bayesian Credible Intervals for a Proportion I am trying to calculate Bayesian Credible Intervals for a proportion (disease prevalence values to be more specific) and am having trouble using R to do this. I am working with ncredint() function but have not had success with it. Please help! Example: Positive samples = 3 Total sampled = 10 Prevalence = 0.3 pvec - seq(1,10,by=1) npost = dbinom(pvec,10,prob=0.3, log=FALSE) ncredint(pvec, npost, tol=0.01, verbose=FALSE) But I don't get the right Bayesian CI. What am I doing wrong? Thanks! Tina -- View this message in context: http://r.789695.n4.nabble.com/Bayesian-Credible-Intervals-for-a-Proportion-tp3600976p3600976.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.