I have been utilizing code from the answer of a previous question with great success. Last night, after successfully using the code many times I started to receive an error when trying to execute the second part of the code to access list results. The lst_elements list is not being created. This is my code.
# Run Google Distance API ALl Transit
res <- lapply(1:nrow(Lankenau), function(x) {
google_distance(origins = c(Lankenau[x,"LAT"],Lankenau[x,"LONG"]),
destinations = c(Lankenau[x,"O_Lat"],Lankenau[x,"O_Long"]),
mode = "transit",arrival_time = time)})
lst_elements <- lapply(res, function(x){
stats::setNames(
cbind(
distance_elements(x)[[1]][['duration']],
distance_elements(x)[[1]][['distance']]
)
, c("duration_text", "duration_value", "distance_text", "distance_value")
)
})
and the error received
Error in names(object) <- nm : attempt to set an attribute on NULL
3.
stats::setNames(cbind(distance_elements(x)[[1]][["duration"]],
distance_elements(x)[[1]][["distance"]]), c("duration_text",
"duration_value", "distance_text", "distance_value"))
2.
FUN(X[[i]], ...)
1.
lapply(res, function(x) {
stats::setNames(cbind(distance_elements(x)[[1]][["duration"]],
distance_elements(x)[[1]][["distance"]]), c("duration_text",
"duration_value", "distance_text", "distance_value")) ...
any tips would be great! I'm not sure what happened. The exact same good is still working for a different dataframe. Would this suggest that the error is stemming from the data.frame itself?