Is there any generic function that gets the "home" directory? This should return /home/<user> in Linux and x:/Documents and Settings/<user> (or whatever) in Windows XP. Another (unrelated) question: what is the _simplest_ way to read and write R variables to/from files such that they are stored in a human-readable but R-like form? For example, if (say), x is a vector defined as x <- c(1, 2, 3), can I write (and read) x as a file with just one line, namely: c(1, 2, 3) ? Alberto Monteiro
If you want get a username of user currently running R on Linux,you can use a
system command and read enviroment variables:
paste("/home/",system
("whoami",intern=TRUE),sep="")
Andris Jankevics
On Piektdiena, 23. Marts 2007 14:30, Alberto Monteiro
wrote:> Is there any generic function that gets the "home" directory?
This
> should return /home/<user> in Linux and
> x:/Documents and Settings/<user> (or whatever) in Windows XP.
>
> Another (unrelated) question: what is the _simplest_ way to
> read and write R variables to/from files such that they are
> stored in a human-readable but R-like form? For example, if
> (say), x is a vector defined as x <- c(1, 2, 3), can I write
> (and read) x as a file with just one line, namely: c(1, 2, 3) ?
>
> Alberto Monteiro
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
On 3/23/07, Alberto Monteiro <albmont@centroin.com.br> wrote:> > Is there any generic function that gets the "home" directory? This > should return /home/<user> in Linux and > x:/Documents and Settings/<user> (or whatever) in Windows XP. > > Another (unrelated) question: what is the _simplest_ way to > read and write R variables to/from files such that they are > stored in a human-readable but R-like form? For example, if > (say), x is a vector defined as x <- c(1, 2, 3), can I write > (and read) x as a file with just one line, namely: c(1, 2, 3) ??dput Alberto Monteiro> > ______________________________________________ > R-help@stat.math.ethz.ch 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]]
Sys.getenv("HOME") works in Linux at least
- Henrik
Andris Jankevics wrote:> If you want get a username of user currently running R on Linux,you can use
a
> system command and read enviroment variables:
>
> paste("/home/",system
("whoami",intern=TRUE),sep="")
>
>
> Andris Jankevics
>
> On Piektdiena, 23. Marts 2007 14:30, Alberto Monteiro wrote:
>
>> Is there any generic function that gets the "home" directory?
This
>> should return /home/<user> in Linux and
>> x:/Documents and Settings/<user> (or whatever) in Windows XP.
>>
>> Another (unrelated) question: what is the _simplest_ way to
>> read and write R variables to/from files such that they are
>> stored in a human-readable but R-like form? For example, if
>> (say), x is a vector defined as x <- c(1, 2, 3), can I write
>> (and read) x as a file with just one line, namely: c(1, 2, 3) ?
>>
>> Alberto Monteiro
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch 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 at stat.math.ethz.ch 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.
>
--
Henrik Andersson
Danish Meteorological Institute
Lyngbyvej 100
2100 Copenhagen ?
Denmark
Tel: +45 39157215
Email: han at dmi.dk
See: ?R.home ?dput On 3/23/07, Alberto Monteiro <albmont at centroin.com.br> wrote:> Is there any generic function that gets the "home" directory? This > should return /home/<user> in Linux and > x:/Documents and Settings/<user> (or whatever) in Windows XP. > > Another (unrelated) question: what is the _simplest_ way to > read and write R variables to/from files such that they are > stored in a human-readable but R-like form? For example, if > (say), x is a vector defined as x <- c(1, 2, 3), can I write > (and read) x as a file with just one line, namely: c(1, 2, 3) ? > > Alberto Monteiro > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >
Andris Jankevics wrote:> If you want get a username of user currently running R on Linux,you can use a > system command and read enviroment variables: > > paste("/home/",system ("whoami",intern=TRUE),sep="") > >This would be more to the point (and safer), I think. > Sys.getenv("HOME") HOME "/home/bs/pd"> Andris Jankevics > > On Piektdiena, 23. Marts 2007 14:30, Alberto Monteiro wrote: > >> Is there any generic function that gets the "home" directory? This >> should return /home/<user> in Linux and >> x:/Documents and Settings/<user> (or whatever) in Windows XP. >> >> Another (unrelated) question: what is the _simplest_ way to >> read and write R variables to/from files such that they are >> stored in a human-readable but R-like form? For example, if >> (say), x is a vector defined as x <- c(1, 2, 3), can I write >> (and read) x as a file with just one line, namely: c(1, 2, 3) ? >> >> Alberto Monteiro >> >> ______________________________________________ >> R-help at stat.math.ethz.ch 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 at stat.math.ethz.ch 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. >