Skip to content
Prev 263894 / 398502 Next

import text-records and set the fields in a table

As long as all the fields in each entry are the same, then the
following will work

df<-data.frame(photo_id=NA,owner=NA,secret=NA,server=NA,farm=NA,title=NA,
	ispublic=NA,isfriend=NA,isfamily=NA,tags=NA)

x<-'<photo id="5876248819" owner="13716719 at N04" secret="faf9bb7f52"
server="5264" farm="6" title="our rose garden" ispublic="1"
isfriend="0" isfamily="0" tags="flowers plants green rose yellow
garden nikon" />'

y<-strsplit(x,split="=\"")
tmp<-c()
for (i in 2:length(y[[1]])){
	tmp[i-1]<-strsplit(y[[1]][i],split="\"")[[1]][1]
}

df[1,]<-tmp
photo_id        owner     secret server farm           title ispublic
1 5876248819 13716719 at N04 faf9bb7f52   5264    6 our rose garden        1
  isfriend isfamily                                          tags
1        0        0 flowers plants green rose yellow garden nikon


You could exend this to loop through all your data.
On Mon, Jun 27, 2011 at 10:09 PM, mari681 <marianna.bolognesi at gmail.com> wrote: