Bill
2014-Mar-30 09:01 UTC
Error in match.names(clabs, names(xi)) : names do not match previous names
Hi. I am running the code below. I am getting the error
Error in match.names(clabs, names(xi)) :
names do not match previous names
I don't really want to specify the size of the allFuku data frame at the
beginning but even when I tried it I still got this error.
v12=paste(0,1:9,"-",2010,"",sep="")
v13=paste(10:12,"-",2010,"",sep="")
v14=paste(0,1:9,"-",2011,"",sep="")
v15=paste(10:12,"-",2011,"",sep="")
v16=paste(0,1:9,"-",2012,"",sep="")
v17=paste(10:12,"-",2012,"",sep="")
v18=paste(0,1:9,"-",2013,"",sep="")
v19=paste(10:12,"-",2013,"",sep="")
v100=paste(0,1:9,"-",2014,"",sep="")
v10=paste(10:12,"-",2014,"",sep="")
datesFuku=c(v12,v13,v14,v15,v16,v17,v18,v19,v100,v10)
urlsFuku=paste("http://www.tutiempo.net/en/Climate/FUKUSHIMA/
",datesFuku,"/","475950.htm",sep="")
allFuku=data.frame(matrix(ncol = 19, nrow = 100)) #need to initialize it
with column names
for (url in urlsFuku) {
temp.tables=readHTMLTable(url)
temp.df=temp.tables[[3]]
lastrow=nrow(temp.df)
temp.df=temp.df[-c(lastrow-1,lastrow),]
temp.df=na.omit(temp.df)
SOURCE <- getURL(url,encoding="UTF-8")
PARSED <- htmlParse(SOURCE) #Format the html code
monthYear=xpathSApply(PARSED, "//h2/span",xmlValue)
month =strsplit(monthYear," ")[[1]][1]
year =strsplit(monthYear," ")[[1]][2]
temp.df=cbind(month=NA,temp.df)
temp.df=cbind(year=NA,temp.df)
temp.df[,month]<-month
temp.df[,year]<-year
allFuku=rbind(allFuku,temp.df)
}
write.csv(allFuku,"allFuku.csv")
Thank you.
[[alternative HTML version deleted]]