[R] Reading CSV file every time when R starts

MacQueen, Don macqueen1 at llnl.gov
Mon Jun 23 21:14:18 CEST 2014


However, be careful, because .Rprofile runs before any saved .RData file
is loaded. If the object you created in .Rprofile is later saved when you
quit R, then the next time you start R, the saved version will replace the
version created in .Rprofile. (Unless you start R using R --no-restore)
This means that if you create the object in .Rprofile, and then later
change it, then later save it when you quit R, the next time you start R
you will have the modified version, not the original version.

See ?Startup for this information (?Startup also answers your original
question)

-Don

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 6/23/14 10:51 AM, "Christofer Bogaso" <bogaso.christofer at gmail.com>
wrote:

>Hi Greg,
>
>Thanks for your prompt reply. I have added 'library(utils)' in my
>Rprofile file and now it is working fine.
>
>Thanks and regards,
>
>On Mon, Jun 23, 2014 at 11:34 PM, Greg Snow <538280 at gmail.com> wrote:
>> The .Rprofile file is processed before all the standard packages are
>> loaded, that is why you are seeing the error.  If you instead run the
>> command as utils::read.csv or use library or require to manually load
>> the utils package before calling read.csv then everything should work
>> for you.
>>
>> On Mon, Jun 23, 2014 at 11:42 AM, Christofer Bogaso
>> <bogaso.christofer at gmail.com> wrote:
>>> Hi again,
>>>
>>> I am trying to build a procedure such that whenever R starts, it will
>>> read some CSV file.
>>>
>>> Therefore I put a code sometime like 'read.csv(...)' in my Rprofile
>>> file. However if I put this function there then I am getting an error
>>> saying 'Error: could not find function "read.csv"', whenever R starts.
>>>
>>> So is it the case that, read.csv() function will not work if it put to
>>> run with Rprofile file?
>>>
>>> I got similar error with flush.console() function as well.
>>>
>>> Can someone tell me how I can achieve that? My goal is to read some
>>> CSV file on startup of R.
>>>
>>> Thanks for your pointer.
>>>
>>> ______________________________________________
>>> R-help at 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.
>>
>>
>>
>> --
>> Gregory (Greg) L. Snow Ph.D.
>> 538280 at gmail.com
>
>______________________________________________
>R-help at 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.



More information about the R-help mailing list