Hello everybody, I have programed a function to translate the R object structure into a XML data structure but I haven't found a function in the XML package to export this data in an XML file! my data look like that: <Factor>Assessor:codec</Factor> <Sum Sq> 33.98159</Sum Sq> <Df> 28</Df> <F value> 6.510894</F value> <Pr(>F)> 1.725149e-22</Pr(>F)> </line> <line> 6 <Factor>Assessor:Sample</Factor> <Sum Sq> 33.82264</Sum Sq> <Df> 126</Df> <F value> 1.440098</F value> <Pr(>F)> 1.752742e-03</Pr(>F)> </line> <line> 7 <Factor>codec:Sample</Factor> <Sum Sq>253.04055</Sum Sq> <Df> 18</Df> <F value> 75.417587</F value> <Pr(>F)>4.055009e-180</Pr(>F)> </line> <line> 8 <Factor>Residuals</Factor> <Sum Sq>214.73234</Sum Sq> <Df>1152</Df> <F value>NA</F value> <Pr(>F)>NA</Pr(>F)> </line> </anova:2> </anova> for data I basically used the function xmlNode,addChildren,xmlchildren. I don't know if it's sufficient to recognise a xml file So thanks for your help! Regards, Guillaume [[alternative HTML version deleted]]
See the StatDataML package. On Thu, Jun 25, 2009 at 10:54 AM, guillaume Le Ray<leray.guillaume at gmail.com> wrote:> Hello everybody, > > I have programed a function to translate the R object structure into a XML > data structure but I haven't found a function in the XML package to export > this data in an XML file! > > my data look like that: > ? ?<Factor>Assessor:codec</Factor> > ? ?<Sum Sq> 33.98159</Sum Sq> > ? ?<Df> ?28</Df> > ? ?<F value> ?6.510894</F value> > ? ?<Pr(>F)> 1.725149e-22</Pr(>F)> > ? </line> > ? <line> > ? ?6 > ? ?<Factor>Assessor:Sample</Factor> > ? ?<Sum Sq> 33.82264</Sum Sq> > ? ?<Df> 126</Df> > ? ?<F value> ?1.440098</F value> > ? ?<Pr(>F)> 1.752742e-03</Pr(>F)> > ? </line> > ? <line> > ? ?7 > ? ?<Factor>codec:Sample</Factor> > ? ?<Sum Sq>253.04055</Sum Sq> > ? ?<Df> ?18</Df> > ? ?<F value> 75.417587</F value> > ? ?<Pr(>F)>4.055009e-180</Pr(>F)> > ? </line> > ? <line> > ? ?8 > ? ?<Factor>Residuals</Factor> > ? ?<Sum Sq>214.73234</Sum Sq> > ? ?<Df>1152</Df> > ? ?<F value>NA</F value> > ? ?<Pr(>F)>NA</Pr(>F)> > ? </line> > ?</anova:2> > ?</anova> > > for data I basically used the function xmlNode,addChildren,xmlchildren. I > don't know if it's sufficient to recognise a xml file > > > So thanks for your help! > > > Regards, > > Guillaume > > ? ? ? ?[[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. >
Hi Guillaume Once you have created an XML representation using any of the various ways to represent XML in R via the XML package (e.g. internal nodes, lists of lists, hash trees), you can use the saveXML() function: saveXML(myXML, "fileName.xml") Personally, I use newXMLNode() and friends and build the tree with internal nodes. D. guillaume Le Ray wrote:> Hello everybody, > > I have programed a function to translate the R object structure into a XML > data structure but I haven't found a function in the XML package to export > this data in an XML file! > > my data look like that: > <Factor>Assessor:codec</Factor> > <Sum Sq> 33.98159</Sum Sq> > <Df> 28</Df> > <F value> 6.510894</F value> > <Pr(>F)> 1.725149e-22</Pr(>F)> > </line> > <line> > 6 > <Factor>Assessor:Sample</Factor> > <Sum Sq> 33.82264</Sum Sq> > <Df> 126</Df> > <F value> 1.440098</F value> > <Pr(>F)> 1.752742e-03</Pr(>F)> > </line> > <line> > 7 > <Factor>codec:Sample</Factor> > <Sum Sq>253.04055</Sum Sq> > <Df> 18</Df> > <F value> 75.417587</F value> > <Pr(>F)>4.055009e-180</Pr(>F)> > </line> > <line> > 8 > <Factor>Residuals</Factor> > <Sum Sq>214.73234</Sum Sq> > <Df>1152</Df> > <F value>NA</F value> > <Pr(>F)>NA</Pr(>F)> > </line> > </anova:2> > </anova> > > for data I basically used the function xmlNode,addChildren,xmlchildren. I > don't know if it's sufficient to recognise a xml file > > > So thanks for your help! > > > Regards, > > Guillaume > > [[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.
BTW, the XML you show is not legal XML. For instance, the element <Pr(>F)>NA</Pr(>F)> is not a legal XML element name. Similarly </anova:2> is not a legal name since it is "2". And anova:2 means an element with name 2 with (XML) name space prefix "anova" (which must be declared previously) As Gabor mentioned, StatDataML is one approach to generating an XML representation of an R object. Since the objects look related to fitted models, you might also want to look at PMML (Predictive Model Markup Language) as that is a more widely used standard. D. guillaume Le Ray wrote:> Hello everybody, > > I have programed a function to translate the R object structure into a XML > data structure but I haven't found a function in the XML package to export > this data in an XML file! > > my data look like that: > <Factor>Assessor:codec</Factor> > <Sum Sq> 33.98159</Sum Sq> > <Df> 28</Df> > <F value> 6.510894</F value> > <Pr(>F)> 1.725149e-22</Pr(>F)> > </line> > <line> > 6 > <Factor>Assessor:Sample</Factor> > <Sum Sq> 33.82264</Sum Sq> > <Df> 126</Df> > <F value> 1.440098</F value> > <Pr(>F)> 1.752742e-03</Pr(>F)> > </line> > <line> > 7 > <Factor>codec:Sample</Factor> > <Sum Sq>253.04055</Sum Sq> > <Df> 18</Df> > <F value> 75.417587</F value> > <Pr(>F)>4.055009e-180</Pr(>F)> > </line> > <line> > 8 > <Factor>Residuals</Factor> > <Sum Sq>214.73234</Sum Sq> > <Df>1152</Df> > <F value>NA</F value> > <Pr(>F)>NA</Pr(>F)> > </line> > </anova:2> > </anova> > > for data I basically used the function xmlNode,addChildren,xmlchildren. I > don't know if it's sufficient to recognise a xml file > > > So thanks for your help! > > > Regards, > > Guillaume > > [[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.