Re: [R] Repeating value occurence
It is not exactly clear from your message what you want. If you want n random values holding either -1, 0 or 1, use sample(c(-1,0,1), 10, replace=TRUE) or also sample(3, 10, replace=TRUE)-2 If you want n values following the pattern -1, 0, 1, 0 as your example seems to follow, use n-10 pattern- c(-1,0,1,0) rep(pattern, ceiling(n/length(pattern)))[1:n] If you want a sequence of random real numbers between -1 and 1, use runif(10, min=-1, max=1) Here's hoping I haven't just solved your homework... Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Rustamali Manesiya Sent: donderdag 13 januari 2011 5:12 To: r-help@r-project.org Subject: [R] Repeating value occurence How can achieve this in R using seq, or rep function c(-1,0,1,0,-1,0,1,0,-1,0) The range value is between-1 and 1, and I want it such that there could be n number of points between -1 and 1 Anyone? Please help Thanks Rusty [[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] Ghost values after subsetting
I am using subset to select the data I want to use for my analysis and find that after I subset my data frame on one column I get ghost values in the other columns. here is an example: table(data$Dags) 2008/04/12 2008/04/13 2008/04/16 2008/04/17 2008/04/19 2008/05/06 103140 82187179212 68 2008/05/07 2008/05/12 2008/05/15 2008/05/25 2008/05/28 2008/05/29 2009/04/17 184308120227250150259 2009/04/18 2009/04/20 2009/04/21 2009/05/04 2009/05/15 2009/06/09 2009/06/10 246241252153366225 79 2009/06/24 2009/06/25 2009/06/26 2010/03/11 2010/04/27 2010/05/07 2010/05/08 126278297135285286275 2010/05/10 2010/05/11 2010/05/20 2010/05/21 2010/06/02 2010/07/20 2010/08/12 290 22259291381 20648 2010/08/16 2010/08/18 11 2 data10-subset(data, data$Year==2010 data$Recatpure1==1) table(data10$Dags) 2008/04/12 2008/04/13 2008/04/16 2008/04/17 2008/04/19 2008/05/06 0 0 0 0 0 0 0 2008/05/07 2008/05/12 2008/05/15 2008/05/25 2008/05/28 2008/05/29 2009/04/17 0 0 0 0 0 0 0 2009/04/18 2009/04/20 2009/04/21 2009/05/04 2009/05/15 2009/06/09 2009/06/10 0 0 0 0 0 0 0 2009/06/24 2009/06/25 2009/06/26 2010/03/11 2010/04/27 2010/05/07 2010/05/08 0 0 0 23 38 20 29 2010/05/10 2010/05/11 2010/05/20 2010/05/21 2010/06/02 2010/07/20 2010/08/12 18 1 15 45 38 1 5 2010/08/16 2010/08/18 0 0 How can I perform a subset so that these ghost values do not appear at all in my new table? [[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] Method dispatch for function call operator?
Dear R gurus, I am trying to create a nicer API interface for some R modules I have written. Here, I heavily rely on S3 method dispatch mechanics and makeActiveBinding() function I have discovered that I apparently can't dispatch on function call operator (). While .Primitive(() exists, which leads me to believe that things like x(...) are internally translated to .Primitive(()(x, ...), I can't seem to do something like: x - integer() class(x) - testclass (.testclass - function(o, x, y) print(paste(x, y)) x(1, 2) Similar code does work for other operators like [. A workaround I have discovered is to make x a function from the beginning and then extend the functionality by via S3 methods. Unfortunately, it does not allow me to do something I'd really like to - use syntax like this: x(...) - y For this, I'd need to dispatch on something like (-.testclass - function(x, arglist, value) Currently, I am using the index operator for this (i.e. x[...] - y) - it works nicely, but I'd prefer the () syntax, if possible. Does anyone know a way to do this? -- View this message in context: http://r.789695.n4.nabble.com/Method-dispatch-for-function-call-operator-tp3215381p3215381.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] add a linear regression line to the plot
Dear R users, I am a new R user. My problem is very simple: I want to add a linear regression line to the plot(type=p), codes are as below: x-c(10,20,40,80) y-c(30,40,100,200) plot(x,y,type=p) lines(lm(x~y),col=red,lwd=1.5) I got only plot without linear line. Many thanks ahead for your advice! Xipei Wang E-mail:wangxi...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] add a linear regression line to the plot
Dear R users, I am a new R user. My problem is very simple: I want to add a linear regression line to the plot(type=p), codes are as below: x-c(10,20,40,80) y-c(30,40,100,200) plot(x,y,type=p) lines(lm(x~y),col=red,lwd=1.5) I got only plot without linear line. Many thanks ahead for your advice! Xipei Wang [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to disable using enter key to exit the browser in debugging mode
Thanks for this. I am an Emacs user but still having this problem with ESS. Curious to know how other editors manage this. Feng On Thu, Jan 13, 2011 at 1:29 AM, Gene Leynes gleyne...@gmail.comgleynes%...@gmail.com wrote: That also drives me crazy! I don't have that problem when I use the StatEt plug-in for Eclipse. Of course, using a new IDE is a big undertaking, but I can assure you: it's worth it! This is just one small benefit. On Wed, Jan 12, 2011 at 4:00 PM, Feng Li m...@feng.li wrote: Dear R, How can I disable using enter key to exit the browser() in debug mode? I would love to have this option because it is so annoying to jump out of the debugging mode unexpectedly when I don't want to. I guess some of us have encouraged at least one of these situations, 1, Accidentally pressed the enter key within the browser. 2, Copy and paste a piece of debugging code containing empty lines to the prompt within the debugging mode. 3, If I paste a piece of code to the prompt to debug as follows, it will eventually jump out before I can do anything. ### copy starting from this line ## test - function() { x- 5 browser() y-4 } test() end of copy at this line Any suggestions are most welcome! Feng -- Feng Li Department of Statistics Stockholm University 106 91 Stockholm, Sweden http://feng.li/ [[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. -- Feng Li Department of Statistics Stockholm University 106 91 Stockholm, Sweden http://feng.li/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] add a linear regression line to the plot
Such things are very easy with the ggplot2 package install.packages(ggplot2) library(ggplot2) Dataset - data.frame(A = c(10,20,40,80), B = c(30,40,100,200)) ggplot(data = Dataset, aes(x = A, y = B)) + geom_point() + geom_smooth(method = lm) More info and example on the ggplot2 website: http://had.co.nz/ggplot2/ Best regards, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie Kwaliteitszorg Gaverstraat 4 9500 Geraardsbergen Belgium Research Institute for Nature and Forest team Biometrics Quality Assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens wangxipei Verzonden: donderdag 13 januari 2011 9:35 Aan: r-help Onderwerp: [R] add a linear regression line to the plot Dear R users, I am a new R user. My problem is very simple: I want to add a linear regression line to the plot(type=p), codes are as below: x-c(10,20,40,80) y-c(30,40,100,200) plot(x,y,type=p) lines(lm(x~y),col=red,lwd=1.5) I got only plot without linear line. Many thanks ahead for your advice! Xipei Wang E-mail:wangxi...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] add a linear regression line to the plot
On Thu, 13-Jan-2011 at 04:35PM +0800, wangxipei wrote: | | Dear R users, |I am a new R user. My problem is very simple: I want to add a linear regression line to the plot(type=p), codes are as below: | | x-c(10,20,40,80) | y-c(30,40,100,200) | plot(x,y,type=p) | lines(lm(x~y),col=red,lwd=1.5) | | I got only plot without linear line. | Many thanks ahead for your advice! What about if you tried lines(lm(y~x),col=red,lwd=1.5) My guess is that would be more likely to work. -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Average minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) . Eleanor Roosevelt ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] using Smolyak to genarate intervals
Hello I am running a program from value intervals for a set of variables. I thought I could use Smolyak to get my intervals adding points as I need them , so instead of running the program for a whole interval I would run only for the most important points. I am new to Smolyak algorithm though, and I can not understand how can i use smolyak.quad(d,k), to solve my problem. Anybody can give me some lights? -- View this message in context: http://r.789695.n4.nabble.com/using-Smolyak-to-genarate-intervals-tp3215484p3215484.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] Don´t know what test i have to use
Thanks for the advice, I will use next years. Till know i´ve just got data for 3 independent months and one of the months it´s the joining for all the summer because of the small sample size, so, I suppose, I can't use it in the way you say. - Mario Garrido Escudero PhD student Dpto. de Biología Animal, Ecología, Parasitología, Edafología y Qca. Agrícola Universidad de Salamanca -- View this message in context: http://r.789695.n4.nabble.com/Don-t-know-what-test-i-have-to-use-tp3214491p3215456.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] Method dispatch for function call operator?
On 11-01-13 3:09 AM, Taras Zakharko wrote: Dear R gurus, I am trying to create a nicer API interface for some R modules I have written. Here, I heavily rely on S3 method dispatch mechanics and makeActiveBinding() function I have discovered that I apparently can't dispatch on function call operator (). While .Primitive(() exists, which leads me to believe that things like x(...) are internally translated to .Primitive(()(x, ...), I can't seem to do something like: The ( function is not a function call operator. It's essentially a no-op. I believe its only purpose is to help in deparsing, so that things like (x + y) would deparse in the same way as entered. x- integer() class(x)- testclass (.testclass- function(o, x, y) print(paste(x, y)) x(1, 2) Similar code does work for other operators like [. A workaround I have discovered is to make x a function from the beginning and then extend the functionality by via S3 methods. Unfortunately, it does not allow me to do something I'd really like to - use syntax like this: x(...)- y You can use this syntax by defining a function `x-` - function(...) {} and it could be an S3 method, but it is a completely separate object from x. Duncan Murdoch For this, I'd need to dispatch on something like (-.testclass- function(x, arglist, value) Currently, I am using the index operator for this (i.e. x[...]- y) - it works nicely, but I'd prefer the () syntax, if possible. Does anyone know a way to do this? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Method dispatch for function call operator?
The details here are much more appropriate for R-devel, but please check the help pages for ( and [, and note - [ is generic and ( is not. - the primitive `(` is used to implement constructions such as (x - pi) and not x(...). The special handling of operators such as [ is part of the parser, and you are guessing incorrectly how function calls are parsed. (Note to Duncan Murdoch whose reply came in whilst I was writig this: ( is essentially a no-op, but it does turn visibility on, something often used with assignments.) On Thu, 13 Jan 2011, Taras Zakharko wrote: Dear R gurus, I am trying to create a nicer API interface for some R modules I have written. Here, I heavily rely on S3 method dispatch mechanics and makeActiveBinding() function I have discovered that I apparently can't dispatch on function call operator (). While .Primitive(() exists, which leads me to believe that things like x(...) are internally translated to .Primitive(()(x, ...), I can't seem to do something like: x - integer() class(x) - testclass (.testclass - function(o, x, y) print(paste(x, y)) x(1, 2) Similar code does work for other operators like [. A workaround I have discovered is to make x a function from the beginning and then extend the functionality by via S3 methods. Unfortunately, it does not allow me to do something I'd really like to - use syntax like this: x(...) - y For this, I'd need to dispatch on something like (-.testclass - function(x, arglist, value) Currently, I am using the index operator for this (i.e. x[...] - y) - it works nicely, but I'd prefer the () syntax, if possible. Does anyone know a way to do this? -- View this message in context: http://r.789695.n4.nabble.com/Method-dispatch-for-function-call-operator-tp3215381p3215381.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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] add a linear regression line to the plot
?abline On Thu, Jan 13, 2011 at 12:29 AM, wo bellew...@163.com wrote: Dear R users, I am a new R user. My problem is very simple: I want to add a linear regression line to the plot(type=p), codes are as below: x-c(10,20,40,80) y-c(30,40,100,200) plot(x,y,type=p) lines(lm(x~y),col=red,lwd=1.5) I got only plot without linear line. Many thanks ahead for your advice! Xipei Wang [[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] Ghost values after subsetting
Hi Jacob, You don't give us enough information to answer your question. Specifically, what is your dataframe? str(data) would be helpful (and calling your data data is not usually wise). My guess is that Dags is actually a factor -- do you want it to be a factor? -- and so you are retaining all of the levels. You need to think about how you are getting the data into R, whether you want a factor for that column, and whether you should drop the unused levels. Reading the help for factor may be enlightening. Sarah On Thu, Jan 13, 2011 at 3:57 AM, Jacob Kasper jacobkas...@gmail.com wrote: I am using subset to select the data I want to use for my analysis and find that after I subset my data frame on one column I get ghost values in the other columns. here is an example: table(data$Dags) 2008/04/12 2008/04/13 2008/04/16 2008/04/17 2008/04/19 2008/05/06 103 140 82 187 179 212 68 2008/05/07 2008/05/12 2008/05/15 2008/05/25 2008/05/28 2008/05/29 2009/04/17 184 308 120 227 250 150 259 2009/04/18 2009/04/20 2009/04/21 2009/05/04 2009/05/15 2009/06/09 2009/06/10 246 241 252 153 366 225 79 2009/06/24 2009/06/25 2009/06/26 2010/03/11 2010/04/27 2010/05/07 2010/05/08 126 278 297 135 285 286 275 2010/05/10 2010/05/11 2010/05/20 2010/05/21 2010/06/02 2010/07/20 2010/08/12 290 22 259 291 381 20 648 2010/08/16 2010/08/18 11 2 data10-subset(data, data$Year==2010 data$Recatpure1==1) table(data10$Dags) 2008/04/12 2008/04/13 2008/04/16 2008/04/17 2008/04/19 2008/05/06 0 0 0 0 0 0 0 2008/05/07 2008/05/12 2008/05/15 2008/05/25 2008/05/28 2008/05/29 2009/04/17 0 0 0 0 0 0 0 2009/04/18 2009/04/20 2009/04/21 2009/05/04 2009/05/15 2009/06/09 2009/06/10 0 0 0 0 0 0 0 2009/06/24 2009/06/25 2009/06/26 2010/03/11 2010/04/27 2010/05/07 2010/05/08 0 0 0 23 38 20 29 2010/05/10 2010/05/11 2010/05/20 2010/05/21 2010/06/02 2010/07/20 2010/08/12 18 1 15 45 38 1 5 2010/08/16 2010/08/18 0 0 How can I perform a subset so that these ghost values do not appear at all in my new table? -- 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] Ghost values after subsetting
It is a factor, thank you for pointing me in the right direction. Jacob On Thu, Jan 13, 2011 at 11:12, Sarah Goslee sarah.gos...@gmail.com wrote: Hi Jacob, You don't give us enough information to answer your question. Specifically, what is your dataframe? str(data) would be helpful (and calling your data data is not usually wise). My guess is that Dags is actually a factor -- do you want it to be a factor? -- and so you are retaining all of the levels. You need to think about how you are getting the data into R, whether you want a factor for that column, and whether you should drop the unused levels. Reading the help for factor may be enlightening. Sarah On Thu, Jan 13, 2011 at 3:57 AM, Jacob Kasper jacobkas...@gmail.com wrote: I am using subset to select the data I want to use for my analysis and find that after I subset my data frame on one column I get ghost values in the other columns. here is an example: table(data$Dags) 2008/04/12 2008/04/13 2008/04/16 2008/04/17 2008/04/19 2008/05/06 103140 82187179212 68 2008/05/07 2008/05/12 2008/05/15 2008/05/25 2008/05/28 2008/05/29 2009/04/17 184308120227250150 259 2009/04/18 2009/04/20 2009/04/21 2009/05/04 2009/05/15 2009/06/09 2009/06/10 246241252153366225 79 2009/06/24 2009/06/25 2009/06/26 2010/03/11 2010/04/27 2010/05/07 2010/05/08 126278297135285286 275 2010/05/10 2010/05/11 2010/05/20 2010/05/21 2010/06/02 2010/07/20 2010/08/12 290 22259291381 20 648 2010/08/16 2010/08/18 11 2 data10-subset(data, data$Year==2010 data$Recatpure1==1) table(data10$Dags) 2008/04/12 2008/04/13 2008/04/16 2008/04/17 2008/04/19 2008/05/06 0 0 0 0 0 0 0 2008/05/07 2008/05/12 2008/05/15 2008/05/25 2008/05/28 2008/05/29 2009/04/17 0 0 0 0 0 0 0 2009/04/18 2009/04/20 2009/04/21 2009/05/04 2009/05/15 2009/06/09 2009/06/10 0 0 0 0 0 0 0 2009/06/24 2009/06/25 2009/06/26 2010/03/11 2010/04/27 2010/05/07 2010/05/08 0 0 0 23 38 20 29 2010/05/10 2010/05/11 2010/05/20 2010/05/21 2010/06/02 2010/07/20 2010/08/12 18 1 15 45 38 1 5 2010/08/16 2010/08/18 0 0 How can I perform a subset so that these ghost values do not appear at all in my new table? -- Sarah Goslee http://www.functionaldiversity.org [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to disable using enter key to exit the browser in debugging mode
You do not mean the enter key: it is not that which exits the browser but rather a newline (which can be entered via 'return', and in other ways). This is part of the parser, and there is no way to turn it off. Somehow other experienced R users have never encountered this. But if you wish you could submit this as a 'wishlist' request to R-bugs, and if enough users support it (and especially if someone submits a high-quality patch to do this), it might be added in a future release. On Wed, 12 Jan 2011, Feng Li wrote: Dear R, How can I disable using enter key to exit the browser() in debug mode? I would love to have this option because it is so annoying to jump out of the debugging mode unexpectedly when I don't want to. I guess some of us have encouraged at least one of these situations, 1, Accidentally pressed the enter key within the browser. 2, Copy and paste a piece of debugging code containing empty lines to the prompt within the debugging mode. 3, If I paste a piece of code to the prompt to debug as follows, it will eventually jump out before I can do anything. ### copy starting from this line ## test - function() { x- 5 browser() y-4 } test() end of copy at this line Any suggestions are most welcome! Feng -- Feng Li Department of Statistics Stockholm University 106 91 Stockholm, Sweden http://feng.li/ [[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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Unexpected behaviour of write.csv - read.csv
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Assuming the following: x - data.frame(a=1:10, b=runif(10)) str(x) 'data.frame': 10 obs. of 2 variables: $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... write.csv(x, x.csv) x2 - read.csv(x.csv) str(x2) 'data.frame': 10 obs. of 3 variables: $ X: int 1 2 3 4 5 6 7 8 9 10 $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... Using the two functions write.csv and read.csv, I would assume, that the resulting data.frame x2 be identical with x, but it has an additional column X, which contains the row names of x. I know read.table and write.table which work as expected, but I would like to use a csv for data exchange reasons. I know that I can use write.csv(x, x.csv, row.names=FALSE) and it would work, but shouldn't that be the default behaviour? And if this is not compliant with csv files, shouldn't the function read.csv convert the first column into the row names? Cheers, Rainer - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0u4X8ACgkQoYgNqgF2egrLIgCeIqAevHGcOAK56qPcpNJ+vWav iF0An2pk1RsY1GLJbvdMHG7FFpx437gB =d5aG -END PGP SIGNATURE- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to disable using enter key to exit the browser in debugging mode
Thanks for Prof. Ripley explaining this to me. I totally agree with you that I can avoid this problem if I am debugging carefully enough. But it would be very convenient to have this feature for the newbies like me. I will submit this as a feature request. Feng On Thu, Jan 13, 2011 at 12:20 PM, Prof Brian Ripley rip...@stats.ox.ac.ukwrote: You do not mean the enter key: it is not that which exits the browser but rather a newline (which can be entered via 'return', and in other ways). This is part of the parser, and there is no way to turn it off. Somehow other experienced R users have never encountered this. But if you wish you could submit this as a 'wishlist' request to R-bugs, and if enough users support it (and especially if someone submits a high-quality patch to do this), it might be added in a future release. On Wed, 12 Jan 2011, Feng Li wrote: Dear R, How can I disable using enter key to exit the browser() in debug mode? I would love to have this option because it is so annoying to jump out of the debugging mode unexpectedly when I don't want to. I guess some of us have encouraged at least one of these situations, 1, Accidentally pressed the enter key within the browser. 2, Copy and paste a piece of debugging code containing empty lines to the prompt within the debugging mode. 3, If I paste a piece of code to the prompt to debug as follows, it will eventually jump out before I can do anything. ### copy starting from this line ## test - function() { x- 5 browser() y-4 } test() end of copy at this line Any suggestions are most welcome! Feng -- Feng Li Department of Statistics Stockholm University 106 91 Stockholm, Sweden http://feng.li/ [[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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/http://www.stats.ox.ac.uk/%7Eripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 -- Feng Li Department of Statistics Stockholm University 106 91 Stockholm, Sweden http://feng.li/ [[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] unicodepdf font problem
Hi! Sorry for the missing specs, here they are: version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 12.1 year 2010 month 12 day16 svn rev53855 language R version.string R version 2.12.1 (2010-12-16) OS: Windows 7 (English version, 32 bit) Note that \U0171 != ü. See http://www.fileformat.info/info/unicode/char/171/index.htm Anyway, I have no problem with #369; (~u) and other special Hungarian characters in my R-Gui. It is correctly displayed in the console, in plots, etc. The problem is with the pdf conversion. The same holds for my Ubuntu Hardy Heron system*, with exactly the same error messages as reported in an earlier thread http://www.mail-archive.com/r-help@r-project.org/msg89792.html As far as I know, Hershey fonts do not contain \U0171. Regards, Denes * The specs of Ubuntu: version _ platform x86_64-pc-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 12.0 year 2010 month 10 day15 svn rev53317 language R version.string R version 2.12.0 (2010-10-15) On Jan 12, 2011, at 11:11 PM, tde...@cogpsyphy.hu wrote: Dear List, I would like to print a plot into pdf. The problem is that the character \U0171 is replaced by a simple 'u' (i.e. without accents) in the pdf file. Example: # this works fine plot(1,type=n) text(1,1,print \U0171) # this fails pdf(trial.pdf) plot(1,type=n) text(1,1,print \U0171) dev.off() Have you tried: pdf(trial.pdf) plot(1,type=n) text(1,1,print ü) dev.off() Your default screen fonts may not be the same as your default pdf fonts. A lot depends on system specifics, none of which have you provided. I found an earlier post at http://www.mail-archive.com/r-help@r-project.org/msg65541.html, but it is too hard to understand at my R-level. Any help is appreciated. 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] Method dispatch for function call operator?
Thank you both for very helpful answers. I have indeed missed the help pages about ( and now the situation is more clear. You can use this syntax by defining a function `x-` - function(...) {} and it could be an S3 method, but it is a completely separate object from x. Unfortunately, it won't work as assignment function form treats the first argument specially. My intention was to create syntactic sugar like x$metadata(condition) - newvalue instead of x$setMetadata(condition, value=newvalue) I know that metadata(x, condition) - newvalue would work, but I would like to avoid that particular syntax for a number of reasons. Well, you can't have everything, I guess. I'll just stick to the [] operator. Thanks again for the clarification! -- View this message in context: http://r.789695.n4.nabble.com/Method-dispatch-for-function-call-operator-tp3215381p3215590.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] Memory leak shen using foreach()
Dear list, I am using the foreach/doSNOW packages to loop faster over some hundreds of gzipped files, each of about 1mb zipped, around 10mb unzipped. This is the loop I've written: cl.tmp - makeCluster(rep(localhost, 4), type=SOCK) registerDoSNOW(cl.tmp) output - foreach(f=dir(rec=T)) %dopar% { load(f) # do a bunch of operations on the file's data frame save( data, file = f, compress=T) rm( bunch of objects) gc() } stopCluster(cl.tmp) While this works, it eats away all the pc's memory as if it does not discard the data after each iteration of the loop is finished. The pagefile usage drops to normal when the stopCluster() command is executed. Does anyone have an idea where this leak's coming from, and a remedy? Thanks in advance! Vassilis -- View this message in context: http://r.789695.n4.nabble.com/Memory-leak-shen-using-foreach-tp3215612p3215612.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] Weighted Optimization
You will have to modify your likelihood in such a way that it also includes the weights. If your likelihood has the following form: l = sum(log p_i) you could for example add the weights to the likelihood: lw = sum(w_i * log p_i) (although I am not sure that this is the correct way to add the weights in your case) Therefore, you will have to change your functions negllh and se to also accepts the weights as input parameters: negllh - function([PARAMETERS YOU HAVE ALREADY HERE], weights, ...) }{ ... } se - function([PARAMETERS YOU HAVE ALREADY HERE], weights, ...) { ... } You can then call optim adding weights as additional parameter which gets passed on to negllh and se: gh.fit = try(optim(vega, negllh,hessian = se,pdf = gh.pdf, tmp.data = data, transf = transform, const.pars = vars[!opt.pars], silent = silent, par.names = names(vars), weights = w, ...)) HTH, Jan Quoting JASON SCALLY j.sca...@student.qut.edu.au: Hi All, I am trying to code an R script which gives me the time varying parameters of the NIG and GH distributions. Further, becasue I think these these time varying parameters should be more responsive to more recent observations, I would like to include a weighted likelihood estimation proceedure where the observations have an exponentially decaying weighting rather than the equal weighting implied by a standard MLE approach. The optimization function which leads to my parameter estimates is given by; gh.fit = try(optim(vega, negllh,hessian = se,pdf = gh.pdf, tmp.data = data, transf = transform, const.pars = vars[!opt.pars], silent = silent, par.names = names(vars), ...)) param.est = gh.fit$par In the above, vega are the parameters to estimate and pdf is the GH pdf. This seems to work well for the case where observations are equally weighted. However, I'm stuck on how to include a weighted vector (w_i) to turn this problem into a weighted ML optimization. Would you please be able to suggest a function or change in code which may allow me to do this? Thank you in advance for your time. Jason __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Contour plot with time on both X-axis (day) and on Y-axis (hours)
Hello all, I'd like to graphically represent an hourly temperature timeseries ( http://r.789695.n4.nabble.com/file/n3215785/data.csv data.csv , and see below for pre-process of the data) with the R functions image + contour. To do that I wrote that script : http://r.789695.n4.nabble.com/file/n3215785/Timetemp.r Timetemp.r , which basically : - creates the x-axis, a vector which will contain the days, - creates the y-axis, a vector which will contain the hours of the day, - creates the z-matrix, which has x columns and y rows, - plots the image+contour graph of the x-y-z dataset. This works fine, except that I have some troubles with the time format : I can't set a date (day/month/year) to the x-axis of the resulting graph. Does anyone knows where the pb is ? Thanks ! xav ||| Pre-process of data.csv: data - na.omit(read.csv(data.csv, header = T, sep = ,, dec = .)) data - data[,-1] data[[1]] - strptime(data[[1]], %m/%d/%y %I:%M:%S %p, tz = America/Santiago) -- View this message in context: http://r.789695.n4.nabble.com/Contour-plot-with-time-on-both-X-axis-day-and-on-Y-axis-hours-tp3215785p3215785.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] add a linear regression line to the plot
Hi, lines(lm(x~y),col=red,lwd=1.5) should be abline(lm(y~x),col=red,lwd=1.5) hth. Am 13.01.2011 09:35, schrieb wangxipei: Dear R users, I am a new R user. My problem is very simple: I want to add a linear regression line to the plot(type=p), codes are as below: x-c(10,20,40,80) y-c(30,40,100,200) plot(x,y,type=p) lines(lm(x~y),col=red,lwd=1.5) I got only plot without linear line. Many thanks ahead for your advice! Xipei Wang E-mail:wangxi...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Eik Vettorazzi Department of Medical Biometry and Epidemiology University Medical Center Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Unexpected behaviour of write.csv - read.csv
On 11-01-13 6:26 AM, Rainer M Krug wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Assuming the following: x- data.frame(a=1:10, b=runif(10)) str(x) 'data.frame': 10 obs. of 2 variables: $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... write.csv(x, x.csv) x2- read.csv(x.csv) str(x2) 'data.frame': 10 obs. of 3 variables: $ X: int 1 2 3 4 5 6 7 8 9 10 $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... Using the two functions write.csv and read.csv, I would assume, that the resulting data.frame x2 be identical with x, but it has an additional column X, which contains the row names of x. I know read.table and write.table which work as expected, but I would like to use a csv for data exchange reasons. I know that I can use write.csv(x, x.csv, row.names=FALSE) and it would work, but shouldn't that be the default behaviour? I don't think so. The CSV format is an export format which holds less information than a dataframe. By exporting the dataframe to CSV and importing the result, you are discarding information and you should expect to get something different. If you want to save a dataframe to disk and read it back unchanged, you should use save() and load(). Duncan Murdoch And if this is not compliant with csv files, shouldn't the function read.csv convert the first column into the row names? Cheers, Rainer - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0u4X8ACgkQoYgNqgF2egrLIgCeIqAevHGcOAK56qPcpNJ+vWav iF0An2pk1RsY1GLJbvdMHG7FFpx437gB =d5aG -END PGP SIGNATURE- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Unexpected behaviour of write.csv - read.csv
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/13/2011 02:56 PM, Duncan Murdoch wrote: On 11-01-13 6:26 AM, Rainer M Krug wrote: Hi Assuming the following: x- data.frame(a=1:10, b=runif(10)) str(x) 'data.frame':10 obs. of 2 variables: $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... write.csv(x, x.csv) x2- read.csv(x.csv) str(x2) 'data.frame':10 obs. of 3 variables: $ X: int 1 2 3 4 5 6 7 8 9 10 $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... Using the two functions write.csv and read.csv, I would assume, that the resulting data.frame x2 be identical with x, but it has an additional column X, which contains the row names of x. I know read.table and write.table which work as expected, but I would like to use a csv for data exchange reasons. I know that I can use write.csv(x, x.csv, row.names=FALSE) and it would work, but shouldn't that be the default behaviour? I don't think so. The CSV format is an export format which holds less information than a dataframe. By exporting the dataframe to CSV and importing the result, you are discarding information and you should expect to get something different. OK - I can follow this logic - and I think I can accept it. If you want to save a dataframe to disk and read it back unchanged, you should use save() and load(). And now my question from a previous thread (write.table equivalent for lists?) comes up again: using save() and load() definitely works, but it is highly unsave - as it even keeps the names of the object, more then one can be saved, I can not easily assign the saved object to a new name, I have problems using the saved object if I have forgotten what the variable name was. So I would like to expand my previous question: what are the proper functions to store R objects? One could argue that all write... functions are export functions - therefore keeping the data, but not necessarily column names, rownames, attributes, ... So what can I really do to save an R object for later usage in R? Rainer Duncan Murdoch And if this is not compliant with csv files, shouldn't the function read.csv convert the first column into the row names? Cheers, Rainer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0vB2oACgkQoYgNqgF2egqenQCeJJNdIiX2faKBPGeilzOz73wM RmoAn05oGZvo41wCp1+hWwTqTmNoQrNo =xfWD -END PGP SIGNATURE- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Unexpected behaviour of write.csv - read.csv
Hi, I thought this was already clear from the replies to your previous post: - save/load - saveObject/loadObject from R.utils - dput/dget (I don't remember who proposed it sorry) There might be more possibilities, but that should do what you're looking for. And you should already know how each of them work and therefore the pros and cons. HTH, Ivan Le 1/13/2011 15:08, Rainer M Krug a écrit : -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/13/2011 02:56 PM, Duncan Murdoch wrote: On 11-01-13 6:26 AM, Rainer M Krug wrote: Hi Assuming the following: x- data.frame(a=1:10, b=runif(10)) str(x) 'data.frame':10 obs. of 2 variables: $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... write.csv(x, x.csv) x2- read.csv(x.csv) str(x2) 'data.frame':10 obs. of 3 variables: $ X: int 1 2 3 4 5 6 7 8 9 10 $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... Using the two functions write.csv and read.csv, I would assume, that the resulting data.frame x2 be identical with x, but it has an additional column X, which contains the row names of x. I know read.table and write.table which work as expected, but I would like to use a csv for data exchange reasons. I know that I can use write.csv(x, x.csv, row.names=FALSE) and it would work, but shouldn't that be the default behaviour? I don't think so. The CSV format is an export format which holds less information than a dataframe. By exporting the dataframe to CSV and importing the result, you are discarding information and you should expect to get something different. OK - I can follow this logic - and I think I can accept it. If you want to save a dataframe to disk and read it back unchanged, you should use save() and load(). And now my question from a previous thread (write.table equivalent for lists?) comes up again: using save() and load() definitely works, but it is highly unsave - as it even keeps the names of the object, more then one can be saved, I can not easily assign the saved object to a new name, I have problems using the saved object if I have forgotten what the variable name was. So I would like to expand my previous question: what are the proper functions to store R objects? One could argue that all write... functions are export functions - therefore keeping the data, but not necessarily column names, rownames, attributes, ... So what can I really do to save an R object for later usage in R? Rainer Duncan Murdoch And if this is not compliant with csv files, shouldn't the function read.csv convert the first column into the row names? Cheers, Rainer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0vB2oACgkQoYgNqgF2egqenQCeJJNdIiX2faKBPGeilzOz73wM RmoAn05oGZvo41wCp1+hWwTqTmNoQrNo =xfWD -END PGP SIGNATURE- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. Säugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] unicodepdf font problem
On Jan 13, 2011, at 7:01 AM, tde...@cogpsyphy.hu wrote: Hi! Sorry for the missing specs, here they are: version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 12.1 year 2010 month 12 day16 svn rev53855 language R version.string R version 2.12.1 (2010-12-16) OS: Windows 7 (English version, 32 bit) You are after what Adobe calls: udblacute; 0171. It is recognized in the list of adobe glyphs: str(tools::Adobe_glyphs[371, ]) 'data.frame': 1 obs. of 2 variables: $ adobe : chr udblacute $ unicode: chr 0171 Consulted the help pages points {graphics} postscript {grDevices} pdf {grDevices} charsets {tools} postscriptFonts {grDevices} I have tried a variety of the pdfFonts installed on my Mac without success. You can perhaps make a list of fonts on your machines with names(pdfFonts()). Perhaps the range of fonts and the glyphs they contain is different on your machines. I get consistently warning messages saying there is a conversion failure: pdf(trial.pdf, family=Helvetica) # also tried with font=Helvetica but I think that is erroneous plot(1,type=n) text(1,1,print \U0170\U0171) Warning messages: 1: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for c5 2: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for b0 3: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for c5 4: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for b1 5: In text.default(1, 1, print Űű) : font metrics unknown for Unicode character U+0170 6: In text.default(1, 1, print Űű) : font metrics unknown for Unicode character U+0171 7: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for c5 8: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for b0 9: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for c5 10: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for b1 And this is despite my system saying the \U0170 and \U0171 are present in the Helvetica font. Also tried family=URWHelvetica and family=NimbusSanand and a bunch of others without success, but my last best hope after reading the material in help(postscript) in the Families section had been NimbusSan. There is also information on that page regarding encodings that appears to be very machine specific. Note that \U0171 != ü. See http://www.fileformat.info/info/unicode/char/171/index.htm Anyway, I have no problem with #369; (~u) and other special Hungarian characters in my R-Gui. It is correctly displayed in the console, in plots, etc. The problem is with the pdf conversion. The same holds for my Ubuntu Hardy Heron system*, with exactly the same error messages as reported in an earlier thread http://www.mail-archive.com/r-help@r-project.org/msg89792.html As far as I know, Hershey fonts do not contain \U0171. Regards, Denes * The specs of Ubuntu: version _ platform x86_64-pc-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 12.0 year 2010 month 10 day15 svn rev53317 language R version.string R version 2.12.0 (2010-10-15) On Jan 12, 2011, at 11:11 PM, tde...@cogpsyphy.hu wrote: Dear List, I would like to print a plot into pdf. The problem is that the character \U0171 is replaced by a simple 'u' (i.e. without accents) in the pdf file. Example: # this works fine plot(1,type=n) text(1,1,print \U0171) # this fails pdf(trial.pdf) plot(1,type=n) text(1,1,print \U0171) dev.off() Have you tried: pdf(trial.pdf) plot(1,type=n) text(1,1,print ü) dev.off() Your default screen fonts may not be the same as your default pdf fonts. A lot depends on system specifics, none of which have you provided. I found an earlier post at http://www.mail-archive.com/r-help@r-project.org/msg65541.html, but it is too hard to understand at my R-level. Any help is appreciated. David Winsemius, MD West Hartford, CT 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] s3 methods on S4 objects
On 01/12/2011 10:54 PM, steven mosher wrote: I have J Chambers wonderful text ( Software for data Analysis) and I've been trying my hand at some very routine S4 OOP development. One of the things I was trying to do was to create some very basic S4 classes. The first was simply a class that had a data.frame as part of its representation. setClass(df,representation(dirframe=data.frame)) The object basically contains a data.frame that represents a file directory listing with a column named filename, size, time, etc. And then I have methods for doing various things with this object. I then tried to tackle the problem of coercing this S4 object to a data.frame. Again just a learning exercise. The goal would be able to make a call like this testFrame - as.data.frame(x) where x, was an object of class df If I try to define as.data.frame as a S4 method, then I can make it work, but I then destroy the S3 functionality of as.data.frame, so that if I were to try to coerce a matrix to a data.frame it would work. Hi Steven -- This works for me setClass(A, representation=representation(df=data.frame)) setMethod(as.data.frame, A, function(x, row.names=NULL, optional=FALSE, ...) { ## implementation, e.g., callGeneric(x@df, row.names=row.names, optional=optional, ...) }) as.data.frame(new(A)) Object of class data.frame data frame with 0 columns and 0 rows as.data.frame(matrix(0, 3, 5)) V1 V2 V3 V4 V5 1 0 0 0 0 0 2 0 0 0 0 0 3 0 0 0 0 0 Maybe you call setGeneric (no need to, setMethod will promote as.data.frame automatically) in a way that does not specify the default (arg useAsDefault) correctly? Martin So, I guess my question is what do I do, write an s3 method for as.data.frame that takes a df object as a paramter? The book wasn't exactly clear ( or I'm not that bright), or is there a way to make the S4 method I wrote as.data.frame call the S3 method if needed? [[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. -- Computational Biology Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: M1-B861 Telephone: 206 667-2793 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 Smolyak to genarate intervals
On Jan 13, 2011, at 4:27 AM, laleluia wrote: Hello I am running a program from value intervals for a set of variables. I thought I could use Smolyak to get my intervals adding points as I need them , so instead of running the program for a whole interval I would run only for the most important points. I am new to Smolyak algorithm though, and I can not understand how can i use smolyak.quad(d,k), to solve my problem. Anybody can give me some lights? You've been posting this 4 times on an almost daily basis. Either no one knows what the Smolyak algorithm is (and I certainly don't) or they think that the lack of any programming code or even reference to a particular R package makes any comment too speculative to be useful. Please read the Posting Guide regading the recommended items that might increase the chances of success in snagging someone with a shared interest. -- 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] unicodepdf font problem RESOLVED
Dear David, Thank you for your efforts. Inspired by your remarks, I started a new google-search and found this: http://stackoverflow.com/questions/3434349/sweave-not-printing-localized-characters SO HERE COMES THE SOLUTION (it works on both OSs): pdf.options(encoding = CP1250) pdf() plot(1,type=n) text(1,1,\U0171) dev.off() CP1250 should work for all Central-European languages: http://en.wikipedia.org/wiki/Windows-1250 Thank you again, Denes On Jan 13, 2011, at 7:01 AM, tde...@cogpsyphy.hu wrote: Hi! Sorry for the missing specs, here they are: version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 12.1 year 2010 month 12 day16 svn rev53855 language R version.string R version 2.12.1 (2010-12-16) OS: Windows 7 (English version, 32 bit) You are after what Adobe calls: udblacute; 0171. It is recognized in the list of adobe glyphs: str(tools::Adobe_glyphs[371, ]) 'data.frame': 1 obs. of 2 variables: $ adobe : chr udblacute $ unicode: chr 0171 Consulted the help pages points {graphics} postscript {grDevices} pdf {grDevices} charsets {tools} postscriptFonts {grDevices} I have tried a variety of the pdfFonts installed on my Mac without success. You can perhaps make a list of fonts on your machines with names(pdfFonts()). Perhaps the range of fonts and the glyphs they contain is different on your machines. I get consistently warning messages saying there is a conversion failure: pdf(trial.pdf, family=Helvetica) # also tried with font=Helvetica but I think that is erroneous plot(1,type=n) text(1,1,print \U0170\U0171) Warning messages: 1: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for c5 2: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for b0 3: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for c5 4: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for b1 5: In text.default(1, 1, print Űű) : font metrics unknown for Unicode character U+0170 6: In text.default(1, 1, print Űű) : font metrics unknown for Unicode character U+0171 7: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for c5 8: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for b0 9: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for c5 10: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for b1 And this is despite my system saying the \U0170 and \U0171 are present in the Helvetica font. Also tried family=URWHelvetica and family=NimbusSanand and a bunch of others without success, but my last best hope after reading the material in help(postscript) in the Families section had been NimbusSan. There is also information on that page regarding encodings that appears to be very machine specific. Note that \U0171 != ü. See http://www.fileformat.info/info/unicode/char/171/index.htm Anyway, I have no problem with #369; (~u) and other special Hungarian characters in my R-Gui. It is correctly displayed in the console, in plots, etc. The problem is with the pdf conversion. The same holds for my Ubuntu Hardy Heron system*, with exactly the same error messages as reported in an earlier thread http://www.mail-archive.com/r-help@r-project.org/msg89792.html As far as I know, Hershey fonts do not contain \U0171. Regards, Denes * The specs of Ubuntu: version _ platform x86_64-pc-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 12.0 year 2010 month 10 day15 svn rev53317 language R version.string R version 2.12.0 (2010-10-15) On Jan 12, 2011, at 11:11 PM, tde...@cogpsyphy.hu wrote: Dear List, I would like to print a plot into pdf. The problem is that the character \U0171 is replaced by a simple 'u' (i.e. without accents) in the pdf file. Example: # this works fine plot(1,type=n) text(1,1,print \U0171) # this fails pdf(trial.pdf) plot(1,type=n) text(1,1,print \U0171) dev.off() Have you tried: pdf(trial.pdf) plot(1,type=n) text(1,1,print ü) dev.off() Your default screen fonts may not be the same as your default pdf fonts. A lot depends on system specifics, none of which have you provided. I found an earlier post at http://www.mail-archive.com/r-help@r-project.org/msg65541.html, but it is too hard to understand at
[R] how to calculate the consistency of different clusterings
Dear R-listers, I do clustering on tens of individuals by thousands of traits. I have known the assignment of each individual. I want to classify the individuals by randomly resampling different subsets of the traits, for example, randomly resampling 100 traits for 100 times, then 200 traits for 100 times, then 300 traits for 100 times, ,,. By each subset of traits, I do clustering of the same individuals. In the end, I want to get the consistency (in percentage) of each of these clusterings (as examples, here cluster.1, cluster.2 and cluster.3 in the dummy data) with the assignment which is already known (populations in the dummy data). I want to know how such work can be implemented, maybe by using R. #dummy data, clus.data - data.frame(individual = paste(ind, 1:12, sep = ), populations = c(rep(popA, 5), rep(popB, 7)), cluster.1 = c(rep(1, 5), rep(2, 7)), cluster.2 = c(rep(2, 4), rep(1, 8)), cluster.3 = c(rep(4, 7), rep(5, 5))) clus.data Thanks. -- Jian-Feng, Mao the Institute of Botany, Chinese Academy of Botany, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] unicodepdf font problem RESOLVED
I have many German umlauts in my data sets and code them UTF-8. When it comes to plotting on pdf, I figured out that CP1257 is a good choice to output Umlauts. I have no experiences with CP1250, but maybe this small hint helps: pdf(file=paste(sharepath, /filename.pdf, sep=), 9, 6, pointsize = 11, family = Helvetica, encoding = CP1257) *S* On 11-01-13 16:17, tde...@cogpsyphy.hu wrote: Date: Thu, 13 Jan 2011 16:17:04 +0100 (CET) From: tde...@cogpsyphy.hu To: David Winsemius dwinsem...@comcast.net Cc: r-help@r-project.org Subject: Re: [R] unicodepdf font problem RESOLVED Dear David, Thank you for your efforts. Inspired by your remarks, I started a new google-search and found this: http://stackoverflow.com/questions/3434349/sweave-not-printing-localized-characters SO HERE COMES THE SOLUTION (it works on both OSs): pdf.options(encoding = CP1250) pdf() plot(1,type=n) text(1,1,\U0171) dev.off() CP1250 should work for all Central-European languages: http://en.wikipedia.org/wiki/Windows-1250 Thank you again, Denes On Jan 13, 2011, at 7:01 AM, tde...@cogpsyphy.hu wrote: Hi! Sorry for the missing specs, here they are: version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 12.1 year 2010 month 12 day16 svn rev53855 language R version.string R version 2.12.1 (2010-12-16) OS: Windows 7 (English version, 32 bit) You are after what Adobe calls: udblacute; 0171. It is recognized in the list of adobe glyphs: str(tools::Adobe_glyphs[371, ]) 'data.frame': 1 obs. of 2 variables: $ adobe : chr udblacute $ unicode: chr 0171 Consulted the help pages points {graphics} postscript {grDevices} pdf {grDevices} charsets {tools} postscriptFonts {grDevices} I have tried a variety of the pdfFonts installed on my Mac without success. You can perhaps make a list of fonts on your machines with names(pdfFonts()). Perhaps the range of fonts and the glyphs they contain is different on your machines. I get consistently warning messages saying there is a conversion failure: pdf(trial.pdf, family=Helvetica) # also tried with font=Helvetica but I think that is erroneous plot(1,type=n) text(1,1,print \U0170\U0171) Warning messages: 1: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for c5 2: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for b0 3: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for c5 4: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for b1 5: In text.default(1, 1, print Űű) : font metrics unknown for Unicode character U+0170 6: In text.default(1, 1, print Űű) : font metrics unknown for Unicode character U+0171 7: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for c5 8: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for b0 9: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for c5 10: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for b1 And this is despite my system saying the \U0170 and \U0171 are present in the Helvetica font. Also tried family=URWHelvetica and family=NimbusSanand and a bunch of others without success, but my last best hope after reading the material in help(postscript) in the Families section had been NimbusSan. There is also information on that page regarding encodings that appears to be very machine specific. Note that \U0171 != ü. See http://www.fileformat.info/info/unicode/char/171/index.htm Anyway, I have no problem with #369; (~u) and other special Hungarian characters in my R-Gui. It is correctly displayed in the console, in plots, etc. The problem is with the pdf conversion. The same holds for my Ubuntu Hardy Heron system*, with exactly the same error messages as reported in an earlier thread http://www.mail-archive.com/r-help@r-project.org/msg89792.html As far as I know, Hershey fonts do not contain \U0171. Regards, Denes * The specs of Ubuntu: version _ platform x86_64-pc-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 12.0 year 2010 month 10 day15 svn rev53317 language R version.string R version 2.12.0 (2010-10-15) On Jan 12, 2011, at 11:11 PM, tde...@cogpsyphy.hu wrote: Dear List, I would like to print a plot into pdf. The problem is that the character \U0171 is replaced by a simple 'u' (i.e. without accents) in the pdf file. Example: # this works fine
Re: [R] unicodepdf font problem RESOLVED
Good work, Denes; Setting encodings to CP1250 in the pdf call allows the Hungarian umlaut glyph to be printed to a pdf document on Macs as well, which by the way uses a default postscript/pdf family=Helvetica. -- David. On Jan 13, 2011, at 10:17 AM, tde...@cogpsyphy.hu wrote: Dear David, Thank you for your efforts. Inspired by your remarks, I started a new google-search and found this: http://stackoverflow.com/questions/3434349/sweave-not-printing-localized-characters SO HERE COMES THE SOLUTION (it works on both OSs): pdf.options(encoding = CP1250) pdf() plot(1,type=n) text(1,1,\U0171) dev.off() CP1250 should work for all Central-European languages: http://en.wikipedia.org/wiki/Windows-1250 Thank you again, Denes On Jan 13, 2011, at 7:01 AM, tde...@cogpsyphy.hu wrote: Hi! Sorry for the missing specs, here they are: version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 12.1 year 2010 month 12 day16 svn rev53855 language R version.string R version 2.12.1 (2010-12-16) OS: Windows 7 (English version, 32 bit) You are after what Adobe calls: udblacute; 0171. It is recognized in the list of adobe glyphs: str(tools::Adobe_glyphs[371, ]) 'data.frame': 1 obs. of 2 variables: $ adobe : chr udblacute $ unicode: chr 0171 Consulted the help pages points {graphics} postscript {grDevices} pdf {grDevices} charsets {tools} postscriptFonts {grDevices} I have tried a variety of the pdfFonts installed on my Mac without success. You can perhaps make a list of fonts on your machines with names(pdfFonts()). Perhaps the range of fonts and the glyphs they contain is different on your machines. I get consistently warning messages saying there is a conversion failure: pdf(trial.pdf, family=Helvetica) # also tried with font=Helvetica but I think that is erroneous plot(1,type=n) text(1,1,print \U0170\U0171) Warning messages: 1: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for c5 2: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for b0 3: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for c5 4: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for b1 5: In text.default(1, 1, print Űű) : font metrics unknown for Unicode character U+0170 6: In text.default(1, 1, print Űű) : font metrics unknown for Unicode character U+0171 7: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for c5 8: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for b0 9: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for c5 10: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for b1 And this is despite my system saying the \U0170 and \U0171 are present in the Helvetica font. Also tried family=URWHelvetica and family=NimbusSanand and a bunch of others without success, but my last best hope after reading the material in help(postscript) in the Families section had been NimbusSan. There is also information on that page regarding encodings that appears to be very machine specific. Note that \U0171 != ü. See http://www.fileformat.info/info/unicode/char/171/index.htm Anyway, I have no problem with #369; (~u) and other special Hungarian characters in my R-Gui. It is correctly displayed in the console, in plots, etc. The problem is with the pdf conversion. The same holds for my Ubuntu Hardy Heron system*, with exactly the same error messages as reported in an earlier thread http://www.mail-archive.com/r-help@r-project.org/msg89792.html As far as I know, Hershey fonts do not contain \U0171. Regards, Denes * The specs of Ubuntu: version _ platform x86_64-pc-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 12.0 year 2010 month 10 day15 svn rev53317 language R version.string R version 2.12.0 (2010-10-15) On Jan 12, 2011, at 11:11 PM, tde...@cogpsyphy.hu wrote: Dear List, I would like to print a plot into pdf. The problem is that the character \U0171 is replaced by a simple 'u' (i.e. without accents) in the pdf file. Example: # this works fine plot(1,type=n) text(1,1,print \U0171) # this fails pdf(trial.pdf) plot(1,type=n) text(1,1,print \U0171) dev.off() Have you tried: pdf(trial.pdf) plot(1,type=n) text(1,1,print ü) dev.off() Your default screen fonts may not be the same as your default pdf fonts. A lot depends on system specifics,
Re: [R] unicodepdf font problem RESOLVED
On Jan 13, 2011, at 10:41 AM, Sascha Vieweg wrote: I have many German umlauts in my data sets and code them UTF-8. When it comes to plotting on pdf, I figured out that CP1257 is a good choice to output Umlauts. I have no experiences with CP1250, but maybe this small hint helps: pdf(file=paste(sharepath, /filename.pdf, sep=), 9, 6, pointsize = 11, family = Helvetica, encoding = CP1257) Just an FYI for the archives, that encoding fails with pdf(encoding=CP1257) on a Mac when printing that target umlaut. David. *S* On 11-01-13 16:17, tde...@cogpsyphy.hu wrote: Date: Thu, 13 Jan 2011 16:17:04 +0100 (CET) From: tde...@cogpsyphy.hu To: David Winsemius dwinsem...@comcast.net Cc: r-help@r-project.org Subject: Re: [R] unicodepdf font problem RESOLVED Dear David, Thank you for your efforts. Inspired by your remarks, I started a new google-search and found this: http://stackoverflow.com/questions/3434349/sweave-not-printing-localized-characters SO HERE COMES THE SOLUTION (it works on both OSs): pdf.options(encoding = CP1250) pdf() plot(1,type=n) text(1,1,\U0171) dev.off() CP1250 should work for all Central-European languages: http://en.wikipedia.org/wiki/Windows-1250 Thank you again, Denes On Jan 13, 2011, at 7:01 AM, tde...@cogpsyphy.hu wrote: Hi! Sorry for the missing specs, here they are: version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 12.1 year 2010 month 12 day16 svn rev53855 language R version.string R version 2.12.1 (2010-12-16) OS: Windows 7 (English version, 32 bit) You are after what Adobe calls: udblacute; 0171. It is recognized in the list of adobe glyphs: str(tools::Adobe_glyphs[371, ]) 'data.frame': 1 obs. of 2 variables: $ adobe : chr udblacute $ unicode: chr 0171 Consulted the help pages points {graphics} postscript {grDevices} pdf {grDevices} charsets {tools} postscriptFonts {grDevices} I have tried a variety of the pdfFonts installed on my Mac without success. You can perhaps make a list of fonts on your machines with names(pdfFonts()). Perhaps the range of fonts and the glyphs they contain is different on your machines. I get consistently warning messages saying there is a conversion failure: pdf(trial.pdf, family=Helvetica) # also tried with font=Helvetica but I think that is erroneous plot(1,type=n) text(1,1,print \U0170\U0171) Warning messages: 1: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for c5 2: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for b0 3: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for c5 4: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for b1 5: In text.default(1, 1, print Űű) : font metrics unknown for Unicode character U+0170 6: In text.default(1, 1, print Űű) : font metrics unknown for Unicode character U+0171 7: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for c5 8: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for b0 9: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for c5 10: In text.default(1, 1, print Űű) : conversion failure on 'print Űű' in 'mbcsToSbcs': dot substituted for b1 And this is despite my system saying the \U0170 and \U0171 are present in the Helvetica font. Also tried family=URWHelvetica and family=NimbusSanand and a bunch of others without success, but my last best hope after reading the material in help(postscript) in the Families section had been NimbusSan. There is also information on that page regarding encodings that appears to be very machine specific. Note that \U0171 != ü. See http://www.fileformat.info/info/unicode/char/171/index.htm Anyway, I have no problem with #369; (~u) and other special Hungarian characters in my R-Gui. It is correctly displayed in the console, in plots, etc. The problem is with the pdf conversion. The same holds for my Ubuntu Hardy Heron system*, with exactly the same error messages as reported in an earlier thread http://www.mail-archive.com/r-help@r-project.org/msg89792.html As far as I know, Hershey fonts do not contain \U0171. Regards, Denes * The specs of Ubuntu: version _ platform x86_64-pc-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 12.0 year 2010 month 10 day15 svn rev53317 language R version.string R version 2.12.0 (2010-10-15) On Jan 12, 2011, at 11:11 PM,
[R] setting up a genoud run
Hello - and sorry for a possibly stupid question, I'm just starting to learn rgenoud. I am defining a function with 5 parameters (p1, p2, p3, p4a, and p4b) and then want to optimize it using genoud. But I am doing something wrong. Before genoud is even able to run it says: Error in p2 + 1.2 : 'p2' is missing. I assume I did not specify it right. My code is below. The task is: I want to find those values of p1, p2, p3, p4a and p4b at which the function f1 is at its maximum. At the same time, I want the value of each of those 5 parameters to be between 0 and 1000. Thanks a lot for your advice! library(rgenoud) f1 = function(p1,p2,p3,p4b,p4a) { y = 2 + 1.5*p1 + 0.3*(p2+1.2+0.6*p4a)-1.2*p3 + 0.9*p4b return(y) } f1(p1=1,p2=2,p3=4,p4b=4,p4a=6) # seems to be working npredictors=5 genoud(f1,nvars=npredictors,max=TRUE,pop.size=1000,max.generations=100,wait.generations=10, hard.generation.limit=TRUE,starting.values=rep(500,npredictors), Domains=matrix(rep(c(0,1000),npredictors),ncol=2,byrow=T),boundary.enforcement=2) -- Dimitri Liakhovitski Ninah Consulting __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] speed up subsetting with certain conditions
On 1/12/11 6:44 PM, Duke wrote: Thanks so much for your suggestion Martin. I had Bioconductor installed but I honestly do not know all its applications. Anyway, I am testing GenomicRanges with my data now. I will report back when I get the result. I got the results. My code took ~ 580 min ( ~ 10 hrs) to finish, where as using GenomicRanges per Martin suggested, it took only 22 min (about 30 times less!). Thanks so much for this improvement Martin. D. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rotated, Right-Justified Labels for Shortened Tick Marks
Jim, This was the solution I was hoping to avoid having to implement... but thank you it does what I was looking for visually (except for the las=1 rotation). Is there no other parameter *within* axis that I could adjust? If not, it seems like axis could be rewritten to have the axis tick label positions move in concert with the shortening tick marks... -D On Wed, Jan 12, 2011 at 10:53 PM, Jim Lemon j...@bitwrit.com.au wrote: On 01/13/2011 11:59 AM, dms wrote: Hello R-help, I'm trying to make a fairly simple plot axis that goes something like this: plot(-10:10,-10:10, yaxt='n') axis(side=2, las=1, hadj=1, tck=-.01, cex.axis=.6) ...but as you can see, the labels are not close enough to the y-axis (where I want them... to save space for publication). Can anybody help me figure out how to move these labels over the the right a bit? Hi D, Try this: plot(-10:10,-10:10, yaxt='n') axis(side=2,at=seq(-10,10,by=5),labels=rep(,5),tck=-.01) par(cex=0.6) mtext(seq(-10,10,by=5),at=seq(-10,10,by=5),side=2,line=0.3,cex=0.6) par(cex=1) 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] add a linear regression line to the plot
Hi, if it should be lines so you can do that xy.lm - lm(y~x) lines(x, xy.lm$coeff[1] + x*xy.lm$coeff[2], col=blue, lwd=3) Regards ep -- View this message in context: http://r.789695.n4.nabble.com/add-a-linear-regression-line-to-the-plot-tp3215455p3216099.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] Unexpected behaviour of write.csv - read.csv
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ivan Calandra Sent: Thursday, January 13, 2011 6:44 AM To: r-help@r-project.org Subject: Re: [R] Unexpected behaviour of write.csv - read.csv Hi, I thought this was already clear from the replies to your previous post: - save/load - saveObject/loadObject from R.utils - dput/dget (I don't remember who proposed it sorry) Add serialize()/unserialize() from base. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com There might be more possibilities, but that should do what you're looking for. And you should already know how each of them work and therefore the pros and cons. HTH, Ivan Le 1/13/2011 15:08, Rainer M Krug a écrit : -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/13/2011 02:56 PM, Duncan Murdoch wrote: On 11-01-13 6:26 AM, Rainer M Krug wrote: Hi Assuming the following: x- data.frame(a=1:10, b=runif(10)) str(x) 'data.frame':10 obs. of 2 variables: $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... write.csv(x, x.csv) x2- read.csv(x.csv) str(x2) 'data.frame':10 obs. of 3 variables: $ X: int 1 2 3 4 5 6 7 8 9 10 $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... Using the two functions write.csv and read.csv, I would assume, that the resulting data.frame x2 be identical with x, but it has an additional column X, which contains the row names of x. I know read.table and write.table which work as expected, but I would like to use a csv for data exchange reasons. I know that I can use write.csv(x, x.csv, row.names=FALSE) and it would work, but shouldn't that be the default behaviour? I don't think so. The CSV format is an export format which holds less information than a dataframe. By exporting the dataframe to CSV and importing the result, you are discarding information and you should expect to get something different. OK - I can follow this logic - and I think I can accept it. If you want to save a dataframe to disk and read it back unchanged, you should use save() and load(). And now my question from a previous thread (write.table equivalent for lists?) comes up again: using save() and load() definitely works, but it is highly unsave - as it even keeps the names of the object, more then one can be saved, I can not easily assign the saved object to a new name, I have problems using the saved object if I have forgotten what the variable name was. So I would like to expand my previous question: what are the proper functions to store R objects? One could argue that all write... functions are export functions - therefore keeping the data, but not necessarily column names, rownames, attributes, ... So what can I really do to save an R object for later usage in R? Rainer Duncan Murdoch And if this is not compliant with csv files, shouldn't the function read.csv convert the first column into the row names? Cheers, Rainer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0vB2oACgkQoYgNqgF2egqenQCeJJNdIiX2faKBPGeilzOz73wM RmoAn05oGZvo41wCp1+hWwTqTmNoQrNo =xfWD -END PGP SIGNATURE- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. Säugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help
Re: [R] setting up a genoud run
As a follow up to my original question, I got it to run by re-specifying my function a bit like this - I made the vector of 5 predictors the argument of my function: f1 = function(predictors) { # predictors: p1,p2,p3,p4b,p4a y = 2 + 1.5*predictors[1] + 0.3*(predictors[2]+1.2+0.6*predictors[5])-1.2*predictors[3] + 0.9*predictors[4] return(y) } f1(c(1,2,4,5,6)) # checking it works npredictors=5 genoud(f1,nvars=npredictors,max=TRUE,pop.size=1000,max.generations=100,wait.generations=10, hard.generation.limit=TRUE,starting.values=rep(0,npredictors), Domains=matrix(rep(c(0,1000),npredictors),ncol=2,byrow=T),boundary.enforcement=2) It has run, but starting in Generation 13, it said: at least one gradient is too large. G[3]: -inf Also, it gives me the following parameters as the answer: 1000 1000 0 1000 1000 (which makes sense). I am wondering what does it mean that one gradient is too large? Thanks a lot for explaining! Dimitri On Thu, Jan 13, 2011 at 11:10 AM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello - and sorry for a possibly stupid question, I'm just starting to learn rgenoud. I am defining a function with 5 parameters (p1, p2, p3, p4a, and p4b) and then want to optimize it using genoud. But I am doing something wrong. Before genoud is even able to run it says: Error in p2 + 1.2 : 'p2' is missing. I assume I did not specify it right. My code is below. The task is: I want to find those values of p1, p2, p3, p4a and p4b at which the function f1 is at its maximum. At the same time, I want the value of each of those 5 parameters to be between 0 and 1000. Thanks a lot for your advice! library(rgenoud) f1 = function(p1,p2,p3,p4b,p4a) { y = 2 + 1.5*p1 + 0.3*(p2+1.2+0.6*p4a)-1.2*p3 + 0.9*p4b return(y) } f1(p1=1,p2=2,p3=4,p4b=4,p4a=6) # seems to be working npredictors=5 genoud(f1,nvars=npredictors,max=TRUE,pop.size=1000,max.generations=100,wait.generations=10, hard.generation.limit=TRUE,starting.values=rep(500,npredictors), Domains=matrix(rep(c(0,1000),npredictors),ncol=2,byrow=T),boundary.enforcement=2) -- Dimitri Liakhovitski Ninah Consulting -- Dimitri Liakhovitski Ninah Consulting www.ninah.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] 2d plot with modification of plotting symbol to indicate third dimension.
Duncan: I must humbly disagree. Here's the problem: in order to accurately represent the value, the point = circle _area_ must be proportional to the value. That is, the eye sees the areas, not the radii, as the point size. A delightful reference on this is Howard Wainer's 1982 or so (can't remember exactly) article in THE AMERICAN STATISTICIAN, How to Graph Data Badly (or maybe Plot Data). Anyway, using cex, I have no idea whether a point drawn with cex = 1.23 is 1.23 times the area or radius -- or neither -- of a point drawn with cex =1. Indeed, it might vary depending on the implementation/OS/graphics fonts. So it seems better to me to draw the point with symbols(), where you can have complete control over the size. Obviously, let me know if I'm wrong about this. Cheers, Bert On Wed, Jan 12, 2011 at 9:11 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 11-01-12 9:33 PM, John Sorkin wrote: I would like to plot 3-dimensional data on a two-dimensional scatter-plot. Is there a way I can automatically modify the plot symbol (e.g. changing size or color) to indicate the value of a third variable? E.g. How can I plot weight vs. age and indicate the value of muscle mass for each value weight-age pair by making the plot point proportional to the subject's muscle mass? Just set cex to the other variable. For example, plot(1:10, 1:10, cex=1:10) Similarly, col and pch can be set to vector values, which are recycled through the points. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics 467-7374 http://devo.gene.com/groups/devo/depts/ncb/home.shtml __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 2d plot with modification of plotting symbol to indicate third dimension.
On Thu, 13 Jan 2011, Bert Gunter wrote: Duncan: I must humbly disagree. Here's the problem: in order to accurately represent the value, the point = circle _area_ must be proportional to the value. That is, the eye sees the areas, not the radii, as the point size. A delightful reference on this is Howard Wainer's 1982 or so (can't remember exactly) article in THE AMERICAN STATISTICIAN, How to Graph Data Badly (or maybe Plot Data). ('Display' Data, 1984). In a pseudo-3D plot, such as scatter3dplot, size perception can be even more complex. Anyway, using cex, I have no idea whether a point drawn with cex = 1.23 is 1.23 times the area or radius -- or neither -- of a point drawn with cex =1. Indeed, it might vary depending on the implementation/OS/graphics fonts. It will be approximately 1.23 times the radius. For the default pch=1 (and we seem to be talking about circles), in the graphics devices points() and symbols() will call the same graphics primitives for circles. Now circles will have their sizes rounded to something, maybe the nearest pixel, maybe 0.01bp, maybe something else, so you may not have much control over very small circles, but you will over those of diameter about 5mm or more. So it seems better to me to draw the point with symbols(), where you can have complete control over the size. In some ways this goes back to S, where AFAIR (and ?points suggest) pch=1 was an octagon and symbols() was the only way to draw circles. Obviously, let me know if I'm wrong about this. Cheers, Bert On Wed, Jan 12, 2011 at 9:11 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 11-01-12 9:33 PM, John Sorkin wrote: I would like to plot 3-dimensional data on a two-dimensional scatter-plot. Is there a way I can automatically modify the plot symbol (e.g. changing size or color) to indicate the value of a third variable? E.g. How can I plot weight vs. age and indicate the value of muscle mass for each value weight-age pair by making the plot point proportional to the subject's muscle mass? Just set cex to the other variable. For example, plot(1:10, 1:10, cex=1:10) Similarly, col and pch can be set to vector values, which are recycled through the points. Duncan Murdoch -- Bert Gunter Genentech Nonclinical Biostatistics 467-7374 http://devo.gene.com/groups/devo/depts/ncb/home.shtml -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 2d plot with modification of plotting symbol to indicate third dimension.
On Wed, Jan 12, 2011 at 9:33 PM, John Sorkin jsor...@grecc.umaryland.edu wrote: I would like to plot 3-dimensional data on a two-dimensional scatter-plot. Is there a way I can automatically modify the plot symbol (e.g. changing size or color) to indicate the value of a third variable? E.g. How can I plot weight vs. age and indicate the value of muscle mass for each value weight-age pair by making the plot point proportional to the subject's muscle mass? Check out: http://flowingdata.com/2010/11/23/how-to-make-bubble-charts/ -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] s3 methods on S4 objects
On Thu, Jan 13, 2011 at 6:46 AM, Martin Morgan mtmor...@fhcrc.org wrote: On 01/12/2011 10:54 PM, steven mosher wrote: I have J Chambers wonderful text ( Software for data Analysis) and I've been trying my hand at some very routine S4 OOP development. One of the things I was trying to do was to create some very basic S4 classes. The first was simply a class that had a data.frame as part of its representation. setClass(df,representation(dirframe=data.frame)) The object basically contains a data.frame that represents a file directory listing with a column named filename, size, time, etc. And then I have methods for doing various things with this object. I then tried to tackle the problem of coercing this S4 object to a data.frame. Again just a learning exercise. The goal would be able to make a call like this testFrame - as.data.frame(x) where x, was an object of class df If I try to define as.data.frame as a S4 method, then I can make it work, but I then destroy the S3 functionality of as.data.frame, so that if I were to try to coerce a matrix to a data.frame it would work. Hi Steven -- This works for me setClass(A, representation=representation(df=data.frame)) setMethod(as.data.frame, A, function(x, row.names=NULL, optional=FALSE, ...) { ## implementation, e.g., callGeneric(x@df, row.names=row.names, optional=optional, ...) }) this makes no sense to me. Looking at this in the manual: A call to callGeneric can only appear inside a method definition. It then results in a call to the current generic function. The value of that call is the value of callGeneric. While it can be called from any method, it is useful and typically used in methods for group generic functions. I'm further confused. what is the current generic function? as.data.frame(new(A)) Object of class data.frame data frame with 0 columns and 0 rows as.data.frame(matrix(0, 3, 5)) V1 V2 V3 V4 V5 1 0 0 0 0 0 2 0 0 0 0 0 3 0 0 0 0 0 Maybe you call setGeneric (no need to, setMethod will promote as.data.frame automatically) in a way that does not specify the default (arg useAsDefault) correctly? I think that may have been the mistake.. what do you mean by no need to call setGeneric? I really like chambers book, but there are certain parts where the lack of simple examples really makes it difficult to follow. Martin So, I guess my question is what do I do, write an s3 method for as.data.frame that takes a df object as a paramter? The book wasn't exactly clear ( or I'm not that bright), or is there a way to make the S4 method I wrote as.data.frame call the S3 method if needed? [[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. -- Computational Biology Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: M1-B861 Telephone: 206 667-2793 [[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] Grid drawing over the filled.contour's legend
Hello, For a reason I can't seem to figure out (have searched posts on this forum for filled.contour grid), the grid (in the code below) is plotting over the legend that accompanies the filled.contour. The dataset has 40 columns and 20 rows. Where have I gone wrong? How can I draw a grid with 40 columns and 20 rows that is constrained to the plotted region and doesn't draw over the legend? vs2d_conc20-read.table(textConnection(0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Re: [R] Unexpected behaviour of write.csv - read.csv
On Thu, 13 Jan 2011, Duncan Murdoch wrote: On 11-01-13 6:26 AM, Rainer M Krug wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Assuming the following: x- data.frame(a=1:10, b=runif(10)) str(x) 'data.frame': 10 obs. of 2 variables: $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... write.csv(x, x.csv) x2- read.csv(x.csv) str(x2) 'data.frame': 10 obs. of 3 variables: $ X: int 1 2 3 4 5 6 7 8 9 10 $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... Using the two functions write.csv and read.csv, I would assume, that the resulting data.frame x2 be identical with x, but it has an additional column X, which contains the row names of x. I know read.table and write.table which work as expected, but I would like to use a csv for data exchange reasons. I know that I can use write.csv(x, x.csv, row.names=FALSE) and it would work, but shouldn't that be the default behaviour? I don't think so. The CSV format is an export format which holds less information than a dataframe. By exporting the dataframe to CSV and importing the result, you are discarding information and you should expect to get something different. You need to read it with read.csv(x.csv, row.names=1) Nothing in the csv format lets R know that the first column is the row names (in the format used by read.table, having a header that is one column short does). Now R could guess that a .csv file with an empty string for the first column name is meant to be the row names, but that would be merely a guess based on one (barely documented for spreadsheets) convention. If you want to save a dataframe to disk and read it back unchanged, you should use save() and load(). Or one of the other serialization options such as serialize() and .saveRDS(). R's own admin uses .saveRDS() for such purposes. Duncan Murdoch And if this is not compliant with csv files, shouldn't the function read.csv convert the first column into the row names? Cheers, Rainer - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0u4X8ACgkQoYgNqgF2egrLIgCeIqAevHGcOAK56qPcpNJ+vWav iF0An2pk1RsY1GLJbvdMHG7FFpx437gB =d5aG -END PGP SIGNATURE- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Unexpected behaviour of write.csv - read.csv
On Thu, Jan 13, 2011 at 1:06 PM, Prof Brian Ripley rip...@stats.ox.ac.uk wrote: On Thu, 13 Jan 2011, Duncan Murdoch wrote: On 11-01-13 6:26 AM, Rainer M Krug wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Assuming the following: x- data.frame(a=1:10, b=runif(10)) str(x) 'data.frame': 10 obs. of 2 variables: $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... write.csv(x, x.csv) x2- read.csv(x.csv) str(x2) 'data.frame': 10 obs. of 3 variables: $ X: int 1 2 3 4 5 6 7 8 9 10 $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... Using the two functions write.csv and read.csv, I would assume, that the resulting data.frame x2 be identical with x, but it has an additional column X, which contains the row names of x. I know read.table and write.table which work as expected, but I would like to use a csv for data exchange reasons. I know that I can use write.csv(x, x.csv, row.names=FALSE) and it would work, but shouldn't that be the default behaviour? I don't think so. The CSV format is an export format which holds less information than a dataframe. By exporting the dataframe to CSV and importing the result, you are discarding information and you should expect to get something different. You need to read it with read.csv(x.csv, row.names=1) Nothing in the csv format lets R know that the first column is the row names (in the format used by read.table, having a header that is one column short does). Now R could guess that a .csv file with an empty string for the first column name is meant to be the row names, but that would be merely a guess based on one (barely documented for spreadsheets) convention. read.csv / read.table already use heuristics to determine the column types so adding this to the heuristic seems not to be a departure from the established philosophy. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] s3 methods on S4 objects
On 01/13/2011 09:49 AM, steven mosher wrote: On Thu, Jan 13, 2011 at 6:46 AM, Martin Morgan mtmor...@fhcrc.org mailto:mtmor...@fhcrc.org wrote: On 01/12/2011 10:54 PM, steven mosher wrote: I have J Chambers wonderful text ( Software for data Analysis) and I've been trying my hand at some very routine S4 OOP development. One of the things I was trying to do was to create some very basic S4 classes. The first was simply a class that had a data.frame as part of its representation. setClass(df,representation(dirframe=data.frame)) The object basically contains a data.frame that represents a file directory listing with a column named filename, size, time, etc. And then I have methods for doing various things with this object. I then tried to tackle the problem of coercing this S4 object to a data.frame. Again just a learning exercise. The goal would be able to make a call like this testFrame - as.data.frame(x) where x, was an object of class df If I try to define as.data.frame as a S4 method, then I can make it work, but I then destroy the S3 functionality of as.data.frame, so that if I were to try to coerce a matrix to a data.frame it would work. Hi Steven -- This works for me setClass(A, representation=representation(df=data.frame)) setMethod(as.data.frame, A, function(x, row.names=NULL, optional=FALSE, ...) { ## implementation, e.g., callGeneric(x@df, row.names=row.names, optional=optional, ...) }) this makes no sense to me. Looking at this in the manual: A call to callGeneric can only appear inside a method definition. It then results in a call to the current generic function. The value of that call is the value of callGeneric. While it can be called from any method, it is useful and typically used in methods for group generic functions. callGeneric is not necessary, and I should just have said as.data.frame(x@df, row.names=row.names, optional=optional, ...) I'm further confused. what is the current generic function? I think of a generic 'foo' as a function, and inside that function are functions foo,A-method, foo,B-method etc for classes A, B, When in one of these methods, foo,A-method, the current generic is the function 'foo'. For as.data.frame, the generic is unambiguous ('as.data.frame' !) and the interesting case are the group generics (?Logic, for instance), where a single method setMethod(Logic, function(e1, e2) callGeneric(YOUR CODE HERE)) and you'll have in effect written 'methods' for all the operators defined in the 'Logic' group. Cool. as.data.frame(new(A)) Object of class data.frame data frame with 0 columns and 0 rows as.data.frame(matrix(0, 3, 5)) V1 V2 V3 V4 V5 1 0 0 0 0 0 2 0 0 0 0 0 3 0 0 0 0 0 Maybe you call setGeneric (no need to, setMethod will promote as.data.frame automatically) in a way that does not specify the default (arg useAsDefault) correctly? I think that may have been the mistake.. what do you mean by no need to call setGeneric? The only code I had was what was written above -- setClass and setMethod. I could also have setGeneric(as.data.frame) and would have been ok -- the default behavior of setGeneric in this case is to make a generic function as.data.frame, AND a method as.data.frame,ANY-method. The as.data.frame,ANY-method is implemented as base::as.data.frame, and is where objects not handled by methods I implement might end up being dispatched to. In a new R session, try setGeneric(as.data.frame) showMethods(as.data.frame) selectMethod(as.data.frame, ANY) If I had done setGeneric(as.data.frame, function(x) standardGeneric(as.data.frame)) Creating a generic for 'as.data.frame' in package '.GlobalEnv' (the supplied definition differs from and overrides the implicit generic in package 'base': Formal arguments differ: (x), (x, row.names, optional, ...)) [1] as.data.frame then I'm in trouble -- I've created a generic 'as.data.frame', but since the signature of my generic differs from the signature of base::as.data.frame, the default behavior does NOT create a as.data.frame,ANY method. Not sure if this helps or not... Martin I really like chambers book, but there are certain parts where the lack of simple examples really makes it difficult to follow. Martin So, I guess my question is what do I do, write an s3 method for as.data.frame that takes a df object as a paramter? The book wasn't exactly clear ( or I'm not that bright), or is there a way to make the S4 method I wrote as.data.frame call the S3 method if needed? [[alternative HTML version deleted]]
Re: [R] s3 methods on S4 objects
Martin, that helps. I I made the mistake you outlined below setGeneric(as.data.frame, function(x) standardGeneric(as.data.frame)) Creating a generic for 'as.data.frame' in package '.GlobalEnv' (the supplied definition differs from and overrides the implicit generic in package 'base': Formal arguments differ: (x), (x, row.names, optional, ...)) [1] as.data.frame then I'm in trouble -- I've created a generic 'as.data.frame', but since the signature of my generic differs from the signature of base::as.data.frame, the default behavior does NOT create a as.data.frame,ANY method. this, as you note leads to trouble And of course got in trouble. setClass(Class=ftpdir, representation = list(dirframe=data.frame)) if (!isGeneric(as.data.frame)) { setGeneric(as.data.frame, function(dirlist ) standardGeneric(as.data.frame)) } setMethod(as.data.frame, signature(dirlist = ftpdir ), function (dirlist ) { return( dirlist@dirframe) } ) On Thu, Jan 13, 2011 at 10:33 AM, Martin Morgan mtmor...@fhcrc.org wrote: On 01/13/2011 09:49 AM, steven mosher wrote: On Thu, Jan 13, 2011 at 6:46 AM, Martin Morgan mtmor...@fhcrc.org mailto:mtmor...@fhcrc.org wrote: On 01/12/2011 10:54 PM, steven mosher wrote: I have J Chambers wonderful text ( Software for data Analysis) and I've been trying my hand at some very routine S4 OOP development. One of the things I was trying to do was to create some very basic S4 classes. The first was simply a class that had a data.frame as part of its representation. setClass(df,representation(dirframe=data.frame)) The object basically contains a data.frame that represents a file directory listing with a column named filename, size, time, etc. And then I have methods for doing various things with this object. I then tried to tackle the problem of coercing this S4 object to a data.frame. Again just a learning exercise. The goal would be able to make a call like this testFrame - as.data.frame(x) where x, was an object of class df If I try to define as.data.frame as a S4 method, then I can make it work, but I then destroy the S3 functionality of as.data.frame, so that if I were to try to coerce a matrix to a data.frame it would work. Hi Steven -- This works for me setClass(A, representation=representation(df=data.frame)) setMethod(as.data.frame, A, function(x, row.names=NULL, optional=FALSE, ...) { ## implementation, e.g., callGeneric(x@df, row.names=row.names, optional=optional, ...) }) this makes no sense to me. Looking at this in the manual: A call to callGeneric can only appear inside a method definition. It then results in a call to the current generic function. The value of that call is the value of callGeneric. While it can be called from any method, it is useful and typically used in methods for group generic functions. callGeneric is not necessary, and I should just have said as.data.frame(x@df, row.names=row.names, optional=optional, ...) I'm further confused. what is the current generic function? I think of a generic 'foo' as a function, and inside that function are functions foo,A-method, foo,B-method etc for classes A, B, When in one of these methods, foo,A-method, the current generic is the function 'foo'. For as.data.frame, the generic is unambiguous ('as.data.frame' !) and the interesting case are the group generics (?Logic, for instance), where a single method setMethod(Logic, function(e1, e2) callGeneric(YOUR CODE HERE)) and you'll have in effect written 'methods' for all the operators defined in the 'Logic' group. Cool. as.data.frame(new(A)) Object of class data.frame data frame with 0 columns and 0 rows as.data.frame(matrix(0, 3, 5)) V1 V2 V3 V4 V5 1 0 0 0 0 0 2 0 0 0 0 0 3 0 0 0 0 0 Maybe you call setGeneric (no need to, setMethod will promote as.data.frame automatically) in a way that does not specify the default (arg useAsDefault) correctly? I think that may have been the mistake.. what do you mean by no need to call setGeneric? The only code I had was what was written above -- setClass and setMethod. I could also have setGeneric(as.data.frame) and would have been ok -- the default behavior of setGeneric in this case is to make a generic function as.data.frame, AND a method as.data.frame,ANY-method. The as.data.frame,ANY-method is implemented as base::as.data.frame, and is where objects not handled by methods I implement might end up being dispatched to. In a new R session, try setGeneric(as.data.frame) showMethods(as.data.frame)
[R] send commands from script to console
Hi, I'm working with R in windows and I wonder if there is any command (of the kind CTRL+ ) to transfer the commands I've worked with (like: model-glm(prevalencia~edadysexo*mes*zona,binomial)) to a script automatically, without the results I received from R after execute them. Another question, what's the combination of CTRL+ for transfer the orders in the other way, fom the script to the console? Thanks very much Sorry for the explanation, but I don't know the generic names of each kind of commands - Mario Garrido Escudero PhD student Dpto. de Biología Animal, Ecología, Parasitología, Edafología y Qca. Agrícola Universidad de Salamanca -- View this message in context: http://r.789695.n4.nabble.com/send-commands-from-script-to-console-tp3216553p3216553.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] Colouring areas on a map with updated maptools functions
Hi - I'm trying to plot a map from a shapefile and then colour different areas of it depending on different attributes of those areas. A couple of years ago I used some code to do this that would plot a map in R from a shapefile (states within a country). It then uploaded a .txt file which had the same number of rows as the shapefile and one column populated with numbers from 1 to 8 which represented an attribute for each of those states. The code then plotted those numbers as colours on the map so each state had the appropriate colour. This was the code: x-read.shape(NGADMIN2.SHP) xpolys-Map2poly(x) coverage-read.table(coveragemar08.txt,header=T) colour1-coverage[,2] palette(c(red4,red3,red2,orangered,orange,gold1,yellow,white)) plot(xpolys, axes=F, colour1) I've now come back to using this and discovered that some of these functions are no longer in use. I've figured out how to change most of it and now have this: x=readShapePoly(NGADMIN2.shp) coverage-read.table(coveragemar08.txt,header=T) colour1-coverage[,2] palette(c(red4,red3,red2,orangered,orange,gold1,yellow,white)) plot(x, axes=F, colour1) but it falls over at the last line. It doesn't like the inclusion of ,colour1 and I get an error: Error in as.double(x) : cannot coerce type 'S4' to vector of type 'double' I cannot work out how to fix this. Can anyone help? Or do I need to change something else about how I'm doing this? Thanks in advance Helen [[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] Question about histogram
Dear list, I'm new to R, please bear with my silly questions. I'm trying to get an understanding of why the results I get from a call to hist() are not as I thought I would get. When I use the parameter freq=FALSE, I think the plot will contain bars that none of them is larger than 1, because they're probabilities. But for my code, the bars exceeded 1. The actual data seems immaterial. I tried with dummy data: hist(runif(1000), freq=FALSE) and the histogram includes bars well over 1 in height. The man page says that freq=FALSE produces densities, so that the total area is 1. Clearly if all the values are between 0 and 1, as is the case here, some of the bars stand out above 1, for the area to be 1. I thought that it is the sum of the bar heights that would be 1, so that the bars reflect probabilities for each interval, rather than densities. So, the answer to my question would be because it's densities, not probabilities, but then the question is, why densities and not probabilities? Regards, 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] Unexpected behaviour of write.csv - read.csv
Another option to consider is instead of save/load to use save/attach. You save the data, but then instead of loading it back into the global environment you use the attach function to attach it in a new environment (position 2 on the search list by default). It will be attached with the same name as it had when you saved it, but it will not overwrite something by the same name in the global environment. You can still use it as it is, or assign it to a new name in the global environment. When you are through using it you can then detach it. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Rainer M Krug Sent: Thursday, January 13, 2011 7:09 AM To: Duncan Murdoch Cc: R-help Subject: Re: [R] Unexpected behaviour of write.csv - read.csv -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/13/2011 02:56 PM, Duncan Murdoch wrote: On 11-01-13 6:26 AM, Rainer M Krug wrote: Hi Assuming the following: x- data.frame(a=1:10, b=runif(10)) str(x) 'data.frame':10 obs. of 2 variables: $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... write.csv(x, x.csv) x2- read.csv(x.csv) str(x2) 'data.frame':10 obs. of 3 variables: $ X: int 1 2 3 4 5 6 7 8 9 10 $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... Using the two functions write.csv and read.csv, I would assume, that the resulting data.frame x2 be identical with x, but it has an additional column X, which contains the row names of x. I know read.table and write.table which work as expected, but I would like to use a csv for data exchange reasons. I know that I can use write.csv(x, x.csv, row.names=FALSE) and it would work, but shouldn't that be the default behaviour? I don't think so. The CSV format is an export format which holds less information than a dataframe. By exporting the dataframe to CSV and importing the result, you are discarding information and you should expect to get something different. OK - I can follow this logic - and I think I can accept it. If you want to save a dataframe to disk and read it back unchanged, you should use save() and load(). And now my question from a previous thread (write.table equivalent for lists?) comes up again: using save() and load() definitely works, but it is highly unsave - as it even keeps the names of the object, more then one can be saved, I can not easily assign the saved object to a new name, I have problems using the saved object if I have forgotten what the variable name was. So I would like to expand my previous question: what are the proper functions to store R objects? One could argue that all write... functions are export functions - therefore keeping the data, but not necessarily column names, rownames, attributes, ... So what can I really do to save an R object for later usage in R? Rainer Duncan Murdoch And if this is not compliant with csv files, shouldn't the function read.csv convert the first column into the row names? Cheers, Rainer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0vB2oACgkQoYgNqgF2egqenQCeJJNdIiX2faKBPGeilzOz73wM RmoAn05oGZvo41wCp1+hWwTqTmNoQrNo =xfWD -END PGP SIGNATURE- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] send commands from script to console
In the windows GUI cntrl+r will send the current line or selection to the command line. There is not a similar sequence to send from the command line to a script, but you can use the history function to create a new script from the recent commands (you can set how many). Another option is ?txtStart in the TeachingDemos package which can be used to create a script (in a file) with all the commands you issue (well the ones that don't result in an error) going forward. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of gaiarrido Sent: Thursday, January 13, 2011 1:04 PM To: r-help@r-project.org Subject: [R] send commands from script to console Hi, I'm working with R in windows and I wonder if there is any command (of the kind CTRL+ ) to transfer the commands I've worked with (like: model-glm(prevalencia~edadysexo*mes*zona,binomial)) to a script automatically, without the results I received from R after execute them. Another question, what's the combination of CTRL+ for transfer the orders in the other way, fom the script to the console? Thanks very much Sorry for the explanation, but I don't know the generic names of each kind of commands - Mario Garrido Escudero PhD student Dpto. de Biología Animal, Ecología, Parasitología, Edafología y Qca. Agrícola Universidad de Salamanca -- View this message in context: http://r.789695.n4.nabble.com/send- commands-from-script-to-console-tp3216553p3216553.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question about histogram
Because a histogram is descriptive and makes no assumptions about what it describes? Attaching a probability to the bars assumes that some random draw is being made. Suppose my data is a count of computers running a particular OS. What would be the value in reporting this as a probability that a randomly chosen computer is running Ubuntu? Density is more universal, IMO. -- Jonathan P. Daily Technician - USGS Leetown Science Center 11649 Leetown Road Kearneysville WV, 25430 (304) 724-4480 Is the room still a room when its empty? Does the room, the thing itself have purpose? Or do we, what's the word... imbue it. - Jubal Early, Firefly r-help-boun...@r-project.org wrote on 01/13/2011 01:37:01 PM: [image removed] [R] Question about histogram Longe to: r-help 01/13/2011 03:11 PM Sent by: r-help-boun...@r-project.org Dear list, I'm new to R, please bear with my silly questions. I'm trying to get an understanding of why the results I get from a call to hist() are not as I thought I would get. When I use the parameter freq=FALSE, I think the plot will contain bars that none of them is larger than 1, because they're probabilities. But for my code, the bars exceeded 1. The actual data seems immaterial. I tried with dummy data: hist(runif(1000), freq=FALSE) and the histogram includes bars well over 1 in height. The man page says that freq=FALSE produces densities, so that the total area is 1. Clearly if all the values are between 0 and 1, as is the case here, some of the bars stand out above 1, for the area to be 1. I thought that it is the sum of the bar heights that would be 1, so that the bars reflect probabilities for each interval, rather than densities. So, the answer to my question would be because it's densities, not probabilities, but then the question is, why densities and not probabilities? Regards, 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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] What does the shell() command do?
This depends partly on what operating system you are using (the posting guide suggests including this type of information). But basically shell will pass a command to the operating system (or a shell for unix Oss) for it to run the command. So in your example it is expecting to run dir/b on a file in the OS, not R. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of l.chhay Sent: Wednesday, January 12, 2011 5:18 PM To: r-help@r-project.org Subject: [R] What does the shell() command do? Dear R community, I am trying to understand what the shell() function does. An example is: xfile - shell(paste(dir/b , paste(directory.folder,file.name,sep=)),intern=T) I'm afraid I wasn't able to completely understand the explanation under the Help files. Thanks for your help! Leanne. -- View this message in context: http://r.789695.n4.nabble.com/What-does- the-shell-command-do-tp3215032p3215032.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] Writing out data from a list
Hello, I have a list of data, such that: [[1]] [1] 0.00 0.00 0.03 0.01 0.00 0.00 0.00 0.00 0.01 0.01 0.00 0.00 0.01 0.00 0.00 0.03 0.01 0.00 0.01 0.00 0.03 0.16 0.14 0.02 0.17 0.01 0.01 0.00 0.00 0.03 0.00 0.00 0.00 0.00 0.00 0.01 0.00 0.00 0.00 0.00 0.00 [42] 0.00 0.00 0.00 0.00 0.01 0.00 0.00 0.00 0.00 0.00 0.04 0.08 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.01 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 [[2]] [1] 0.00 0.00 0.00 0.00 0.01 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.07 0.00 0.00 0.03 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 [[3]] [1] 0.00 0.00 0.00 0.00 0.00 0.00 0.01 0.00 0.00 0.01 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 etc. I would like to write to a text file with this data, but would like each section of the file to be separated by some text. For example: Event 1 Random Text 0 0 0.03 0.01 Event 2 Random Text 0 0 0 0 0.01 etc. Is there some way to continually write text out using a loop and also attaching a string before each data segment? Thank you in advance! -Aaron [[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] Writing out data from a list
a- list(a=c(0.00,0.00),b=c(2,2,2),c=c(3,3,3)) t-NULL m-1 for( i in a) {t-c(t,paste(Event,m),i);m-m+1} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question about histogram
Hi: On Thu, Jan 13, 2011 at 10:37 AM, Longe longeli...@gmail.com wrote: Dear list, I'm new to R, please bear with my silly questions. I'm trying to get an understanding of why the results I get from a call to hist() are not as I thought I would get. When I use the parameter freq=FALSE, I think the plot will contain bars that none of them is larger than 1, because they're probabilities. But for my code, the bars exceeded 1. Your perception is incorrect, I'm afraid; the bars in a histogram are not probabilities, but rather crude estimates of the density in each subinterval. The *area* of each rectangle gives an approximation to the probability content (the integral of the density) in each corresponding interval. (Think of the process of Riemann integration from calculus as an analogy.) An example of a continuous distribution whose density is greater than 1 is the Uniform(0, 0.5) distribution (or any uniform distribution defined on an interval of width 1). The distribution is a rectangle with width 0.5 and area 1 (since all continuous probability densities have total area 1 under the density function by definition). The height of the rectangle is the density of the uniform distribution... As the width of the interval gets smaller, the density (height) must get bigger since the area is fixed, and is in fact the reciprocal of its width in the uniform case. The actual data seems immaterial. I tried with dummy data: hist(runif(1000), freq=FALSE) and the histogram includes bars well over 1 in height. The man page says that freq=FALSE produces densities, so that the total area is 1. Clearly if all the values are between 0 and 1, as is the case here, some of the bars stand out above 1, for the area to be 1. I thought that it is the sum of the bar heights that would be 1, so that the bars reflect probabilities for each interval, rather than densities. So, the answer to my question would be because it's densities, not probabilities, but then the question is, why densities and not probabilities? Histograms are meant to estimate continuous probability density functions. OTOH, in a bar chart of a discrete distribution, relative frequencies are estimated probabilities of each category because the probabilities are point masses that add to 1. Perhaps this is the source of your confusion - a histogram does not have the same interpretation as a bar chart, because it's estimating a smooth curve over a continuous interval rather than a set of (probability) masses at fixed points. HTH, Dennis Regards, 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. [[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] Metafor vs Meta vs Spreadsheet: wrong numbers
Dear Serge-Étienne, Try: res - rma.uni(yi, vi, data=dat, method=DL) for the random-effects model when using the metafor package. You used method=HE -- this will give you a different estimator of tau^2 then the one used in the meta package. Best, -- Wolfgang Viechtbauer Department of Psychiatry and Neuropsychology School for Mental Health and Neuroscience Maastricht University, P.O. Box 616 6200 MD Maastricht, The Netherlands Tel: +31 (43) 368-5248 Fax: +31 (43) 368-8689 Web: http://www.wvbauer.com Original Message From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Serge-Étienne Parent Sent: Wednesday, January 12, 2011 18:18 To: r-help@r-project.org Subject: [R] Metafor vs Meta vs Spreadsheet: wrong numbers Hello, I experimented the Metafor and Meta packages in the scope of replacing Excel for meta-analysis. I performed the first working example provided in Michael Borenstein's book Introduction to Meta-Analysis with Excel, Metafor and Meta. The numbers given by my spreadsheet, which I validated from Borenstein's book, conrespond quite closely to those given by Meta, but are different from those obtained using Metafor. For the fixed effect, I infer that the differences are related to numerical issues, but for the random effect, the numbers are considerably different. Unfortunately, I could not find where I made it wrong. I would be grateful if someone would have a look at my calculations. Here are the meta-analysis commands: ### USING METAFOR library(metafor) ( dat-escalc(m1i=m1i, sd1i=sd1i, n1i=n1i, m2i=m2i, sd2i=sd2i, n2i=n2i, measure=SMD, data=metaData, append=T) ) # COMPUTE EFFECT SIZE ( res-rma.uni(yi,vi,data=dat,method=HE, level=95) ) ### RANDOM EFFECT ( res-rma.uni(yi,vi,data=dat,method=FE, level=95) ) ### FIXED EFFECT ### USING META ( res-metacont(metaData[,3], metaData[,1], metaData[,2], metaData[,6], metaData[,4], metaData[,5], studlab=rownames(metaData),sm=SMD, level = 0.95, level.comb = 0.95, comb.fixed=TRUE, comb.random=TRUE, label.e=Experimental, label.c=Control, bylab=rownames(metaData)) ) The whole R script is temporarly available at http://bit.ly/eYesbZ The spreadsheet is temporarly available at http://bit.ly/fAYWPo Kind regards, S.-É. Parent, Eng., Ph.D. Department of Soils and Agrifood Engineering, Université Laval Canada __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] PBSmodelling: Change the edit option of a widget
Is it possible to toggle the edit option of a widget? I would like to make it so that when a user clicks on a boolean (like use constraints) it will lock or unlock the field in which they would enter the constraints. I can imagine redrawing the whole GUI using a function attached to the boolean, but that's clunky and slow. I tried changing the .PBSmod variable... but that doesn't redraw the GUI, even if you use updateGUI(G) or updateGUI(L) 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] Fitting an Inverse Gamma Distribution
http://r.789695.n4.nabble.com/file/n3216865/Inverse_Gamma.png Hello, I am seeking help in estimating the parameters of an inverse gamma distribution (from the 'actuar' package) using a function like 'fitdistr'. Unfortunately I haven't found such a package using findFn('fit Inverse Gamma') from the 'sos' package and was therefore hoping someone might be aware of such a function? Secondly, is there a way to shift the pdf (code below) to the right (rather than the data to the left)? I tried: par(new=T) shift-1 hist(iniSal_US_forHist,breaks=seq(1.1,21,by=0.625),col=grey,freq=F,xlim=c(0-shift,21-shift),plot=F) curve(dinvgamma(x,scale=11.835,shape=4.4242),from=0,to=20,add=T,col=purple,lwd=2) but this failed in shifting the curve. More broadly, the data plotted in the histogram represents a calibration target for output generated by a finite difference solute transport model. The values that will be generated by the finite difference model would ideally fit the shifted (if that can be figured out) inverse gamma pdf. To the extent that fit is deemed poor, the parameter estimation software associated with the finite difference model will adjust parameters until a better fit is found. I will try to use a goodness of fit test to determine if one set of parameter values in the finite difference model produce output that fits the inv. gamma curve herein better than another. But first I need to establish the curve the finite difference model output should target and would greatly appreciate any leads on how it might be shifted and/or fit more precisely by a fitdistr-like function. library(MASS) library(actuar) iniSal_US_forHist-c(2.368000,3.532614,3.064330,3.347069,3.066333,4.233636,3.465650,2.858553, 2.946731,2.945417,2.415000,2.873019,5.521000,5.788148,5.314630,5.509672,6.032840,6.009310, 4.110833,6.073182,5.652833,4.425733,6.481852,4.076857,3.289310,4.524000,3.985811,5.399714, 4.490606,6.956729,5.270933,8.099107,5.058250,6.394500,5.644000,5.202459,5.67,3.152680, 3.220952,2.777381,3.115467,3.642759,3.488333,3.022439,2.610290,2.618571,3.218000,3.417634, 10.327317,7.344270,6.886154,4.015800,3.063103,6.832292,4.600238,2.939000,5.999027,7.894878, 4.411538,2.384762,6.816154,2.782500,2.475333,2.799138,2.739063,2.619917,2.892545,2.468167, 2.577079,2.821875,2.502500,2.969032,2.046023,3.073077,4.408000,3.411774,3.50,4.283607, 4.284000,4.276714,3.228103,2.639875,3.453194,2.821200,3.838723,1.714253,2.273750,2.611882, 2.321781,2.567500,2.557045,1.288875,2.175211,1.736000,2.250781,7.433366,7.033553,5.47, 7.132727,8.505937,9.174545,6.554487,7.060286,6.617160,8.210986,4.404045,6.062381,5.149625, 2.972105,5.358889,3.910968,3.715873,1.728966,2.843667,4.413906,3.016346,7.168636,3.839394, 3.930141,7.019882,3.459429,5.050250,3.492714,3.226667,3.987667,2.770227,3.661167,1.553000, 2.867391,2.897193,2.611707,2.577167,2.904697,2.733077,2.507241,11.044865,6.425484,8.567222, 8.552344,7.493396,4.807381,9.697869,9.471333,6.783175,4.563571,8.059649,9.448679,5.803778, 4.769423,4.424634,7.586042,4.451556,3.622373,6.390152,4.424375,4.135806,5.025400,5.410635, 7.012292,2.961071,3.192188,2.989643,3.471429,2.867966,1.980541,3.172344,2.574783,2.958983, 1.708140,3.604853,3.479000,2.845000,2.742603,2.923968,3.620308,2.452500,2.721375,3.166333, 2.742162,2.793000,3.337000,5.192025,5.365875,3.079000,8.415970,6.612277,6.734706,4.856857, 5.164783,7.743667,6.894151,4.666538,9.227167,8.077581,6.109833,6.621724,18.098182,12.705600, 15.490784,17.394750,12.422364,14.832727,8.326000,11.352400,3.431429,2.658261,3.219773,3.605185, 4.030299,3.262241,3.503250,3.522763,2.847312,2.996618,3.075769,3.387731,3.066923,3.078200, 2.466957,3.214167,2.707778,3.384839,2.283556,2.912258,3.378000,2.726750,2.95,2.195000, 4.819063,3.604578,3.694906,5.068000,4.676582,3.028831,4.261042,3.593235,4.501224,2.880317, 5.750333,3.257833,3.967458,2.522292,2.725738,2.549231,2.591389,2.990488,2.681222,2.685854, 2.284750,2.585938,2.432824,3.108875,2.611340,3.916667,2.418095,2.476406,2.801235,3.278000, 2.434921,2.617826,3.133939,2.774321,4.196173,3.764286,3.555833,5.317361,3.970800,4.136400, 4.487013,3.746393,4.754000,3.854316,3.742353,3.044079,2.817821,3.995179,3.643134,3.642593, 3.604533,2.935902,4.088310,5.344407,3.076883,3.287105,3.720870,2.032258,2.872593,5.787313, 6.017838,5.425205,4.880600,3.582295,4.90,3.489016,4.603030,5.344407,6.184286,4.047083, 4.788304,4.661325,4.815938,4.056790,3.765595,5.348772,5.200222,4.906311,3.900147,3.782897, 3.767313,3.417732,3.725455,2.888750,2.552333,2.521613,2.531522,2.510833,2.710208,2.445273, 2.619750,2.094737,2.399355,2.758000,2.317077,2.247755,3.594333,4.607805,2.69,3.084706, 3.529000,2.326200,3.309851,2.647805,2.802250,2.778667,3.231235,2.418065,3.134545,3.807843, 2.988372,2.709792,3.084035,3.633279,2.958750,2.170081,2.67,2.640706,2.841600,3.399219, 2.561373,2.574824,3.046447,2.647500,3.554875,1.865000,2.858333,2.355000,2.508082,2.376833,
Re: [R] metafor/ meta-regression
Dear Fernanda, Currently, there is no option in metafor that will automatically give you standardized coefficients for meta-regression models. The question is also how you would like to standardize those coefficients. In the usual regression models, the standardized coefficients are those that you would obtain if both the dependent and the independent variables are all rescalled to have a mean of 0 and a standard deviation of 1. For meta-regression models, I don't see how rescalling the dependent variable (i.e., the outcome) would give you something sensible. There are some additional issues with the fact that you would also have to rescale the sampling variances accordingly. One possibility may be to just rescale the predictors. If this is what you want, then you can always just rescale the variables manually (the scale() function will help you do that). For example: data(dat.bcg) dat - escalc(measure=RR, ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, append=TRUE) res - rma(yi, vi, mods=cbind(ablat, year), data=dat, method=REML) res dat$ablat.std - c(scale(dat$ablat)) dat$year.std - c(scale(dat$year)) res - rma(yi, vi, mods=cbind(ablat.std, year.std), data=dat, method=REML) res Part of the output: estimate se zvalpvalci.lbci.ub intrcpt -0.7321 0.1238 -5.9137 .0001 -0.9748 -0.4895 *** ablat.std -0.4046 0.1478 -2.7371 0.0062 -0.6943 -0.1149 ** year.std 0.0209 0.1605 0.1299 0.8966 -0.2938 0.3355 So, the results indicate that, for a one standard deviation increase in absolute latitude, the relative risk decreases on average by .41 points. And for a one standard deviation increase in year, the relative risk increases on average by .02 points. Whether one can determine the relative importance of predictors this way (this at least seems to be the reason why people often ask for standardized coefficients) is another issue. Best, -- Wolfgang Viechtbauer Department of Psychiatry and Neuropsychology School for Mental Health and Neuroscience Maastricht University, P.O. Box 616 6200 MD Maastricht, The Netherlands Tel: +31 (43) 368-5248 Fax: +31 (43) 368-8689 Web: http://www.wvbauer.com Original Message From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Fernanda Melo Carneiro Sent: Wednesday, January 12, 2011 20:18 To: r-h...@stat.math.ethz.ch Subject: [R] metafor/ meta-regression Hi I have tryed to do the meta-regression in metafor package, but I would like to get the standardized coefficients for each variable, however in command: res-rma.uni (yi, vi, method=REML, mods=~cota+DL+uso+gadiente+idade, data=turbidez) I just have the coefficients no standardized (estimate) of the multiple regression. What I need to do? Thanks Fernanda Melo Carneiro contato: (62) 3521-1480 e 8121-7374 www.ecoevol.ufg.br Laboratório de Ecologia Teórica e Síntese (UFG) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] PBSmodelling: Change the edit option of a widget
For the benefit of others searching the help: I think you can change the state of widgets by using setWidgetState see ?setWidgetState in package:PBSmodelling -- Forwarded message -- From: Gene Leynes gleyne...@gmail.com gleynes%...@gmail.com Date: Thu, Jan 13, 2011 at 4:30 PM Subject: PBSmodelling: Change the edit option of a widget To: r-help@r-project.org Cc: www...@gmail.com Is it possible to toggle the edit option of a widget? I would like to make it so that when a user clicks on a boolean (like use constraints) it will lock or unlock the field in which they would enter the constraints. I can imagine redrawing the whole GUI using a function attached to the boolean, but that's clunky and slow. I tried changing the .PBSmod variable... but that doesn't redraw the GUI, even if you use updateGUI(G) or updateGUI(L) 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] send commands from script to console
Thanks very much - Mario Garrido Escudero PhD student Dpto. de Biología Animal, Ecología, Parasitología, Edafología y Qca. Agrícola Universidad de Salamanca -- View this message in context: http://r.789695.n4.nabble.com/send-commands-from-script-to-console-tp3216553p3216780.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] Rotated, Right-Justified Labels for Shortened Tick Marks
mgp[2]! That's exactly what I wanted! Thank you Vicki! #final solution: plot(-10:10,-10:10, yaxt='n') axis(side=2, las=1, hadj=1, tck=-.01, cex.axis=.6, mgp=c(3,.5,0)) On Thu, Jan 13, 2011 at 8:29 AM, Lancaster, Vicki vicki.lancas...@fda.hhs.gov wrote: Try using mgp: From help(par) mgp The margin line (in mex units) for the axis title, axis labels and axis line. Note that mgp[1] affects title whereas mgp[2:3] affect axis. The default is c(3, 1, 0). -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Dave Schruth Sent: Thursday, January 13, 2011 11:01 AM To: Jim Lemon Cc: r-help@r-project.org Subject: Re: [R] Rotated, Right-Justified Labels for Shortened Tick Marks Jim, This was the solution I was hoping to avoid having to implement... but thank you it does what I was looking for visually (except for the las=1 rotation). Is there no other parameter *within* axis that I could adjust? If not, it seems like axis could be rewritten to have the axis tick label positions move in concert with the shortening tick marks... -D On Wed, Jan 12, 2011 at 10:53 PM, Jim Lemon j...@bitwrit.com.au wrote: On 01/13/2011 11:59 AM, dms wrote: Hello R-help, I'm trying to make a fairly simple plot axis that goes something like this: plot(-10:10,-10:10, yaxt='n') axis(side=2, las=1, hadj=1, tck=-.01, cex.axis=.6) ...but as you can see, the labels are not close enough to the y-axis (where I want them... to save space for publication). Can anybody help me figure out how to move these labels over the the right a bit? Hi D, Try this: plot(-10:10,-10:10, yaxt='n') axis(side=2,at=seq(-10,10,by=5),labels=rep(,5),tck=-.01) par(cex=0.6) mtext(seq(-10,10,by=5),at=seq(-10,10,by=5),side=2,line=0.3,cex=0.6) par(cex=1) Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fitting an Inverse Gamma Distribution
On 14/01/2011 11:46 a.m., emorway wrote: http://r.789695.n4.nabble.com/file/n3216865/Inverse_Gamma.png Hello, I am seeking help in estimating the parameters of an inverse gamma distribution (from the 'actuar' package) using a function like 'fitdistr'. Unfortunately I haven't found such a package using findFn('fit Inverse Gamma') from the 'sos' package and was therefore hoping someone might be aware of such a function? In my package GeneralizedHyperbolic on R-Forge (not yet in the CRAN version) you will find a fitting routine for the generalized inverse Gaussian distribution which has the inverse Gaussian as a special case. David Scott Secondly, is there a way to shift the pdf (code below) to the right (rather than the data to the left)? I tried: par(new=T) shift-1 hist(iniSal_US_forHist,breaks=seq(1.1,21,by=0.625),col=grey,freq=F,xlim=c(0-shift,21-shift),plot=F) curve(dinvgamma(x,scale=11.835,shape=4.4242),from=0,to=20,add=T,col=purple,lwd=2) but this failed in shifting the curve. More broadly, the data plotted in the histogram represents a calibration target for output generated by a finite difference solute transport model. The values that will be generated by the finite difference model would ideally fit the shifted (if that can be figured out) inverse gamma pdf. To the extent that fit is deemed poor, the parameter estimation software associated with the finite difference model will adjust parameters until a better fit is found. I will try to use a goodness of fit test to determine if one set of parameter values in the finite difference model produce output that fits the inv. gamma curve herein better than another. But first I need to establish the curve the finite difference model output should target and would greatly appreciate any leads on how it might be shifted and/or fit more precisely by a fitdistr-like function. library(MASS) library(actuar) iniSal_US_forHist-c(2.368000,3.532614,3.064330,3.347069,3.066333,4.233636,3.465650,2.858553, 2.946731,2.945417,2.415000,2.873019,5.521000,5.788148,5.314630,5.509672,6.032840,6.009310, 4.110833,6.073182,5.652833,4.425733,6.481852,4.076857,3.289310,4.524000,3.985811,5.399714, 4.490606,6.956729,5.270933,8.099107,5.058250,6.394500,5.644000,5.202459,5.67,3.152680, 3.220952,2.777381,3.115467,3.642759,3.488333,3.022439,2.610290,2.618571,3.218000,3.417634, 10.327317,7.344270,6.886154,4.015800,3.063103,6.832292,4.600238,2.939000,5.999027,7.894878, 4.411538,2.384762,6.816154,2.782500,2.475333,2.799138,2.739063,2.619917,2.892545,2.468167, 2.577079,2.821875,2.502500,2.969032,2.046023,3.073077,4.408000,3.411774,3.50,4.283607, 4.284000,4.276714,3.228103,2.639875,3.453194,2.821200,3.838723,1.714253,2.273750,2.611882, 2.321781,2.567500,2.557045,1.288875,2.175211,1.736000,2.250781,7.433366,7.033553,5.47, 7.132727,8.505937,9.174545,6.554487,7.060286,6.617160,8.210986,4.404045,6.062381,5.149625, 2.972105,5.358889,3.910968,3.715873,1.728966,2.843667,4.413906,3.016346,7.168636,3.839394, 3.930141,7.019882,3.459429,5.050250,3.492714,3.226667,3.987667,2.770227,3.661167,1.553000, 2.867391,2.897193,2.611707,2.577167,2.904697,2.733077,2.507241,11.044865,6.425484,8.567222, 8.552344,7.493396,4.807381,9.697869,9.471333,6.783175,4.563571,8.059649,9.448679,5.803778, 4.769423,4.424634,7.586042,4.451556,3.622373,6.390152,4.424375,4.135806,5.025400,5.410635, 7.012292,2.961071,3.192188,2.989643,3.471429,2.867966,1.980541,3.172344,2.574783,2.958983, 1.708140,3.604853,3.479000,2.845000,2.742603,2.923968,3.620308,2.452500,2.721375,3.166333, 2.742162,2.793000,3.337000,5.192025,5.365875,3.079000,8.415970,6.612277,6.734706,4.856857, 5.164783,7.743667,6.894151,4.666538,9.227167,8.077581,6.109833,6.621724,18.098182,12.705600, 15.490784,17.394750,12.422364,14.832727,8.326000,11.352400,3.431429,2.658261,3.219773,3.605185, 4.030299,3.262241,3.503250,3.522763,2.847312,2.996618,3.075769,3.387731,3.066923,3.078200, 2.466957,3.214167,2.707778,3.384839,2.283556,2.912258,3.378000,2.726750,2.95,2.195000, 4.819063,3.604578,3.694906,5.068000,4.676582,3.028831,4.261042,3.593235,4.501224,2.880317, 5.750333,3.257833,3.967458,2.522292,2.725738,2.549231,2.591389,2.990488,2.681222,2.685854, 2.284750,2.585938,2.432824,3.108875,2.611340,3.916667,2.418095,2.476406,2.801235,3.278000, 2.434921,2.617826,3.133939,2.774321,4.196173,3.764286,3.555833,5.317361,3.970800,4.136400, 4.487013,3.746393,4.754000,3.854316,3.742353,3.044079,2.817821,3.995179,3.643134,3.642593, 3.604533,2.935902,4.088310,5.344407,3.076883,3.287105,3.720870,2.032258,2.872593,5.787313, 6.017838,5.425205,4.880600,3.582295,4.90,3.489016,4.603030,5.344407,6.184286,4.047083, 4.788304,4.661325,4.815938,4.056790,3.765595,5.348772,5.200222,4.906311,3.900147,3.782897, 3.767313,3.417732,3.725455,2.888750,2.552333,2.521613,2.531522,2.510833,2.710208,2.445273, 2.619750,2.094737,2.399355,2.758000,2.317077,2.247755,3.594333,4.607805,2.69,3.084706,
Re: [R] 2d plot with modification of plotting symbol to indicate third dimension.
have you taken a look at the hexbin package? 'cex' , 'pch' 'col' will let you make the changes Sent from my iPad On Jan 12, 2011, at 21:33, John Sorkin jsor...@grecc.umaryland.edu wrote: I would like to plot 3-dimensional data on a two-dimensional scatter-plot. Is there a way I can automatically modify the plot symbol (e.g. changing size or color) to indicate the value of a third variable? E.g. How can I plot weight vs. age and indicate the value of muscle mass for each value weight-age pair by making the plot point proportional to the subject's muscle mass? Thanks, John John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Confidentiality Statement: This email message, including any attachments, is for th...{{dropped:6}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] system(wait = FALSE) seems to fail
I'm having problems with system(wait = FALSE) with R 2.12.1 (both i386 and x64 versions) on a 64-bit Windows 7 machine. This is as expected: print(system(cmd /c dir, wait = TRUE)) This fails: print(system(cmd /c dir, wait = FALSE)) I did not see this with 2.12.0, and things seem to work fine with R 2.12.1 on a 32-bit XP machine. Can anybody else confirm what I'm seeing here? Oliver __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] CSV value not being read as it appears
I have a frustrating issue which I am hoping someone may have a suggestion about. I am running XP and R 2.12.0 and saved an EXCEL file that I was sent as a csv file. The initial code I ran follows. dec - read.csv(g://FMH/FO30122010.csv,header=T) dec.open - subset (dec, Status == Open) table(dec.open$AMHS) I was checking the output and noticed a difference between my manual count and R output. Two subject's rows were not being detected by the subset command: For the AMHS where there was a discrepancy I then ran: wm - subset (dec, AMHS == WM) The problem appears to be that there is a space before the 'Open value for two indivduals, as per the example below. 10/02/2010 Open 22/08/2007 Open Checking in EXCEL there does not appear to be a space and the format is the same (e.g 'general'). I resolved the problem by copying over the values for the two individuals where I identified a problem. Given this problem was not detected by visual scanning I would appreciate advice on how this problem can be detected in future without my having to manually check raw data against R output. Any assistance is appreciated, Bob __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] CSV value not being read as it appears
try strip.white=TRUE to strip out white space Sent from my iPad On Jan 13, 2011, at 21:44, bgr...@dyson.brisnet.org.au wrote: I have a frustrating issue which I am hoping someone may have a suggestion about. I am running XP and R 2.12.0 and saved an EXCEL file that I was sent as a csv file. The initial code I ran follows. dec - read.csv(g://FMH/FO30122010.csv,header=T) dec.open - subset (dec, Status == Open) table(dec.open$AMHS) I was checking the output and noticed a difference between my manual count and R output. Two subject's rows were not being detected by the subset command: For the AMHS where there was a discrepancy I then ran: wm - subset (dec, AMHS == WM) The problem appears to be that there is a space before the 'Open value for two indivduals, as per the example below. 10/02/2010 Open 22/08/2007 Open Checking in EXCEL there does not appear to be a space and the format is the same (e.g 'general'). I resolved the problem by copying over the values for the two individuals where I identified a problem. Given this problem was not detected by visual scanning I would appreciate advice on how this problem can be detected in future without my having to manually check raw data against R output. Any assistance is appreciated, Bob __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R not recognized in command line
It may very well have been an error in the PATH variable. But, I simply deleted the R_HOME variable and also deleted it from the PATH variable. Then I made a new one with the exact same values as before (but it worked this time). R_HOME = C:\Program Files\R\R-2.12.1 path = ...;%R_HOME%\bin\i386;... R is now recognized as a command. Thank you all very much. Im sorry I could not provide a satisfactory solution On Thu, Jan 13, 2011 at 1:12 AM, Daniel Nordlund djnordl...@frontier.comwrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Aaditya Nanduri Sent: Wednesday, January 12, 2011 9:31 PM To: gleyne...@gmail.com gleynes%...@gmail.com Cc: r-help@r-project.org; spec...@stat.berkeley.edu; Uwe Ligges Subject: Re: [R] R not recognized in command line @ Daniel Nordlund : I've also tried the dir that you recommended. R is still not recognized as a command in CMD.exe @ Uwe Ligges : There are no blanks before or after the semicolon. I added them after I copied it so that it would be more legible. And for some of the dir's in the path, having a backslash at the end still works. However, I tried it with and without the backslash for the R_HOME\bin and \bin\i386 folders. Nothing seems to work. @Gene Lynes : I have been using the GUI the whole time so it wasnt too hard changing the path constantly. And I've also set the R_HOME variable as well. I'm starting to regret clearing the partition that had Ubuntu. Life would've been so much easier had I not erased it. I will definitely let you know if I have any breakthroughs. Well, (1) either the path is still not correct, (2) R is not installed where you think it is, or (3) your windows installation is corrupted. (There are probably other options as well. Let's make sure R is installed where you think it is. The default directory for 32-bit R-2.12.1 on Windows (if you accepted the defaults) is C:\Program Files\R\R-2.12.1\bin\i386 So open up a Windows command shell and execute Rterm by typing the full path and filename C:\Program Files\R\R-2.12.1\bin\i386\Rterm.exe Make sure you include the double quotes around the complete path (because of the space in the directory path, and if you changed the installation directory then you obviously would need to change the command). Does R start up? If it does, then you still don't have the correct path stored in the PATH environment variable. If R doesn't start, then it is not installed where you think it is. Let us know your results are. Dan Daniel Nordlund Bothell, WA USA 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. -- Aaditya Nanduri aaditya.nand...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Sorting a vector with conditions
Hi, Suposse I have a vector: v-c(10,13,4,6,45,27,32,21,1,8,14,36) how do i sort just the odd numbers leaving the rest - the even numbers - on the same positions as they already are on the vector? thanks AD. -- View this message in context: http://r.789695.n4.nabble.com/Sorting-a-vector-with-conditions-tp3217031p3217031.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] bug in qplot (library ggplot2)
Hello, this following code give a nice png: /library(ggplot2) i - 1 png(file=paste('test ',i,'.png',sep='')) qplot(carat, data=diamonds, fill=color,geom='histogram')+scale_y_continuous(i) dev.off() / I would like to get more files, but the following code doesn't make any file: /library(ggplot2) for (i in 1:2) { png(file=paste('test ',i,'.png',sep='')) qplot(carat, data=diamonds, fill=color,geom='histogram')+scale_y_continuous(i) dev.off() } / Have you got any idea? Have I made something false? Thanks, Pierre-Olivier R version 2.12.1 (2010-12-16) Platform: i386-redhat-linux-gnu (32-bit) [[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] question about deparse(substitute(...))
Dear R helpers: I like to apply deparse(substitute()) on multiple arguments to collect the names of the arguments into a character vector. I used function test.fun as below. it works when there is only one input argument. but it does not work for multiple arguements. can someone kindly help? test.fun - function(...){deparse(substitute(...))} test.fun(x) #this works test.fun(x,y,z) # I like c('x','y','z') be the output, but cannot get it. Thanks in advance. -Sean [[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] Fwd: helps in data analysis
Dear List, I posted this in R-mixed and did not receive any feedback. I might post it in the wrong place. I re-post in R-help and hope to receive any suggestions and\or thoughts regarding data analysis. The objective of the study is to investigate effects of soil properties on insect outbreaks. There are four study fields (or sites). Data were collected from 1996 through 2009. Below is sampling number per site per year. table(alldfv3$year, alldfv3$site) 1 2 3 4 1996 256 265 222 197 1997 239 272 249 236 1998 216 239 216 222 1999 236 246 216 232 2000 237 251 247 246 2001 236 248 0 0 2002 233 249 210 208 2003 261 300 265 256 2004 268 281 278 263 2005 265 282 273 263 2006 268 283 277 263 2007 274 285 278 0 2008 276 288 280 0 2009 268 293 279 0 As you can see, data were not collected in some study sites in some years and sampling numbers per site per year are also vary. Sampling was conducted every 8 feet in each study site. Investigator recorded GPS (long and lat) of each sampling point. Within each sampling point, soil insects were collected and counted and soil data were also collected from each sampling site only in 2007. Investigator assumes that soil properties (e.g. pH, Mg, Ca, lime, etc) are relatively consistent year to year. Thus, measurements of soil properties in 2007 were applied to other years. So, GPS reading for insects and soil properties are different. To investigate the effect of soils on insect, first I ran thin plate spline regression to fit surface to soil data. And then, I obtained predicted soil properties using insect GPS readings so that I have the same GPS readings between insect and soils data. Due to the corlinearity among predictors, I conducted principal component analysis and obtained first 4 principal components accounting over 85 % total variation. Using coefficient of 4 principal components, new 4 predictors were obtained as follows (i.e., PC1 ~ PC4); head(df.chf09) chafer year longitude latitude paddock2 PC1 PC2 PC3 PC4 12152 0 2009 -87.85045 33.90220 11 1.1790748 -2.895178 -1.522787 -2.33674507 12153 0 2009 -87.85045 33.90214 11 0.7852655 -3.758568 -1.691573 -2.16018891 12154 0 2009 -87.85046 33.90206 11 0.5025919 -4.447035 -1.794957 -1.17294024 12155 0 2009 -87.85046 33.90199 11 0.5575338 -4.587492 -1.894354 -0.24759008 12156 0 2009 -87.85046 33.90192 11 0.7923091 -4.505882 -2.194825 0.04366179 12157 0 2009 -87.85046 33.90186 11 1.0542226 -4.448612 -2.605783 0.35938751 Below is summary of an insect species (chafer). year chf.sum chf.mean chf.max chf.min chf.n0 1 2 3 4 5 6 7 8 13 19961100 1.17 13 0 940 498 161 122 68 34 22 18 4 12 1 1997 250 0.25 8 0 996 855 80 35 14 6 4 1 0 1 0 1998 57 0.06 4 0 893 854 28 6 3 2 0 0 0 0 0 1999 4 0.00 1 0 930 926 4 0 0 0 0 0 0 0 0 2000 0 0.00 0 0 981 981 0 0 0 0 0 0 0 0 0 2001 16 0.03 5 0 484 474 7 2 0 0 1 0 0 0 0 2002 20 0.02 3 0 900 886 10 2 2 0 0 0 0 0 0 2003 48 0.04 5 0 1082 1050 22 7 1 1 1 0 0 0 0 2004 92 0.08 4 0 1090 1019 55 12 3 1 0 0 0 0 0 2005 236 0.22 6 0 1083 931 104 28 10 6 2 2 0 0 0 2006 30 0.03 3 0 1091 1067 20 2 2 0 0 0 0 0 0 2007 16 0.02 2 0 837 822 14 1 0 0 0 0 0 0 0 2008 28 0.03 4 0 844 822 18 3 0 1 0 0 0 0 0 2009 93 0.11 4 0 840 764 62 12 1 1 0 0 0 0 0 , where first column: year of data collection second column: sum of insect collected in each year third column: mean (sum/obs) fourth/fifth column: maximum/minimum number of insects sixth column: total observation number seventh through end of columns: frequencies of each respective insect counts. As you can see, I have data with extreme number of zeros in each year and by different insects. Even in 2000, there is no insect count at all. So, I tried fitting 'zero inflated Poisson model' to the data using cozigam function as follows: chf.res1 - cozigam(chafer ~ s(longitude, latitude) + s(PC1) + s(PC2) + s(PC3) + s(PC4) + (year) + paddock2, family=poisson, data=df.chf09) iteration = 2norm = 1.023552 iteration = 3norm = 0.4258558 iteration = 4norm = 0.003208923 iteration = 5norm = 0.006238185 iteration = 6norm = 0.006029638 iteration = 7norm = 0.005037579 iteration = 8norm = 0.004390153 iteration = 9norm = 0.003970208 iteration = 10 norm = 0.003670730 iteration = 11 norm = 0.00343349 iteration = 12 norm = 0.003229298 iteration = 13 norm = 0.003043741 iteration = 14 norm = 0.002869686 iteration = 15 norm =
Re: [R] Sorting a vector with conditions
On Jan 13, 2011, at 8:06 PM, ADias wrote: Hi, Suposse I have a vector: v-c(10,13,4,6,45,27,32,21,1,8,14,36) NOT executable R. how do i sort just the odd numbers leaving the rest - the even numbers - on the same positions as they already are on the vector? v[v %% 2 !=0] - sort(v[v %% 2 !=0]) v [1] 10 1 4 6 13 21 32 27 45 8 14 36 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] bug in qplot (library ggplot2)
On Jan 13, 2011, at 8:17 PM, Pierre-Olivier Chasset wrote: Hello, this following code give a nice png: /library(ggplot2) i - 1 png(file=paste('test ',i,'.png',sep='')) qplot(carat, data=diamonds, fill=color,geom='histogram')+scale_y_continuous(i) dev.off() / I would like to get more files, but the following code doesn't make any file: /library(ggplot2) for (i in 1:2) { png(file=paste('test ',i,'.png',sep='')) qplot(carat, data=diamonds, fill=color,geom='histogram')+scale_y_continuous(i) dev.off() Read the FAQs. } / Have you got any idea? Have I made something false? Thanks, Pierre-Olivier 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] Grid drawing over the filled.contour's legend
Add the following lines before grid: # insert 3 lines of code, stolen from filled.contour(): mar.orig - par(mar) w - (3 + mar.orig[2]) * par(csi) * 2.54 layout(matrix(c(2, 1), nc = 2), widths = c(1, lcm(w))) Taken from thil list somewhere. Ciao! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Fwd: Re: [R-sig-hpc] Working doSNOW foreach openMPI example
Whas missing the R in the command line: mpirun -n --hostfile /home/hostfile R --no-save -f rtest.R Hope this helps mario On 13-Jan-11 22:08, Justin Moriarty wrote: Hi, Just wanted to share a working example of doSNOW and foreach for an openMPI cluster. The function eddcmp() is just an example and returns some inocuous warnings. The example first has each node return its nodename, then runs an example comparing dopar, do and a for loop. In the directory containing rtest.R it is run from the command line with: mpirun -n --hostfile /home/hostfile --no-save -f rtest.R Here is the code for rtest.R: # library(doSNOW) library(panel) cl-makeMPIcluster(3) registerDoSNOW(cl) clusterEvalQ(cl,library(panel)) res-clusterCall(cl, function(){Sys.info()[nodename]}) print(do.call(rbind,res)) sme- matrix(rnorm(100),10,10) clusterExport(cl,sme) myfun-function() { for(i in 1:1000) { x-eddcmp(sme) } } ged-0 system.time({ ged-foreach(i=1:10) %dopar% { myfun() } }) system.time({ ged-foreach(i=1:10) %do% { myfun() } }) system.time({ for(i in 1:10) { ged-myfun() } }) stopCluster(cl) mpi.quit() # Cheers, Justin [[alternative HTML version deleted]] ___ R-sig-hpc mailing list r-sig-...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-hpc -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] question about deparse(substitute(...))
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Sean Zhang Sent: Thursday, January 13, 2011 4:37 PM To: r-help@r-project.org Subject: [R] question about deparse(substitute(...)) Dear R helpers: I like to apply deparse(substitute()) on multiple arguments to collect the names of the arguments into a character vector. I used function test.fun as below. it works when there is only one input argument. but it does not work for multiple arguements. can someone kindly help? test.fun - function(...){deparse(substitute(...))} test.fun(x) #this works test.fun(x,y,z) # I like c('x','y','z') be the output, but cannot get it. One way is: f - function(...) lapply(substitute(placeholderFunction(...))[-1], deparse) f(x, log(y), (function(a){a+a^2/2+a^3/6})(z)) [[1]] [1] x [[2]] [1] log(y) [[3]] [1] (function(a) { [2] a + a^2/2 + a^3/6 [3] })(z) Use paste(collapse=\n,s) or s[1] on deparse's output if you require one string per input. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com Thanks in advance. -Sean [[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] Direchlet Process Simulation
Hello, I am looking for a simulator for the Dirichlet Process SImulator. Can you advise me if R has one? -- Thanks, Jim. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] RSQLite - How to express(or save) a dataframe as an output?
Dear R helpers Suppose following is an output due to some R process. I wish to save it as a table in 'temp.db' df - data.frame(x = c(5, 4, 3, 11), y = c(25, 16, 9, 121)) library(RSQLite) write('** Initializing','') drv - dbDriver(SQLite, shared.cache = TRUE) con - dbConnect(drv, dbname = temp.db, loadable.extensions=TRUE) on.exit(dbUnloadDriver(drv)) on.exit(dbDisconnect(con)) write('** Save output', '') dbBeginTransaction(con) dbGetPreparedQuery(con, INSERT INTO output(df) VALUES (?), data.frame(output)) dbCommit(con) dbGetPreparedQuery(con, INSERT INTO output(df) VALUES (?), data.frame(output)) # - I get following message Error in dbGetPreparedQuery(con, INSERT INTO output(df) VALUES (?), : error in evaluating the argument 'bind.data' in selecting a method for function 'dbGetPreparedQuery' [[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.