[R] Finding and changing .Rprofile

2018-08-17 Thread philipsm
I would like to change my .Rprofile file, but I cannot find it. I use  
a Mac Pro and RStudio. I believe the file is a hidden file and I have  
checked for it accordingly. I can not find it with a Spotlight search.  
It is not in my "default working directory". Is that the same thing as  
my "home directory"? I believe I can put a new .Rprofile file in any  
project directory, but that is not what I want to do. I want a  
.Rprofile file that will apply automatically whenever I start working  
on another project. Was one installed automatically when I installed R  
and RStudio many months ago and if so, where can I find it? If it was  
not installed automatically and I have to create my own, where should  
I put it?


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Finding and changing .Rprofile

2018-08-17 Thread philipsm

Thanks!


Quoting Marc Schwartz :


On Aug 17, 2018, at 4:06 PM, phili...@cpanel1.stormweb.net wrote:

I would like to change my .Rprofile file, but I cannot find it. I  
use a Mac Pro and RStudio. I believe the file is a hidden file and  
I have checked for it accordingly. I can not find it with a  
Spotlight search. It is not in my "default working directory". Is  
that the same thing as my "home directory"? I believe I can put a  
new .Rprofile file in any project directory, but that is not what I  
want to do. I want a .Rprofile file that will apply automatically  
whenever I start working on another project. Was one installed  
automatically when I installed R and RStudio many months ago and if  
so, where can I find it? If it was not installed automatically and  
I have to create my own, where should I put it?



Hi,

As an FYI, there is a dedicated R list for macOS users:

  https://stat.ethz.ch/mailman/listinfo/r-sig-mac

which should be used for macOS specific questions vis-a-vis R.

The default .Rprofile is stored in your user home folder, which is  
/Users/YourUserName/.Rprofile or abbreviated as ~/.Rprofile.


As you note, because it is a hidden file, with a leading '.', Finder  
and Spotlight will not show it by default.


You can change that behavior relative to hidden files, by opening a  
Terminal and using the following command:


  defaults write com.apple.finder AppleShowAllFiles TRUE

then restart Finder, by using Alt-RightClick on the Finder icon in  
the dock and selecting Relaunch. You can reverse that behavior by  
changing the TRUE to FALSE in the above command.


If you don't want to make that global change, you can use the  
following command in a Terminal session:


  open -a Textedit ~/.Rprofile

That will bring up the Textedit editor application with the file  
loaded. You can then edit the file content and save it.


Whichever way you edit the file, be sure to restart any R sessions  
you have running, so that future R sessions will pick up the changes.


Making the change to that file will generally affect all R sessions  
for your user profile.


I don't use RStudio, so it may have other relevant features, and  
they have their own support lists linked on their site.


Regards,

Marc Schwartz


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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() function

2018-08-19 Thread philipsm
I am having trouble with what must be a very simple problem. Here is a  
reproducible example:


library(lubridate)
st <- c("1961-01","1961-04","1983-02")
print(st)
#[1] "1961-01" "1961-04" "1983-02"
st1 <- as.Date(st, format=("%Y-%m"))
print(st1)
#[1] NA NA NA

Why the heck am I getting three NAs instead of three Dates?I have  
studied the R documentation for as.Date() and it has not turned on the  
light bulb for me.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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() function

2018-08-19 Thread philipsm

Thanks Erin and Jim. You have indeed solved my problem.

Philip


Quoting Erin Hodgess :


Hi Philip:

Here is something to consider:


#potential solution:
sta <- paste(st,"-01",sep="")
st1 <- as.Date(sta, format=("%Y-%m-%d"))
print(st1)

[1] "1961-01-01" "1961-04-01" "1983-02-01"


Hope this helps!
Erin

Erin Hodgess, PhD
mailto: erinm.hodg...@gmail.com


On Sun, Aug 19, 2018 at 3:25 PM  wrote:


I am having trouble with what must be a very simple problem. Here is a
reproducible example:

library(lubridate)
st <- c("1961-01","1961-04","1983-02")
print(st)
#[1] "1961-01" "1961-04" "1983-02"
st1 <- as.Date(st, format=("%Y-%m"))
print(st1)
#[1] NA NA NA

Why the heck am I getting three NAs instead of three Dates?I have
studied the R documentation for as.Date() and it has not turned on the
light bulb for me.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Multi-word column names in a data frame

2018-09-04 Thread philipsm
I am having trouble working with column names in a data frame. My  
column names are multi-word text strings and I like it that way. I  
want to loop through the columns, plotting graphs for each one, and I  
want to use the column names in the chart labels and in the file names  
when I save the charts. Here is a simple reproducible example that  
does not work.


library(dplyr)
`RefDate` <- as.Date(c("2010-11-1","2010-12-01","2011-01-01"))
`Number of vegetables` <- c(14,23,45)
`Number of people` <- c(20,30,40)
MyData <- data.frame(RefDate,`Number of vegetables`,`Number of  
people`,check.names=FALSE)

MyVars <- c("Number of vegetables","Number of people")
for (A in MyVars) {
  g2 <- ggplot(MyData,aes(RefDate,eval(parse(text=A + geom_line() +
labs(title = paste(A," adjusted",sep=""))
  g2
  ggsave(paste(A,".jpg",sep=""),g2,height=5,width=8,dpi=300)
}

Philip

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.