[R] How to save a data set as .txt on fly?

David Winsemius dwinsemius at comcast.net
Fri Nov 26 04:56:23 CET 2010


On Nov 25, 2010, at 10:45 PM, Stephen Liu wrote:

> Hi folks,
>
> Win7 64bit
>
> I tried to save DNase, a data set on database, as .txt file for  
> future use with
> load.
>
> I can't do it on fly;
>> save(DNase, file="C:/Users/satimis/Documents/aaa.txt")
>> load(file="C:/Users/satimis/Documents/aaa.txt")
>> aaa
> Error: object 'aaa' not found
>> aaa.txt
> Error: object 'aaa.txt' not found

But you didn't try:

DNase    # which was after all the name of the object you saved.
>
>
> I must perform following steps;
>> aaa<-DNase
>> save(aaa, file="C:/Users/satimis/Documents/aaa.txt")
>> load(file="C:/Users/satimis/Documents/aaa.txt")
>
>> aaa
>    Run        conc density
> 1     1  0.04882812   0.017
> 2     1  0.04882812   0.018
> 3     1  0.19531250   0.121
> ....
>
>
> Is there any way doing it on fly?

Does the above "method" (typing the name of the save object rather  
than the file name) meet your definition of "on the fly"?
>
> Besides aaa.txt can't be read direct with Notepad nor WordPad

Right. Try reading the Posting Guide which among many other useful  
things has a method for saving objects in text format.

>
> TIA
>
> B.R.
> Stephen L
>
>
>
> ______________________________________________
> 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list