I am trying to put a copy of my Rprofile from my work computer onto my home computer, but R does not seem to be able to find it.
I have tried several responses to similar questions including:
In Windows, you set the R_USER profile by opening up a command line and running:
SETX R_PROFILE_USER "C:/.../.Rprofile"
Sys.getenv("R_PROFILE_USER")
[1] "C:/Users/Sally/Rprofile"
but this does not work.
I also tried:
candidates <- c( Sys.getenv("R_PROFILE"),
file.path(Sys.getenv("R_HOME"), "etc", "Rprofile.site"),
Sys.getenv("R_PROFILE_USER"),
file.path(getwd(), ".Rprofile") )
Filter(file.exists, candidates)
[1] "C:/PROGRA~1/R/R-32~1.2/etc/Rprofile.site"
I changed the location of the Rprofile file to match the Filter results with no luck.
sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
If anyone has any suggestions it would be appreciated.
Thanks,
Sally
That is Windows for you -- you need to define $HOME as an evironment variable, or place it in $USER or ... whatever else they decide next.
On operating systems with an x or X in the name, $HOME is well defined and ~/.Rprofile is found.
Possible workaround: just edit $RHOME/etc/Rprofile.site but remember that this file will vanish next time you upgrade R on Windows.
Related
I have installed RStudio on a new computer, and has developed encoding issues. When I type accented text in console (no file writing or reading involved, just plain console) I lose Czech accents (as in this example - notice the accented N and Č)
> "Ňuf ňuf ňufičky"
[1] "Nuf nuf nuficky"
I know it is a settings issue - I have other R installations that behave correctly - but I am unable to find exact place in my settings to force UTF-8 behavior. Any help would be appreciated.
My session info is:
R version 3.4.2 (2017-09-28)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.4.2 tools_3.4.2 yaml_2.1.14
For the benefit of posterity - I overcame my problem by setting code page to 1250 (while keeping US English as my language).
if (.Platform$OS.type == 'windows') {
Sys.setlocale(category = 'LC_ALL','English_United States.1250')
} else {
Sys.setlocale(category = 'LC_ALL','en_US.UTF-8')
}
in the .Rprofile
Perhaps:
new.locale <- ifelse(.Platform$OS.type=="windows", "Czech_Czech Republic.1250", "en_US.UTF-8")
Sys.setlocale("LC_CTYPE", new.locale)
Also learn to specify your OS.
I have used fread to read data. But the error has arisen:
showProgress is not type integer but type 'logical'. Please report.
Here is the reproducible script:
library(data.table)
x <- "sgsddsfsfsf"
write.csv2(x,"check.csv", row.names=FALSE)
fread("check.csv", stringsAsFactor=FALSE)
Example of printscreen:
> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.9.8
loaded via a namespace (and not attached):
[1] tools_3.3.2
Just fixed. Please try again from dev. Thanks for reporting.
Fixed fread() error occurring for a subset of Windows users: showProgress is not type integer but type logical, #1944 and #1111. Our tests cover this usage (it is just default usage), pass on AppVeyor (Windows), win-builder (Windows) and CRAN's Windows so perhaps it only occurs on a specific and different version of Windows to all those. Thanks to #demydd for reporting. Fixed by using strictly logical type at R level and Rboolean at C level, consistently throughout.
I have a list that contain several large files. All the files have the same column names. I want to combine them into an rds file and save with the filename in a column. I have read some of the SO answers and have written the following code. But I ham getting error. This is my attempt:
list.nam<- list.files(pattern="*.I S")
list.fil <- lapply (list.nam, readRDS)
#listfil is 3.8 GB
# running this line gives error
for (i in 1:length(list.fil))
{list.fil[[i]]<-cbind(list.fil[[i]],list.nam[i])
}
data_rbind <- do.call("rbind", list.fil)
colnames(data_rbind)[c(1,2,3,4)]<-c("Time","MRP", "Lot", "Name")
saveRDS(data_rbind, "master.rds")
This is the error:
Error: cannot allocate vector of size 3.9 Mb
In addition: There were 22 warnings (use warnings() to see them)
> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] tools_3.2.2
Please help.Is the problem I am facing is virtual address space limitation?
Is it possible to do the above operations on-disk using a package like ff? Any help is highly appreciated?
I first changed my working directory in my .Rprofile. Next I tried to choose a file using file.choose().
The first time I run file.choose it shows the default directory listing. Subsequent executions show form the current directory.
> getwd()
[1] "C:/Users/dinesh/Desktop/lab/M1/sp500"
> mydata=read.csv(file.choose(),stringsAsFactor=F,header=T)
Error in file.choose() : file choice cancelled <<<<<< wrong dir
> mydata=read.csv(file.choose(),stringsAsFactor=F,header=T)
Error in file.choose() : file choice cancelled <<<<<<<<<<<< right dir
OTOH if in second command I were to run list.files() I would get the correct listing. And again, first invocation of file.choose will behave unexpectedly.
NEXT I changed the current dir again, to setwd("c:/Users") and tried list.files() and file.choose() and got the same pattern of outcomes.
Why does it behave this way, or, what am I missing? I am using R 3.1.2 on Windows 7.
--EDIT added more details
From Profile:
if (readline("Wanna pick a new working dir (by choosing a file)? y/xyz: ") == "y") {
try(setwd(dirname(file.choose())))
}
Using RGui
From sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
I'm seeing behavior I don't expect with the cat commands and flush.console() in RGui 2.12.0 (but not Rterm) for Windows. I wanted to see whether it was a problem with my system (or a known behavior) before reporting it as a bug. Specifically I'm seeing strange UNICODE looking characters as it iterates through. Please forgive the use of the huge rnorm() I couldn't figure out how to slow execution in an established way.
for (i in 1:100) {cat(i,"\r");flush.console();rnorm(1000000)}
R version 2.12.0 (2010-10-15)
Platform: i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
It worked as you would expect under R-2.10.0, which is the previous version of R installed in my seldom-used Windows machine. ;-)
I would say report it, but I would just send it to R-devel as "unexpected behavior" as you did here. Make sure to check against the latest daily build before reporting it, since it may have already been fixed.
The problem was in the RGui and the devs claim it will be fixed in the next minor release of 2.12.