[R] save to Rdata file and to txt

Mark Sharp msharp at txbiomed.org
Thu Jun 14 19:14:11 CEST 2012


Though not exactly what you asked for, I find the output of dput() to be useful
dput(moransl, file = "moransl.txt")

results in 
list("Moran.I.First", structure(list(observed = 0.06988288, expected = -0.03225806, 
    sd = 0.02513276, p.value = 4.822722e-05), .Names = c("observed", 
"expected", "sd", "p.value")))

R. Mark Sharp
msharp at TxBiomed.org




On May 15, 2012, at 12:35 PM, David L Carlson wrote:

> capture.output(moransI, file="moransI.txt")
> 
> 
> ----------------------------------------------
> David L Carlson
> Associate Professor of Anthropology
> Texas A&M University
> College Station, TX 77843-4352
> 
> 
>> -----Original Message-----
>> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
>> project.org] On Behalf Of Alaios
>> Sent: Tuesday, May 15, 2012 12:10 PM
>> To: R help
>> Subject: [R] save to Rdata file and to txt
>> 
>> Dear all,
>> I am using the
>> 
>> 
>> save(moransI,file=saveString) to save a variable called moransI to a
>> file.
>> This works well but unfortunately I have to open R every time I want to
>> look to the contents.
>> 
>> Would it be also possible to have a second line that saves the contents
>> of the moransI variable in a normal txt file?
>> The ideal is inside the txt file to get what you see in R's console
>> when you print the moransI variable.
>> So something like that
>> 
>> moransI
>> [[1]]
>> [1] "Moran.I.First"
>> 
>> [[2]]
>> [[2]]$observed
>> [1] 0.06988288
>> 
>> [[2]]$expected
>> [1] -0.03225806
>> 
>> [[2]]$sd
>> [1] 0.02513276
>> 
>> [[2]]$p.value
>> [1] 4.822722e-05
>> 
>> 
>> 
>> Cheers
>> Alex
>> 
>> 	[[alternative HTML version deleted]]
>> 
>> ______________________________________________
>> 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.
> 
> ______________________________________________
> 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