Re: [R] regular pentagon
On Sun, Mar 9, 2014 at 5:11 AM, Rolf Turner r.tur...@auckland.ac.nz wrote: On 08/03/14 10:22, Yuanzhi Li wrote: Hello, everyone, Do you have any idea to get a set of random points within a regular pentagon? Thanks in advance! You can easily do this using the spatstat package. Or with sines, cosines, and 72 degrees. Generate points in a triangle and apply a random (0,4) integer multiple of 72 rotation Never mind asking us if we have any idea, do you (original poster) have any idea? Barry [[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] Can rJava connect with Oracle JDK7 on Mac OS X?
Hello, I'm writing a program that provide an interactive interface between R and JavaFX (2.2+), https://github.com/oogasawa/rjfx.chart on the top of the rJava package. This program works fine on Linux and MS-Windows, but it does not work on Mac OS X. The reason seems that rJava on Mac OS X ignores JAVA_HOME environment variable, and uses JDK distributed by Appele (now it's version is 1.6). Since JavaFX (2.2+) requires JDK7 or higher, this means that program can not run on OS X. Does someone knows how to get around this? I have installed JDK7u51 from Oracle Web site: (MacBook Pro, OS X 10.9) $ env | grep JAVA_HOME JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home $ java -version java version 1.7.0_51 Java(TM) SE Runtime Environment (build 1.7.0_51-b13) Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode) However, when I install the program (rjfx.chart), R required to install JDK6 and the result is as follows: library(rJava) .jinit() s=.jnew(java/lang/System) .jcall(s, Ljava/lang/String;, getProperty, java.version) [1] 1.6.0_65 I would like to appreciate any comments and suggestions. Sincerely, Osamu Ogasawara __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] package environment versus namespace environment
On 14-03-08 6:42 PM, Benjamin Tyner wrote: Duncan, Thank you for the informative link. So, do the loaded namespaces have an ordering akin to the package search path that determines that functions in the base namespace can see objects in the utils namespace? (I noticed that loadedNamespaces() just comes back in alphabetical order.) No. The article that Henrik cited gives a reasonable description up until near the end, where (in my opinion) it makes things unnecessarily complicated. I'd recommend that you stop reading around where he tries to explain the dotted lines. In particular, ignore the second version of the Map of the World; the first one is accurate, the second is just misleading. In answer to your question: Gupta's article misses the possibility of packages that are loaded but not in the search path. In the notation of the first part of that article, loading a namespace just puts it in the middle two columns (i.e. creates the namespace and imports environments) without putting it in the search list. That happens when you import or load a package without attaching it. The search path imposes an ordering, things that aren't in it aren't ordered. Duncan Murdoch Regards Ben On 03/07/2014 11:46 AM, Duncan Murdoch wrote: On 07/03/2014 10:16 AM, Benjamin Tyner wrote: Hello, I realize that a function in environment: base (for example, function head1 below) is unable to see (without resorting to ::, anyway) objects in utils (for example, head below), since package:base is after package:utils on the search path. However, I'm wondering what is the machinery that allows a function in environment: namespace:base (for example, function head2 below) to be able to see head just fine, without needing to resort to ::. See Luke Tierney's article in R News, Name space management for R. Luke Tierney, R News, 3(1):2-6, June 2003 http://cran.r-project.org/doc/Rnews/Rnews_2003-1.pdf There's a link to it from the R help system. Run help.start(), then look at Technical papers in the Miscellaneous Material section. I believe most of what it says is still current; the only thing I can see at a glance that is no longer correct is that in those days namespaces were optional in packages. Now all packages have namespaces. Duncan Murdoch I'm also wondering more generally, why there is a need (practically speaking) for a distinction between the environment associated with a package and the environment associated with the namespace. $ export R_PROFILE=/home/btyner/Rprofile.site $ cat /home/btyner/Rprofile.site sys.source(/home/btyner/head1.R, envir = baseenv()) sys.source(/home/btyner/head2.R, envir = .BaseNamespaceEnv) $ cat /home/btyner/head1.R head1 - function(x) head(x) $ cat /home/btyner/head2.R head2 - function(x) head(x) $ Rscript -e head1(letters) Error in head1(letters) : could not find function head Execution halted $ Rscript -e head2(letters) [1] a b c d e f $ Rscript -e sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets base Regards Ben __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Saving R files
Hi David, Again, please keep the list copied. I think the documentation is clear, but if you still have doubts why don't you try it and see? Best, Ista On Sat, Mar 8, 2014 at 11:39 PM, David Parkhurst parkh...@imap.iu.edu wrote: That talks about saving to file .RData. I'm still asking, can I save to files with an arbitrary name in any directory on my hard drive? Again, that may be implied, but I wasn't confident that if I saved my workspace that way, that I would be able get it back later, after working on other projects. I'd like to put files in specific places where I can find them, such as to the file=C:\am\myfiles\ProjectA.RData that I referred to in my original posting. David On 3/8/2014 11:29 PM, Ista Zahn wrote: On Sat, Mar 8, 2014 at 11:14 PM, David Parkhurst parkh...@imap.iu.edu wrote: The penultimate line in ?rm is rm(list = ls()). I don't see anything that specific in ?save, and that's why I asked. Perhaps there's language in ?save that implies that to those more experienced in R than I am, but I'm not that experienced. Yes--see e.g., the second paragraph of the description in ?save: ‘save.image()’ is just a short-cut for ‘save my current workspace’, i.e., ‘save(list = ls(all = TRUE), file = .RData)’. It is also what happens with ‘q(yes)’. The documentation of the arguments list to save (especially the list argument) will also tell you that you can pass a character vector of object names to be saved. Such a vector can be returned from 'ls()'. Best, Ista David On 3/8/2014 10:07 PM, Ista Zahn wrote: Hi David, Please keep the list copied, that will give someone else an opportunity to respond to you as well (I've cc'd the list here). On Sat, Mar 8, 2014 at 8:42 PM, IU parkh...@imap.iu.edu wrote: Thank you---but can't you tell from what I wrote that I DID read ?save, and didn't see the answer to my question there. To be honest, no. You say you guessed at the the syntax based on what you read in ?rm. Why you would do that instead of referring directly to ?save is made me suspect that you didn't actually read the documentation, especially since the relevant arguments are the same in both functions. At any rate, what is it you find unclear about the documentation for the save function? It all seems pretty clear to me, but then I've been reading R documentation for some time. Perhaps if you explain what you didn't understand someone can help you clarify. And thanks for the reminder about the FAQ. Sure, anytime. Best, Ista DFP (iPad) On Mar 8, 2014, at 8:31 PM, Ista Zahn istaz...@gmail.com wrote: Hi David, Did you actually read the help file for 'save'? The answer to your fist question is there. The answer to your second question is in section 2.16 of the 'R for Windows FAQ'. Best, Ista On Sat, Mar 8, 2014 at 7:45 PM, David Parkhurst parkh...@imap.iu.edu wrote: Sometimes I don't understand the details of writeups I get, with ?save and the like. Anyway, that's my problem now. Can I do this (in Windows 7) to save everything that comes up with ls(), guessed at by what I find with ?rm: save(list=ls(),file=C:\am\myfiles\ProjectA.RData) Or would I need forward slashes, but this would otherwise work? If not, how could I accomplish this goal? David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] as.Date converts to NA
Hello, I have some problems with as.Date. strDates - c (01/05/1965, 08/16/1975) dates - as.Date (strDates, %m/%d%/%Y) dates [1] NA NA # I expected my dates. What was going wrong? Thanks Hermann [[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] as.Date converts to NA
On 09.03.2014 11:34, Hermann Norpois wrote: Hello, I have some problems with as.Date. strDates - c (01/05/1965, 08/16/1975) dates - as.Date (strDates, %m/%d%/%Y) ^ Remove the % after the d. Best, Uwe Ligges dates [1] NA NA # I expected my dates. What was going wrong? Thanks Hermann [[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] as.Date converts to NA
On Sun, 9 Mar 2014, Hermann Norpois wrote: Hello, I have some problems with as.Date. strDates - c (01/05/1965, 08/16/1975) dates - as.Date (strDates, %m/%d%/%Y) Instead of %d% just %d: R as.Date(strDates, %m/%d/%Y) [1] 1965-01-05 1975-08-16 dates [1] NA NA # I expected my dates. What was going wrong? Thanks Hermann [[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] Can rJava connect with Oracle JDK7 on Mac OS X?
This is all in the R-admin manual. You may have to install rJava from the sources. And such questions belong on r-sig-mac: see the posting guide. On 9 Mar 2014, at 11:32, Osamu Ogasawara osamu.ogasaw...@gmail.com wrote: Hello, I'm writing a program that provide an interactive interface between R and JavaFX (2.2+), https://github.com/oogasawa/rjfx.chart on the top of the rJava package. This program works fine on Linux and MS-Windows, but it does not work on Mac OS X. The reason seems that rJava on Mac OS X ignores JAVA_HOME environment variable, and uses JDK distributed by Appele (now it's version is 1.6). Since JavaFX (2.2+) requires JDK7 or higher, this means that program can not run on OS X. Does someone knows how to get around this? I have installed JDK7u51 from Oracle Web site: (MacBook Pro, OS X 10.9) $ env | grep JAVA_HOME JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home $ java -version java version 1.7.0_51 Java(TM) SE Runtime Environment (build 1.7.0_51-b13) Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode) However, when I install the program (rjfx.chart), R required to install JDK6 and the result is as follows: library(rJava) .jinit() s=.jnew(java/lang/System) .jcall(s, Ljava/lang/String;, getProperty, java.version) [1] 1.6.0_65 I would like to appreciate any comments and suggestions. Sincerely, Osamu Ogasawara __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] package environment versus namespace environment
Duncan, Thanks for the explanation and commentary. Starting to make more sense...so, long story short, it seems the first thing one should check is whether base imports utils: packageDescription(base) Package: base Version: 3.0.1 Priority: base Title: The R Base Package Author: R Core Team and contributors worldwide Maintainer: R Core Team [1]r-c...@r-project.org Description: Base R functions License: Part of R 3.0.1 Built: R 3.0.1; ; 2013-10-16 10:50:56 UTC; unix -- File: /usr/lib/R/library/base/Meta/package.rds I'll interpret the lack of an Imports: line to mean that base does not import any packages. So then the next thing to check is the enclosing environment: parent.env(.BaseNamespaceEnv) environment: R_GlobalEnv Ah-ha! Unlike the base package environment, the base namespace environment has its enclosing environment already on the search path, so eventually leads back to utils. (This is the piece of the puzzle prompting my original question about ... machinery that allows ...) So hypothetically, if I had attached utils ahead of .GlobalEnv on the search path, then functions in the base namespace would no longer be able to see objects in utils? (I realize the answer may be vacuous, since library() does not honor pos=1). Regards, Ben On 03/09/2014 09:09 AM, Duncan Murdoch wrote: On 14-03-08 6:42 PM, Benjamin Tyner wrote: Duncan, Thank you for the informative link. So, do the loaded namespaces have an ordering akin to the package search path that determines that functions in the base namespace can see objects in the utils namespace? (I noticed that loadedNamespaces() just comes back in alphabetical order.) No. The article that Henrik cited gives a reasonable description up until near the end, where (in my opinion) it makes things unnecessarily complicated. I'd recommend that you stop reading around where he tries to explain the dotted lines. In particular, ignore the second version of the Map of the World; the first one is accurate, the second is just misleading. In answer to your question: Gupta's article misses the possibility of packages that are loaded but not in the search path. In the notation of the first part of that article, loading a namespace just puts it in the middle two columns (i.e. creates the namespace and imports environments) without putting it in the search list. That happens when you import or load a package without attaching it. The search path imposes an ordering, things that aren't in it aren't ordered. Duncan Murdoch Regards Ben On 03/07/2014 11:46 AM, Duncan Murdoch wrote: On 07/03/2014 10:16 AM, Benjamin Tyner wrote: Hello, I realize that a function in environment: base (for example, function head1 below) is unable to see (without resorting to ::, anyway) objects in utils (for example, head below), since package:base is after package:utils on the search path. However, I'm wondering what is the machinery that allows a function in environment: namespace:base (for example, function head2 below) to be able to see head just fine, without needing to resort to ::. See Luke Tierney's article in R News, Name space management for R. Luke Tierney, R News, 3(1):2-6, June 2003 [2]http://cran.r-project.org/doc/Rnews/Rnews_2003-1.pdf There's a link to it from the R help system. Run help.start(), then look at Technical papers in the Miscellaneous Material section. I believe most of what it says is still current; the only thing I can see at a glance that is no longer correct is that in those days namespaces were optional in packages. Now all packages have namespaces. Duncan Murdoch I'm also wondering more generally, why there is a need (practically speaking) for a distinction between the environment associated with a package and the environment associated with the namespace. $ export R_PROFILE=/home/btyner/Rprofile.site $ cat /home/btyner/Rprofile.site sys.source(/home/btyner/head1.R, envir = baseenv()) sys.source(/home/btyner/head2.R, envir = .BaseNamespaceEnv) $ cat /home/btyner/head1.R head1 - function(x) head(x) $ cat /home/btyner/head2.R head2 - function(x) head(x) $ Rscript -e head1(letters) Error in head1(letters) : could not find function head Execution halted $ Rscript -e head2(letters) [1] a b c d e f $ Rscript -e sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8
Re: [R] Saving R files
Can I do this (in Windows 7) to save everything that comes up with ls(), guessed at by what I find with ?rm: save(list=ls(),file=C:\am\myfiles\ProjectA.RData) Or would I need forward slashes, but this would otherwise work? You did not show the error message you got from that failing command. I get: x - 1 save(x, file=C:\am\myfiles\ProjectA.RData) Error: '\m' is an unrecognized escape in character string starting C:\am\m C:\am\myfiles\ProjectA.RData Error: '\m' is an unrecognized escape in character string starting C:\am\m which is intended to make it clear that \m is not legal in a string. If, instead of 'escape' it said 'backslashed character', would you have understood that the problem is with how backslashes are represented in R strings? Bill Dunlap TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ista Zahn Sent: Sunday, March 09, 2014 7:25 AM To: David Parkhurst Cc: r-help@r-project.org Subject: Re: [R] Saving R files Hi David, Again, please keep the list copied. I think the documentation is clear, but if you still have doubts why don't you try it and see? Best, Ista On Sat, Mar 8, 2014 at 11:39 PM, David Parkhurst parkh...@imap.iu.edu wrote: That talks about saving to file .RData. I'm still asking, can I save to files with an arbitrary name in any directory on my hard drive? Again, that may be implied, but I wasn't confident that if I saved my workspace that way, that I would be able get it back later, after working on other projects. I'd like to put files in specific places where I can find them, such as to the file=C:\am\myfiles\ProjectA.RData that I referred to in my original posting. David On 3/8/2014 11:29 PM, Ista Zahn wrote: On Sat, Mar 8, 2014 at 11:14 PM, David Parkhurst parkh...@imap.iu.edu wrote: The penultimate line in ?rm is rm(list = ls()). I don't see anything that specific in ?save, and that's why I asked. Perhaps there's language in ?save that implies that to those more experienced in R than I am, but I'm not that experienced. Yes--see e.g., the second paragraph of the description in ?save: ‘save.image()’ is just a short-cut for ‘save my current workspace’, i.e., ‘save(list = ls(all = TRUE), file = .RData)’. It is also what happens with ‘q(yes)’. The documentation of the arguments list to save (especially the list argument) will also tell you that you can pass a character vector of object names to be saved. Such a vector can be returned from 'ls()'. Best, Ista David On 3/8/2014 10:07 PM, Ista Zahn wrote: Hi David, Please keep the list copied, that will give someone else an opportunity to respond to you as well (I've cc'd the list here). On Sat, Mar 8, 2014 at 8:42 PM, IU parkh...@imap.iu.edu wrote: Thank you---but can't you tell from what I wrote that I DID read ?save, and didn't see the answer to my question there. To be honest, no. You say you guessed at the the syntax based on what you read in ?rm. Why you would do that instead of referring directly to ?save is made me suspect that you didn't actually read the documentation, especially since the relevant arguments are the same in both functions. At any rate, what is it you find unclear about the documentation for the save function? It all seems pretty clear to me, but then I've been reading R documentation for some time. Perhaps if you explain what you didn't understand someone can help you clarify. And thanks for the reminder about the FAQ. Sure, anytime. Best, Ista DFP (iPad) On Mar 8, 2014, at 8:31 PM, Ista Zahn istaz...@gmail.com wrote: Hi David, Did you actually read the help file for 'save'? The answer to your fist question is there. The answer to your second question is in section 2.16 of the 'R for Windows FAQ'. Best, Ista On Sat, Mar 8, 2014 at 7:45 PM, David Parkhurst parkh...@imap.iu.edu wrote: Sometimes I don't understand the details of writeups I get, with ?save and the like. Anyway, that's my problem now. Can I do this (in Windows 7) to save everything that comes up with ls(), guessed at by what I find with ?rm: save(list=ls(),file=C:\am\myfiles\ProjectA.RData) Or would I need forward slashes, but this would otherwise work? If not, how could I accomplish this goal? David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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
Re: [R] Saving R files
I hadn’t seen an error message because I hadn’t tried it yet. I was leery of doing so for two reasons. First, I didn’t seen anything in the ?save page that said it was possible to save to a file and directory of the user’s choice, and later to retrieve it! It would be very useful to a novice like me if the ?save page had an example at the end showing that being done. (Frankly, many of the help pages seem very dense, and not sufficiently informative, to a novice like me.) The second thing that made me leery of trying it was the text in the “R for Windows FAQ” in section 2.10, that made me think (evidently wrongly) that my projects had to be kept within R’s own directories. I think you are suggesting that what I was asking about would work if I used forward slashes. I'll try that. Thank you for the information you’ve provided. It is helpful. David On 3/9/2014 3:05 PM, William Dunlap wrote: Can I do this (in Windows 7) to save everything that comes up with ls(), guessed at by what I find with ?rm: save(list=ls(),file=C:\am\myfiles\ProjectA.RData) Or would I need forward slashes, but this would otherwise work? You did not show the error message you got from that failing command. I get: x - 1 save(x, file=C:\am\myfiles\ProjectA.RData) Error: '\m' is an unrecognized escape in character string starting C:\am\m C:\am\myfiles\ProjectA.RData Error: '\m' is an unrecognized escape in character string starting C:\am\m which is intended to make it clear that \m is not legal in a string. If, instead of 'escape' it said 'backslashed character', would you have understood that the problem is with how backslashes are represented in R strings? Bill Dunlap TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ista Zahn Sent: Sunday, March 09, 2014 7:25 AM To: David Parkhurst Cc: r-help@r-project.org Subject: Re: [R] Saving R files Hi David, Again, please keep the list copied. I think the documentation is clear, but if you still have doubts why don't you try it and see? Best, Ista On Sat, Mar 8, 2014 at 11:39 PM, David Parkhurst parkh...@imap.iu.edu wrote: That talks about saving to file .RData. I'm still asking, can I save to files with an arbitrary name in any directory on my hard drive? Again, that may be implied, but I wasn't confident that if I saved my workspace that way, that I would be able get it back later, after working on other projects. I'd like to put files in specific places where I can find them, such as to the file=C:\am\myfiles\ProjectA.RData that I referred to in my original posting. David On 3/8/2014 11:29 PM, Ista Zahn wrote: On Sat, Mar 8, 2014 at 11:14 PM, David Parkhurst parkh...@imap.iu.edu wrote: The penultimate line in ?rm is rm(list = ls()). I don't see anything that specific in ?save, and that's why I asked. Perhaps there's language in ?save that implies that to those more experienced in R than I am, but I'm not that experienced. Yes--see e.g., the second paragraph of the description in ?save: ‘save.image()’ is just a short-cut for ‘save my current workspace’, i.e., ‘save(list = ls(all = TRUE), file = .RData)’. It is also what happens with ‘q(yes)’. The documentation of the arguments list to save (especially the list argument) will also tell you that you can pass a character vector of object names to be saved. Such a vector can be returned from 'ls()'. Best, Ista David On 3/8/2014 10:07 PM, Ista Zahn wrote: Hi David, Please keep the list copied, that will give someone else an opportunity to respond to you as well (I've cc'd the list here). On Sat, Mar 8, 2014 at 8:42 PM, IU parkh...@imap.iu.edu wrote: Thank you---but can't you tell from what I wrote that I DID read ?save, and didn't see the answer to my question there. To be honest, no. You say you guessed at the the syntax based on what you read in ?rm. Why you would do that instead of referring directly to ?save is made me suspect that you didn't actually read the documentation, especially since the relevant arguments are the same in both functions. At any rate, what is it you find unclear about the documentation for the save function? It all seems pretty clear to me, but then I've been reading R documentation for some time. Perhaps if you explain what you didn't understand someone can help you clarify. And thanks for the reminder about the FAQ. Sure, anytime. Best, Ista DFP (iPad) On Mar 8, 2014, at 8:31 PM, Ista Zahn istaz...@gmail.com wrote: Hi David, Did you actually read the help file for 'save'? The answer to your fist question is there. The answer to your second question is in section 2.16 of the 'R for Windows FAQ'. Best, Ista On Sat, Mar 8, 2014 at 7:45 PM, David Parkhurst parkh...@imap.iu.edu wrote: Sometimes I don't understand the details of writeups I get, with ?save and the like. Anyway, that's my problem
[R] Help - Strucchange pakage
Hi there, in Zeileis, Klieber Kramer and Hornik (2003) - Testing and dating of structural changes in practice its shows how to use the strucchange pakge to determine breakpoints in time series, my question is in regard to one of the figures that is presented in this paper. At the end of every example its shown a neat graph (ex: Figure 13) of the fitted model for the series being tested. My question is: Is there a function in R that outputs those kinds of graphs? Thanks very much for your attention, José Robalo. [[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] as.Date converts to NA
Hi, Check for the additional % in your code %d%. as.Date(strDates,%m/%d/%Y) #[1] 1965-01-05 1975-08-16 A.K. On Sunday, March 9, 2014 12:16 PM, Hermann Norpois hnorp...@gmail.com wrote: Hello, I have some problems with as.Date. strDates - c (01/05/1965, 08/16/1975) dates - as.Date (strDates, %m/%d%/%Y) dates [1] NA NA # I expected my dates. What was going wrong? Thanks Hermann [[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] cum sums
Suppose I have a dataframe beginning: id yr val a 1950 1 b 1950 10 a 1951 2 I'm trying to produce a table of cumulative sums of val, disaggregated by id and then yr, so the result should begin id yr cumval a 1950 1 a 1951 3 b 1950 10 I've been trying to do this using aggregate and passing the function cumsum, but I can't get it to work. Can someone tell me how to do this? Thanks! Philip A. Viton City Planning, Ohio State University 275 West Woodruff Avenue, Columbus OH 43210 vito...@osu.edu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help - Strucchange pakage
On Sun, 9 Mar 2014, Umaga Optudio wrote: Hi there, in Zeileis, Klieber Kramer and Hornik (2003) - Testing and dating of structural changes in practice its shows how to use the strucchange pakge to determine breakpoints in time series, my question is in regard to one of the figures that is presented in this paper. At the end of every example its shown a neat graph (ex: Figure 13) of the fitted model for the series being tested. My question is: Is there a function in R that outputs those kinds of graphs? Yes. However, the oil price data is not freely available and hence it is not in the package. The other two applications (Nile and seatbelt data) are used for the examples in ?breakpoints. Thanks very much for your attention, Jos? Robalo. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to obtain a mean by more than one other variable
I'm trying to create a new variable (meanABUNDHA) by obtaining a mean value *by* other variables. I surveyed birds (multiple species) at multiple sites and have multiple surveys within a REP (i.e. in example data below, SURVEY 55 and 57 are in REP 11). I need the mean ABUNDHA (pooling SURVEY) for each BIRD species by REP and by SITE. Below, I would average 0.77 and 0.15 for MALL in REP 11 at SITE 1 to get 0.46 meanABUNDHA. An example of my data are as follows, including the new variable I hope to create meanABUNDHA: SITEREP SURVEY BIRDABUNDHA meanABUNDHA 1 1157 MALL 0.770.46 1 1155 MALL 0.150.46 1 1258 MALL 0.140.14 1 2 58 BAEA 0.030.03 3 4 64 AMCR 0.220.45 3 5 65 AMCR 0.670.45 7 11 56 MALL 0.010.01 I'm not sure how to incorporate more than one by=? data.all4[,mean(ABUNDHA),by= REP] #Add new column containing the by-REP mean of ABUNDHA data.all5-data.all4[,ABUNDHAmean:=mean(ABUNDHA),by=REP] Thank you for any guidance!! [[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] cum sums
On 03/10/2014 05:57 AM, Philip A. Viton wrote: Suppose I have a dataframe beginning: id yr val a 1950 1 b 1950 10 a 1951 2 I'm trying to produce a table of cumulative sums of val, disaggregated by id and then yr, so the result should begin id yr cumval a 1950 1 a 1951 3 b 1950 10 I've been trying to do this using aggregate and passing the function cumsum, but I can't get it to work. Can someone tell me how to do this? Hi Philip, Kinda messy, but try this: df-read.table(text=id yr val a 1950 1 b 1950 10 a 1951 2 b 1952 3 c 1952 4 a 1954 5 b 1954 2 c 1954 3,header=TRUE) dfc-by(df[,2:3],df$id,cumsum) ids-names(dfc) dfcc-cbind(rep(ids[1],dim(dfc[[1]])[1]),dfc[[1]]) names(dfcc)-names(df) for(n in 2:length(dfc)) { dfpc-cbind(rep(ids[n],dim(dfc[[n]])[1]),dfc[[n]]) names(dfpc)-names(df) dfcc-rbind(dfcc,dfpc) } 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 resolving issues with generating a chi-squared density plot from scratch
I wrote the code to graph a chi-squared density function, shade the percentile, and point to the CV, but it has a few issues I can't seem to resolve 1. It won't work at all for DF = 1 due to ylim going to infinity, but I haven't been able to resolve this still after hours of trying. 2) The y-axis is numbered only relatively; I'd prefer they were the actual prob densities, but again, I fiddled with a few things, but it just wouldn't get me what I wanted. 3) For low degrees of freedom and higher percentiles, the arrow pointing to CV seems to end up going diagonal instead of straight down Here's the code below and here's the URL for R fiddle for the code which might make it easier to fix: http://www.r-fiddle.org/#/fiddle?id=ChFi0dyJversion=4 chi.dens = function(x = NULL, df = NULL, cv = NULL) { # x = percentile/quantile # df = degrees of freedom # cv = critical value if(x1 ||x0) stop(Percentile must be between 0 and 1) # Error-handling qend = qchisq(x, df) perc = x qt0=qchisq(0.5, df) # Defining for arrows later dy0=dchisq(0.45, df) # Defining for arrows later xrange = qchisq (0.999, df) x = seq(0, xrange) y = dchisq(x, df) yheight = max(dchisq(x, df)) # Creating plot plot(x,y,type = l, ylim=c(0,yheight),axes=FALSE) title( Chi-squared Density Curve with) mtext(bquote(paste(DF = , .(df), and Percentile = , .(perc))), side = 3, line = 0) # Input information # Shading left tail-region qt = signif(qend,5) x0=seq(0, qt) y0=dchisq(x0, df) polygon(c(0, x0, qt), c(0, y0, 0), col = lightblue) xtks=signif(seq(0,xrange,length=10),3) axis(1, pos=0, at=xtks, labels=xtks) y.unit=max(dchisq(x, df))/5 y.pos=seq(0,5*y.unit, length=5) y.lab=c(0, 1, 2, 3, 4) # Y axis numbers only reflect relative densities to each other. axis(2,pos=0, at=y.pos, labels=y.lab)# set up y-axis # Normal CV less than the 99.9 Percentile: if(qt = xrange){ if(length(cv)==0) text(0.75*xrange,3*y.unit, bquote(paste(CV = , .(qend))), cex=1.2, col = red,adj=0.5) # if(length(perc)==1) text(0.35*xrange,3*y.unit, paste(Area = , perc), cex=1.2, col=darkblue, adj=0.5) if(perc0.5){ arrows(0.35*xrange, 2.5*y.unit, qt0, 0.3*dy0, length=0.1, angle=20) # pointing to the shaded region } if(perc=0.5){ arrows(0.35*xrange, 2.5*y.unit, qt/2, 0.3*dy0, length=0.1, angle=20) # pointing to the shaded region } arrows(0.75*xrange, 2.5*y.unit, qt, 0, length=0.1, angle=20) points(qt,0,pch=17, col=red) } # When CV is greater than the 99.9 Percentile: if(qt xrange){ print(CV may be too far to the right to be shown on graph due to the high percentile) if(length(cv)==0) text(0.75*xrange,3*y.unit, bquote(paste(CV = , .(qend))), cex=1.2, col = red,adj=0.5) if(length(perc)==1) text(0.35*xrange,3*y.unit, paste(Area = , perc), cex=1.2, col=darkblue, adj=0.5) if(perc0.5){ arrows(0.35*xrange, 2.5*y.unit, qt0, 0.3*dy0, length=0.1, angle=20) # pointing to the shaded region } if(perc=0.5){ arrows(0.35*xrange, 2.5*y.unit, qt/2, 0.3*dy0, length=0.1, angle=20) # pointing to the shaded region } arrows(0.75*xrange, 2.5*y.unit, qt, 0, length=0.1, angle=20) points(qt,0,pch=17, col=red) } } [[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 obtain a mean by more than one other variable
Tena koe Erynn Have you checked tapply and aggregate? HTH Peter Alspach -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Erynn Call Sent: Monday, 10 March 2014 3:40 p.m. To: r-help@r-project.org Subject: [R] How to obtain a mean by more than one other variable I'm trying to create a new variable (meanABUNDHA) by obtaining a mean value *by* other variables. I surveyed birds (multiple species) at multiple sites and have multiple surveys within a REP (i.e. in example data below, SURVEY 55 and 57 are in REP 11). I need the mean ABUNDHA (pooling SURVEY) for each BIRD species by REP and by SITE. Below, I would average 0.77 and 0.15 for MALL in REP 11 at SITE 1 to get 0.46 meanABUNDHA. An example of my data are as follows, including the new variable I hope to create meanABUNDHA: SITEREP SURVEY BIRDABUNDHA meanABUNDHA 1 1157 MALL 0.770.46 1 1155 MALL 0.150.46 1 1258 MALL 0.140.14 1 2 58 BAEA 0.030.03 3 4 64 AMCR 0.220.45 3 5 65 AMCR 0.670.45 7 11 56 MALL 0.010.01 I'm not sure how to incorporate more than one by=? data.all4[,mean(ABUNDHA),by= REP] #Add new column containing the by-REP mean of ABUNDHA data.all5-data.all4[,ABUNDHAmean:=mean(ABUNDHA),by=REP] Thank you for any guidance!! [[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. The contents of this e-mail are confidential and may be ...{{dropped:14}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 obtain a mean by more than one other variable
One function I like is from package psych. library(psych) describe.by(ARK$TotalWater, group=Tray:Pot) Andrew Koeser On 3/9/2014 10:39 PM, Erynn Call wrote: I'm trying to create a new variable (meanABUNDHA) by obtaining a mean value *by* other variables. I surveyed birds (multiple species) at multiple sites and have multiple surveys within a REP (i.e. in example data below, SURVEY 55 and 57 are in REP 11). I need the mean ABUNDHA (pooling SURVEY) for each BIRD species by REP and by SITE. Below, I would average 0.77 and 0.15 for MALL in REP 11 at SITE 1 to get 0.46 meanABUNDHA. An example of my data are as follows, including the new variable I hope to create meanABUNDHA: SITEREP SURVEY BIRDABUNDHA meanABUNDHA 1 1157 MALL 0.770.46 1 1155 MALL 0.150.46 1 1258 MALL 0.140.14 1 2 58 BAEA 0.030.03 3 4 64 AMCR 0.220.45 3 5 65 AMCR 0.670.45 7 11 56 MALL 0.010.01 I'm not sure how to incorporate more than one by=? data.all4[,mean(ABUNDHA),by= REP] #Add new column containing the by-REP mean of ABUNDHA data.all5-data.all4[,ABUNDHAmean:=mean(ABUNDHA),by=REP] Thank you for any guidance!! [[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. -- Andrew Koeser, BCMA, Ph.D. Assistant Professor of Landscape Management University of Florida - Gulf Coast Research and Education Center 813-633-4150 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cum sums
Tena koe Philip An alternative to Jim's solution which seems to work and you may, or may not, find less messy: df - read.table(text=id yr val a 1950 1 b 1950 10 a 1951 2 b 1952 3 c 1952 4 a 1954 5 b 1954 2 c 1954 3,header=TRUE) df1 - df[order(df$id, df$yr),] df1$valCS - unlist(by(df1$val, df1$id, cumsum)) df1 If you need to get back to the original order you can sort by row.names. HTH Peter Alspach -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jim Lemon Sent: Monday, 10 March 2014 3:04 p.m. To: Philip A. Viton Cc: r-help@r-project.org Subject: Re: [R] cum sums On 03/10/2014 05:57 AM, Philip A. Viton wrote: Suppose I have a dataframe beginning: id yr val a 1950 1 b 1950 10 a 1951 2 I'm trying to produce a table of cumulative sums of val, disaggregated by id and then yr, so the result should begin id yr cumval a 1950 1 a 1951 3 b 1950 10 I've been trying to do this using aggregate and passing the function cumsum, but I can't get it to work. Can someone tell me how to do this? Hi Philip, Kinda messy, but try this: df-read.table(text=id yr val a 1950 1 b 1950 10 a 1951 2 b 1952 3 c 1952 4 a 1954 5 b 1954 2 c 1954 3,header=TRUE) dfc-by(df[,2:3],df$id,cumsum) ids-names(dfc) dfcc-cbind(rep(ids[1],dim(dfc[[1]])[1]),dfc[[1]]) names(dfcc)-names(df) for(n in 2:length(dfc)) { dfpc-cbind(rep(ids[n],dim(dfc[[n]])[1]),dfc[[n]]) names(dfpc)-names(df) dfcc-rbind(dfcc,dfpc) } 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. The contents of this e-mail are confidential and may be ...{{dropped:14}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.