Re: [R] NextMethod in boxcox
However, note that I DID get it WRONG: The method invoked by the NextMethod() call in the boxcox.formula method is boxcox.default, NOT boxcox.lm. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Fri, Feb 14, 2014 at 5:07 PM, Bert Gunter bgun...@gene.com wrote: Inline. Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Fri, Feb 14, 2014 at 4:19 PM, Gene Leynes gleyne...@gmail.com wrote: In searching for NextMethod on http://www.rseek.org/ I found some helpful tutorials on S3 and S4 methods. Between your answer and the tutorials, I think I'm starting to understand. The NextMethod is just a dispatcher type of thing that doesn't do anything directly. I think you're saying that when lm is called on a boxcox object then this part of the code handles it (maybe I have it backwards though). So, can you tell from this what the next method would be? I tried doing debug(boxcox.default) but there is no boxcox.default. Study the tutorials. You still don't appear to get it. Of course there is a boxcox.default. ?methods methods(boxcox) It is not exported from MASS so must be accessed via ::: ?:: -- Bert Did you mistakenly say boxplot instead of boxcox when referring to the default method that does the heavy lifting? Yes. Thanks. I just want to see the code that calculates the log likelihood values of y in boxcox. Thank you On Fri, Feb 14, 2014 at 4:33 PM, Bert Gunter gunter.ber...@gene.com wrote: Well, since this is really a question about understanding how S3 methods work, and this is not the place for a tutorial, I think what you need to do is search out a tutorial that you understand. But very briefly, it does what it says. The object argument is supplied to the boxcox generic; lm() takes this (presumably a formula) as an argument and replaces the object argument with the fit, which is of lm class . NextMethod() then would call the next method, boxcox.lm on object . boxcox.lm does something similar, calling boxplot.default on the (possibly fixed up) fit, as that is the next method after boxplot.lm on object. boxplot.default is where all the work is done. *** If this is wrong in any way, I would appreciate being corrected.*** Others may have useful tutorials that provide greater detail. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Fri, Feb 14, 2014 at 2:00 PM, Gene Leynes gleyne...@gmail.com wrote: Yes I read the help on NextMethod. In fact, since people frequently respond with did you read the help I mentioned that I had read the help in my original post. I'm very grateful for the time and effort that people put into answering questions, so I always try to answer the question myself first usually for more than one day. I didn't find anything in ?NextMethod that helped me understand how NextMethod works here: m - length(lambda) object - lm(object, y = TRUE, qr = TRUE, ...) result - NextMethod() This part seemed like the the most likely part: NextMethod invokes the next method (determined by the class vector, either of the object supplied to the generic, or of the first argument to the function containing NextMethod if a method was invoked directly). NormallyNextMethod is used with only one argument, generic, but if further arguments are supplied these modify the call to the next method. But, since NextMethod is called with no arguments, what class vector determines the next method? If this is invoking the next method, then was the previous method? How can it be called with no arguments? Maybe my problem is that I don't understand the S3 and S4 classes and I should really read something else, because this help doesn't seem to stand on it's own. I've been using R for a long time and this help left me scratching my head. I don't actually care about NextMethod, I was just trying to figure out how the boxcox function is calculating the y part of the return values. Since I couldn't figure it out from ?boxcox I tried to dig into the code, but I was stymied by the code. Does the lm function compute the boxcox transformation? On Thu, Feb 13, 2014 at 4:59 PM, Bert Gunter gunter.ber...@gene.com wrote: Have you tried: ?NextMethod ? -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, Feb 13, 2014 at 2:17 PM, Gene Leynes gleyne...@gmail.com wrote:
Re: [R] minor version upgrade requires library refresh?
On Feb 13, 2014, at 11:36 AM, Ross Boylan wrote: If R changes from 3.0.1 to 3.0.2, or more generally from m.n.p to m.n.q, is it necessary to refresh libraries to match the version, e.g., with update.packages(checkBuilt=TRUE, ask=FALSE)? The R Windows FAQ 2.8 says For those with a personal library (folder R\win-library\x.y of your home directory, R\win64-library\x.y on 64-bit builds), you will need to update that too when the minor version of R changes (e.g. from 3.0.2 to 3.1.0). When n changes you need to update any existing library. This suggests that in m.n.q n is the minor version (which would make q the release?), and that the minor version does not change between 3.0.1 and 3.0.1. Huh? But I'm not sure. I'm interested in Unix as well as Windows. Thanks. Ross Boylan [[alternative HTML version deleted]] Please learn to post in plain text. -- David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] samSeq and poissonSeq - quantile.default error
Dear all, I have a RNA-seq cancer dataset (2 classes) with all raw integer counts, does NOT contain any NaN or missing value. When I run samseq and Poission-seq, I got the following error: Error in quantile.default(prop, c(0.25, 0.75)) : missing values and NaN's not allowed if 'na.rm' is FALSE Does anyone know how to fix this problem? Thank you, Jia I've tried the following: In samr, I tried to change depth = samr.estimate.depth(x) to depth = samr.estimate.depth(x, na.rm=TRUE) which didn't work. In samr.estimate.depth, I also tried to change qs - quantile(prop, c(0.25, 0.75)) to qs - quantile(prop, c(0.25, 0.75), na.rm = TRUE) which didn't work either. My code to call samseq: x=data.matrix(data) y - c(rep(1, 27), rep(2, 22)) output = SAMseq(x, y, resp.type = Two class unpaired,nperms = 100, random.seed = NULL, nresamp = 20, fdr.output = 0.05, na.rm = TRUE) code to call PoissonSeq: x=data.matrix(data) y - c(rep(1, 27), rep(2, 22)) type - twoclass pair - FALSE #not matched-pair design dat - list(n=x, y=y, type=type, pair = pair) para - list(npermu=100, seed=10) #default params output = PS.Main(dat=dat, para=para) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] NextMethod in boxcox
Yes I read the help on NextMethod. In fact, since people frequently respond with did you read the help I mentioned that I had read the help in my original post. I'm very grateful for the time and effort that people put into answering questions, so I always try to answer the question myself first usually for more than one day. I didn't find anything in ?NextMethod that helped me understand how NextMethod works here: m - length(lambda) object - lm(object, y = TRUE, qr = TRUE, ...) result - NextMethod() This part seemed like the the most likely part: NextMethod invokes the next method (determined by the class vector, either of the object supplied to the generic, or of the first argument to the function containing NextMethod if a method was invoked directly). NormallyNextMethod is used with only one argument, generic, but if further arguments are supplied these modify the call to the next method. But, since NextMethod is called with no arguments, what class vector determines the next method? If this is invoking the next method, then was the previous method? How can it be called with no arguments? Maybe my problem is that I don't understand the S3 and S4 classes and I should really read something else, because this help doesn't seem to stand on it's own. I've been using R for a long time and this help left me scratching my head. I don't actually care about NextMethod, I was just trying to figure out how the boxcox function is calculating the y part of the return values. Since I couldn't figure it out from ?boxcox I tried to dig into the code, but I was stymied by the code. Does the lm function compute the boxcox transformation? On Thu, Feb 13, 2014 at 4:59 PM, Bert Gunter gunter.ber...@gene.com wrote: Have you tried: ?NextMethod ? -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, Feb 13, 2014 at 2:17 PM, Gene Leynes gleyne...@gmail.com wrote: I was trying to understand the boxcox function in MASS to get a better understanding of where and how the log-Likelihood values are calculated. By using debug(boxcox) I found this code while running the examples: m - length(lambda) object - lm(object, y = TRUE, qr = TRUE, ...) result - NextMethod() Can someone tell me how this is optimizing the values for Lambda? I'm assuming that it has something to do with the qr decomposition that happens in lm? Thank you, Gene Notes and disclaimers: - Yes, I read the help for NextMethod and boxcox. - I don't think my OS / R / MASS versions are relevant but if you must know I happen to be on Windows 8 right now and using R version 3.0.2 (2013-09-25) -- Frisbee Sailing, Platform: x86_64-w64-mingw32/x64 (64-bit). MASS version is 7.3-29. [[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.
[R] psych package - Cronbach`s Alpha - warning message
Dear R-help, I try to estimate alpha for a factor that loads onto two items, using the psych-package (newest version). The data is from the boston housing data set. The problem I face can be reproduced by the following approximation of the correlation matrix: library(psych) tt - cbind(c(1,0.58) , c(0.58,1)) colnames(tt) = rownames(tt) = list(V1 , V2) alpha(tt) R Version 3.0.2 (2013-09-25) 64 Bit - Platform: Windows 7 Professional, 64 bit I have tried on two different Windows computers - same warning messages: In matrix(unlist(drop.item), ncol = 6, byrow = TRUE) : data length [10] is not a sub-multiple or multiple of the number of columns [6] What is the reason for the warning? Is it to be taken seriously? How can I avoid this warning? I would be very thankful for any ideas or advice! Thank you a lot in advance!!! [[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] NextMethod in boxcox
In searching for NextMethod on http://www.rseek.org/ I found some helpful tutorials on S3 and S4 methods. Between your answer and the tutorials, I think I'm starting to understand. The NextMethod is just a dispatcher type of thing that doesn't do anything directly. I think you're saying that when lm is called on a boxcox object then this part of the code handles it (maybe I have it backwards though). So, can you tell from this what the next method would be? I tried doing debug(boxcox.default) but there is no boxcox.default. Did you mistakenly say boxplot instead of boxcox when referring to the default method that does the heavy lifting? I just want to see the code that calculates the log likelihood values of y in boxcox. Thank you On Fri, Feb 14, 2014 at 4:33 PM, Bert Gunter gunter.ber...@gene.com wrote: Well, since this is really a question about understanding how S3 methods work, and this is not the place for a tutorial, I think what you need to do is search out a tutorial that you understand. But very briefly, it does what it says. The object argument is supplied to the boxcox generic; lm() takes this (presumably a formula) as an argument and replaces the object argument with the fit, which is of lm class . NextMethod() then would call the next method, boxcox.lm on object . boxcox.lm does something similar, calling boxplot.default on the (possibly fixed up) fit, as that is the next method after boxplot.lm on object. boxplot.default is where all the work is done. *** If this is wrong in any way, I would appreciate being corrected.*** Others may have useful tutorials that provide greater detail. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Fri, Feb 14, 2014 at 2:00 PM, Gene Leynes gleyne...@gmail.com wrote: Yes I read the help on NextMethod. In fact, since people frequently respond with did you read the help I mentioned that I had read the help in my original post. I'm very grateful for the time and effort that people put into answering questions, so I always try to answer the question myself first usually for more than one day. I didn't find anything in ?NextMethod that helped me understand how NextMethod works here: m - length(lambda) object - lm(object, y = TRUE, qr = TRUE, ...) result - NextMethod() This part seemed like the the most likely part: NextMethod invokes the next method (determined by the class vector, either of the object supplied to the generic, or of the first argument to the function containing NextMethod if a method was invoked directly). NormallyNextMethod is used with only one argument, generic, but if further arguments are supplied these modify the call to the next method. But, since NextMethod is called with no arguments, what class vector determines the next method? If this is invoking the next method, then was the previous method? How can it be called with no arguments? Maybe my problem is that I don't understand the S3 and S4 classes and I should really read something else, because this help doesn't seem to stand on it's own. I've been using R for a long time and this help left me scratching my head. I don't actually care about NextMethod, I was just trying to figure out how the boxcox function is calculating the y part of the return values. Since I couldn't figure it out from ?boxcox I tried to dig into the code, but I was stymied by the code. Does the lm function compute the boxcox transformation? On Thu, Feb 13, 2014 at 4:59 PM, Bert Gunter gunter.ber...@gene.com wrote: Have you tried: ?NextMethod ? -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, Feb 13, 2014 at 2:17 PM, Gene Leynes gleyne...@gmail.com wrote: I was trying to understand the boxcox function in MASS to get a better understanding of where and how the log-Likelihood values are calculated. By using debug(boxcox) I found this code while running the examples: m - length(lambda) object - lm(object, y = TRUE, qr = TRUE, ...) result - NextMethod() Can someone tell me how this is optimizing the values for Lambda? I'm assuming that it has something to do with the qr decomposition that happens in lm? Thank you, Gene Notes and disclaimers: - Yes, I read the help for NextMethod and boxcox. - I don't think my OS / R / MASS versions are relevant but if you must know I happen to be on Windows 8 right now and using R version 3.0.2 (2013-09-25) -- Frisbee Sailing, Platform: x86_64-w64-mingw32/x64 (64-bit). MASS version is 7.3-29.
[R] Product of MSE and number of parameters when generating covariance matrix for Nonlinear least squares?
Hi! In 'An Introduction to R', section 11.7 on nonlinear least squares fitting, the following example is given for obtaining the standard errors of the estimated parameters: To obtain the approximate standard errors (SE) of the estimates we do: sqrt(diag(2*out$minimum/(length(y) - 2) * solve(out$hessian))) The 2 in the line above represents the number of parameters. I know the inverted Hessian is multiplied by the mean square error and that the denominator of the MSE is the degrees of freedom (number of samples - number of parameters) but why does the numerator of the MSE (which is the RSS) get multiplied by the number of parameters? I have read through explanations of the method for obtaining the SE but I don't see where the MSE gets multiplied by the number of parameters or why this is needed as shown in the example? Thanks for any help! -- View this message in context: http://r.789695.n4.nabble.com/Product-of-MSE-and-number-of-parameters-when-generating-covariance-matrix-for-Nonlinear-least-square-tp4685348.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] NextMethod in boxcox
I found some good explanations of what the Box Cox transform for anyone who happens upon this thread while searching for boxcox details: This is the best explanation I found of what how the Box Cox transformation is calculated. It explains why QR decomposition is used, has nice code examples that are probably more illustrative than anything actually implemented in MASS, which I expect would have a lot of extra mechanics to make it robust. http://www.r-bloggers.com/on-box-cox-transform-in-regression-models/ http://freakonometrics.blog.free.fr/index.php?post/2012/11/13/On-Box-Cox-transform-in-regression-models As usual, Julian Faraway provides some great basic notes on using tranformations, including the Box Cox transformation: http://cran.r-project.org/doc/contrib/Faraway-PRA.pdf A useful, compact, and complete explanation of how the log likelihood function is derived: http://data.princeton.edu/wws509/notes/c2s10.html An useful discussion on the practical limitations of the Box Cox transformation, and some alternative approaches, such as mixed models. http://robjhyndman.com/hyndsight/transformations/ A much more complete and helpful help for NextMethod can be found in 5.5 of R's Language documentation. (Although I'm still not sure how to see the code in boxcox!) http://cran.r-project.org/doc/manuals/R-lang.pdf Also, a more simple and candid summary of S3 and S4 methods is here http://cran.r-project.org/doc/contrib/R_language.pdf http://www.r-project.org/conferences/useR-2004/Keynotes/Leisch.pdf [[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] NextMethod in boxcox
On Fri, Feb 14, 2014 at 7:38 PM, Bert Gunter gunter.ber...@gene.com wrote: However, note that I DID get it WRONG: The method invoked by the NextMethod() call in the boxcox.formula method is boxcox.default, NOT boxcox.lm. The method chain is slightly unusual here, because of the liberal way S3 objects are defined. boxcox.default works with lm objects that have $qr and $y components boxcox.lm works with any lm object, updating it to make sure it has $qr and $y, then callling boxcox.default boxcox.formula works with a formula, creating a suitable lm object then calling boxcox.default The calls to boxcox.default are done with NextMethod(), but there isn't really inheritance in the usual OOP sense. -thomas Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Fri, Feb 14, 2014 at 5:07 PM, Bert Gunter bgun...@gene.com wrote: Inline. Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Fri, Feb 14, 2014 at 4:19 PM, Gene Leynes gleyne...@gmail.com wrote: In searching for NextMethod on http://www.rseek.org/ I found some helpful tutorials on S3 and S4 methods. Between your answer and the tutorials, I think I'm starting to understand. The NextMethod is just a dispatcher type of thing that doesn't do anything directly. I think you're saying that when lm is called on a boxcox object then this part of the code handles it (maybe I have it backwards though). So, can you tell from this what the next method would be? I tried doing debug(boxcox.default) but there is no boxcox.default. Study the tutorials. You still don't appear to get it. Of course there is a boxcox.default. ?methods methods(boxcox) It is not exported from MASS so must be accessed via ::: ?:: -- Bert Did you mistakenly say boxplot instead of boxcox when referring to the default method that does the heavy lifting? Yes. Thanks. I just want to see the code that calculates the log likelihood values of y in boxcox. Thank you On Fri, Feb 14, 2014 at 4:33 PM, Bert Gunter gunter.ber...@gene.com wrote: Well, since this is really a question about understanding how S3 methods work, and this is not the place for a tutorial, I think what you need to do is search out a tutorial that you understand. But very briefly, it does what it says. The object argument is supplied to the boxcox generic; lm() takes this (presumably a formula) as an argument and replaces the object argument with the fit, which is of lm class . NextMethod() then would call the next method, boxcox.lm on object . boxcox.lm does something similar, calling boxplot.default on the (possibly fixed up) fit, as that is the next method after boxplot.lm on object. boxplot.default is where all the work is done. *** If this is wrong in any way, I would appreciate being corrected.*** Others may have useful tutorials that provide greater detail. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Fri, Feb 14, 2014 at 2:00 PM, Gene Leynes gleyne...@gmail.com wrote: Yes I read the help on NextMethod. In fact, since people frequently respond with did you read the help I mentioned that I had read the help in my original post. I'm very grateful for the time and effort that people put into answering questions, so I always try to answer the question myself first usually for more than one day. I didn't find anything in ?NextMethod that helped me understand how NextMethod works here: m - length(lambda) object - lm(object, y = TRUE, qr = TRUE, ...) result - NextMethod() This part seemed like the the most likely part: NextMethod invokes the next method (determined by the class vector, either of the object supplied to the generic, or of the first argument to the function containing NextMethod if a method was invoked directly). NormallyNextMethod is used with only one argument, generic, but if further arguments are supplied these modify the call to the next method. But, since NextMethod is called with no arguments, what class vector determines the next method? If this is invoking the next method, then was the previous method? How can it be called with no arguments? Maybe my problem is that I don't understand the S3 and S4 classes and I should really read something else, because this help doesn't seem to stand on it's own. I've been using R for a long time and this help left me scratching my head. I
Re: [R] For two vectors, how to plot bin-to-bin histogram comparision in R?
Hi, Try ?multhist() from library(plotrix) set.seed(49) vec1 - rnorm(1e4,0,0.5) set.seed(9453) vec2 - rnorm(1e4,0,0.5) library(plotrix) multhist(list(vec1,vec2)) A.K. I've met a problem recently. Have you ever been met a plot like the belowing? In this picture, as you see, the solid black bars represent one vector (named as vector A), and the empty bars represent the other vector (named as vector B). I know how to plot two histogram together in one picture. however, I don't know how to draw and compare them in bin-to-bin form just like the above picture. Did anybody know how to plot this in R? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Printing a matrix in latexVerbatim without rownames.
On Feb 13, 2014, at 2:07 PM, Gil Gamesh wrote: Hi, I'm printing a bunch of summary tables to a latex file using latexVerbatim from the Hmisc package. An example looks like this... x Visit N Min. 1st Qu. Median Mean 3rd Qu. Max. NAs [1,] 1 92 25 27.28 29.05 29.47 31.75 34.8 0 You should post dput(x) And I'm using commands like this... w-latexVerbatim(x, file=SummaryTables.tex, append=TRUE) My question is, can I lose the row label [1,]? I've tried using rowname=NULL as per the help page for latexVerbatim, but to no effect. That is how R prints matrix objects. Perhaps you could convert to a dataframe and suppress rownames. But knowing whether that is effective would be facilitated by following the advice to post a reproducible example. Maybe there's a way to use rownamesTexCmd to delete the rownames? Many thanks, Gil [[alternative HTML version deleted]] Please post in plain text. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] why warnings message is there after running the plm regression
beer - read.csv(C:/Users/Administrator/Desktop/beer.csv) View(beer) attach(beer)The following objects are masked from chem_1: C_SALE, CFO, Company, DISEX, PPE, REV, ROA, SALE, TA, TAC, Year library(plm) y-cbind(TAC) x-cbind(TA,REV,PPE,ROA) pdata-plm.data(beer,index=c(Company,Year)) pooling-plm(y~x,data=pdata,model=pooling) summary(pooling)Oneway (individual) effect Pooling Model Call: plm(formula = y ~ x, data = pdata, model = pooling) Balanced Panel: n=14, T=10, N=140 Residuals : Min. 1st Qu. Median 3rd Qu. Max. -3.7 -0.20500 -0.00497 0.19400 1.16000 Coefficients : Estimate Std. Error t-value Pr(|t|) (Intercept) -0.048250 0.094661 -0.5097 0.6110848 xTA -68.865413 25.424371 -2.7086 0.0076314 ** xREV 0.363786 0.092291 3.9417 0.0001293 *** xPPE 0.551753 0.202364 2.7265 0.0072501 ** xROA 0.953009 0.031102 30.6414 2.2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Total Sum of Squares:426.26 Residual Sum of Squares: 32.02 R-Squared : 0.92488 Adj. R-Squared : 0.89185 F-statistic: 415.539 on 4 and 135 DF, p-value: 2.22e-16Warning messages:1: In if (is.na(le)) { : the condition has length 1 and only the first element will be used2: In if (is.na(le)) __no length(.)__ else if (give.length) { : the condition has length 1 and only the first element will be used3: In if (le 0) paste0([1:, paste(le), ]) else (0) : the condition has length 1 and only the first element will be used After running I found this warnings message. would some help me to find out this problem. Ramesh Chandra Das Doctoral Student Vinod Gupta School of Management Indian Institute of Technology, Kharagpur, West Bengal, India, PIN - 721 302 Phone: 91+ 9002883115 [[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] why warnings message is there after running the plm regression
On 02/15/2014 03:19 PM, Ramesh Chandra Das wrote: beer- read.csv(C:/Users/Administrator/Desktop/beer.csv) View(beer) attach(beer)The following objects are masked from chem_1: C_SALE, CFO, Company, DISEX, PPE, REV, ROA, SALE, TA, TAC, Year library(plm) y-cbind(TAC) x-cbind(TA,REV,PPE,ROA) pdata-plm.data(beer,index=c(Company,Year)) pooling-plm(y~x,data=pdata,model=pooling) summary(pooling)Oneway (individual) effect Pooling Model Call: plm(formula = y ~ x, data = pdata, model = pooling) Balanced Panel: n=14, T=10, N=140 Residuals : Min. 1st Qu. Median 3rd Qu. Max. -3.7 -0.20500 -0.00497 0.19400 1.16000 Coefficients : Estimate Std. Error t-value Pr(|t|) (Intercept) -0.048250 0.094661 -0.5097 0.6110848 xTA -68.865413 25.424371 -2.7086 0.0076314 ** xREV 0.363786 0.092291 3.9417 0.0001293 *** xPPE 0.551753 0.202364 2.7265 0.0072501 ** xROA 0.953009 0.031102 30.6414 2.2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Total Sum of Squares:426.26 Residual Sum of Squares: 32.02 R-Squared : 0.92488 Adj. R-Squared : 0.89185 F-statistic: 415.539 on 4 and 135 DF, p-value: 2.22e-16Warning messages:1: In if (is.na(le)) { : the condition has length 1 and only the first element will be used2: In if (is.na(le)) __no length(.)__ else if (give.length) { : the condition has length 1 and only the first element will be used3: In if (le 0) paste0([1:, paste(le), ]) else (0) : the condition has length 1 and only the first element will be used After running I found this warnings message. would some help me to find out this problem. Hi Ramesh, This warning is given when a vector like this: le-c(4,2,6,5) is used in a test like this: if(is.na(le)) ... R only looks at the first value in the vector for the test, but warns you that there were other values that were not tested. If the test was: if(is.na(le[1])) It doesn't matter if le has only one value or more than one and you don't get the warning. It usually doesn't mess anything up. 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] Problem with POSIXt time zone
Hello I have to convert character strings into POSIXt format. And would like to combine two of them. The following code does not what I expect. The single conversions of the character strings, gives a the date and time with time zone GMT as I expect. However if I combine two date time with c() the time zone is changed to CET. strptime(paste(01.01.2013, 20:00:00),format=%d.%m.%Y %H:%M:%S, tz=GMT) [1] 2013-01-01 20:00:00 GMT strptime(paste(02.01.2013, 01:00:00),format=%d.%m.%Y %H:%M:%S, tz=GMT) [1] 2013-01-02 01:00:00 GMT c(strptime(paste(01.01.2013, 20:00:00),format=%d.%m.%Y %H:%M:%S, tz=GMT), + strptime(paste(02.01.2013, 01:00:00),format=%d.%m.%Y %H:%M:%S, tz=GMT)) [1] 2013-01-01 21:00:00 CET 2013-01-02 02:00:00 CET Is that a bug? How can I solve this problem? I really need the time in the time zone GMT else I run into troubles when the time changes to summer time. Thanks for any help. Kind regards Raphael Felber PhD Student Eidgenössisches Departement für Wirtschaft, Bildung und Forschung WBF Agroscope Institut für Nachhaltigkeitswissenschaften INH Klima und Lufthygiene Reckenholzstrasse 191, CH-8046 Zürich Tel. +41 44 377 75 11 Fax +41 44 377 72 01 raphael.fel...@agroscope.admin.chmailto:raphael.fel...@agroscope.admin.ch www.agroscope.chhttp://www.agroscope.ch/ [[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] a question about boxplot
Dear all, a simple question about boxplot() function, on how not to display a set of values (outliers), but keep the same median of the original dataset on the display ; more precisely : given a dataset : 1,2,3,4,5,6, 100, 200,300 the median is : 5 after removing the extreme values : 100, 200, 300 the median is 3.5, but would still like to display a boxplot with median of 5. would this be possible ? thank you ! -- bogdan [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with POSIXt time zone
Hi Raphael Bug or not that for others to say. Here is an explanation and a work around. This is on my Windows 8 laptop and R-3.0.2: ## strptime gives you POSIXlt objects (see ?DateTimeClasses or ?striptime) t1 - strptime(paste(01.01.2013, 20:00:00),format=%d.%m.%Y %H:%M:%S, tz=GMT) t2 - strptime(paste(02.01.2013, 01:00:00),format=%d.%m.%Y %H:%M:%S, tz=GMT) ## c is probably doing some conversions. It does that for other classes of objects so be aware! c(t1, t2) [1] 2013-01-01 21:00:00 CET 2013-01-02 02:00:00 CET ## see which methods there exists for c() methods(c) [1] c.bibentry* c.Datec.noquote c.numeric_version [5] c.person* c.POSIXct c.POSIXlt Non-visible functions are asterisked ## since strptime gives POSIXlt this is called c.POSIXlt function (..., recursive = FALSE) as.POSIXlt(do.call(c, lapply(list(...), as.POSIXct))) bytecode: 0x061770e8 environment: namespace:base ## c.POSIXcl converts to POSIXct ## and so c.POISXct is called which does an unclass whereby information on time zone is lost ## the unclass gives us the number of second since 1st Janaury 1970 c.POSIXct function (..., recursive = FALSE) .POSIXct(c(unlist(lapply(list(...), unclass bytecode: 0x0617bd40 environment: namespace:base ## last in c.POSIXct we now call .POSIXct with tz set NULL by default. Is this a bug Since tz=NULL by default the time zone information is now read from your locale on your computer (that depends what is set by the OS. On our linux HPC it is set to UTC) .POSIXct function (xx, tz = NULL) structure(xx, class = c(POSIXct, POSIXt), tzone = tz) bytecode: 0x0aa25ad0 environment: namespace:base ## However when I am dealing with data with timestamps those are usually save in the UTC = GMT zone format because we get data from all over the world and we do not want to deal with day light saving times. So do this to begin with in the R session: Sys.setenv(TZ=GMT) ## and then we have: c(t1, t2) [1] 2013-01-01 20:00:00 GMT 2013-01-02 01:00:00 GMT Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of raphael.fel...@agroscope.admin.ch Sent: 14. februar 2014 09:24 To: r-help@r-project.org Subject: [R] Problem with POSIXt time zone Hello I have to convert character strings into POSIXt format. And would like to combine two of them. The following code does not what I expect. The single conversions of the character strings, gives a the date and time with time zone GMT as I expect. However if I combine two date time with c() the time zone is changed to CET. strptime(paste(01.01.2013, 20:00:00),format=%d.%m.%Y %H:%M:%S, tz=GMT) [1] 2013-01-01 20:00:00 GMT strptime(paste(02.01.2013, 01:00:00),format=%d.%m.%Y %H:%M:%S, tz=GMT) [1] 2013-01-02 01:00:00 GMT c(strptime(paste(01.01.2013, 20:00:00),format=%d.%m.%Y %H:%M:%S, tz=GMT), + strptime(paste(02.01.2013, 01:00:00),format=%d.%m.%Y %H:%M:%S, tz=GMT)) [1] 2013-01-01 21:00:00 CET 2013-01-02 02:00:00 CET Is that a bug? How can I solve this problem? I really need the time in the time zone GMT else I run into troubles when the time changes to summer time. Thanks for any help. Kind regards Raphael Felber PhD Student Eidgenössisches Departement für Wirtschaft, Bildung und Forschung WBF Agroscope Institut für Nachhaltigkeitswissenschaften INH Klima und Lufthygiene Reckenholzstrasse 191, CH-8046 Zürich Tel. +41 44 377 75 11 Fax +41 44 377 72 01 raphael.fel...@agroscope.admin.chmailto:raphael.fel...@agroscope.admi n.ch www.agroscope.chhttp://www.agroscope.ch/ [[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] a question about boxplot
On 02/14/2014 07:52 PM, Bogdan Tanasa wrote: Dear all, a simple question about boxplot() function, on how not to display a set of values (outliers), but keep the same median of the original dataset on the display ; more precisely : given a dataset : 1,2,3,4,5,6, 100, 200,300 the median is : 5 after removing the extreme values : 100, 200, 300 the median is 3.5, but would still like to display a boxplot with median of 5. would this be possible ? thank you ! Hi bogdan, You could do something like this: x-c(1,2,3,4,5,6,100,200,300) x_box-boxplot(x,plot=FALSE) x_box$stats-matrix(c(1,3,5,5.5,6),ncol=1) x_box$out-NA bxp(x_box) Note that the box may not represent what you want. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] What is the effect of how.many in the contrast function
Thanks Dr. I did read the help page but maybe I just don't understand enough about contrasts to take what I need from it. It says: If value supplies more than how.many contrasts, the first how.many are used. If too few are supplied, a suitable contrast matrix is created by extending value after ensuring its columns are contrasts (orthogonal to the constant term) and not collinear. I suppose what this means is that if the matrix is not extended then there is some type of problem with orthogonality? Perhaps my real question should be, why is a contrast matrix with only one column not suitable. Maybe I should read the book you are referring to. Can you provide a reference? Thanks! -- View this message in context: http://r.789695.n4.nabble.com/What-is-the-effect-of-how-many-in-the-contrast-function-tp4685294p4685300.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] Ignore errors and proceed to next
Hi all, I have a very large number of vectors that I want first to look fast which distribution might be considered candidate for fitting. I made a simple loop that checks for all vector (the code below is for one vector and being called for each vector separately). If a good fit is found this is dumped to a txt file so to allow me later on, see results distList-c(norm,exp,gamma,lnorm) for (dist in distList) { if (gofstat(fitdist(onVector,distr=dist))$kstest ==not rejected){ # keep it out-capture.output(gofstat(fitdist(onVector,distr=distr))$ks) print(sprintf(Saving to file %s ,filename)) cat(out,file=paste(filename,.txt,sep=),sep=\n,append=TRUE) } } the major problem is that these for loops return errors (sometimes for a given vector a specific distribution does not make sense or the vector might be zero or containing only many times the same element) . The easiest would be in errors and warning just move to the next element of the for loop. Something like that for () { if error==skip to next element else do normal stuff } how I can do that in R? Regards Alex [[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] a question about boxplot
that is a great suggestion ! thanks a lot Jim ! On Fri, Feb 14, 2014 at 1:14 AM, Jim Lemon j...@bitwrit.com.au wrote: On 02/14/2014 08:08 PM, Bogdan Tanasa wrote: thank you Jim ...the idea behind would be to subset a set of values ? I would need to automate it the display for a list of numbers (1,2,3,, ...,1000) where I would need to remove some values above an arbitrary threshold (let's say 700), but keep the same median as in the initial dataset. That is a bit more complicated. I would suggest then getting the median separately and plugging it into the boxplot of the reduced data: x_median-median(x) x_box-boxplot(x,plot=FALSE) # drop the outliers x-x[x100] # get the boxplot stats for the reduced data x_box-boxplot(x,plot=FALSE) # put the old median back in x_box$stats[3]-x_median bxp(x_box) Again, because you have altered the stats passed to bxp, this is not a true boxplot. Jim [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with POSIXt time zone
Thanks a lot for the fast answer. Sys.setenv(TZ=GMT) is a good solution for me. Best regards Raphael -Ursprüngliche Nachricht- Von: Frede Aakmann Tøgersen [mailto:fr...@vestas.com] Gesendet: Freitag, 14. Februar 2014 10:02 An: Felber Raphael Agroscope; r-help@r-project.org Betreff: RE: Problem with POSIXt time zone Hi Raphael Bug or not that for others to say. Here is an explanation and a work around. This is on my Windows 8 laptop and R-3.0.2: ## strptime gives you POSIXlt objects (see ?DateTimeClasses or ?striptime) t1 - strptime(paste(01.01.2013, 20:00:00),format=%d.%m.%Y %H:%M:%S, tz=GMT) t2 - strptime(paste(02.01.2013, 01:00:00),format=%d.%m.%Y %H:%M:%S, tz=GMT) ## c is probably doing some conversions. It does that for other classes of objects so be aware! c(t1, t2) [1] 2013-01-01 21:00:00 CET 2013-01-02 02:00:00 CET ## see which methods there exists for c() methods(c) [1] c.bibentry* c.Datec.noquote c.numeric_version [5] c.person* c.POSIXct c.POSIXlt Non-visible functions are asterisked ## since strptime gives POSIXlt this is called c.POSIXlt function (..., recursive = FALSE) as.POSIXlt(do.call(c, lapply(list(...), as.POSIXct))) bytecode: 0x061770e8 environment: namespace:base ## c.POSIXcl converts to POSIXct ## and so c.POISXct is called which does an unclass whereby information on time zone is lost ## the unclass gives us the number of second since 1st Janaury 1970 c.POSIXct function (..., recursive = FALSE) .POSIXct(c(unlist(lapply(list(...), unclass bytecode: 0x0617bd40 environment: namespace:base ## last in c.POSIXct we now call .POSIXct with tz set NULL by default. Is this a bug Since tz=NULL by default the time zone information is now read from your locale on your computer (that depends what is set by the OS. On our linux HPC it is set to UTC) .POSIXct function (xx, tz = NULL) structure(xx, class = c(POSIXct, POSIXt), tzone = tz) bytecode: 0x0aa25ad0 environment: namespace:base ## However when I am dealing with data with timestamps those are usually save in the UTC = GMT zone format because we get data from all over the world and we do not want to deal with day light saving times. So do this to begin with in the R session: Sys.setenv(TZ=GMT) ## and then we have: c(t1, t2) [1] 2013-01-01 20:00:00 GMT 2013-01-02 01:00:00 GMT Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of raphael.fel...@agroscope.admin.ch Sent: 14. februar 2014 09:24 To: r-help@r-project.org Subject: [R] Problem with POSIXt time zone Hello I have to convert character strings into POSIXt format. And would like to combine two of them. The following code does not what I expect. The single conversions of the character strings, gives a the date and time with time zone GMT as I expect. However if I combine two date time with c() the time zone is changed to CET. strptime(paste(01.01.2013, 20:00:00),format=%d.%m.%Y %H:%M:%S, tz=GMT) [1] 2013-01-01 20:00:00 GMT strptime(paste(02.01.2013, 01:00:00),format=%d.%m.%Y %H:%M:%S, tz=GMT) [1] 2013-01-02 01:00:00 GMT c(strptime(paste(01.01.2013, 20:00:00),format=%d.%m.%Y %H:%M:%S, tz=GMT), + strptime(paste(02.01.2013, 01:00:00),format=%d.%m.%Y %H:%M:%S, tz=GMT)) [1] 2013-01-01 21:00:00 CET 2013-01-02 02:00:00 CET Is that a bug? How can I solve this problem? I really need the time in the time zone GMT else I run into troubles when the time changes to summer time. Thanks for any help. Kind regards Raphael Felber PhD Student Eidgenössisches Departement für Wirtschaft, Bildung und Forschung WBF Agroscope Institut für Nachhaltigkeitswissenschaften INH Klima und Lufthygiene Reckenholzstrasse 191, CH-8046 Zürich Tel. +41 44 377 75 11 Fax +41 44 377 72 01 raphael.fel...@agroscope.admin.chmailto:raphael.fel...@agroscope.admi n.ch www.agroscope.chhttp://www.agroscope.ch/ [[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] Ignore errors and proceed to next
Hi See ?try ?tryCatch So you still want to do these distribution tests even though you have been warned not to? Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Alaios Sent: 14. februar 2014 10:14 To: R-help@r-project.org Subject: [R] Ignore errors and proceed to next Hi all, I have a very large number of vectors that I want first to look fast which distribution might be considered candidate for fitting. I made a simple loop that checks for all vector (the code below is for one vector and being called for each vector separately). If a good fit is found this is dumped to a txt file so to allow me later on, see results distList-c(norm,exp,gamma,lnorm) for (dist in distList) { if (gofstat(fitdist(onVector,distr=dist))$kstest ==not rejected){ # keep it out-capture.output(gofstat(fitdist(onVector,distr=distr))$ks) print(sprintf(Saving to file %s ,filename)) cat(out,file=paste(filename,.txt,sep=),sep=\n,append=TRUE) } } the major problem is that these for loops return errors (sometimes for a given vector a specific distribution does not make sense or the vector might be zero or containing only many times the same element) . The easiest would be in errors and warning just move to the next element of the for loop. Something like that for () { if error==skip to next element else do normal stuff } how I can do that in R? Regards Alex [[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] Regex with criteria from multiple lines
Hello, I do data analysis on json data (Twitter). An example of the data: ** \id\: 433662713886429200, \id_str\: \433662713886429184\, \text\: \Hond vast in water in Bargerveen bij Zwartemeer - http://t.co/FqbkOMzYd1 #Zwartemeer #bargerveen #hond #innood\, \source\: \a href=\https://about.twitter.com/products/tweetdeck\; rel=\nofollow\TweetDeck/a\, ** I get the contents of the text field like this: r - regexpr(^( )*\text(.*?),$, myjsondata) text - regmatches(myjsondata,r) txt - gsub(\text\:|\,|\,,text) Unfortunately, in json there are more fields with the same name, for example: ** \id\: 433662713886429200, \id_str\: \433662713886429184\, \text\: \Hond vast in water in Bargerveen bij Zwartemeer - http://t.co/FqbkOMzYd1 #Zwartemeer #bargerveen #hond #innood\, \source\: \a href=\https://about.twitter.com/products/tweetdeck\; rel=\nofollow\TweetDeck/a\, ... \entities\: { \hashtags\: [ { \text\: \Zwartemeer\, ... \text\: \bargerveen\, ... \text\: \hond\, etc. ** I only want to get the data from the text field between the id_str and the source fields. I don't want to have the data from the text fields below hashtags. I do understand regex, but I don't understand how to do it with the criteria from multiple lines. I know it's possible to use a Json library in R, but in my case I can't, because I get the json from raw clipboard data. Thanks ! Mark Stam [[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] Ignore errors and proceed to next
Hi thanks for the answer. I have so vast majority of vectors that some distributions will not work for some cases but they work for others pretty well. This is the reason I store only those that worked to helpe get a coarse understanding how to proceed. If you have a better idea let me know On Friday, February 14, 2014 10:35 AM, Frede Aakmann Tøgersen fr...@vestas.com wrote: Hi See ?try ?tryCatch So you still want to do these distribution tests even though you have been warned not to? Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Alaios Sent: 14. februar 2014 10:14 To: R-help@r-project.org Subject: [R] Ignore errors and proceed to next Hi all, I have a very large number of vectors that I want first to look fast which distribution might be considered candidate for fitting. I made a simple loop that checks for all vector (the code below is for one vector and being called for each vector separately). If a good fit is found this is dumped to a txt file so to allow me later on, see results distList-c(norm,exp,gamma,lnorm) for (dist in distList) { if (gofstat(fitdist(onVector,distr=dist))$kstest ==not rejected){ # keep it out-capture.output(gofstat(fitdist(onVector,distr=distr))$ks) print(sprintf(Saving to file %s ,filename)) cat(out,file=paste(filename,.txt,sep=),sep=\n,append=TRUE) } } the major problem is that these for loops return errors (sometimes for a given vector a specific distribution does not make sense or the vector might be zero or containing only many times the same element) . The easiest would be in errors and warning just move to the next element of the for loop. Something like that for () { if error==skip to next element else do normal stuff } how I can do that in R? Regards Alex [[alternative HTML version deleted]] [[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] a question about boxplot
Thank you Jim ! I made a little change in the script when assigning the median values - and it works ! thank you very much ! x_median-median(x,na.rm=T) y_median-median(y,na.rm=T) x-x[x10] y-y[y10] xy_box-boxplot(list(x,y),plot=FALSE) xy_box$stats[3,1]-x_median xy_box$stats[3,2]-y_median bxp(xy_box) On Fri, Feb 14, 2014 at 2:13 AM, Jim Lemon j...@bitwrit.com.au wrote: On 02/14/2014 08:48 PM, Bogdan Tanasa wrote: Dear Jim, one more question please : how could I plot in this way 2 boxplots - eg - bxp(x_box, y_box) or boxplot(x_box, y_box) do not work ... thanks ! x_median-median(x,na.rm=T) x_box-boxplot(x,plot=FALSE) # drop the outliers x-x[x10] # get the boxplot stats for the reduced data x_box-boxplot(x,plot=FALSE) # put the old median back in x_box$stats[3]-x_median bxp(x_box) y_median-median(y,na.rm=T) y_box-boxplot(y,plot=FALSE) # drop the outliers y-y[y10] # get the boxplot stats for the reduced data y_box-boxplot(y,plot=FALSE) # put the old median back in y_box$stats[3]-y_median bxp(y_box) bxp(x_box, y_box) Try this (untested): x_median-median(x,na.rm=T) y_median-median(y,na.rm=T) x-x[x10] y-y[y10] xy_box-boxplot(list(x,y),plot=FALSE) xy_box$stats[[1]][3]-x_median xy_box$stats[[2]][3]-y_median bxp(xy_box) Jim [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Simulate from an ARIMA Model with fixed errors
Hi everyone!I am trying to make some synthetic data using two AR(1) models, but I am having some troubles.I want to make data from:x_t = \alpha x_{t-1} + a_{1t}y_t = \beta y_{t-1} + \gamma a_{1t} + \sqrt{1-\gamma^2} a_{2t}But I don't know how to set a fixed error term in the arima.sim() function...Thanks!-Chris -- View this message in context: http://r.789695.n4.nabble.com/Simulate-from-an-ARIMA-Model-with-fixed-errors-tp4685316.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] R windows close while calculating frequency
HI , I am using R on a very huge datasets which contains lot of text. I prepared a all word vector of words by using strsplit function. Now I want to compute frequency of unique words from all word vector. For doing so, I used two ways 1) as.data.frame(table(x)) 2) sapply(x,x,length) x contains approximately 9 lac words and no.of unique words is around 33k. When I run any one of these command, R window closes automatically. Please let me know what is the solution for this? -- View this message in context: http://r.789695.n4.nabble.com/R-windows-close-while-calculating-frequency-tp4685315.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 windows close while calculating frequency
That sounds like the operating system is terminating R due to overloading the system. You have not supplied the information requested in the Posting Guide, so you may not get very specific responses on how to solve this. I would suggest running partial data sets of larger and larger size to identify the largest you can successfully analyze. You may be able to use a more efficient algorithm or you may have to run your analysis using a machine with more memory or reconfigured process usage limits. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On February 14, 2014 3:05:47 AM PST, vikrant vikrant.shi...@tcs.com wrote: HI , I am using R on a very huge datasets which contains lot of text. I prepared a all word vector of words by using strsplit function. Now I want to compute frequency of unique words from all word vector. For doing so, I used two ways 1) as.data.frame(table(x)) 2) sapply(x,x,length) x contains approximately 9 lac words and no.of unique words is around 33k. When I run any one of these command, R window closes automatically. Please let me know what is the solution for this? -- View this message in context: http://r.789695.n4.nabble.com/R-windows-close-while-calculating-frequency-tp4685315.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] What is the effect of how.many in the contrast function
http://cran.r-project.org/web/packages/MASS/citation.html --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On February 13, 2014 11:04:46 PM PST, jimj j...@sfu.ca wrote: Thanks Dr. I did read the help page but maybe I just don't understand enough about contrasts to take what I need from it. It says: If value supplies more than how.many contrasts, the first how.many are used. If too few are supplied, a suitable contrast matrix is created by extending value after ensuring its columns are contrasts (orthogonal to the constant term) and not collinear. I suppose what this means is that if the matrix is not extended then there is some type of problem with orthogonality? Perhaps my real question should be, why is a contrast matrix with only one column not suitable. Maybe I should read the book you are referring to. Can you provide a reference? Thanks! -- View this message in context: http://r.789695.n4.nabble.com/What-is-the-effect-of-how-many-in-the-contrast-function-tp4685294p4685300.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] Regex with criteria from multiple lines
You need to use the JSON library or equivalent to solve this problem. I don't understand why you think that having the data in the clipboard prevents you from doing this since that is just another file (but I usually avoid using the clipboard for reproducible analysis anyway). --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On February 14, 2014 1:29:59 AM PST, Mark Stam digis...@gmail.com wrote: Hello, I do data analysis on json data (Twitter). An example of the data: ** \id\: 433662713886429200, \id_str\: \433662713886429184\, \text\: \Hond vast in water in Bargerveen bij Zwartemeer - http://t.co/FqbkOMzYd1 #Zwartemeer #bargerveen #hond #innood\, \source\: \a href=\https://about.twitter.com/products/tweetdeck\; rel=\nofollow\TweetDeck/a\, ** I get the contents of the text field like this: r - regexpr(^( )*\text(.*?),$, myjsondata) text - regmatches(myjsondata,r) txt - gsub(\text\:|\,|\,,text) Unfortunately, in json there are more fields with the same name, for example: ** \id\: 433662713886429200, \id_str\: \433662713886429184\, \text\: \Hond vast in water in Bargerveen bij Zwartemeer - http://t.co/FqbkOMzYd1 #Zwartemeer #bargerveen #hond #innood\, \source\: \a href=\https://about.twitter.com/products/tweetdeck\; rel=\nofollow\TweetDeck/a\, ... \entities\: { \hashtags\: [ { \text\: \Zwartemeer\, ... \text\: \bargerveen\, ... \text\: \hond\, etc. ** I only want to get the data from the text field between the id_str and the source fields. I don't want to have the data from the text fields below hashtags. I do understand regex, but I don't understand how to do it with the criteria from multiple lines. I know it's possible to use a Json library in R, but in my case I can't, because I get the json from raw clipboard data. Thanks ! Mark Stam [[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] the unwanted persistence of refClass methods
Hello, On Feb 13, 2014, at 2:16 PM, Ross Boylan r...@biostat.ucsf.edu wrote: Redefining methods of a refClass does not change the methods for existing instances. I found this somewhat surprising, and also pretty inconvenient for debugging. The documentation for reference classes does say that their methods should be minimalist, which I suppose is partly because of this behavior. Is there a way around this behavior apart from passing the pieces of the old instance to the new constructor, or putting all computations in not class functions? I am interested in learning how others deal with this issue, too. I use the latter method during development. I write simple wrapper methods around the functions I am working on. Once development becomes stable, I often choose to incorporate the function in the method but not always. It's not a great system but it allows me to tweak the function until I get it right without a lot of fussing. To my simpleton way of thinking, it seems like changes to the Reference Class definition might be 'pushable' into a particular instance's environment. I don't know how to make that happen in a user friendly way. foo_f = function(x, a = 3) {a * x} foo - setRefClass(foo) foo$methods(f = function(x, ...) {foo_f(x, ...)}) x - foo$new() x$f(10) # [1] 30 x$f(10, a = 2) # [1] 20 Cheers, Ben foo - setRefClass(foo, methods=list(f=function(x) 3*x)) a - foo() a$f(10) [1] 30 foo - setRefClass(foo, method=list(f=function(x) 2*x)) a$f(10) [1] 30 b - foo() b$f(10) [1] 20 Ross Boylan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Ben Tupper Bigelow Laboratory for Ocean Sciences 60 Bigelow Drive, P.O. Box 380 East Boothbay, Maine 04544 http://www.bigelow.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] duplicate couples (time-id) Error in pdim.default(index[[1]], index[[2]]) :
Sir, can you solve my problem. I did not get why this type of problem is there. duplicate couples (time-id)Error in pdim.default(index[[1]], index[[2]]) : Thanks and regards Ramesh Chandra Das Doctoral Student Vinod Gupta School of Management Indian Institute of Technology, Kharagpur, West Bengal, India, PIN - 721 302 Phone: 91+ 9002883115 [[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] dim vector or data.frame
Hi, In my function, I want to allow input to be a vector or a data.frame. Certain operations need to be done if the length or nrows exceeds one, but since nrow doesn't work for vectors, I cannot simply use if( nrow(input)1 | length(input)1 ) ... So is there a more elegant way to do this then with the following code? if( if(is.vector(input)) length(input)1 else nrow(input)1 ) ... thanks ahead, Berry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] duplicate couples (time-id) Error in pdim.default(index[[1]], index[[2]]) :
Sorry, psychic powers too weak. Suggest you read the Posting Guide for this mailing list. You may also benefit from reading http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On February 14, 2014 4:57:01 AM PST, Ramesh Chandra Das rameshchandrada...@gmail.com wrote: Sir, can you solve my problem. I did not get why this type of problem is there. duplicate couples (time-id)Error in pdim.default(index[[1]], index[[2]]) : Thanks and regards Ramesh Chandra Das Doctoral Student Vinod Gupta School of Management Indian Institute of Technology, Kharagpur, West Bengal, India, PIN - 721 302 Phone: 91+ 9002883115 [[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] dim vector or data.frame
Hi Berry, What about using NROW(input) ? Best, Jorge.- On Sat, Feb 15, 2014 at 2:26 AM, Berry Boessenkool berryboessenk...@hotmail.com wrote: Hi, In my function, I want to allow input to be a vector or a data.frame. Certain operations need to be done if the length or nrows exceeds one, but since nrow doesn't work for vectors, I cannot simply use if( nrow(input)1 | length(input)1 ) ... So is there a more elegant way to do this then with the following code? if( if(is.vector(input)) length(input)1 else nrow(input)1 ) ... thanks ahead, Berry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] dim vector or data.frame
Yes. And there's also a possibility of keeping the vector as a one column data frame (using a drop=FALSE argument in indexing to avoid conversion to vectors perhaps) so that nrow() can be used. This has the disadvantage of the inefficiency of using a data frame when a vector will do, and the advantage of avoiding the test. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Fri, Feb 14, 2014 at 7:44 AM, Jorge I Velez jorgeivanve...@gmail.com wrote: Hi Berry, What about using NROW(input) ? Best, Jorge.- On Sat, Feb 15, 2014 at 2:26 AM, Berry Boessenkool berryboessenk...@hotmail.com wrote: Hi, In my function, I want to allow input to be a vector or a data.frame. Certain operations need to be done if the length or nrows exceeds one, but since nrow doesn't work for vectors, I cannot simply use if( nrow(input)1 | length(input)1 ) ... So is there a more elegant way to do this then with the following code? if( if(is.vector(input)) length(input)1 else nrow(input)1 ) ... thanks ahead, Berry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 superscript
Hi, Try: x - 1985:1990 set.seed(45) y - sample(70:90,length(x),replace=TRUE) plot(x,y,xlab=Year,ylab=expression(Temperature~degree*C),main=April Average Temperature 1985-1990,type=p) A.K. I want to provide a label for my x,y plot as such: ylab=Temperature (^oC), where the o is meant to be superscripted. This isn't working. I've googled it and looked at the user manual but I can't figure it out. Can anyone explain the mechanism for superscripting something please? I've tried: plot(x,y, xlab(expression(Year)), ylab(expression(Temperature(~{o}~C)), main(expression(April Average Temperature 1961-2010)), type=p), and I've tried some other things that I can't remember all of now. Very confused. It should be a simple thing to superscript something in a heading! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 write a regression model for finding the radius of a cylinder given height and volume
URL - http://r.789695.n4.nabble.com/file/n4685033/cylinder.dat; cyl - read.table(URL, header = TRUE) plot(vol ~ ht, data = cyl) Since importing data is one of the more error-prone operations in any computer system, I like to recommend that people always take a look at what they read before doing much with it. Assuming that read.table made a data.frame with numeric columns named 'vol' and 'ht' is often overly optimistic. In this case it worked as hoped, but using str() and summary() on the output of read.table can alert you to problems. str(cyl) 'data.frame': 14 obs. of 2 variables: $ vol: int 7 12 22 27 32 41 48 60 77 85 ... $ ht : num 0.5 0.6 1 1.4 1.6 2 2.4 2.8 3.5 4 ... summary(cyl) vol ht Min. : 7.00 Min. :0.500 1st Qu.: 28.25 1st Qu.:1.450 Median : 54.00 Median :2.600 Mean : 61.71 Mean :2.893 3rd Qu.: 96.25 3rd Qu.:4.375 Max. :130.00 Max. :6.000 You want to at least check the names, types, and distribution of values of all the columns. E.g., if your file contained a . somewhere in the second column to indicate a missing value you would see that 'ht' is not a numeric column: str(badCyl) 'data.frame': 14 obs. of 2 variables: $ vol: int 7 12 22 27 32 41 48 60 77 85 ... $ ht : Factor w/ 14 levels .,0.5,0.6,..: 2 3 4 5 6 7 8 9 10 11 ... summary(badCyl) vol ht Min. : 7.00 . :1 1st Qu.: 28.25 0.5:1 Median : 54.00 0.6:1 Mean : 61.71 1 :1 3rd Qu.: 96.25 1.4:1 Max. :130.00 1.6:1 (Other):8 plot(vol~ht, data=badCyl) would give you a mysterious looking plot. Bill Dunlap TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Rui Barradas Sent: Tuesday, February 11, 2014 3:02 AM To: nivek; r-help@r-project.org Subject: Re: [R] How to write a regression model for finding the radius of a cylinder given height and volume Hello, It really looked like homework. As for your question, maybe this helps. URL - http://r.789695.n4.nabble.com/file/n4685033/cylinder.dat; cyl - read.table(URL, header = TRUE) plot(vol ~ ht, data = cyl) The vectors you want are simply cyl$vol cyl[[vol]] cyl[[1]] and the same for height. To find the radius you can note that your formula is equivalent to V=pi*r^2*H and use something like (note that the model has no intercept) fit - lm(vol ~ 0 + ht, data = cyl) summary(fit) r - sqrt(coef(fit)/pi) r For linear models in R start by reading the file R-intro.pdf that comes with any installation of R, folder 'doc' chapter 11 Statistical models in R. Hope this helps, Rui Barradas Em 11-02-2014 06:06, nivek escreveu: Thank you for your help. This is not homework however and my difficulty is in the fact that i cannot figure out how the declare a variable for the height or the volume given a data set where the matrix is already formed. I have looked on many sites for the is answer and it seems like it would be an easy one. So for this problem the provided data column 2 is the height data and column 1 is the volume. What command do I use to read those values and form a vector. Thank you for your time. -- View this message in context: http://r.789695.n4.nabble.com/How-to-write-a- regression-model-for-finding-the-radius-of-a-cylinder-given-height-and-volume- tp4685033p4685090.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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Printing a matrix in latexVerbatim without rownames.
Have you tried setting all the rownames to be the empty string? Its a bit of a kludge, but a simple one. On Thu, Feb 13, 2014 at 3:07 PM, Gil Gamesh games...@gmail.com wrote: Hi, I'm printing a bunch of summary tables to a latex file using latexVerbatim from the Hmisc package. An example looks like this... x Visit N Min. 1st Qu. Median Mean 3rd Qu. Max. NAs [1,] 1 92 25 27.28 29.05 29.47 31.75 34.8 0 And I'm using commands like this... w-latexVerbatim(x, file=SummaryTables.tex, append=TRUE) My question is, can I lose the row label [1,]? I've tried using rowname=NULL as per the help page for latexVerbatim, but to no effect. Maybe there's a way to use rownamesTexCmd to delete the rownames? Many thanks, Gil [[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. -- Gregory (Greg) L. Snow Ph.D. 538...@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] duplicate couples (time-id) Error in pdim.default(index[[1]], index[[2]]) :
Hi, Check these links: http://r.789695.n4.nabble.com/quot-duplicate-couples-time-id-quot-Problem-td4636316.html http://stackoverflow.com/questions/15960129/r-plm-year-fixed-effects-year-and-quarter-data A.K. On Friday, February 14, 2014 7:57 AM, Ramesh Chandra Das rameshchandrada...@gmail.com wrote: Sir, can you solve my problem. I did not get why this type of problem is there. duplicate couples (time-id)Error in pdim.default(index[[1]], index[[2]]) : Thanks and regards Ramesh Chandra Das Doctoral Student Vinod Gupta School of Management Indian Institute of Technology, Kharagpur, West Bengal, India, PIN - 721 302 Phone: 91+ 9002883115 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to superscript
The given solution is the right one for the degree symbol, but does not answer the overall question of how to superscript, in particular how to superscript with nothing actually preceding the superscript. In general ^ is used to obtain superscripts in plotmath (RTFM!) and if nothing comes before the superscript, replace the nothing by {}. The following seems to work: plot(1:10,xlab=,ylab=expression(Temperature~{}^o*C)) The degree symbol however may be rendered better by degree than by {}^o. cheers, Rolf Turner On 15/02/14 06:20, arun wrote: Hi, Try: x - 1985:1990 set.seed(45) y - sample(70:90,length(x),replace=TRUE) plot(x,y,xlab=Year,ylab=expression(Temperature~degree*C),main=April Average Temperature 1985-1990,type=p) A.K. I want to provide a label for my x,y plot as such: ylab=Temperature (^oC), where the o is meant to be superscripted. This isn't working. I've googled it and looked at the user manual but I can't figure it out. Can anyone explain the mechanism for superscripting something please? I've tried: plot(x,y, xlab(expression(Year)), ylab(expression(Temperature(~{o}~C)), main(expression(April Average Temperature 1961-2010)), type=p), and I've tried some other things that I can't remember all of now. Very confused. It should be a simple thing to superscript something in a heading! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] NextMethod in boxcox
Well, since this is really a question about understanding how S3 methods work, and this is not the place for a tutorial, I think what you need to do is search out a tutorial that you understand. But very briefly, it does what it says. The object argument is supplied to the boxcox generic; lm() takes this (presumably a formula) as an argument and replaces the object argument with the fit, which is of lm class . NextMethod() then would call the next method, boxcox.lm on object . boxcox.lm does something similar, calling boxplot.default on the (possibly fixed up) fit, as that is the next method after boxplot.lm on object. boxplot.default is where all the work is done. *** If this is wrong in any way, I would appreciate being corrected.*** Others may have useful tutorials that provide greater detail. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Fri, Feb 14, 2014 at 2:00 PM, Gene Leynes gleyne...@gmail.com wrote: Yes I read the help on NextMethod. In fact, since people frequently respond with did you read the help I mentioned that I had read the help in my original post. I'm very grateful for the time and effort that people put into answering questions, so I always try to answer the question myself first usually for more than one day. I didn't find anything in ?NextMethod that helped me understand how NextMethod works here: m - length(lambda) object - lm(object, y = TRUE, qr = TRUE, ...) result - NextMethod() This part seemed like the the most likely part: NextMethod invokes the next method (determined by the class vector, either of the object supplied to the generic, or of the first argument to the function containing NextMethod if a method was invoked directly). NormallyNextMethod is used with only one argument, generic, but if further arguments are supplied these modify the call to the next method. But, since NextMethod is called with no arguments, what class vector determines the next method? If this is invoking the next method, then was the previous method? How can it be called with no arguments? Maybe my problem is that I don't understand the S3 and S4 classes and I should really read something else, because this help doesn't seem to stand on it's own. I've been using R for a long time and this help left me scratching my head. I don't actually care about NextMethod, I was just trying to figure out how the boxcox function is calculating the y part of the return values. Since I couldn't figure it out from ?boxcox I tried to dig into the code, but I was stymied by the code. Does the lm function compute the boxcox transformation? On Thu, Feb 13, 2014 at 4:59 PM, Bert Gunter gunter.ber...@gene.com wrote: Have you tried: ?NextMethod ? -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, Feb 13, 2014 at 2:17 PM, Gene Leynes gleyne...@gmail.com wrote: I was trying to understand the boxcox function in MASS to get a better understanding of where and how the log-Likelihood values are calculated. By using debug(boxcox) I found this code while running the examples: m - length(lambda) object - lm(object, y = TRUE, qr = TRUE, ...) result - NextMethod() Can someone tell me how this is optimizing the values for Lambda? I'm assuming that it has something to do with the qr decomposition that happens in lm? Thank you, Gene Notes and disclaimers: - Yes, I read the help for NextMethod and boxcox. - I don't think my OS / R / MASS versions are relevant but if you must know I happen to be on Windows 8 right now and using R version 3.0.2 (2013-09-25) -- Frisbee Sailing, Platform: x86_64-w64-mingw32/x64 (64-bit). MASS version is 7.3-29. [[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] NextMethod in boxcox
Inline. Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Fri, Feb 14, 2014 at 4:19 PM, Gene Leynes gleyne...@gmail.com wrote: In searching for NextMethod on http://www.rseek.org/ I found some helpful tutorials on S3 and S4 methods. Between your answer and the tutorials, I think I'm starting to understand. The NextMethod is just a dispatcher type of thing that doesn't do anything directly. I think you're saying that when lm is called on a boxcox object then this part of the code handles it (maybe I have it backwards though). So, can you tell from this what the next method would be? I tried doing debug(boxcox.default) but there is no boxcox.default. Study the tutorials. You still don't appear to get it. Of course there is a boxcox.default. ?methods methods(boxcox) It is not exported from MASS so must be accessed via ::: ?:: -- Bert Did you mistakenly say boxplot instead of boxcox when referring to the default method that does the heavy lifting? Yes. Thanks. I just want to see the code that calculates the log likelihood values of y in boxcox. Thank you On Fri, Feb 14, 2014 at 4:33 PM, Bert Gunter gunter.ber...@gene.com wrote: Well, since this is really a question about understanding how S3 methods work, and this is not the place for a tutorial, I think what you need to do is search out a tutorial that you understand. But very briefly, it does what it says. The object argument is supplied to the boxcox generic; lm() takes this (presumably a formula) as an argument and replaces the object argument with the fit, which is of lm class . NextMethod() then would call the next method, boxcox.lm on object . boxcox.lm does something similar, calling boxplot.default on the (possibly fixed up) fit, as that is the next method after boxplot.lm on object. boxplot.default is where all the work is done. *** If this is wrong in any way, I would appreciate being corrected.*** Others may have useful tutorials that provide greater detail. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Fri, Feb 14, 2014 at 2:00 PM, Gene Leynes gleyne...@gmail.com wrote: Yes I read the help on NextMethod. In fact, since people frequently respond with did you read the help I mentioned that I had read the help in my original post. I'm very grateful for the time and effort that people put into answering questions, so I always try to answer the question myself first usually for more than one day. I didn't find anything in ?NextMethod that helped me understand how NextMethod works here: m - length(lambda) object - lm(object, y = TRUE, qr = TRUE, ...) result - NextMethod() This part seemed like the the most likely part: NextMethod invokes the next method (determined by the class vector, either of the object supplied to the generic, or of the first argument to the function containing NextMethod if a method was invoked directly). NormallyNextMethod is used with only one argument, generic, but if further arguments are supplied these modify the call to the next method. But, since NextMethod is called with no arguments, what class vector determines the next method? If this is invoking the next method, then was the previous method? How can it be called with no arguments? Maybe my problem is that I don't understand the S3 and S4 classes and I should really read something else, because this help doesn't seem to stand on it's own. I've been using R for a long time and this help left me scratching my head. I don't actually care about NextMethod, I was just trying to figure out how the boxcox function is calculating the y part of the return values. Since I couldn't figure it out from ?boxcox I tried to dig into the code, but I was stymied by the code. Does the lm function compute the boxcox transformation? On Thu, Feb 13, 2014 at 4:59 PM, Bert Gunter gunter.ber...@gene.com wrote: Have you tried: ?NextMethod ? -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Thu, Feb 13, 2014 at 2:17 PM, Gene Leynes gleyne...@gmail.com wrote: I was trying to understand the boxcox function in MASS to get a better understanding of where and how the log-Likelihood values are calculated. By using debug(boxcox) I found this code while running the examples: m - length(lambda) object - lm(object, y = TRUE, qr = TRUE, ...) result - NextMethod() Can someone tell me how this is optimizing the values for Lambda? I'm