Off topic:How to write information fetched from xml files into a table/text in R?
0
0
Entering edit mode
8.8 years ago
niveditaj20 ▴ 50

I have parsed xml files in R environment and retrieved desired columns as below -

xmlfiles <- list.files(pattern = "*.xml")

input<-sapply(seq(xmlfiles), function(i){
doc <- xmlTreeParse(xmlfiles[i], useInternal = TRUE)

xpathSApply(doc, c('//phase', '//overall_status', '//primary_condition', '//nct_id', '//intervention_name', '//other_name', '//other_name.1', '//other_name.2', '//other_name.3', '//sponsors.lead_sponsor.agency'), xmlValue)
})

I want to write information fetched from xml files into a table/text but have been facing the following error-

write.table(input, file="output.txt", row.names=F, sep="\t")
Error in data.frame(c("NCT00752076", "Recruiting", "N/A", "cancer cell lines establishment",  :
arguments imply differing number of rows: 6, 4, 3, 5

Kindly need your inputs.

R xml • 1.5k views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 2051 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6