Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
589 views
in Technique[技术] by (71.8m points)

r - How to create .Renviron file?

I need to use my user defined folder where I stored my packages. I have referred the link given below.

R libraries installation

I have applied the same but it didn't work for me. I have created a file called .Renviron with data R_LIBS=c:/Rpackages ,where my packages installed. But, still it is showing there is no such package 'RODBC' exists. Also, I put this file in my Documents folder in C drive and tried. That also gave the same error. Still the file type is showing as text document. How to change this file type?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

On mac (or linux)

Open the terminal and type

touch $HOME/.Renviron

To open the file you just created, navigate through finder to /Users/<your-user-name>/.Renviron, or simply open the terminal and type

open $HOME/.Renviron

On windows

Click on start and open powershell. Copy this code into powershell

Add-Content c:Users$env:USERNAMEDocuments.Renviron "TEST_VARIABLE_1=my_username"
Add-Content c:Users$env:USERNAMEDocuments.Renviron "TEST_VARIABLE_2=123"

You'll now have a file called .Renviron located in the Documents folder. Close and reopen RStudio. Then run Sys.getenv('TEST_VARIABLE_1') to access the variable in R (obviously that works for any other environment variables you set as well).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...