r - Error in : object of type 'closure' is not subsettable -
r - Error in <my code> : object of type 'closure' is not subsettable -
i able work out code my scraping. seemed working fine , of sudden when ran again, got next error message:
error in url[i] = paste("http://en.wikipedia.org/wiki/", gsub(" ", "_", : object of type 'closure' not subsettable
i not sure why changed nil in code.
please advise.
library(xml) library(plyr) names <- c("george clooney", "kevin costner", "george bush", "amar shanghavi") for(i in 1:length(names)) { url[i] = paste('http://en.wikipedia.org/wiki/', gsub(" ","_", names[i]) , sep="") # parsing code }
in general error message means have tried utilize indexing on function. can reproduce error message with, example
mean[1] ## error in mean[1] : object of type 'closure' not subsettable mean[[1]] ## error in mean[[1]] : object of type 'closure' not subsettable mean$a ## error in mean$a : object of type 'closure' not subsettable
the closure mentioned in error message (loosely) function , environment stores variables when function called.
in specific case, joshua mentioned, trying access url
function variable. if define variable named url
, error goes away.
as matter of practise, should avoid naming variables after base-r functions. (calling variables data
mutual source of error.)
there several related errors trying subset operators or keywords.
`+`[1] ## error in `+`[1] : object of type 'builtin' not subsettable `if`[1] ## error in `if`[1] : object of type 'special' not subsettable
r r-faq
Comments
Post a Comment