[R] Confidence Intervals for logistic regression
Dear UseRs, I have fitted a logistic regression using glm and want a 95% confidence interval on a response probability. Can I use predict(model, newdata, se.fit=T) Will fit +/- 1.96se give me a 95% of the logit? And then exp(fit +/- 1.96se) / (exp(fit +/- 1.96se) +1) to get the probabilities? Troy [[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] hi!! please help me!
I made some anonymous function which performs some process in matlab code.. But I want to perform it in R program... Is there any method??? -- View this message in context: http://r.789695.n4.nabble.com/hi-please-help-me-tp2315919p2315919.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 extract se(coef) from cph?
In an upcoming release of the rms package, all fit objects can be printed using LaTeX if putting LaTeX code directly to the console (this is optimized for Sweave). You will be able to say print(fit, latex=TRUE). Frank E Harrell Jr Professor and ChairmanSchool of Medicine Department of Biostatistics Vanderbilt University On Thu, 5 Aug 2010, David Winsemius wrote: On Aug 5, 2010, at 4:03 PM, Biau David wrote: Hello, I am modeling some survival data wih cph (Design). I have modeled a predictor which showed non linear effect with restricted cubic splines. I would like to retrieve the se(coef) for other, linear, predictors. The cph object has a var. The vcov function is an extractor function. You would probably be using something like: diag(vcov(fit))^(1/2) This is just to make nice LateX tables automatically. Are you sure Frank has not already programed that for you somewhere? Perhaps latex.cph? I have the coefficients with coef(). How do I do that? Thanks, David Biau. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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: For Loop
Hi r-help-boun...@r-project.org napsal dne 05.08.2010 10:47:03: I have some code that is working. The code calculates the error from the real vale when it does a run. The error in metres in called errorxy I want to do 10 runs of the code and everytime it does a run I want to an output of the errorxy, so that it can form an array. I am guessing I should use a for loop around the entire set of code? Perhaps. Perhaps not. Regards Petr Any help? -- View this message in context: http://r.789695.n4.nabble.com/For-Loop- tp2314593p2314593.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] m-estimators
Dear colleagues can somebody help me by showing how we can compute m-estimators in R? thanks Dr. Iasonas Lamprianou Assistant Professor (Educational Research and Evaluation) Department of Education Sciences European University-Cyprus P.O. Box 22006 1516 Nicosia Cyprus Tel.: +357-22-713178 Fax: +357-22-590539 Honorary Research Fellow Department of Education The University of Manchester Oxford Road, Manchester M13 9PL, UK Tel. 0044 161 275 3485 iasonas.lampria...@manchester.ac.uk __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 64-bit R on 64-bit Windows box... Still not enough memory?!
On Thu, Aug 05, 2010 at 04:40:48PM -0700, noclue_ wrote: I have a 64-bit windows box - Intel Xeon CPU E7340 @ 2.4GHz 31.9GB of RAM I have R 2.11.1 (64bit) running on it. My csv data is 3.6 GB (with about 15 million obs, 120 variables.) Here is my guess: Your vraiables are mstly numeric but only given with two significant digits in the csv file: A B ... 0.0 12.0 1.3 0.4 2.3 1.1 So that would make 15e6 * 120 * 3 / 1024^3 = 5.0 Gb You ahve 3.6Gb - but that's close enough. If you read that into R, each nume ris represented as a double - i.e. 8 byte. Thus the entire data frame takes 15e6 * 120 * 8 / 1024^3 = 13.4Gb With almost half of your memory taken things can get problematic. Once you start actually working with the data you'll have to allow for a lot more space because copies will probably be made in the process. So you may have to put your data into a database and process it in pieces. Or use sqldf or bigmemory or something like that. cu Philipp -- Dr. Philipp Pagel Lehrstuhl für Genomorientierte Bioinformatik Technische Universität München Wissenschaftszentrum Weihenstephan Maximus-von-Imhof-Forum 3 85354 Freising, Germany http://webclu.bio.wzw.tum.de/~pagel/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Tobit Modelling
Hi Patrick, Well tobit regression is applicable when there is censoring in the data. Tobit regression in R has been implemented in the R package survival An easy user interface is there in the packages AER and Zelig. On Fri, Aug 6, 2010 at 6:12 AM, Patrick Sessford psessf...@hotmail.comwrote: Dear R-users, I would like to model data where the response variable consists of many minus ones and many different positive values that seem to follow an apparently separate distribution (ie. -1, -1, 0.5, -1, 3, 3.5, 1.2, -1, -1, 0.4, etc); no values of the response can be less than minus one or between minus and zero (exclusive). I am aware of tobit regression but unaware of exactly how to implement it in R. If anyone is able to help me on this issue I'd be extremely grateful; for example, if my (continuous) explanatory variables were x1 and x2, how should I define the model? Thank you for your time. Pat [[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] Is R GPL or LGPL (or can I write a commercial front end to R)?
Note I'm not asking for any legal advice here obviously, simply what the intention of the R foundation is with regard to allowing commercial connection to R. I've looked at various threads on the r-devel archive and it looks like this may have been discussed before, but as far as could tell, not to any great resolution, and not, it seems, specifically covering this angle. In the doc\COPYRIGHTS file it is made clear that the intention is that you can write R packages that include functions implemented in C (and hence are provided in native libraries linked to R.dll) and distribute them under licenses not compatible with GPL. This was achieved by making the relevant header files available under the LGPL. This was an explicit change that was made in February 2001, and the intention was to allow for DLLs that require the API header files for compilation and are linked against R.dll to not be infected with the GPL. However the Rembedded.h header file isn't included in the list in the doc\COPYRIGHTS file, and the copyright statement in the Rembedded.h header file lists the GPL and not the LGPL as the relevant license. So it doesn't look like it was the intention to allow that I be able to use the R invocation API to launch R and embed it in a product (such as a new GUI, or other such integration) and ship that product under a license not compatible with GPL. Is this correct? Or is it the intention that I be able to write a commercial front-end of some kind for R? My understanding of LGPL is that ALL of the source files that go into R.dll (and indeed all libraries that R.dll itself linked to, apart from those covered by the GPL system library exception) would need to be released under LGPL in order to allow me to link to R.dll and not have my program subject to GPL. If that weren't the situation then I could take a library covered by GPL, write a different interface to it, put LGPL on those headers compile up a new DLL and I've then got LGPL access to a library previously released under GPL, which can't be the intention, otherwise LGPL would drive a coach and horses through GPL. This would apply to native libraries (dlls) providing functions in addon packages too, and so hence I'm not sure I necessarily understand how simply putting LGPL on the header files is sufficient to achieve the intention. There is provision in the GPL license (it's mentioned in the FAQ) for providing for linking to a GPL library through one specific interface by providing specific exception text in the copyright header in all of the files that make up the library. That would only be possible if the copyright holders of all relevant GPL code agreed to that, as that would be an extra grant to the license. So if R linked to any third party GPL code, this wouldn't be possible I don't think. So I guess the question here is what the intention is of the R foundation with respect to the limitations or freedoms that they are intending to allow. After all, as the copyright owners they aren't going to sue if a use falls within their intention, even if on a strict interpretation of the license such use wouldn't be allowed. So it seems to be the intention that I can write a DLL to provide R functions in an add on package, which requires linkage to R.dll. Not convinced that the license it set up right to cover that, but that appears to be the intention. Question is whether at the other end, at the invocation API end, whether it is the intention to be able to use the invocation API and link to R.dll without my program being subjected to GPL. Note that I'm not talking here about anything to do with code written in the language of R. This is purely concerned with treating R as a library with an interface and wanting to link to that interface and whether the intention or the actuality of the license allow that. 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.
Re: [R] Confidence Intervals for logistic regression
Dear Troy, use this commend, your will get IC95% and OR. logistic.model - glm(formula =y~ x1+x2, family = binomial) summary(logistic.model) sum.coef-summary(logistic.model)$coef est-exp(sum.coef[,1]) upper.ci-exp(sum.coef[,1]+1.96*sum.coef[,2]) lower.ci-exp(sum.coef[,1]-1.96*sum.coef[,2]) cbind(est,upper.ci,lower.ci) regards. 2010/8/6 Troy S troysocks-tw...@yahoo.com Dear UseRs, I have fitted a logistic regression using glm and want a 95% confidence interval on a response probability. Can I use predict(model, newdata, se.fit=T) Will fit +/- 1.96se give me a 95% of the logit? And then exp(fit +/- 1.96se) / (exp(fit +/- 1.96se) +1) to get the probabilities? Troy [[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] Confidence Intervals for logistic regression
Sorry about earlier reply - didn't read your email properly (obviously :) You're suggestion was right, so as well as method for Aline below, another way of doing the same thing is: pred - predict(y.glm, newdata= something, se.fit=TRUE) ci - matrix( c(pred$fit + 1.96 * pred$se.fit, pred$fit - 1.96 * pred$se.fit), ncol=2 ) lines( something, plogis( ci[,1] ) ) lines( something, plogis( ci[,2] ) ) On 6 August 2010 18:39, aline uwimana rwan...@gmail.com wrote: Dear Troy, use this commend, your will get IC95% and OR. logistic.model - glm(formula =y~ x1+x2, family = binomial) summary(logistic.model) sum.coef-summary(logistic.model)$coef est-exp(sum.coef[,1]) upper.ci-exp(sum.coef[,1]+1.96*sum.coef[,2]) lower.ci-exp(sum.coef[,1]-1.96*sum.coef[,2]) cbind(est,upper.ci,lower.ci) regards. 2010/8/6 Troy S troysocks-tw...@yahoo.com Dear UseRs, I have fitted a logistic regression using glm and want a 95% confidence interval on a response probability. Can I use predict(model, newdata, se.fit=T) Will fit +/- 1.96se give me a 95% of the logit? And then exp(fit +/- 1.96se) / (exp(fit +/- 1.96se) +1) to get the probabilities? Troy [[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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] McLeod.Li.test
Hi, I wanted to know that in the McLeod.Li.test P-value graph, at what level is the dotted line drawn? Also can it be changed? 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.
[R] R code for EGARCH
Hi, Can we run EGARCH in R. If yes, I would be grateful if someone could tell me the R codes for running EGARCH model. 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.
Re: [R] Stopping precision using 'optim'
On 06.08.2010 02:44, Jeremy Beaulieu wrote: Hi all~ I am wondering if it is possible to alter the stopping precision for parameters estimated using the 'optim'? Have you read the Details section of ?optim It tells us that there are abstol and reltol ... If it helps, I am minimizing the log-likelihood of a function using constraints (i.e. L-BFG-S). Well, L-BFGS-B, I think. Uwe Ligges -Jeremy __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] wavlet transform
Hello I wrote this simple code lev=8; wname='d8'; dec=dwt(ld, filter=wname, n.levels=lev, boundary=periodic, fast=TRUE); i_ld=idwt(dec); before http://r.789695.n4.nabble.com/file/n2316043/1.png 1.png after http://r.789695.n4.nabble.com/file/n2316043/2.png 2.png I don't uderstand why there is a difference between signal befor dwt and after idwt thank you -- View this message in context: http://r.789695.n4.nabble.com/wavlet-transform-tp2316043p2316043.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] R:Backward elimination in svyglm function in R
Dear all, someone knows how to get the best fit model by using the svyglm function with backward elimination method. thanx [[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] Is R GPL or LGPL (or can I write a commercial front end to R)?
Tom Quarendon wrote: Note I'm not asking for any legal advice here obviously, simply what the intention of the R foundation is with regard to allowing commercial connection to R. I can't speak for the R Foundation, but I can say that its intentions aren't all you have to consider. R has many copyright owners. You need to get permission from all of them if you want a special license, so the easiest thing is to stay with a GPL v2 compatible license. If you don't want to do that, then you could go ahead with some other license and see what happens, but it might not be until your project becomes popular that someone decides to take action. So in the latter case I'd get a legal opinion, not a mailing list opinion, before I invested a lot of time or money. Duncan Murdoch I've looked at various threads on the r-devel archive and it looks like this may have been discussed before, but as far as could tell, not to any great resolution, and not, it seems, specifically covering this angle. In the doc\COPYRIGHTS file it is made clear that the intention is that you can write R packages that include functions implemented in C (and hence are provided in native libraries linked to R.dll) and distribute them under licenses not compatible with GPL. This was achieved by making the relevant header files available under the LGPL. This was an explicit change that was made in February 2001, and the intention was to allow for DLLs that require the API header files for compilation and are linked against R.dll to not be infected with the GPL. However the Rembedded.h header file isn't included in the list in the doc\COPYRIGHTS file, and the copyright statement in the Rembedded.h header file lists the GPL and not the LGPL as the relevant license. So it doesn't look like it was the intention to allow that I be able to use the R invocation API to launch R and embed it in a product (such as a new GUI, or other such integration) and ship that product under a license not compatible with GPL. Is this correct? Or is it the intention that I be able to write a commercial front-end of some kind for R? My understanding of LGPL is that ALL of the source files that go into R.dll (and indeed all libraries that R.dll itself linked to, apart from those covered by the GPL system library exception) would need to be released under LGPL in order to allow me to link to R.dll and not have my program subject to GPL. If that weren't the situation then I could take a library covered by GPL, write a different interface to it, put LGPL on those headers compile up a new DLL and I've then got LGPL access to a library previously released under GPL, which can't be the intention, otherwise LGPL would drive a coach and horses through GPL. This would apply to native libraries (dlls) providing functions in addon packages too, and so hence I'm not sure I necessarily understand how simply putting LGPL on the header files is sufficient to achieve the intention. There is provision in the GPL license (it's mentioned in the FAQ) for providing for linking to a GPL library through one specific interface by providing specific exception text in the copyright header in all of the files that make up the library. That would only be possible if the copyright holders of all relevant GPL code agreed to that, as that would be an extra grant to the license. So if R linked to any third party GPL code, this wouldn't be possible I don't think. So I guess the question here is what the intention is of the R foundation with respect to the limitations or freedoms that they are intending to allow. After all, as the copyright owners they aren't going to sue if a use falls within their intention, even if on a strict interpretation of the license such use wouldn't be allowed. So it seems to be the intention that I can write a DLL to provide R functions in an add on package, which requires linkage to R.dll. Not convinced that the license it set up right to cover that, but that appears to be the intention. Question is whether at the other end, at the invocation API end, whether it is the intention to be able to use the invocation API and link to R.dll without my program being subjected to GPL. Note that I'm not talking here about anything to do with code written in the language of R. This is purely concerned with treating R as a library with an interface and wanting to link to that interface and whether the intention or the actuality of the license allow that. 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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help
Re: [R] Plotting range of values in barplot()
On 08/06/2010 04:22 AM, yankeetilidie wrote: Hello, I am attempting to create a bar plot that contains a range of possible response values on the x-axis of 1 to 5 and contains barplots for the number of responses even in the event that there are 0 responses. For example, I have a data set that contains values of 2, 3, 4, and 5 but I would also like my graph to show that there are no 1's. I have attached the resulting graph. The appropriate values should be 0 - Strongly Disagree, 1 - Somewhat Disagree, 2 - Neutral, 7 - Somewhat Agree, and 12 - Strongly Agree. Hi Steve, Given your labels, I would suggest the following: smw.dat-factor(rep(c(Somewhat Disagree,Neutral, Somewhat Agree,Strongly Agree),c(1,2,7,12)), levels=c(Strongly Disagree,Somewhat Disagree,Neutral, Somewhat Agree,Strongly Agree),ordered=TRUE) library(prettyR) smw.freq-freq(smw.dat,display.na=FALSE) library(plotrix) barp(smw.freq,names.arg=levels(smw.dat),staxx=TRUE, col=rainbow(5),main=Survey answers,xlab=Responses) 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] Is R GPL or LGPL (or can I write a commercial front end to R)?
and horses through GPL. This would apply to native libraries (dlls) providing functions in addon packages too, and so hence I'm not sure I necessarily understand how simply putting LGPL on the header files is sufficient to achieve the intention. There is provision in the GPL license (it's mentioned in the FAQ) for providing for linking to a GPL library through one specific interface by providing specific exception text in the copyright header in all of the files that make up the library. That would only be possible if the copyright holders of all relevant GPL code agreed to that, as that would be an extra grant to the license. So if R linked to any third party GPL code, this wouldn't be possible I don't think. So I guess the question here is what the intention is of the R foundation with respect to the limitations or freedoms that they are intending to allow. After all, as the copyright owners they aren't going to sue if a use falls within their intention, even if on a strict interpretation of the license such use wouldn't be allowed. So it seems to be the intention that I can write a DLL to provide R functions in an add on package, which requires linkage to R.dll. Not convinced that the license it set up right to cover that, but that appears to be the intention. Question is whether at the other end, at the invocation API end, whether it is the intention to be able to use the invocation API and link to R.dll without my program being subjected to GPL. Note that I'm not talking here about anything to do with code written in the language of R. This is purely concerned with treating R as a library with an interface and wanting to link to that interface and whether the intention or the actuality of the license allow that. 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. __ Information from ESET NOD32 Antivirus, version of virus signature database 5346 (20100806) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ Information from ESET NOD32 Antivirus, version of virus signature database 5346 (20100806) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.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] Odp: m-estimators
Hi r-help-boun...@r-project.org napsal dne 06.08.2010 09:10:44: Dear colleagues can somebody help me by showing how we can compute m-estimators in R? Open your favourite browser. Open CRAN page Go to search Input m-estimators as search term. You will got about 3500 hits, definitely some of them will be relevant. Regards Petr thanks Dr. Iasonas Lamprianou Assistant Professor (Educational Research and Evaluation) Department of Education Sciences European University-Cyprus P.O. Box 22006 1516 Nicosia Cyprus Tel.: +357-22-713178 Fax: +357-22-590539 Honorary Research Fellow Department of Education The University of Manchester Oxford Road, Manchester M13 9PL, UK Tel. 0044 161 275 3485 iasonas.lampria...@manchester.ac.uk __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] hi!! please help me!
Didn't we just go through this? In general, you need to translate your matlab code into R. There are some good R-octave equivalence guides online that will help you with that task. In specific, you need to read the posting guide and ask an answerable question. Sarah On Fri, Aug 6, 2010 at 1:31 AM, leepama butch...@hanmail.net wrote: I made some anonymous function which performs some process in matlab code.. But I want to perform it in R program... Is there any method??? -- -- 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] using grib files in R
Hi Janet, This question would probably be more suited for the r-sig-geo mailing list. In my view, the best option is to use a tool like wgrib to dump the layer you want from the grib file to text and then read it into R using e.g. read.table. See also the spatial data classes provided to R through the sp-package. A good book on spatial data in R is the book by Bivand et al [1]. The spatial task view is another good source of information [2]. regards, Paul [1] http://www.springer.com/public+health/epidemiology/book/978-0-387-78170-9 [2] http://cran.r-project.org/web/views/Spatial.html On 08/05/2010 06:37 PM, Janet Nye wrote: I am not new to R, but I am new to .grib files. I am downloading some climate data and I would like to analyze it in R. R has a nice netcdf package, but I don’t see any package available to deal specifically with grib files. I see a few posts from other people using grib files in R. However, I was unclear if they used grib files in a different software program and then imported the data somehow into R. Is it possible to use read grib files in R and then use the data? If so, could someone point me to a book/website that might help me learn how to do this? Any advice would be helpful…I am beginning to think I should use a different software program, but I’d like to use R! Thanks, Janet __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 253 5773 http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 code for EGARCH
Hi, PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Paul On 08/06/2010 11:11 AM, Aditya Damani wrote: Hi, Can we run EGARCH in R. If yes, I would be grateful if someone could tell me the R codes for running EGARCH model. 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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 253 5773 http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Is R GPL or LGPL (or can I write a commercial front end to R)?
license. So it doesn't look like it was the intention to allow that I be able to use the R invocation API to launch R and embed it in a product (such as a new GUI, or other such integration) and ship that product under a license not compatible with GPL. Is this correct? Or is it the intention that I be able to write a commercial front-end of some kind for R? My understanding of LGPL is that ALL of the source files that go into R.dll (and indeed all libraries that R.dll itself linked to, apart from those covered by the GPL system library exception) would need to be released under LGPL in order to allow me to link to R.dll and not have my program subject to GPL. If that weren't the situation then I could take a library covered by GPL, write a different interface to it, put LGPL on those headers compile up a new DLL and I've then got LGPL access to a library previously released under GPL, which can't be the intention, otherwise LGPL would drive a coach and horses through GPL. This would apply to native libraries (dlls) providing functions in addon packages too, and so hence I'm not sure I necessarily understand how simply putting LGPL on the header files is sufficient to achieve the intention. There is provision in the GPL license (it's mentioned in the FAQ) for providing for linking to a GPL library through one specific interface by providing specific exception text in the copyright header in all of the files that make up the library. That would only be possible if the copyright holders of all relevant GPL code agreed to that, as that would be an extra grant to the license. So if R linked to any third party GPL code, this wouldn't be possible I don't think. So I guess the question here is what the intention is of the R foundation with respect to the limitations or freedoms that they are intending to allow. After all, as the copyright owners they aren't going to sue if a use falls within their intention, even if on a strict interpretation of the license such use wouldn't be allowed. So it seems to be the intention that I can write a DLL to provide R functions in an add on package, which requires linkage to R.dll. Not convinced that the license it set up right to cover that, but that appears to be the intention. Question is whether at the other end, at the invocation API end, whether it is the intention to be able to use the invocation API and link to R.dll without my program being subjected to GPL. Note that I'm not talking here about anything to do with code written in the language of R. This is purely concerned with treating R as a library with an interface and wanting to link to that interface and whether the intention or the actuality of the license allow that. 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. __ Information from ESET NOD32 Antivirus, version of virus signature database 5346 (20100806) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ Information from ESET NOD32 Antivirus, version of virus signature database 5346 (20100806) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.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] Is R GPL or LGPL (or can I write a commercial front end to R)?
and are linked against R.dll to not be infected with the GPL. However the Rembedded.h header file isn't included in the list in the doc\COPYRIGHTS file, and the copyright statement in the Rembedded.h header file lists the GPL and not the LGPL as the relevant license. So it doesn't look like it was the intention to allow that I be able to use the R invocation API to launch R and embed it in a product (such as a new GUI, or other such integration) and ship that product under a license not compatible with GPL. Is this correct? Or is it the intention that I be able to write a commercial front-end of some kind for R? My understanding of LGPL is that ALL of the source files that go into R.dll (and indeed all libraries that R.dll itself linked to, apart from those covered by the GPL system library exception) would need to be released under LGPL in order to allow me to link to R.dll and not have my program subject to GPL. If that weren't the situation then I could take a library covered by GPL, write a different interface to it, put LGPL on those headers compile up a new DLL and I've then got LGPL access to a library previously released under GPL, which can't be the intention, otherwise LGPL would drive a coach and horses through GPL. This would apply to native libraries (dlls) providing functions in addon packages too, and so hence I'm not sure I necessarily understand how simply putting LGPL on the header files is sufficient to achieve the intention. There is provision in the GPL license (it's mentioned in the FAQ) for providing for linking to a GPL library through one specific interface by providing specific exception text in the copyright header in all of the files that make up the library. That would only be possible if the copyright holders of all relevant GPL code agreed to that, as that would be an extra grant to the license. So if R linked to any third party GPL code, this wouldn't be possible I don't think. So I guess the question here is what the intention is of the R foundation with respect to the limitations or freedoms that they are intending to allow. After all, as the copyright owners they aren't going to sue if a use falls within their intention, even if on a strict interpretation of the license such use wouldn't be allowed. So it seems to be the intention that I can write a DLL to provide R functions in an add on package, which requires linkage to R.dll. Not convinced that the license it set up right to cover that, but that appears to be the intention. Question is whether at the other end, at the invocation API end, whether it is the intention to be able to use the invocation API and link to R.dll without my program being subjected to GPL. Note that I'm not talking here about anything to do with code written in the language of R. This is purely concerned with treating R as a library with an interface and wanting to link to that interface and whether the intention or the actuality of the license allow that. 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. __ Information from ESET NOD32 Antivirus, version of virus signature database 5346 (20100806) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ Information from ESET NOD32 Antivirus, version of virus signature database 5346 (20100806) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.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.
Re: [R] Is R GPL or LGPL (or can I write a commercial front end to R)?
commercial connection to R. I can't speak for the R Foundation, but I can say that its intentions aren't all you have to consider. R has many copyright owners. You need to get permission from all of them if you want a special license, so the easiest thing is to stay with a GPL v2 compatible license. If you don't want to do that, then you could go ahead with some other license and see what happens, but it might not be until your project becomes popular that someone decides to take action. So in the latter case I'd get a legal opinion, not a mailing list opinion, before I invested a lot of time or money. Duncan Murdoch I've looked at various threads on the r-devel archive and it looks like this may have been discussed before, but as far as could tell, not to any great resolution, and not, it seems, specifically covering this angle. In the doc\COPYRIGHTS file it is made clear that the intention is that you can write R packages that include functions implemented in C (and hence are provided in native libraries linked to R.dll) and distribute them under licenses not compatible with GPL. This was achieved by making the relevant header files available under the LGPL. This was an explicit change that was made in February 2001, and the intention was to allow for DLLs that require the API header files for compilation and are linked against R.dll to not be infected with the GPL. However the Rembedded.h header file isn't included in the list in the doc\COPYRIGHTS file, and the copyright statement in the Rembedded.h header file lists the GPL and not the LGPL as the relevant license. So it doesn't look like it was the intention to allow that I be able to use the R invocation API to launch R and embed it in a product (such as a new GUI, or other such integration) and ship that product under a license not compatible with GPL. Is this correct? Or is it the intention that I be able to write a commercial front-end of some kind for R? My understanding of LGPL is that ALL of the source files that go into R.dll (and indeed all libraries that R.dll itself linked to, apart from those covered by the GPL system library exception) would need to be released under LGPL in order to allow me to link to R.dll and not have my program subject to GPL. If that weren't the situation then I could take a library covered by GPL, write a different interface to it, put LGPL on those headers compile up a new DLL and I've then got LGPL access to a library previously released under GPL, which can't be the intention, otherwise LGPL would drive a coach and horses through GPL. This would apply to native libraries (dlls) providing functions in addon packages too, and so hence I'm not sure I necessarily understand how simply putting LGPL on the header files is sufficient to achieve the intention. There is provision in the GPL license (it's mentioned in the FAQ) for providing for linking to a GPL library through one specific interface by providing specific exception text in the copyright header in all of the files that make up the library. That would only be possible if the copyright holders of all relevant GPL code agreed to that, as that would be an extra grant to the license. So if R linked to any third party GPL code, this wouldn't be possible I don't think. So I guess the question here is what the intention is of the R foundation with respect to the limitations or freedoms that they are intending to allow. After all, as the copyright owners they aren't going to sue if a use falls within their intention, even if on a strict interpretation of the license such use wouldn't be allowed. So it seems to be the intention that I can write a DLL to provide R functions in an add on package, which requires linkage to R.dll. Not convinced that the license it set up right to cover that, but that appears to be the intention. Question is whether at the other end, at the invocation API end, whether it is the intention to be able to use the invocation API and link to R.dll without my program being subjected to GPL. Note that I'm not talking here about anything to do with code written in the language of R. This is purely concerned with treating R as a library with an interface and wanting to link to that interface and whether the intention or the actuality of the license allow that. 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. __ Information from ESET NOD32 Antivirus, version of virus signature database 5346 (20100806) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ Information from ESET
Re: [R] Extracting future and past workday dates
Henrique, that is what I need! Big thanks! Regards, Sergey On Thu, Aug 5, 2010 at 14:56, Henrique Dallazuanna www...@gmail.com wrote: n - 3 w - as.numeric(format(Sys.Date(), '%w')) fut - c(Sys.Date() - 0:(n + ifelse(w - n 6, (w - n) - 6, 0)), Sys.Date() + 1:(n + 1 + ifelse(w + n 6, (w + n) - 6, 0))) sort(fut[!format(fut, '%w') %in% c(6, 0)]) -- Kniven skärpes bara mot stenen. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 grib files in R
In addition to Paul's advice, you may find it useful to know that *.grb files may be read by GDAL drivers in the rgdal package, so that for http://gribs.ocens.net/NorthEurope.wind.grb.bz2, after downloading and uncompressing, GDALinfo(NorthEurope.wind.grb) shows the 122 bands in the file, and readGDAL() will read them into an sp object. Other software may be needed to access metadata. You will probably also need to set the missing values to NA manually - in this example file it was necessary to say: grib - readGDAL(NorthEurope.wind.grb) is.na(grib$band1) - grib$band1 100 image(grib, attr=1) Hope this helps, Roger Paul Hiemstra wrote: Hi Janet, This question would probably be more suited for the r-sig-geo mailing list. In my view, the best option is to use a tool like wgrib to dump the layer you want from the grib file to text and then read it into R using e.g. read.table. See also the spatial data classes provided to R through the sp-package. A good book on spatial data in R is the book by Bivand et al [1]. The spatial task view is another good source of information [2]. regards, Paul [1] http://www.springer.com/public+health/epidemiology/book/978-0-387-78170-9 [2] http://cran.r-project.org/web/views/Spatial.html On 08/05/2010 06:37 PM, Janet Nye wrote: I am not new to R, but I am new to .grib files. I am downloading some climate data and I would like to analyze it in R. R has a nice netcdf package, but I don’t see any package available to deal specifically with grib files. I see a few posts from other people using grib files in R. However, I was unclear if they used grib files in a different software program and then imported the data somehow into R. Is it possible to use read grib files in R and then use the data? If so, could someone point me to a book/website that might help me learn how to do this? Any advice would be helpful…I am beginning to think I should use a different software program, but I’d like to use R! Thanks, Janet __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 253 5773 http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - Roger Bivand Economic Geography Section Department of Economics Norwegian School of Economics and Business Administration Helleveien 30 N-5045 Bergen, Norway -- View this message in context: http://r.789695.n4.nabble.com/using-grib-files-in-R-tp2315130p2316226.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] apply family functions
The data you provided does not match your example: dat - data.frame(Class = c(AAA, C, CC, BB, B, A), Close_date = + c(ini, ini, ini, ini+109, ini+39, ini+24), stringsAsFactors = FALSE) dat Class Close_date 1 AAA 2010-01-01 2 C 2010-01-01 3CC 2010-01-01 4BB 2010-04-20 5 B 2010-02-09 6 A 2010-01-25 In your example output, why is line 2 invalid? Also in your 'for' loop 'ind' was not defined. On Fri, Aug 6, 2010 at 12:59 AM, Steven Kang stochastick...@gmail.com wrote: Hi all, I would like to flag each record in the data according to certain conditions as specified below. For example, If Close_date in *dat* is between (Open Close) or (Open1 Close1) or (Open2 Close2) in *oc, *flag the records as Valid, otherwise Invalid I would like to use sapply family functions if possible due to the nature of large data set. ini - as.Date(2010/1/1, %Y/%m/%d) # Generate arbitrary data frame consisting of date values oc - data.frame(Open = seq(ini, ini + 5, 1), Close = seq(ini + 365, ini + 365 + 5, 1), Open1 = seq(ini + 365*2, ini + 365*2 + 5, 1), Close1 = seq(ini + 365*3, ini + 365*3 + 5, 1), Open2 = seq(ini + 365*4, ini + 365*4 + 5, 1), Close2 = seq(ini + 365*5, ini + 365*5 + 5, 1)) rownames(oc) - c(AAA, AA, A, BBB, BB, B) oc Open Close Open1 Close1 Open2 Close2 AAA 2010-01-01 2011-01-01 2012-01-01 2012-12-31 2013-12-31 2014-12-31 AA 2010-01-02 2011-01-02 2012-01-02 2013-01-01 2014-01-01 2015-01-01 A 2010-01-03 2011-01-03 2012-01-03 2013-01-02 2014-01-02 2015-01-02 BBB 2010-01-04 2011-01-04 2012-01-04 2013-01-03 2014-01-03 2015-01-03 BB 2010-01-05 2011-01-05 2012-01-05 2013-01-04 2014-01-04 2015-01-04 B 2010-01-06 2011-01-06 2012-01-06 2013-01-05 2014-01-05 2015-01-05 dat - data.frame(Class = c(AAA, C, CC, BB, B, A), Close_date = c(ini, ini, ini, ini+109, ini+39, ini+24), stringsAsFactors = FALSE) dat Class Close_date 1 AAA 2010-01-01 2 A 2010-01-01 3 CC 2010-01-01 4 BB 2010-04-20 5 B 2010-02-09 6 A 2010-01-25 Desired result is: Class Close_date Flag 1 AAA 2010-01-01 Valid 2 A 2010-01-01 Invalid 3 CC 2010-01-01 Valid 4 BB 2010-04-20 Valid 5 B 2010-02-09 Valid 6 A 2010-01-25 Valid The following seems to be a failure.. for (i in length(ind)) { dat[[Flag]] - sapply(dat$Close_date, function(x) ifelse((x = oc[ind[i], 1] x oc[ind[i], 2]) | (x = oc[ind[i], 3] x oc[ind[i], 4]) | (x = oc[ind[i], 5] x oc[ind[i], 6]) | (x = oc[ind[i], 7] x oc[ind[i], 8]), Valid, Invalid)) } Any resolution in this would be greatly appreciated. Many thanks in advance. -- Steven [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] hi!! please help me!
Am 06.08.2010 07:31, schrieb leepama: I made some anonymous function which performs some process in matlab code.. But I want to perform it in R program... Is there any method??? You have already got answers to this. Please read the posting guide and please stop using an unspecific subject a la help. Stefan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] data.frame: return all rows where at least one...
Hi, I know ways to do this but they all seem awkward and I somehow believe that there is a convenient shortcut. If I have a data.frame with many columns, how can I request all rows for which at least one column satisfy an expression? For instance, all rows where at least one column is negative. Many thanks, Werner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] data.frame: return all rows where at least one...
On 08/06/2010 08:03 AM, Werner W. wrote: Hi, I know ways to do this but they all seem awkward and I somehow believe that there is a convenient shortcut. Since you don't show us what you tried, I don't know what you consider 'awkward'. If I have a data.frame with many columns, how can I request all rows for which at least one column satisfy an expression? For instance, all rows where at least one column is negative. A small, reproducible example in R is far better to work from than English descriptions. Does your data.frame consist entirely of numeric variables? It sounds like it, in which case, you can use apply, which will coerce your data.frame to a matrix. df1 - data.frame(...) df1[apply(df1, 1, function(x) any(x) 0), ] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 using external BLAS
I have problems building R 2.11.1 with an external BLAS. I've tried several with several libraries: # ACML: export LD_LIBRARY_PATH=/site/VERSIONS/acml-3.6.0/gfortran64_int64/lib BLAS=--with-blas=-L/site/VERSIONS/acml-3.6.0/gfortran64_int64/lib -lacml LAPACK=--with-lapack # MKL 11: BLAS=--with-blas=-L/site/VERSIONS/intel-11.1/mkl/lib/em64t -lmkl_gf_lp64 -lmkl_sequential -lmkl_lapack -lmkl_core LAPACK=--with-lapack # MKL 8.1, trad. way: BLAS=--with-blas=-L/site/intel/cmkl/8.1/lib/em64t -lmkl -lvml -lguide -lpthread LAPACK=--with-lapack I configure R like this: export CFLAGS=-O3 -mtune=opteron export FFLAGS=-O3 -mtune=opteron export CXXFLAGS=-O3 -mtune=opteron export FCFLAGS=-O3 -mtune=opteron ./configure --prefix=/site/VERSIONS/R-2.11.1 \ $BLAS $LAPACK \ --enable-R-shlib In all cases, I get configure:29120: checking whether double complex BLAS can be used configure:29206: result: no The conftestf.f and conftest.c seem to compile fine, but exit status from conftest in line 29181 of configure is nonzero. This is on a Quad-Core AMD Opteron node running CentOS 5.2, with gcc and gfortran version 4.1.2 20071124 (Red Hat 4.1.2-42) (I have also tried without the *FLAGS variables, and without --with-lapack. The result is the same.) (We have successfully built older versions of R with MKL 8.1 earlier, but with intel compilers v. 10.1, using ./configure --prefix=/site/VERSIONS/R-$version \ --with-blas=-L/site/intel/cmkl/8.1/lib/em64t -lmkl -lvml -lguide -lpthread \ --with-lapack=-L/site/intel/cmkl/8.1/lib/em64t -lmkl_lapack64 -lmkl \ --enable-R-shlib but we wanted to switch to gcc because not all R packages compile with icc.) Does anyone have any idea about what could be wrong? -- Regards, Bjørn-Helge Mevik __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] data.frame: return all rows where at least one...
One solution - let's say our data.frame is xx Then: xx - matrix(rnorm(9), 3,3) apply(xx 0, 1, any) Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Fri, Aug 6, 2010 at 4:03 PM, Werner W. pensterfuz...@yahoo.de wrote: Hi, I know ways to do this but they all seem awkward and I somehow believe that there is a convenient shortcut. If I have a data.frame with many columns, how can I request all rows for which at least one column satisfy an expression? For instance, all rows where at least one column is negative. Many thanks, Werner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Tobit Modelling
Hi Patrick Here is some code that might help you implement your tobit regression, if you don´t mind using maximum likelihood. #first declare a likelihood function with a censored model #assume your x2 is censored for values below -1, and using a simple #linear model in this case. Our censoring threshold will be z. YOURX1 = c(1,2,3,4,6,7,8,9,10,11) YOURX2 = c(-1,-1,-1,-1,2.2,3.1,6.4,7, 7.2,8) loglik - function(param, x1, x2, z) { b0- param[1] b1- param[2] sigma - param[3] result - ifelse(x2 z, dnorm(x2, b0 + b1 * x1, sigma, log = T), pnorm((z-b0+b1*x1)/sigma, log = T)) return(sum(result)) } regression - optim( par= c(-3,1,1), fn = loglik, method = L-BFGS-B, lower = c(-Inf, -Inf, 1e-10), #bound solution for b0 and b1 to be any, but sigma 0 x1 = YOURX1, x2 = YOURX2, z = -1, control = list(fnscale = -1)) #maximize likelihood plot(YOURX2 ~ YOURX1) abline(a=regression$par[1], b= regression$par[2]) abline(lm (YOURX2~YOURX1), lty= 2) The key here is that you are analyzing the likelihood for your x2 with different probabilities. The code above was implemented for nonlinear regression, so you can put any model you want with minor changes and it will work identically. Cheers, Cristian. - Cristian Montes Site Productivity Division Head Bioforest S.A. -Mensaje original- De: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] En nombre de Patrick Sessford Enviado el: Jueves, 05 de Agosto de 2010 08:42 p.m. Para: r-help@r-project.org Asunto: [R] Tobit Modelling Dear R-users, I would like to model data where the response variable consists of many minus ones and many different positive values that seem to follow an apparently separate distribution (ie. -1, -1, 0.5, -1, 3, 3.5, 1.2, -1, -1, 0.4, etc); no values of the response can be less than minus one or between minus and zero (exclusive). I am aware of tobit regression but unaware of exactly how to implement it in R. If anyone is able to help me on this issue I'd be extremely grateful; for example, if my (continuous) explanatory variables were x1 and x2, how should I define the model? Thank you for your time. Pat [[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] A %nin% operator?
There's many additional operators defined in the mvbutils package, including %!in%. Kevin On Thu, Aug 5, 2010 at 10:25 AM, David Huffer david.huf...@csosa.govwrote: See Harrell's Hmisc package -- David Huffer, Ph.D. Deputy Director CSOSA/ORE Washington, DC -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ken Williams Sent: Thursday, August 05, 2010 11:20 AM To: r-help@r-project.org Subject: [R] A %nin% operator? Sometimes I write code like this: qf.a - subset(qf, pubid %in% c(104, 106, 107, 108)) qf.b - subset(qf, !pubid %in% c(104, 106, 107, 108)) and I get a little worried that maybe I've remembered the precedence rules wrong, so I change it to qf.a - subset(qf, pubid %in% c(104, 106, 107, 108)) qf.b - subset(qf, !(pubid %in% c(104, 106, 107, 108))) and pretty soon my code looks like fingernail clippings (or Lisp) and I'm thinking about precedence rather than my original task. So I write a %nin% operator which I define as: `%nin%` - function (x, table) match(x, table, nomatch = 0L) == 0L and then I'm happy again. I wonder, would something like this find a home in core R? Or is that too much syntactic sugar for your taste? -- Ken Williams Sr. Research Scientist Thomson Reuters Phone: 651-848-7712 ken.willi...@thomsonreuters.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. -- Kevin Wright [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Is R GPL or LGPL (or can I write a commercial front end to R)?
not be until your project becomes popular that someone decides to take action. So in the latter case I'd get a legal opinion, not a mailing list opinion, before I invested a lot of time or money. Duncan Murdoch I've looked at various threads on the r-devel archive and it looks like this may have been discussed before, but as far as could tell, not to any great resolution, and not, it seems, specifically covering this angle. In the doc\COPYRIGHTS file it is made clear that the intention is that you can write R packages that include functions implemented in C (and hence are provided in native libraries linked to R.dll) and distribute them under licenses not compatible with GPL. This was achieved by making the relevant header files available under the LGPL. This was an explicit change that was made in February 2001, and the intention was to allow for DLLs that require the API header files for compilation and are linked against R.dll to not be infected with the GPL. However the Rembedded.h header file isn't included in the list in the doc\COPYRIGHTS file, and the copyright statement in the Rembedded.h header file lists the GPL and not the LGPL as the relevant license. So it doesn't look like it was the intention to allow that I be able to use the R invocation API to launch R and embed it in a product (such as a new GUI, or other such integration) and ship that product under a license not compatible with GPL. Is this correct? Or is it the intention that I be able to write a commercial front-end of some kind for R? My understanding of LGPL is that ALL of the source files that go into R.dll (and indeed all libraries that R.dll itself linked to, apart from those covered by the GPL system library exception) would need to be released under LGPL in order to allow me to link to R.dll and not have my program subject to GPL. If that weren't the situation then I could take a library covered by GPL, write a different interface to it, put LGPL on those headers compile up a new DLL and I've then got LGPL access to a library previously released under GPL, which can't be the intention, otherwise LGPL would drive a coach and horses through GPL. This would apply to native libraries (dlls) providing functions in addon packages too, and so hence I'm not sure I necessarily understand how simply putting LGPL on the header files is sufficient to achieve the intention. There is provision in the GPL license (it's mentioned in the FAQ) for providing for linking to a GPL library through one specific interface by providing specific exception text in the copyright header in all of the files that make up the library. That would only be possible if the copyright holders of all relevant GPL code agreed to that, as that would be an extra grant to the license. So if R linked to any third party GPL code, this wouldn't be possible I don't think. So I guess the question here is what the intention is of the R foundation with respect to the limitations or freedoms that they are intending to allow. After all, as the copyright owners they aren't going to sue if a use falls within their intention, even if on a strict interpretation of the license such use wouldn't be allowed. So it seems to be the intention that I can write a DLL to provide R functions in an add on package, which requires linkage to R.dll. Not convinced that the license it set up right to cover that, but that appears to be the intention. Question is whether at the other end, at the invocation API end, whether it is the intention to be able to use the invocation API and link to R.dll without my program being subjected to GPL. Note that I'm not talking here about anything to do with code written in the language of R. This is purely concerned with treating R as a library with an interface and wanting to link to that interface and whether the intention or the actuality of the license allow that. Thanks! [[alternative HTML version deleted]] __ R-help@r-project.orgmailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ Information from ESET NOD32 Antivirus, version of virus signature database 5346 (20100806) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ Information from ESET NOD32 Antivirus, version of virus signature database 5346 (20100806) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ R-help@r-project.orgmailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal
Re: [R] Exporting nlme summary
Thanks for all the help. A nice and easy fix. On Thu, Aug 5, 2010 at 6:36 PM, David Winsemius dwinsem...@comcast.netwrote: On Aug 5, 2010, at 6:22 PM, Jun Shen wrote: I believe this has been discussed many times in the archives. Here is one way to do it. Yes, you are so right. Use function sink to direct the output to a file you specify sink( file='your file.txt') after you execute this command, all the output will be saved to your file and you won't see it on the screen. Say summary(horton.nlme) give the output back to console sink() And one line that is equivalent to those three lines: capture.output( summary(horton.nlme) , file='your file.txt') -- David. Hope this helps. Jun Shen Senior Pharmacokineticist Seventh Wave Labs On Thu, Aug 5, 2010 at 2:30 PM, Ronald Wendt rnldwe...@gmail.com wrote: I'm trying to export the results of my summary data for the object horton.nlme, but failing miserably. Running summary(horton.nlme) works fine, but both write.table and write.csv return the error cannot coerce class 'c(summary.lme, nlme, lme)' into a data.frame. I know I can copy and paste the output from the summary function, but it's ugly because the spacing between numbers and fields is minimal. Thanks for any help! David Winsemius, MD West Hartford, CT -- Ronald Wendt Columbia University Master of International Affairs Candidate, 2011 Economic and Political Development [[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] Pausing script to allow user input from keyboard.
Hi all, I have written a simple R script to help me analyze a large data set. I would like to have the script pause to allow the user to input a character string that is subsequently used as a filename when saving tables. I have tried to use the readline command - this seems to work fine when entering commands one by one, but when I copy and paste the entire script into R, it does not pause for input and just charges ahead writes the files. Any help is appreciated, I've copied and pasted the script below. Any help is appreciated - I am really new to R so if you can be as detailed as possible in your responses it would be greatly appreciated. Thanks, JT R version: R 2.11.1 GUI 1.34 OS: OS 10.5.8 Here's the script: #readfiles, a is nuclear measurements, b is cytoplasmic measurements a - read.table(file.choose(), header=TRUE, sep=,) b - read.table(file.choose(), header=TRUE, sep=,) #make a new data frame named new with important columns new - data.frame(a$ImageNumber, a$AreaShape_Area, a $Intensity_IntegratedIntensity_OrigRFP, a $Intensity_IntegratedIntensity_OrigGFP, b $Intensity_MeanIntensity_OrigGFP) #make three new columns, EstCytoIntensity estimates Cytoplasmic intensity based on the mean measured intensity and an estimate of the nuclear volume to the cytoplasmic volume, TotalIntensity is the sum of the integrated nuclear intensity and estimated cytoplasmic intensity, NucToCytoRatio is the ratio of nuclear intensity divided by cytoplasmic intensity new$EstCytoIntensity - b$Intensity_MeanIntensity_OrigGFP * (a $AreaShape_Area/0.3) new$TotalIntensity - new$a.Intensity_IntegratedIntensity_OrigGFP + new $EstCytoIntensity new$NucToCytoRatio - new$a.Intensity_IntegratedIntensity_OrigGFP / new $TotalIntensity #creates a table that determines the means for the measurements of all objects within an image library(plyr) newmean - ddply(new, c(a.ImageNumber), summarize, NuclearMean=mean(a.Intensity_IntegratedIntensity_OrigGFP, trim=0.01), CytoMean=mean(EstCytoIntensity, trim=0.01), IntensityMean=mean(TotalIntensity, trim=0.01), RatioMean=mean(NucToCytoRatio, trim=0.01)) # input file name name - readline(prompt=give filename ) #writes tables based on name given, both 'raw' containing all information and 'mean' containing the image means write.table(new, file=paste(name,raw.csv, sep=), row.names=FALSE, sep=,) write.table (newmean, file=paste(name, mean.csv, sep=), row.names=FALSE, sep=,) #end [[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] Partial Function Application
Hi. I would like to partially apply a function to a list of arguments, and I don't know how to do this in R, without perhaps writing default values to the formals() of my function, or writing to the environment object of a function. For context, my definition of partially apply is: fix some of the arguments, leaving the others as variables, return a new function that takes the un-fixed arguments from the original function as arguments The issue is that I would like several different sets of arguments for the partially applied phase, and I think that would involve copying the function to several different places with the above methods. Alternately, I could hard-code the partial applications using a function() form, but I would prefer not to do this, as there will be a sizable number of these closures needed and I'd prefer to automate the process. Thanks! --Mog __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Pausing script to allow user input from keyboard.
Don't cut/paste; 'source' in the script. readLines is trying to read from stdin which is where the commands are being read from. Using 'source' avoids that problem. You can also look at some examples I have seen using tk/tcl where you can bring up a window for user input. On Fri, Aug 6, 2010 at 9:52 AM, Johnny Tkach johnny.tk...@utoronto.ca wrote: Hi all, I have written a simple R script to help me analyze a large data set. I would like to have the script pause to allow the user to input a character string that is subsequently used as a filename when saving tables. I have tried to use the readline command - this seems to work fine when entering commands one by one, but when I copy and paste the entire script into R, it does not pause for input and just charges ahead writes the files. Any help is appreciated, I've copied and pasted the script below. Any help is appreciated - I am really new to R so if you can be as detailed as possible in your responses it would be greatly appreciated. Thanks, JT R version: R 2.11.1 GUI 1.34 OS: OS 10.5.8 Here's the script: #readfiles, a is nuclear measurements, b is cytoplasmic measurements a - read.table(file.choose(), header=TRUE, sep=,) b - read.table(file.choose(), header=TRUE, sep=,) #make a new data frame named new with important columns new - data.frame(a$ImageNumber, a$AreaShape_Area, a $Intensity_IntegratedIntensity_OrigRFP, a $Intensity_IntegratedIntensity_OrigGFP, b $Intensity_MeanIntensity_OrigGFP) #make three new columns, EstCytoIntensity estimates Cytoplasmic intensity based on the mean measured intensity and an estimate of the nuclear volume to the cytoplasmic volume, TotalIntensity is the sum of the integrated nuclear intensity and estimated cytoplasmic intensity, NucToCytoRatio is the ratio of nuclear intensity divided by cytoplasmic intensity new$EstCytoIntensity - b$Intensity_MeanIntensity_OrigGFP * (a $AreaShape_Area/0.3) new$TotalIntensity - new$a.Intensity_IntegratedIntensity_OrigGFP + new $EstCytoIntensity new$NucToCytoRatio - new$a.Intensity_IntegratedIntensity_OrigGFP / new $TotalIntensity #creates a table that determines the means for the measurements of all objects within an image library(plyr) newmean - ddply(new, c(a.ImageNumber), summarize, NuclearMean=mean(a.Intensity_IntegratedIntensity_OrigGFP, trim=0.01), CytoMean=mean(EstCytoIntensity, trim=0.01), IntensityMean=mean(TotalIntensity, trim=0.01), RatioMean=mean(NucToCytoRatio, trim=0.01)) # input file name name - readline(prompt=give filename ) #writes tables based on name given, both 'raw' containing all information and 'mean' containing the image means write.table(new, file=paste(name,raw.csv, sep=), row.names=FALSE, sep=,) write.table (newmean, file=paste(name, mean.csv, sep=), row.names=FALSE, sep=,) #end [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Pausing script to allow user input from keyboard.
Hi Some time ago somebody advised me to use cat(\n,Enter filename,\n) # prompt x=scan(n=1) # read 1 line from console than use x in further code Regards Petr r-help-boun...@r-project.org napsal dne 06.08.2010 15:52:17: Hi all, I have written a simple R script to help me analyze a large data set. I would like to have the script pause to allow the user to input a character string that is subsequently used as a filename when saving tables. I have tried to use the readline command - this seems to work fine when entering commands one by one, but when I copy and paste the entire script into R, it does not pause for input and just charges ahead writes the files. Any help is appreciated, I've copied and pasted the script below. Any help is appreciated - I am really new to R so if you can be as detailed as possible in your responses it would be greatly appreciated. Thanks, JT R version: R 2.11.1 GUI 1.34 OS: OS 10.5.8 Here's the script: #readfiles, a is nuclear measurements, b is cytoplasmic measurements a - read.table(file.choose(), header=TRUE, sep=,) b - read.table(file.choose(), header=TRUE, sep=,) #make a new data frame named new with important columns new - data.frame(a$ImageNumber, a$AreaShape_Area, a $Intensity_IntegratedIntensity_OrigRFP, a $Intensity_IntegratedIntensity_OrigGFP, b $Intensity_MeanIntensity_OrigGFP) #make three new columns, EstCytoIntensity estimates Cytoplasmic intensity based on the mean measured intensity and an estimate of the nuclear volume to the cytoplasmic volume, TotalIntensity is the sum of the integrated nuclear intensity and estimated cytoplasmic intensity, NucToCytoRatio is the ratio of nuclear intensity divided by cytoplasmic intensity new$EstCytoIntensity - b$Intensity_MeanIntensity_OrigGFP * (a $AreaShape_Area/0.3) new$TotalIntensity - new$a.Intensity_IntegratedIntensity_OrigGFP + new $EstCytoIntensity new$NucToCytoRatio - new$a.Intensity_IntegratedIntensity_OrigGFP / new $TotalIntensity #creates a table that determines the means for the measurements of all objects within an image library(plyr) newmean - ddply(new, c(a.ImageNumber), summarize, NuclearMean=mean(a.Intensity_IntegratedIntensity_OrigGFP, trim=0.01), CytoMean=mean(EstCytoIntensity, trim=0.01), IntensityMean=mean(TotalIntensity, trim=0.01), RatioMean=mean(NucToCytoRatio, trim=0.01)) # input file name name - readline(prompt=give filename ) #writes tables based on name given, both 'raw' containing all information and 'mean' containing the image means write.table(new, file=paste(name,raw.csv, sep=), row.names=FALSE, sep=,) write.table (newmean, file=paste(name, mean.csv, sep=), row.names=FALSE, sep=,) #end [[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] try-error within for loop
Wu Gong wrote: So, try() inside loop should work. Like for () { if (class(try(...,silent=T))==try-error) result[[i]] - NA ... } Thanks a lot, it worked for me! Cheers Olga __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Is R GPL or LGPL (or can I write a commercial front end to R)?
is what the intention is of the R foundation with respect to the limitations or freedoms that they are intending to allow. After all, as the copyright owners they aren't going to sue if a use falls within their intention, even if on a strict interpretation of the license such use wouldn't be allowed. So it seems to be the intention that I can write a DLL to provide R functions in an add on package, which requires linkage to R.dll. Not convinced that the license it set up right to cover that, but that appears to be the intention. Question is whether at the other end, at the invocation API end, whether it is the intention to be able to use the invocation API and link to R.dll without my program being subjected to GPL. Note that I'm not talking here about anything to do with code written in the language of R. This is purely concerned with treating R as a library with an interface and wanting to link to that interface and whether the intention or the actuality of the license allow that. 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. __ Information from ESET NOD32 Antivirus, version of virus signature database 5346 (20100806) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ Information from ESET NOD32 Antivirus, version of virus signature database 5346 (20100806) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ Information from ESET NOD32 Antivirus, version of virus signature database 5346 (20100806) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ Information from ESET NOD32 Antivirus, version of virus signature database 5346 (20100806) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.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. -- Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@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] [OT] R on Atlas library
Dear List, I am aware this is slightly off-topic, but I am sure there are people who already had the problem and who perhaps solved it. I am running long-lasting model fits using constrOptim command. At work there is a linux computer (Quad Core, debian) on which I already have compiled R and Atlas, in the hope that things will go faster on that machine. Atlas offers the possibility to be compiled for multiple cores, I used that option, but without success. Performance meter (top) for Linux shows 25% CPU usage, and there is no loss of performance if I run 4 instances of R doing heavy matrix multiplications. Performance drops when a 5th instance of R is doing the same job, so I assume my attempt was not successful. I am sure I did something wrong. Is there anybody who sucessfully runs R with Atlas and all processors? A short description of the necessary steps would be helpful. Searching around the internet was not very encourageing. Some people wrote that it is not so simple to have Atlas fully exploit a multicore computer. I hope this is not too unspecific. Best wishes, Matthias -- Dr. rer. nat. Matthias Gondan Institut für Psychologie Universität Regensburg D-93050 Regensburg Tel. 0941-943-3856 Fax 0941-943-3233 Email: matthias.gon...@psychologie.uni-regensburg.de http://www.psychologie.uni-r.de/Greenlee/team/gondan/gondan.html -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Partial Function Application
On Aug 6, 2010, at 9:56 AM, Mog wrote: Hi. I would like to partially apply a function to a list of arguments, and I don't know how to do this in R, without perhaps writing default values to the formals() of my function, or writing to the environment object of a function. For context, my definition of partially apply is: fix some of the arguments, leaving the others as variables, return a new function that takes the un-fixed arguments from the original function as arguments I don't understand the difficulties: f1 - function(a,b,c,d) a+b+c+d f1(1,2,3,4) [1] 10 f2 - function(a , b) f1(a,b, 3,4) f2(1,2) [1] 10 f1(1,2) Error in a + b + c : 'c' is missing floop - function(a,b){ for( cc in 2:4) { for (dd in 5:7) { print( f1(a, b, cc, dd) )}} } floop(1,2) [1] 10 [1] 11 [1] 12 [1] 11 [1] 12 [1] 13 [1] 12 [1] 13 [1] 14 The issue is that I would like several different sets of arguments for the partially applied phase, and I think that would involve copying the function to several different places with the above methods. Alternately, I could hard-code the partial applications using a function() form, but I would prefer not to do this, as there will be a sizable number of these closures needed and I'd prefer to automate the process. Thanks! --Mog __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Partial Function Application
Hi, I think you mean Currying, there's a function in roxygen that looks like, Curry function (f, ..., .left = TRUE) { .orig = list(...) function(...) { if (.left) { args - c(.orig, list(...)) } else { args - c(list(...), .orig) } do.call(f, args) } } HTH, baptiste On Aug 6, 2010, at 3:56 PM, Mog wrote: Hi. I would like to partially apply a function to a list of arguments, and I don't know how to do this in R, without perhaps writing default values to the formals() of my function, or writing to the environment object of a function. For context, my definition of partially apply is: fix some of the arguments, leaving the others as variables, return a new function that takes the un-fixed arguments from the original function as arguments The issue is that I would like several different sets of arguments for the partially applied phase, and I think that would involve copying the function to several different places with the above methods. Alternately, I could hard-code the partial applications using a function() form, but I would prefer not to do this, as there will be a sizable number of these closures needed and I'd prefer to automate the process. Thanks! --Mog __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] image plot but data not on grid.
Hi, Would like to make an image however the values in z are not on an uniform grid. Have a dataset with length(x) == length(y) == length(z) x[1],y[1] gives the position of z[1] and would like to encode value of z by a color. looking for something like plot(x,y, col = z) where col for z is cleverly chosen from a colorscale. Hope I made clear what I am looking for. Thanks Eryk __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Partial Function Application
Thank you! That's exactly what I wanted. --Mog __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 on random forest variable importance estimates
Hello, I am using the R randomForest package to classify variable stars. I have a training set of 1755 stars described by (too) many variables. Some of these variables are highly correlated. I believe that I understand how randomForest works and how the variable importance are evaluated (through variable permutations). Here are my questions. 1) variable importance error? Is there any ways to estimate the error on the MeanDecreaseAccuracy? In other words, I would like to know how significant are MeanDecreaseAccuracy differences (and display horizontal error bars in the VarImpPlot output). I have notice that even with relatively large number of trees, I have variation in the importance values from one run to the next. Could this serve as a measure of the errors/uncertainties? 2) how to deal with variable correlation? so far, I am iterating, selecting the most important variable first, removing all other variable that have a high correlation (say higher than 80%), taking the second most important variable left, removing variables with high-correlation with any of the first two variables, and so on... (also using some astronomical insight as to which variables are the most important!) Is there a better way to deal with correlation in randomForest? (I suppose that using many correlated variables should not be a problem for randomForest, but it is for my understanding of the data and for other algorithms). 3) How many variables should eventually be used? I have made successive runs, adding one variable at a time from the most to the least important (not-too-correlated) variables. I then plot the error rate (err.rate) as a function of the number of variable used. As this number increase, the error first sharply decrease, but relatively soon it reaches a plateau . I assume that the point of inflexion can be use to derive the minimum number of variable to be used. Is that a sensible approach? Is there any other suggestion? A measure of the error on err.rate would also here really help. Is there any idea how to estimate this? From the variation between runs or with the help of importanceSD somehow? Thanks very much in advance for any help. Pierre Dubath __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] image plot but data not on grid.
Hi, Not really sure what you are after, but the following plots a series of points of varying colour plot(x,y,type='n') apply(cbind(x,y,z),1,function(a) {points(a[1],a[2],col=a[3],pch=.)}) but its going to be really slow for a large number of points Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of W Eryk Wolski Sent: 06 August 2010 15:25 To: r-help@r-project.org Subject: [R] image plot but data not on grid. Hi, Would like to make an image however the values in z are not on an uniform grid. Have a dataset with length(x) == length(y) == length(z) x[1],y[1] gives the position of z[1] and would like to encode value of z by a color. looking for something like plot(x,y, col = z) where col for z is cleverly chosen from a colorscale. Hope I made clear what I am looking for. Thanks Eryk __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This e-mail has been scanned for all viruses by Star.\ _...{{dropped:12}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] data.frame: return all rows where at least one...
Thanks for the answers! The any function was basically exactly what I was looking for. (previously I used something with rowSums() which is probably not the most efficient way.) Thanks so much, Werner -- View this message in context: http://r.789695.n4.nabble.com/data-frame-return-all-rows-where-at-least-one-tp2316292p2316407.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] image plot but data not on grid.
On Aug 6, 2010, at 10:24 AM, W Eryk Wolski wrote: Hi, Would like to make an image however the values in z are not on an uniform grid. Have a dataset with length(x) == length(y) == length(z) x[1],y[1] gives the position of z[1] and would like to encode value of z by a color. looking for something like plot(x,y, col = z) where col for z is cleverly chosen from a colorscale. ?palette ??palette # for other coloring options ?colorRamp # random integer index from default palette for coloring of random x,y points: plot(rnorm(20), rnorm(20), col=palette()[ runif(20, 1,10) ]) # The cleverness is left to you. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Is R GPL or LGPL (or can I write a commercial front end to R)?
Tom, FWIW, since you appear to be representing World Programming in your queries (at least that is my inference given your e-mail domain), it would be prudent to get formal legal advice here and not place your company at legal and financial risk by basing decisions on comments (well intentioned though they may be) on an e-mail list. You don't want to make key business decisions on beliefs. There are other commercial companies doing what you are proposing to do. However, the devil is in the details. To an extent, the intentions of the various R related copyright holders do not matter. The copyright holders, who are not themselves software licensing lawyers, may not be fully cognizant of all of the legal implications of the licenses they used and how those licenses apply to specific situations. Their intentions, explicit and implicit, must be legally consistent with the licenses under which their code and R are released. The R Foundation cannot make a proactive decision to let you do something that is in violation of the GPL as the R Foundation would put itself at legal risk. One of the key points in the GPL licensing scheme, is that one need not get the permission or the opinion of every copyright holder involved in the code that is desired to be used. Once the copyright holders have made the decision to release their code under the GPL, the only consideration is whether or not the subsequent use of that code by others is legally consistent with the GPL. I can't stop you from doing something with my GPL code, as long as you honor the GPL, even if I might disagree with the application of my code to a particular task (eg. http://www.gnu.org/licenses/gpl-faq.html#NoMilitary). It is when you make the decision to build and distribute (at no cost or otherwise) closed source software on top of open source software that things get dicey. Thus, what will matter in the end, at some point down the road when you have a closed source commercial R product, with revenues at risk, is whether or not the the R Foundation and/or the FSF, will contact you due to a violation of the GPL because of the **specific** way in which your closed source GUI interacts with R. The FSF will have an interest here, because R is a GNU project, not to mention, ensuring that the GPL is properly enforced. The FSF has already shown that it will independently undertake such communications on behalf of GNU projects and enforcing the GPL license. That recently happened, for example, with GNU Go for iOS via the Apple App Store, resulting in the removal of that product. In addition (timing is everything), the Software Freedom Conservancy just won a judgement against Westinghouse due to a GPL violation: http://www.linuxplanet.com/linuxplanet/reports/7145/1/ While the details of these situations are not directly applicable to your query, it is a demonstration that GPL enforcement is moving forward in the courts and legal precedents are being established. In the end, all of that is good, because it will be helpful to others to better understand the legal boundaries and interpretations of the GPL as they apply to specific situations. So there is a real risk to your company, dependent upon fairly low level programming and operational details, which can impact whether or not you can sell a closed source GUI that runs on top of R. At the end of the day, you have a fiduciary responsibility to your company to seek formal legal advice. That is part of the cost of doing business and making informed decisions. HTH, Marc Schwartz On Aug 6, 2010, at 8:42 AM, Tom Quarendon wrote: It wasn't the intention of the GPL I was really interested in, I believe I understand that (or at least I believe I understand the FSF view on things), it was the intention of the authors of R. I believe that the FSF view linking to a DLL creating a derived work and hence you are infected by the GPL. If you want to use GPL code you can, as long as you're willing to be GPL yourself. This doesn't appear to square with the intention of the R authors to allow non-GPL add-on projects with native code. Tom Q. From: Tal Galili [mailto:tal.gal...@gmail.com] Sent: 06 August 2010 12:28 To: Tom Quarendon Cc: Duncan Murdoch; r-help@r-project.org Subject: Re: [R] Is R GPL or LGPL (or can I write a commercial front end to R)? From what I've seen on other OSS project, GPL can be a bit viral, making it (purposefully) difficult for someone to close the source code for free reuse. My tip for you would be to try and see what REvolution computing has been doing with their product (which is a repackaging of R with more code which is proprietary). Also, Richard Stallman (the author of GPL, and other one or two meaningful pieces of code, if to understate) gave a talk on free software and GPL during his talk on useR2010. I don't think he'll say something that would directly answer your
[R] Colours on conditional levelplots in package lattice
I am having difficulty in getting the colours on a conditional levelplot in the package lattice to work as I want them to - I wonder if someone could help me. The colours do not completely agree with the colour key. Here is a specimen example. require(lattice) col1 - c (1.37,2.35,0.20,1.85,0.274,1.56,-0.76,-0.03,-1.39,-0.95,-0.50,0.91,1.58,0.17,-0.34,-0.48,1.50,-0.68,1.05) col2 - c (A,B,C,F,G,H,B,C,E,G,H,A,B,C,D,E,F,G,H) col3 - c (X,Y,X,Y,X,Y,Y,X,X,X,Y,X,Y,X,Y,X,Y,X,Y) col4 - c (1,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,3,3,3) dat1 - data.frame(X1=col1, var1=col2, var2=col3, var3=col4) maxAbsValue - max(abs(as.vector(dat1[, X1]))) colorkeyAt - pretty(c(-maxAbsValue, maxAbsValue), n = 10) boxColours - c(#8B, #A83500, #C46B00, #E2A100, #FFD700, #ADD8E6, #81A2CF, #566CB8, #2B36A1, #8B) levelplot(X1 ~ var1 * var2 | var3, data = dat1, col.regions = boxColours, colorkey = list(at = colorkeyAt, labels = list(labels = colorkeyAt, at = colorkeyAt, cex = 0.6)), panel = function(x, y, z, ...) { panel.fill(col = darkgrey) at = pretty(c(-maxAbsValue, maxAbsValue), n = 10) panel.levelplot(x, y, z, ...) }) I am hoping that all the blue shades appear in panel 1, the reds in panel 2 and a mixture only in panel 3. Can anyone help explain why this is not happening? I am using sessionInfo() R version 2.11.1 (2010-05-31) i386-pc-mingw32 locale: [1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252 [3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C [5] LC_TIME=English_United Kingdom.1252 attached base packages: [1] grid grDevices datasets splines graphics stats tcltk utils methods base other attached packages: [1] RColorBrewer_1.0-2 lattice_0.18-8 rcom_2.2-3 rscproxy_1.3-1 svSocket_0.9-48 [6] TinnR_1.0.3R2HTML_2.1 Hmisc_3.8-2 survival_2.35-8 loaded via a namespace (and not attached): [1] cluster_1.12.3 svMisc_0.9-57 tools_2.11.1 Windows XP Professional Regards Gordon Morrison HSBC Bank plc may be solicited in the course of its placement efforts for a new issue, by investment clients of the firm for whom the Bank as a firm already provides other services. It may equally decide to allocate to its own proprietary book or with an associate of HSBC Group. This represents a potential conflict of interest. HSBC Bank plc has internal arrangements designed to ensure that the firm would give unbiased and full advice to the corporate finance client about the valuation and pricing of the offering as well as internal systems, controls and procedures to identify and manage conflicts of interest. HSBC Bank plc Registered Office: 8 Canada Square, London E14 5HQ, United Kingdom Registered in England - Number 14259 Authorised and regulated by the Financial Services Authority. - SAVE PAPER - THINK BEFORE YOU PRINT! This transmission has been issued by a member of the HSBC Group HSBC for the information of the addressee only and should not be reproduced and/or distributed to any other person. Each page attached hereto must be read in conjunction with any disclaimer which forms part of it. Unless otherwise stated, this transmission is neither an offer nor the solicitation of an offer to sell or purchase any investment. Its contents are based on information obtained from sources believed to be reliable but HSBC makes no representation and accepts no responsibility or liability as to its completeness or accuracy. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] About R base
Hi folks, I have R x64 2.11.1 installed on Win 7 64 bit which is running as VM (guest) on Oracle VirtualBox. Is there any difference between it and R on Linux? I can install another R on Debian 5.04, also running as VM. TIA B.R. Stephen L __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Is R GPL or LGPL (or can I write a commercial front end to R)?
Tom, I would strongly echo the advice of Duncan and Marc and others already on this thread to seek expert legal advice on this issue. At Revolution we rely on the expertise of Mark Radcliffe, the General Legal Counsel of the Open Source Initiative. (Additional information here: http://www.revolutionanalytics.com/downloads/gpl-sources.php .) Because GPL issues draw on aspects of copyright law, contract law, and other legal domains (that can also vary by jurisdiction), legal advice with expertise in all the relevant areas is essential. Hope this helps, # David Smith -- David M Smith da...@revolutionanalytics.com VP of Marketing, Revolution Analytics http://blog.revolutionanalytics.com Tel: +1 (650) 330-0553 x205 (Palo Alto, 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.
Re: [R] Is R GPL or LGPL (or can I write a commercial front end to R)?
. Duncan Murdoch I've looked at various threads on the r-devel archive and it looks like this may have been discussed before, but as far as could tell, not to any great resolution, and not, it seems, specifically covering this angle. In the doc\COPYRIGHTS file it is made clear that the intention is that you can write R packages that include functions implemented in C (and hence are provided in native libraries linked to R.dll) and distribute them under licenses not compatible with GPL. This was achieved by making the relevant header files available under the LGPL. This was an explicit change that was made in February 2001, and the intention was to allow for DLLs that require the API header files for compilation and are linked against R.dll to not be infected with the GPL. However the Rembedded.h header file isn't included in the list in the doc\COPYRIGHTS file, and the copyright statement in the Rembedded.h header file lists the GPL and not the LGPL as the relevant license. So it doesn't look like it was the intention to allow that I be able to use the R invocation API to launch R and embed it in a product (such as a new GUI, or other such integration) and ship that product under a license not compatible with GPL. Is this correct? Or is it the intention that I be able to write a commercial front-end of some kind for R? My understanding of LGPL is that ALL of the source files that go into R.dll (and indeed all libraries that R.dll itself linked to, apart from those covered by the GPL system library exception) would need to be released under LGPL in order to allow me to link to R.dll and not have my program subject to GPL. If that weren't the situation then I could take a library covered by GPL, write a different interface to it, put LGPL on those headers compile up a new DLL and I've then got LGPL access to a library previously released under GPL, which can't be the intention, otherwise LGPL would drive a coach and horses through GPL. This would apply to native libraries (dlls) providing functions in addon packages too, and so hence I'm not sure I necessarily understand how simply putting LGPL on the header files is sufficient to achieve the intention. There is provision in the GPL license (it's mentioned in the FAQ) for providing for linking to a GPL library through one specific interface by providing specific exception text in the copyright header in all of the files that make up the library. That would only be possible if the copyright holders of all relevant GPL code agreed to that, as that would be an extra grant to the license. So if R linked to any third party GPL code, this wouldn't be possible I don't think. So I guess the question here is what the intention is of the R foundation with respect to the limitations or freedoms that they are intending to allow. After all, as the copyright owners they aren't going to sue if a use falls within their intention, even if on a strict interpretation of the license such use wouldn't be allowed. So it seems to be the intention that I can write a DLL to provide R functions in an add on package, which requires linkage to R.dll. Not convinced that the license it set up right to cover that, but that appears to be the intention. Question is whether at the other end, at the invocation API end, whether it is the intention to be able to use the invocation API and link to R.dll without my program being subjected to GPL. Note that I'm not talking here about anything to do with code written in the language of R. This is purely concerned with treating R as a library with an interface and wanting to link to that interface and whether the intention or the actuality of the license allow that. Thanks! __ Information from ESET NOD32 Antivirus, version of virus signature database 5347 (20100806) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ Information from ESET NOD32 Antivirus, version of virus signature database 5347 (20100806) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.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] Is R GPL or LGPL (or can I write a commercial front end to R)?
OK. Can I say once more. I'm not after legal advice! That I can get elsewhere! We understand the need for legal advice and so far our legal advice has been sound on other matters. I was simply trying to understand the apparent contradiction between the GPL and the attempt to allow commercial add-on packages. TomQ. -Original Message- From: David Smith [mailto:da...@revolutionanalytics.com] Sent: 06 August 2010 16:56 To: Tom Quarendon Cc: Marc Schwartz; r-help@r-project.org Subject: Re: [R] Is R GPL or LGPL (or can I write a commercial front end to R)? Tom, I would strongly echo the advice of Duncan and Marc and others already on this thread to seek expert legal advice on this issue. At Revolution we rely on the expertise of Mark Radcliffe, the General Legal Counsel of the Open Source Initiative. (Additional information here: http://www.revolutionanalytics.com/downloads/gpl-sources.php .) Because GPL issues draw on aspects of copyright law, contract law, and other legal domains (that can also vary by jurisdiction), legal advice with expertise in all the relevant areas is essential. Hope this helps, # David Smith -- David M Smith da...@revolutionanalytics.com VP of Marketing, Revolution Analytics http://blog.revolutionanalytics.com Tel: +1 (650) 330-0553 x205 (Palo Alto, CA, USA) __ Information from ESET NOD32 Antivirus, version of virus signature database 5347 (20100806) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ Information from ESET NOD32 Antivirus, version of virus signature database 5347 (20100806) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.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] Tukey post hoc test for testing interaction between two or more predictors
Hi everyone, I woudl like to apply a Tukey post hoc after a repeated measure ANOVA. I followed the suggestions that I found in this help -list especially this one: /[R] Tukey HSD (or other post hoc tests) following repeated measures ANOVA You want to use lme() in package nlme, then glht() in the multcomp package. This will give you multiplicity adjusted p-values and confidence intervals. ## Example require(MASS) ## for oats data set require(nlme) ## for lme() require(multcomp) ## for multiple comparison stuff Aov.mod - aov(Y ~ N + V + Error(B/V), data = oats) Lme.mod - lme(Y ~ N + V, random = ~1 | B/V, data = oats) summary(Aov.mod) anova(Lme.mod) summary(Lme.mod) summary(glht(Lme.mod, linfct=mcp(V=Tukey))) HTH, Mark. /My problem is that in my study I want to test the interactions among different levels of two predictors. Considering oats dataset in MASS package how can I test the contrast between one level of the variable V (for example, Victory) and one level of the variable N(for example 0.0cwt)? Thank you very much for your help. Nicola __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Is R GPL or LGPL (or can I write a commercial front end to R)?
it was the intention to allow that I be able to use the R invocation API to launch R and embed it in a product (such as a new GUI, or other such integration) and ship that product under a license not compatible with GPL. Is this correct? Or is it the intention that I be able to write a commercial front-end of some kind for R? My understanding of LGPL is that ALL of the source files that go into R.dll (and indeed all libraries that R.dll itself linked to, apart from those covered by the GPL system library exception) would need to be released under LGPL in order to allow me to link to R.dll and not have my program subject to GPL. If that weren't the situation then I could take a library covered by GPL, write a different interface to it, put LGPL on those headers compile up a new DLL and I've then got LGPL access to a library previously released under GPL, which can't be the intention, otherwise LGPL would drive a coach and horses through GPL. This would apply to native libraries (dlls) providing functions in addon packages too, and so hence I'm not sure I necessarily understand how simply putting LGPL on the header files is sufficient to achieve the intention. There is provision in the GPL license (it's mentioned in the FAQ) for providing for linking to a GPL library through one specific interface by providing specific exception text in the copyright header in all of the files that make up the library. That would only be possible if the copyright holders of all relevant GPL code agreed to that, as that would be an extra grant to the license. So if R linked to any third party GPL code, this wouldn't be possible I don't think. So I guess the question here is what the intention is of the R foundation with respect to the limitations or freedoms that they are intending to allow. After all, as the copyright owners they aren't going to sue if a use falls within their intention, even if on a strict interpretation of the license such use wouldn't be allowed. So it seems to be the intention that I can write a DLL to provide R functions in an add on package, which requires linkage to R.dll. Not convinced that the license it set up right to cover that, but that appears to be the intention. Question is whether at the other end, at the invocation API end, whether it is the intention to be able to use the invocation API and link to R.dll without my program being subjected to GPL. Note that I'm not talking here about anything to do with code written in the language of R. This is purely concerned with treating R as a library with an interface and wanting to link to that interface and whether the intention or the actuality of the license allow that. Thanks! __ Information from ESET NOD32 Antivirus, version of virus signature database 5347 (20100806) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ Information from ESET NOD32 Antivirus, version of virus signature database 5347 (20100806) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to read a file inside a function?
Hi I wish to read a file from my local directory from inside a function. I am passing the filename as the argument but this does not work. Say for example function(dat) { dat1=read.csv(D:\\dat.csv,header=TRUE) } If I call funtion(dat) I get the following error. 'Intuitively' i understand this is a mistake but how do I overcome this and how can I read a file name passed as an argument please? Error in file(file, rt) : cannot open the connection In addition: Warning message: In file(file, rt) : cannot open file 'D:\dat.csv': No such file or directory Many thanks Raghu [[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] Stopping precision using 'optim'
Read the help file for optim(). ?optim It clearly says the following with regards to L-BFGS-B: factr controls the convergence of the L-BFGS-B method. Convergence occurs when the reduction in the objective is within this factor of the machine tolerance. Default is 1e7, that is a tolerance of about 1e-8. pgtol helps control the convergence of the L-BFGS-B method. It is a tolerance on the projected gradient in the current search direction. This defaults to zero, when the check is suppressed. So, all you need to do is to change these two (I am not sure if you really want to change pgtol) if you want better (or different) answers. You should not *minimize* the log-likelihood. You may have meant that you are minimizing its negative. You can do this by setting control$fnscale = -1. Hope this helps, Ravi. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jeremy Beaulieu Sent: Thursday, August 05, 2010 8:45 PM To: r-help@r-project.org Subject: [R] Stopping precision using 'optim' Hi all~ I am wondering if it is possible to alter the stopping precision for parameters estimated using the 'optim'? If it helps, I am minimizing the log-likelihood of a function using constraints (i.e. L-BFG-S). -Jeremy __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 read a file inside a function?
ff - function(filename) { dat1 - read.csv(file=filename,header=TRUE) } filename - D:\dat.csv ff(filename) - A R learner. -- View this message in context: http://r.789695.n4.nabble.com/How-to-read-a-file-inside-a-function-tp2316516p2316528.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] plotting lines and colors
Dear R People: Suppose I plot the following plot(1:50) Is there a way to plot, say, [1:25] in red and [26:50] in blue, please? (or should I just plot 2 separate lines, please?) I'm about 99% sure that there is no way without 2 lines. thanks for any help, Sincerely, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@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] plotting lines and colors
On Fri, Aug 6, 2010 at 9:42 AM, Erin Hodgess erinm.hodg...@gmail.com wrote: Dear R People: Suppose I plot the following plot(1:50) Is there a way to plot, say, [1:25] in red and [26:50] in blue, please? One simple way is with the col argument, there are certainly fancier solutions too. plot(1:50, col = rep(c(red,blue), each = 25)) Cheers, Josh (or should I just plot 2 separate lines, please?) I'm about 99% sure that there is no way without 2 lines. thanks for any help, Sincerely, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@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. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.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] gsub
i - piante_venere.csv gsub(^.*_(.*)\\.csv$, \\1, i) - A R learner. -- View this message in context: http://r.789695.n4.nabble.com/gsub-tp2316443p2316550.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] Multiply each depth level of an array with another vector element
?sweep -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Maurits Aben Sent: Thursday, August 05, 2010 2:00 PM To: r-help@r-project.org Subject: [R] Multiply each depth level of an array with another vector element Suppose x - array(c(1,1,1,1,2,2,2,2), dim = c(2,2,2)) y - c(5, 10) Now I would like to multiply x[, , 1] with y[1] and x[, , 2] with y[2]. Possible solution is a for-loop: for (i in 1:2) { x[, , i] * y[i] } Another possible solution is this construction: as.vector(t(replicate(nrow(x) * ncol(x), y))) * x I find that these two solutions have a relatively large computation time (on larger arrays) and I suspect there should be solution with less computation time. Is there a faster method to perform this calculation (thus to multiply the depth of an array with respective vector elements)? Best regards, Maurits Aben [[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 read a file inside a function?
On Fri, Aug 6, 2010 at 9:29 AM, Raghuraman Ramachandran optionsra...@gmail.com wrote: Hi I wish to read a file from my local directory from inside a function. I am passing the filename as the argument but this does not work. Say for example function(dat) { dat1=read.csv(D:\\dat.csv,header=TRUE) this does not work because in the quoted string, 'dat' is not evaluated. You have several options, one as shown by Wu Gong, simply pass the entire file path as the argument to your function. Alternately, suppose your data files are always located at D:\\ and always end in .csv you could do this which paste()s D:\\ and .csv to the front and end, respectively, of 'dat'. myfun - function(dat) { filename - paste(D:\\, dat, .csv, sep = ) read.csv(file = filename, header = TRUE) } myfun(datafilename) #or whatever the filename is HTH, Josh } If I call funtion(dat) I get the following error. 'Intuitively' i understand this is a mistake but how do I overcome this and how can I read a file name passed as an argument please? Error in file(file, rt) : cannot open the connection In addition: Warning message: In file(file, rt) : cannot open file 'D:\dat.csv': No such file or directory Many thanks Raghu [[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. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.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] memory use without running gc()
Is there any way to get the current memory used by R without running gc()? I'd like to include the memory usage in logging output, but calling gc() to get that information takes long enough to be noticeable (~ 6 s with ~ 20 GB of ram in use), which goes against the point of logging. 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.
Re: [R] eval-parse and lme in a loop
fortune(106) If the answer is parse() you should usually rethink the question. -- Thomas Lumley R-help (February 2005) Here is one approach that seems to be working: for (meanCol in paste(Mean_, 1:3, sep=)) { cat('\n##',meanCol,'\n\n') f - formula( paste( meanCol, '~ Group + c1 + c2 + c3' ) ) means.lmeWithCovariate - lme(f, data=df, random = ~ 1 | Subject) print(summary(means.lmeWithCovariate)) print(anova(means.lmeWithCovariate)) } -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Connolly, Colm Sent: Thursday, August 05, 2010 3:18 PM To: r-help@r-project.org Subject: [R] eval-parse and lme in a loop Hi everybody, I'm having trouble getting an eval-parse combination to work with lme in a for loop. Consider the code below. The call to lme outside the loop works. The call to aov inside the loop works, but the call to to lme inside the loop does not. The latter fails with Error in model.frame.default(formula = ~meanCol + Group + c1 + c3 + Subject, : variable lengths differ (found for 'Group') and I don't know why the eval-parse portion of the code is node being replaced as it is in the call to aov. Anybody got any idea what's wrong? rm(list=ls()) library('nlme') df=data.frame( Group=rep(c(ctrl, short, long), each=9, times=1), Subject=paste(S, 1:27, sep=), Mean_1=c(-2.335482, 8.269832, 6.704734, -2.355664, 0.724432, 11.212987, 5.966652, 10.741065, 3.567522, 5.359832, 4.899951, 4.084452, 5.976326, 8.634508, 5.750942, 7.455622, 6.823843, 0.903801, 13.198157, 5.238985, 5.171453, 10.273715, 5.184785, 6.225874, 8.889997, 12.096968, 9.843028), Mean_2=c(16.24, -1.486571, 1.817303, 3.814328, -0.343775, 19.323227, -0.390764, 7.149855, 4.517766, -0.967120, 11.219844, 0.561103, 5.188478, -4.819444, 6.253271, 7.062638, 4.502291, - 0.469567, 12.739646, 5.832679, 9.193511, 7.664636, 6.083930, 9.493136, 7.478424, 7.642287, 7.205822), Mean_3=c(7.213662, 2.147219, -1.345795, -0.495567, 3.733844, 3.544084, 0.949573, 4.318238, 2.914248, 3.913391, 9.240128, 8.315122, 12.323612, 14.622557, 11.169847, 10.857631, 14.637243, 7.203096, 7.777472, -1.457673, 2.766380, 9.675148, -5.047292, 1.982447, 3.865502, 5.045913, 10.660579), c1=rnorm(9, mean=0.1, sd=0.4), c2=rnorm(9, mean=0.5, sd=0.7), c3=rnorm(9, mean=0.9, sd=1) ); ## this works means.lmeNoCovariate=lme(Mean_1 ~ Group, data=df, random = ~ 1 | Subject) print(summary(means.lmeNoCovariate)) print(anova(means.lmeNoCovariate)) for (meanCol in paste(Mean_, 1:3, sep=)) { ## LMEs go here cat(## ##\n) cat(### AOV\n) cat(## ##\n) ## this works means.aov-aov(eval(parse(text=meanCol)) ~ Group, data=df); means.aov.summary=summary(means.aov) print(means.aov.summary) cat(## ##\n) cat(### LME\n) cat(## ##\n) ## this doe not work means.lmeWithCovariate=lme(eval(parse(text=meanCol)) ~ Group + c1 + c1 + c3, data=df, random = ~ 1 | Subject) print(summary(means.lmeWithCovariate)) print(anova(means.lmeWithCovariate)) } Regards, -- Colm G. Connolly, Ph. D. Dept of Psychiatry University of California, San Diego 9500 Gilman Dr. #0738 La Jolla, CA 92093-0738 Tel: +1-858-246-0684 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] stats::reshape question
Hello, A quick question for my edification. When I run the following (R 2.8.1 on Microsoft Windows): d = data.frame(x1=c(1,2),x2=c(3,4),y1=c(5,6),y2=c(7,8)) reshape(d,varying=c(y1,x1,y2,x2),v.names=c(y,x),dir=long) I found myself surprised by the results--the column labeled y is actually the data from x1 and x2, and the column labeled x is actually the data from y1 and y2. Is this behaviour of reshape as intended? That is, have I missed something in the documentation? Many thanks for any comments. --Krishna [[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] Multiply each depth level of an array with another vector element
It's interesting that sweep is the slowest one comparing to replicate and rep :) - A R learner. -- View this message in context: http://r.789695.n4.nabble.com/Multiply-each-depth-level-of-an-array-with-another-vector-element-tp2315537p2316586.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] qqline error: Error in sort.list(x, partial = unique(c(lo, hi))) : 'x' must be atomic for 'sort.list' Have you called 'sort' on a list?
Hi all, I'm modeling using lme in the nlme package. qqnorm makes plots just find, but when I try to add a line with qqline, I get the following error: Error in sort.list(x, partial = unique(c(lo, hi))) : 'x' must be atomic for 'sort.list' Have you called 'sort' on a list? For example modelincr10-lme(lruin~can.pos.num, data=rwushi30, random=(~1| site/transect/plot),na.action=na.omit) summary(modelincr10) qqnorm(modelincr10, main=qqnorm res10) qqline(modelincr10) Error in sort.list(x, partial = unique(c(lo, hi))) : 'x' must be atomic for 'sort.list' Have you called 'sort' on a list? Any help much appreciated. Ben [[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] stats::reshape question
It seems that we can't change the order of varying argument or v.names. Notice that the order of variables in varying is like x.1,y.1,x.2,y.2. Code can only be: reshape(d,varying=c(x1,y1,x2,y2),v.names=c(x,y),dir=long) - A R learner. -- View this message in context: http://r.789695.n4.nabble.com/stats-reshape-question-tp2316583p2316606.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] Plotting range of values in barplot()
Hi: As far as I recall, no one has provided a horizontal barchart as a solution, so here's one using lattice: library(lattice) smw.dat-factor(rep(c(Somewhat Disagree, Neutral, Somewhat Agree, Strongly Agree),c(1,2,7,12)), levels=c(Strongly Disagree, Somewhat Disagree, Neutral, Somewhat Agree,Strongly Agree), ordered=TRUE) smw.f - table(smw.dat) barchart( ~ smw.f, horizontal = TRUE, xlim = c(0, 14),scales = list(axs = 'i'), col=rainbow(5), main=Survey answers, xlab=Responses ) Given the lengths of the labels, it might be preferable to view them from this perspective instead. dotchart() [dotplot() in lattice] would be a viable alternative for displaying this discrete distribution, but its colors aren't as pretty :) HTH, Dennis On Fri, Aug 6, 2010 at 3:57 AM, Jim Lemon j...@bitwrit.com.au wrote: On 08/06/2010 04:22 AM, yankeetilidie wrote: Hello, I am attempting to create a bar plot that contains a range of possible response values on the x-axis of 1 to 5 and contains barplots for the number of responses even in the event that there are 0 responses. For example, I have a data set that contains values of 2, 3, 4, and 5 but I would also like my graph to show that there are no 1's. I have attached the resulting graph. The appropriate values should be 0 - Strongly Disagree, 1 - Somewhat Disagree, 2 - Neutral, 7 - Somewhat Agree, and 12 - Strongly Agree. Hi Steve, Given your labels, I would suggest the following: smw.dat-factor(rep(c(Somewhat Disagree,Neutral, Somewhat Agree,Strongly Agree),c(1,2,7,12)), levels=c(Strongly Disagree,Somewhat Disagree,Neutral, Somewhat Agree,Strongly Agree),ordered=TRUE) library(prettyR) smw.freq-freq(smw.dat,display.na=FALSE) library(plotrix) barp(smw.freq,names.arg=levels(smw.dat),staxx=TRUE, col=rainbow(5),main=Survey answers,xlab=Responses) 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. [[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] memory use without running gc()
?memory.size On Fri, Aug 6, 2010 at 1:00 PM, Johann Hibschman jhibsch...@gmail.com wrote: Is there any way to get the current memory used by R without running gc()? I'd like to include the memory usage in logging output, but calling gc() to get that information takes long enough to be noticeable (~ 6 s with ~ 20 GB of ram in use), which goes against the point of logging. 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Computation Duration Time
Is there a way to find out what the computation duration time was to complete executing a code chunk? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] m-estimators
Hi: Try (install package sos first if necessary): library(sos) findFn('M-estimator') This produced 34 hits on my machine (not quite as productive as Petr's search :), but it identifies a few packages that contain functions for robust estimation. It's also a good way to get familiar with a very useful search mechanism to find R functions in the maze of available packages. Typing RSiteSearch('M-estimator') at the R prompt is another way to search within R. HTH, Dennis On Fri, Aug 6, 2010 at 12:10 AM, Iasonas Lamprianou lampria...@yahoo.comwrote: Dear colleagues can somebody help me by showing how we can compute m-estimators in R? thanks Dr. Iasonas Lamprianou Assistant Professor (Educational Research and Evaluation) Department of Education Sciences European University-Cyprus P.O. Box 22006 1516 Nicosia Cyprus Tel.: +357-22-713178 Fax: +357-22-590539 Honorary Research Fellow Department of Education The University of Manchester Oxford Road, Manchester M13 9PL, UK Tel. 0044 161 275 3485 iasonas.lampria...@manchester.ac.uk __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] Computation Duration Time
?Rprof or ?system.time TGS wrote: Is there a way to find out what the computation duration time was to complete executing a code chunk? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] memory use without running gc()
jim holtman jholt...@gmail.com writes: ?memory.size Only works on Windows. I guess I should have specified; this is on Linux. 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.
Re: [R] qqline error: Error in sort.list(x, partial = unique(c(lo, hi))) : 'x' must be atomic for 'sort.list' Have you called 'sort' on a list?
On Aug 6, 2010, at 1:47 PM, Benjamin Caldwell wrote: Hi all, I'm modeling using lme in the nlme package. qqnorm makes plots just find, but when I try to add a line with qqline, I get the following error: Error in sort.list(x, partial = unique(c(lo, hi))) : 'x' must be atomic for 'sort.list' Have you called 'sort' on a list? For example modelincr10-lme(lruin~can.pos.num, data=rwushi30, random=(~1| site/transect/plot),na.action=na.omit) summary(modelincr10) qqnorm(modelincr10, main=qqnorm res10) qqline(modelincr10) Error in sort.list(x, partial = unique(c(lo, hi))) : 'x' must be atomic for 'sort.list' Have you called 'sort' on a list? There is no lme methof for qqline. Have you read the help page for the qqnorm.lme function? ?qqnorm.lme I am guessing that you did not realize it was a completely different function that qqnorm.default. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] gsub
Hi, I'm using gsub, but I've a problem. print(i) [1] piante_venere.csv gsub(\\.csv$, , i) [1] piante_venere gsub(^piante_, , i) [1] venere.csv Can I combine the two expressions? Like this: gsub(.) [1] venere Thanks, Alfredo -- View this message in context: http://r.789695.n4.nabble.com/gsub-tp2316443p2316443.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] Creating timeSeries
Hi I want to create a TimeSeries object with already defined dates (in the first vector) so that all the data are coerced as a time series object with the dates as they are. Is there anyone that have an idea what to do? 2010-07-07 3.900833 3.176667 2.754167 2.045833 1.820833 2010-04-21 4.256667 3.356667 2.70 1.82 1.576667 2010-02-17 4.322500 3.45 2.67 1.792500 1.492500 2009-12-23 4.306667 3.426667 2.68 1.851667 1.481667 2009-10-28 4.34 3.425000 2.677500 2.17 1.522500 2009-09-09 4.472500 3.41 2.64 2.17 1.645000 Serdar (MA) [[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] 64-bit R on 64-bit Windows box... Still not enough memory?!
.Machine$sizeof.pointer [1] 4 -- View this message in context: http://r.789695.n4.nabble.com/64-bit-R-on-64-bit-Windows-box-Still-not-enough-memory-tp2315742p2316493.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] pdf indifferent to lwd after some small number1 (e.g. 0.18)
Hi, To plot a figure, I used lwd=0.18 in the function lines() to plot very fine lines. However, using png() or pdf() to save the figure, it appears that lwd has no effect on pdf() beyond some small number (e.g. 0.18) and the lines looks much thicker than png(). Setting lwd0.18 does not make the lines any finer in pdf(). I also tried specifying the argument lwd in par() instead and still faced the same problem. My understanding is pdf() allows lwd1 but it seems that there is a lower bound. I hope to use pdf() instead of png() because the computer server gives the following error message when png is used: png(file=tmp.png) Error in X11(paste(png::, filename, sep = ), width, height, pointsize, : unable to start device PNG In addition: Warning message: In png(file = tmp.png) : unable to open connection to X11 display '' Thanks for the help and advice in advance regarding the problem I am facing. Best regards, stan My mac machine: version _ platform x86_64-apple-darwin9.8.0 arch x86_64 os darwin9.8.0 system x86_64, darwin9.8.0 status major 2 minor 11.1 year 2010 month 05 day31 svn rev52157 language R version.string R version 2.11.1 (2010-05-31) The computer sever: version _ platform x86_64-unknown-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 9.0 year 2009 month 04 day17 svn rev48333 language R version.string R version 2.9.0 (2009-04-17) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Confidence Intervals for logistic regression
Michael, Thanks for the reply. I believe Aline was sgiving me CI's on coefficients as well. So c(pred$fit + 1.96 * pred$se.fit, pred$fit - 1.96 * pred$se.fit) gives me the CI on the logits if I understand correctly? Maybe the help on predict.glm can be updated. Thanks! On 6 August 2010 01:46, Michael Bedward michael.bedw...@gmail.com wrote: Sorry about earlier reply - didn't read your email properly (obviously :) You're suggestion was right, so as well as method for Aline below, another way of doing the same thing is: pred - predict(y.glm, newdata= something, se.fit=TRUE) ci - matrix( c(pred$fit + 1.96 * pred$se.fit, pred$fit - 1.96 * pred$se.fit), ncol=2 ) lines( something, plogis( ci[,1] ) ) lines( something, plogis( ci[,2] ) ) On 6 August 2010 18:39, aline uwimana rwan...@gmail.com wrote: Dear Troy, use this commend, your will get IC95% and OR. logistic.model - glm(formula =y~ x1+x2, family = binomial) summary(logistic.model) sum.coef-summary(logistic.model)$coef est-exp(sum.coef[,1]) upper.ci-exp(sum.coef[,1]+1.96*sum.coef[,2]) lower.ci-exp(sum.coef[,1]-1.96*sum.coef[,2]) cbind(est,upper.ci,lower.ci) regards. 2010/8/6 Troy S troysocks-tw...@yahoo.com Dear UseRs, I have fitted a logistic regression using glm and want a 95% confidence interval on a response probability. Can I use predict(model, newdata, se.fit=T) Will fit +/- 1.96se give me a 95% of the logit? And then exp(fit +/- 1.96se) / (exp(fit +/- 1.96se) +1) to get the probabilities? Troy [[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] stats::reshape question
Hi: Is this what you were aiming for? reshape(d,varying=list(c(x1,x2), c(y1,y2)),v.names=c(x,y),dir=long) time x y id 1.11 1 5 1 2.11 2 6 2 1.22 3 7 1 2.22 4 8 2 HTH, Dennis On Fri, Aug 6, 2010 at 10:28 AM, Krishna Tateneni taten...@gmail.comwrote: Hello, A quick question for my edification. When I run the following (R 2.8.1 on Microsoft Windows): d = data.frame(x1=c(1,2),x2=c(3,4),y1=c(5,6),y2=c(7,8)) reshape(d,varying=c(y1,x1,y2,x2),v.names=c(y,x),dir=long) I found myself surprised by the results--the column labeled y is actually the data from x1 and x2, and the column labeled x is actually the data from y1 and y2. Is this behaviour of reshape as intended? That is, have I missed something in the documentation? Many thanks for any comments. --Krishna [[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] 64-bit R on 64-bit Windows box... Still not enough memory?!
You are running 32 bit R. Read the RW FAQ. On Aug 6, 2010, at 12:03 PM, noclue_ wrote: .Machine$sizeof.pointer [1] 4 -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Grouping clusters from dendrograms
Hi, I have produced a dendrogram of categorical data in R using the hclust function, although the input was a dissimilarity matrix produced in SAS, as I have defined my own distances. The dendrogram is fine and I can view and use this. However, I was wondering if there is a method by which I can find out the optimal place to place groups, rather than relying on my visual analysis? I don't have multiple trees to compare and therefore would be relying on the data in the one tree. I have tried using dynamic tree cut, but this seems to be producing odd results whereby it is grouping data that overlap branches. However, I'm not sure if this is because of the script I am using to visualise the data which may be incorrect. The script I tried was: dendro-hclust(as.dist(combo2),method=average) cut2-cutreeDynamicTree(dendro,maxTreeHeight=1,deepSplit=TRUE,minModuleSize=1) I then used the following to visualise the data: cut2colour-labels2colors(cut2) plotDendroAndColors(dendro,cut2colour,Dynamic Tree Cut, dendroLabels=FALSE,hang=0.03,addGuide=TRUE,guideHang=0.05) Any advice or ideas would be much appreciated! Thanks, Julia -- View this message in context: http://r.789695.n4.nabble.com/Grouping-clusters-from-dendrograms-tp2316521p2316521.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] R script doesn't load libraries when called from cron
I have R script that i need to run in cron. Either R libraries or some .so libraries that they depend on don't get loaded correctly. Here is an example. I have a file, call it tmp.R tmp.R = R --slave --args $0 $* EOF cmarg = commandArgs()[5] library(R.utils) b-intToBin(cmarg) print(paste( argument is , cmarg, sep=)) print(paste( binary representation of argument is , b)) === It loads a library R.utils, uses function intToBin from it, prints binary rep of the argument. When i run it from command line like ./tmp.R 10 it runs fine. Here is the output: Output: == Loading required package: R.oo Loading required package: R.methodsS3 R.methodsS3 v1.2.0 (2010-03-13) successfully loaded. See ?R.methodsS3 for help. R.oo v1.7.3 (2010-06-04) successfully loaded. See ?R.oo for help. R.utils v1.4.0 (2010-03-24) successfully loaded. See ?R.utils for help. Warning message: package 'R.oo' was built under R version 2.8.1 and help may not work correctly [1] command argument is 10 [1] binary representation of argument is 1010 Now, here is the problem. When i run it from cron I get error message Error in loadNamespace(name) : there is no package called 'R.utils' Calls: sys.load.image ... tryCatch - tryCatchList - tryCatchOne - Anonymous Execution halted seemingly it has problems with loading library, but i cannot figure out why. I tried running it using Rscript program, R CMD BATCH, calling R directly and i always run into the same problem when called from cron. I am running 64 bit R v10 on 64 Red Hat Lunix. -- View this message in context: http://r.789695.n4.nabble.com/R-script-doesn-t-load-libraries-when-called-from-cron-tp2316594p2316594.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] Error on random forest variable importance estimates
From: Pierre Dubath Hello, I am using the R randomForest package to classify variable stars. I have a training set of 1755 stars described by (too) many variables. Some of these variables are highly correlated. I believe that I understand how randomForest works and how the variable importance are evaluated (through variable permutations). Here are my questions. 1) variable importance error? Is there any ways to estimate the error on the MeanDecreaseAccuracy? In other words, I would like to know how significant are MeanDecreaseAccuracy differences (and display horizontal error bars in the VarImpPlot output). If you really want to do it, one possibility is to do permutation test: Permute your response, say, 1000 or 2000 times, run RF on each of these permuted response, and use the importance measures as samples from the null distribution. I have notice that even with relatively large number of trees, I have variation in the importance values from one run to the next. Could this serve as a measure of the errors/uncertainties? Yes. 2) how to deal with variable correlation? so far, I am iterating, selecting the most important variable first, removing all other variable that have a high correlation (say higher than 80%), taking the second most important variable left, removing variables with high-correlation with any of the first two variables, and so on... (also using some astronomical insight as to which variables are the most important!) Is there a better way to deal with correlation in randomForest? (I suppose that using many correlated variables should not be a problem for randomForest, but it is for my understanding of the data and for other algorithms). That depends a lot on what you're trying to do. RF can tolerate problematic data, but that doesn't mean it will magically give you good answers. Trying to draw conclusions about effects when there are highly correlated (and worse, important) variables is a tricky business. 3) How many variables should eventually be used? I have made successive runs, adding one variable at a time from the most to the least important (not-too-correlated) variables. I then plot the error rate (err.rate) as a function of the number of variable used. As this number increase, the error first sharply decrease, but relatively soon it reaches a plateau . I assume that the point of inflexion can be use to derive the minimum number of variable to be used. Is that a sensible approach? Is there any other suggestion? A measure of the error on err.rate would also here really help. Is there any idea how to estimate this? From the variation between runs or with the help of importanceSD somehow? One approach is described in the following paper (in the Proceedings of MCS 2004): http://www.springerlink.com/content/9n61mquugf9tungl/ Best, Andy Thanks very much in advance for any help. Pierre Dubath __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Notice: This e-mail message, together with any attachme...{{dropped:11}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] gsub
On Aug 6, 2010, at 10:14 AM, Alfredo Alessandrini wrote: Hi, I'm using gsub, but I've a problem. print(i) [1] piante_venere.csv gsub(\\.csv$, , i) [1] piante_venere gsub(^piante_, , i) [1] venere.csv Can I combine the two expressions? Like this: gsub(.) [1] venere Thanks, Alfredo The easiest way is to use a back reference to return the part of the vector that you want: gsub(^.*_(.*)\\.csv$, \\1, piante_venere.csv) [1] venere In this case, the \\1 returns the part of the regex defined within the parens. HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] stats::reshape question
Thanks for the reply, I realize that having x and y in that order in varying and v.names will work. The question is why reversing the order (i.e., y followed by x) does not work; it seems unintuitive, so I'm wondering if I've just misread the documentation. On Fri, Aug 6, 2010 at 1:45 PM, Dennis Murphy djmu...@gmail.com wrote: Hi: Is this what you were aiming for? reshape(d,varying=list(c(x1,x2), c(y1,y2)),v.names=c(x,y),dir=long) time x y id 1.11 1 5 1 2.11 2 6 2 1.22 3 7 1 2.22 4 8 2 HTH, Dennis On Fri, Aug 6, 2010 at 10:28 AM, Krishna Tateneni taten...@gmail.comwrote: Hello, A quick question for my edification. When I run the following (R 2.8.1 on Microsoft Windows): d = data.frame(x1=c(1,2),x2=c(3,4),y1=c(5,6),y2=c(7,8)) reshape(d,varying=c(y1,x1,y2,x2),v.names=c(y,x),dir=long) I found myself surprised by the results--the column labeled y is actually the data from x1 and x2, and the column labeled x is actually the data from y1 and y2. Is this behaviour of reshape as intended? That is, have I missed something in the documentation? Many thanks for any comments. --Krishna [[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] How to apply apply?!
guRus I have say a dataframe, d and I wish to do the following: 1) For each row, I want to take one particular value of the row and multiply it by 2. How do I do it. Say the data frame is as below: OPEN HIGH LOW CLOSE 1931.2 1931.2 1931.2 1931.2 0 0 0 999.05 0 0 0 1052.5 0 0 0 987.8 0 0 0 925.6 0 0 0 866 0 0 0 1400.2 0 0 0 754.5 0 0 0 702.6 0 0 0 653.25 0 0 0 348 0 0 0 801 866.55 866.55 866.55 866.55 783.1 783.1 742.25 742.25 575 575 575 575 0 0 0 493 470 470 420 425 355 360 343 360 312.05 312.05 274 280.85 257.35 257.35 197 198.75 182 185.95 137 150.75 120.25 129 90.7 101.25 91.85 91.85 57 66.6 How do I multiply only the close of every row using the 'apply' function? And once multiplied how do I obtain a new table that also contains the new 2*CLOSE column (without cbind?). 2) Also, how do I run a generic function per row. Say for example I want to calculate the Implied Volatility for each row of this data frame ( using the RMterics package). How do I do that please using the apply function? I am focusing on apply because I like the vectorisation concept in R and I do not want to use a for loop etc. Many thanks for the enlightment, Raghu [[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] Creating timeSeries
?xts xts will do what you want. as.xts or xts() are straightforward ways. On Fri, Aug 6, 2010 at 5:11 PM, Serdar Akin akin1...@gmail.com wrote: Hi I want to create a TimeSeries object with already defined dates (in the first vector) so that all the data are coerced as a time series object with the dates as they are. Is there anyone that have an idea what to do? 2010-07-07 3.900833 3.176667 2.754167 2.045833 1.820833 2010-04-21 4.256667 3.356667 2.70 1.82 1.576667 2010-02-17 4.322500 3.45 2.67 1.792500 1.492500 2009-12-23 4.306667 3.426667 2.68 1.851667 1.481667 2009-10-28 4.34 3.425000 2.677500 2.17 1.522500 2009-09-09 4.472500 3.41 2.64 2.17 1.645000 Serdar (MA) [[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.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] pdf indifferent to lwd after some small numberlt; 1 (e.g. 0.18)
Chuen Tan tcs76.geo at yahoo.com writes: Hi, To plot a figure, I used lwd=0.18 in the function lines() to plot very fine lines. However, using png() or pdf() to save the figure, it appears that lwd has no effect on pdf() beyond some small number (e.g. 0.18) and the lines looks much thicker than png(). Setting lwd0.18 does not make the lines any finer in pdf(). I also tried specifying the argument lwd in par() instead and still faced the same problem. This bug has been fixed in the development version of R: see http://stat.ethz.ch/R-manual/R-devel/doc/html/NEWS.html and search for lwd For a Mac, you can get the development version from http://r.research.att.com/ . Your PNG issue may (?) be that you don't have X11 available on your machine -- see the MacOS R FAQ. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 64-bit R on 64-bit Windows box... Still not enough memory?!
On Fri, Aug 06, 2010 at 09:03:09AM -0700, noclue_ wrote: .Machine$sizeof.pointer [1] 4 So it appears you are not on 64bit. Experpt form the help page: [...] sizeof.pointer: the number of bytes in a C ‘SEXP’ type. Will be ‘4’ on 32-bit builds and ‘8’ on 64-bit builds of R. [...] cu Philipp -- Dr. Philipp Pagel Lehrstuhl für Genomorientierte Bioinformatik Technische Universität München Wissenschaftszentrum Weihenstephan Maximus-von-Imhof-Forum 3 85354 Freising, Germany http://webclu.bio.wzw.tum.de/~pagel/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to apply apply?!
For 1, an easy way is dat - transform(dat, CLOSE2=2*CLOSE) For 2: apply(dat,1,fun) On 08/06/2010 03:06 PM, Raghuraman Ramachandran wrote: guRus I have say a dataframe, d and I wish to do the following: 1) For each row, I want to take one particular value of the row and multiply it by 2. How do I do it. Say the data frame is as below: OPEN HIGH LOW CLOSE 1931.2 1931.2 1931.2 1931.2 0 0 0 999.05 0 0 0 1052.5 0 0 0 987.8 0 0 0 925.6 0 0 0 866 0 0 0 1400.2 0 0 0 754.5 0 0 0 702.6 0 0 0 653.25 0 0 0 348 0 0 0 801 866.55 866.55 866.55 866.55 783.1 783.1 742.25 742.25 575 575 575 575 0 0 0 493 470 470 420 425 355 360 343 360 312.05 312.05 274 280.85 257.35 257.35 197 198.75 182 185.95 137 150.75 120.25 129 90.7 101.25 91.85 91.85 57 66.6 How do I multiply only the close of every row using the 'apply' function? And once multiplied how do I obtain a new table that also contains the new 2*CLOSE column (without cbind?). 2) Also, how do I run a generic function per row. Say for example I want to calculate the Implied Volatility for each row of this data frame ( using the RMterics package). How do I do that please using the apply function? I am focusing on apply because I like the vectorisation concept in R and I do not want to use a for loop etc. Many thanks for the enlightment, Raghu [[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. -- Abhijit Dasgupta, PhD Director and Principal Statistician ARAASTAT Ph: 301.385.3067 E: adasgu...@araastat.com W: http://www.araastat.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 apply apply?!
Raghuraman Ramachandran wrote: guRus I have say a dataframe, d and I wish to do the following: 1) For each row, I want to take one particular value of the row and multiply it by 2. How do I do it. Say the data frame is as below: OPEN HIGH LOW CLOSE 1931.2 1931.2 1931.2 1931.2 0 0 0 999.05 0 0 0 1052.5 0 0 0 987.8 0 0 0 925.6 0 0 0 866 0 0 0 1400.2 0 0 0 754.5 0 0 0 702.6 0 0 0 653.25 0 0 0 348 0 0 0 801 866.55 866.55 866.55 866.55 783.1 783.1 742.25 742.25 575 575 575 575 0 0 0 493 470 470 420 425 355 360 343 360 312.05 312.05 274 280.85 257.35 257.35 197 198.75 182 185.95 137 150.75 120.25 129 90.7 101.25 91.85 91.85 57 66.6 Much easier to give us the ?dput output so we can construct this! How do I multiply only the close of every row using the 'apply' function? And once multiplied how do I obtain a new table that also contains the new 2*CLOSE column (without cbind?). Guessing here... but why do you want to use apply? Isn't df$new.col - df$CLOSE * 2 what you want? 2) Also, how do I run a generic function per row. Say for example I want to calculate the Implied Volatility for each row of this data frame ( using the RMterics package). How do I do that please using the apply function? I am focusing on apply because I like the vectorisation concept in R and I do not want to use a for loop etc. Simply read ?apply to see examples. Apply works on matrices, not data.frames, so if you give it a data.frame, it will be coerced into a matrix. apply(your.data, 1, your.function) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 apply apply?!
How do I multiply only the close of every row using the 'apply' function? And once multiplied how do I obtain a new table that also contains the new 2*CLOSE column (without cbind?). You don't use apply in this case - a simple multiplication and variable assignment will do: require(tseries) foo - get.hist.quote('^GDAXI') foo[1:10, ] Open HighLow Close 1991-01-02 1375.4 1375.4 1359.1 1366.1 1991-01-03 1371.7 1374.7 1365.2 1366.7 1991-01-04 1375.4 1398.0 1375.4 1396.1 1991-01-07 1373.6 1373.6 1352.5 1358.2 1991-01-08 1350.4 1357.1 1345.5 1354.0 1991-01-09 1358.6 1380.8 1358.0 1375.2 1991-01-10 1367.9 1383.7 1363.1 1383.4 1991-01-11 1401.3 1406.4 1376.9 1382.3 1991-01-14 1354.5 1354.5 1327.8 1327.8 1991-01-15 1327.0 1330.3 1312.4 1325.6 foo$Close - foo$Close * 2 foo$Close - foo$Close * 2 foo[1:10, ] Open HighLow Close 1991-01-02 1375.4 1375.4 1359.1 2732.2 1991-01-03 1371.7 1374.7 1365.2 2733.4 1991-01-04 1375.4 1398.0 1375.4 2792.2 1991-01-07 1373.6 1373.6 1352.5 2716.4 1991-01-08 1350.4 1357.1 1345.5 2708.0 1991-01-09 1358.6 1380.8 1358.0 2750.4 1991-01-10 1367.9 1383.7 1363.1 2766.8 1991-01-11 1401.3 1406.4 1376.9 2764.6 1991-01-14 1354.5 1354.5 1327.8 2655.6 1991-01-15 1327.0 1330.3 1312.4 2651.2 2) Also, how do I run a generic function per row. Say for example I want to calculate the Implied Volatility for each row of this data frame ( using the RMterics package). How do I do that please using the apply function? I am focusing on apply because I like the vectorisation concept in R and I do not want to use a for loop etc. You can get the manual page of any R-command by either preceding it by a question mark or giving the command as an argument to the help function - specificly: ?apply help(apply) Especially the example section is useful for a jumpstart. Here is an example of computing row means: apply(foo, 1, mean) Instead of 'mean' you can insert whatever function you'd like to apply. cu Philipp -- Dr. Philipp Pagel Lehrstuhl für Genomorientierte Bioinformatik Technische Universität München Wissenschaftszentrum Weihenstephan Maximus-von-Imhof-Forum 3 85354 Freising, Germany http://webclu.bio.wzw.tum.de/~pagel/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.