[R] Convert data frame to XML-Tree

T.Wunder at stud.uni-heidelberg.de T.Wunder at stud.uni-heidelberg.de
Fri Feb 12 10:48:32 CET 2010


Hello,

Quoting Dieter Menne <dieter.menne at menne-biomed.de>:

>
>
> T.Wunder wrote:
>>
>>
>> convertToXML <- function(df,name)
>> {
>> xml <- xmlTree("Test")
>> xml$addNode(name, close=FALSE)
>> for (i in 1:nrow(df)) {
>>      xml$addNode("value", close=FALSE)
>>      for (j in names(df)) {
>>          xml$addNode(j, df[i, j])
>>      }
>>      xml$closeTag()
>> }
>> xml$closeTag()
>> return(xml)
>> }
>>
>> Well, now I get a warning message like
>> "In xmlRoot.XMLInternalDocument(currentNodes[[1]]) : empty XML document"
>>
>> if I use this function. How could this be fixed?
>>
>>
>
> By telling use how you "used" that function.

I'm sorry. I have a data frame df and typed

convertToXML(df,"Tabelle")

and then the above message appeared.

Maybe there is another way of converting data frames? Or does a  
suitable method already exist?

Thanks, Tom



More information about the R-help mailing list