Finally, I managed to automatically generate rather simple XML code. In R this is a matrix. The problem concerns how to write that matrix to file. I use write.table and the extension of file .xml Everything works perfect beside coding some language letters (Polish). But the problem disappears when I change the extension to .txt Therefore I write a file with .txt extension and after that I manually change the extension to .xml - it does not solve the problem. Is it possible to write my matrix or txt file to valid xml file? I need to do it automatically. Best, Robert
On 01/07/2010 10:13 AM, Robert wrote:> Finally, I managed to automatically generate rather simple XML code. In R this is a matrix. The problem concerns how to write that matrix to file. I use write.table and the extension of file .xml Everything works perfect beside coding some language letters (Polish). But the problem disappears when I change the extension to .txt Therefore I write a file with .txt extension and after that I manually change the extension to .xml - it does not solve the problem. Is it possible to write my matrix or txt file to valid xml file? I need to do it automatically. > > Best, > Robert > > ______________________________________________ > 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.Have you checked the XML package? If you print the matrix within R, this it look like you want (including correct langauge encoding? Because in that case, you probably could use sink (see ?sink). Stephan
Dnia 7 stycznia 2010 10:41 S Devriese <sdmaillist at gmail.com> napisa?(a):> Have you checked the XML package? > > If you print the matrix within R, this it look like you want (including > correct langauge encoding? Because in that case, you probably could use > sink (see ?sink). > > StephanYes. In R I get correct view. How to use sink? I have the object: my.matrix and I want to create a file item1.xml How to do it?
Dnia 7 stycznia 2010 10:41 S Devriese <sdmaillist at gmail.com> napisa?(a):> Have you checked the XML package? > > If you print the matrix within R, this it look like you want (including > correct langauge encoding? Because in that case, you probably could use > sink (see ?sink). > > StephanYes. In R I get correct view. How to use sink? I have the object: my.matrix and I want to create a file item1.xml How to do it?
On 01/07/2010 10:57 AM, robert-mcfadden at o2.pl wrote:> Dnia 7 stycznia 2010 10:41 S Devriese <sdmaillist at gmail.com> napisa?(a): >> Have you checked the XML package? >> >> If you print the matrix within R, this it look like you want (including >> correct langauge encoding? Because in that case, you probably could use >> sink (see ?sink). >> >> Stephan > > Yes. In R I get correct view. How to use sink? I have the object: my.matrix > and I want to create a file item1.xml How to do it? > > > ______________________________________________ > 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.you might try # open file connection sink("item1.xml") # print object my.matrix # close file connection sink()
Dnia 7 stycznia 2010 11:30 S Devriese <sdmaillist at gmail.com> napisa?(a):> you might try > > # open file connection > sink("item1.xml") > # print object > my.matrix > # close file connection > sink()Unfortunately, It does not code letter appropriate. To #print object it''s better to use write.table. But thank you for help.