> > > Hi everyone, > > > > I tried writing this data into a file using the save(myList, > file="test1.bin") command, but unfortunately, the numerical values seem > to get garbled when I do so. > > > > The numbers in my RGui look like > > > > 0, 0.5, 0, 1 etc. etc. > > > > But when I stored it into a .bin file, and retrieved it using java code, > it returns data such as, > > > > 2272919233031569408 > > 1701436416123530 > > -2278152494445862686 > > 7161955281552955800 > > > > Etc. etc. > > > > I also tried the second method (using a # Open a file connection) > > Unfortunately, here too the data gets extremely garbled. > > Has anyone faced such a situation before? > > > > Any help / comments / useful links would be much appreciated.... > > > > > > Thanks and best regards, > > Suranga >
> On Mon, Feb 13, 2012 at 10:37 AM, Suranga Kasthurirathne < > suranga...@gmail.com> wrote: > >> >> Hi, >> >> Thank you very much for sharing these ideas. I really appreciate them. >> Let me go try them out :-) >> >> >> >> On Mon, Feb 13, 2012 at 4:37 AM, Rui Barradas <rui1...@sapo.pt> wrote: >> >>> Hello >>> >>> One way is >>> >>> # Write the file >>> save(myList, file="test1.bin") >>> >>> # Reload the data, under the same name, 'myList' >>> load(file="test1.bin") >>> >>> Another way is a bit more complicated >>> >>> # Open a file connection and write the list to it (using comma as >>> separator) >>> fileCon <- file("test2.txt", open="wt") >>> lapply(myList, function(x) writeLines(paste(x, collapse=","), >>> con=fileCon)) >>> close(fileCon) >>> >>> # Load the data, maybe under another name >>> strsplit(readLines(con="test2.txt"), split=",") >>> >>> If you use the first method, the list is retrieved as it was. >>> If you use the second, you lose the list's members' names. >>> >>> Hope this helps, >>> >>> Rui Barradas >>> >>> >>> -- >>> View this message in context: >>> http://r.789695.n4.nabble.com/Writing-output-into-a-file-tp4382243p4382310.html >>> Sent from the R help mailing list archive at Nabble.com. >>> >>> ______________________________________________ >>> R-help@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. >>> >> >> >> >> -- >> Best Regards, >> >> Suranga >> >> > > > -- > Best Regards, > > Suranga > > -- Best Regards, Suranga [[alternative HTML version deleted]] ______________________________________________ R-help@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.