[R] Subscript Error
z2.0
zack.abrahamson at gmail.com
Wed Apr 4 23:25:07 CEST 2012
json_dir is a list of JSON lists mapping lat/long route points between
locations using CloudMade's API.
post_url is the URL of the HTTP request
for (n in json_dir) {
i = i + 1
if (typeof(json_dir[[i]]) != "NULL") {
if (i == 1) {
dat_add <- ldply(json_dir[[i]], function(x)
t(data.frame(x)), .progress = "text")
names(dat_add) <- c("lat", "lon")
json_path <- list(dat_add)
} else {
dat_add <- ldply(json_dir[[i]], function(x)
t(data.frame(x)), .progress = "text")
names(dat_add) <- c("lat", "lon")
json_path <- c(json_path, list(dat_add))
}
p = p + geom_path(aes(lon, lat), data = json_path[[i]])
}
print(paste("Processed ", i, " of ", as.character(length(json_dir)),
" in route set.", sep = ""))
}
This runs until i = 101 and then errors out with,
"Error in json_path[[i]] : subscript out of bounds"
typeof(json_dir[[101]]) = "list", so it's not that the first if-block is
somehow resetting json_path in an errant fashion.
Do lists have a default, built-in limit on no. of elements? Each element I'm
passing contains hundreds or thousands of lat/long pairs, so it's also
possible I'm hitting some upper bound on per-object memory, if that exists,
but Googling around leads me to think that's not the case.
I think I've fucked something up in my logic, but I'm not sure what.
--
View this message in context: http://r.789695.n4.nabble.com/Subscript-Error-tp4533219p4533219.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list