when i parse a web file, it works fine ,
tdata=xpathApply(data,"//table[@id='PL']")
i want to use variable in xpathApply,
x="PL"
tdata=xpathApply(data,"//table[@id=x]")
it can not work,how to write the xpath expression in xpathApply with variable?
think for Dason’s suggestion,
x="PL"
y=paste0("//table[@id='",x,"']")
tdata=xpathApply(data,y)
it is ok,but i feel it is ugly,how can i write it more beautiful?
@Dason’s suggestion of using
pasteor one alike is most likely the only way to go. If you find it ugly, you can sweep it under the rug by creating your own function:After all, you must use a lot of package functions that use
pastesomewhere, so you should be ok with having one of your own 🙂