Skip to content
Prev 383971 / 398502 Next

Help with ggplot error: #Error in FUN(X[[i]], ...) : object 'x' not found

Hello,

I'm getting a different error:


p <- ggplot(c1members2, aes(x,y)) +
   geom_point()

p +  geom_line(data = paths, aes(group = trip_id)) +
   ggtitle(paste0("Optimal route with cost: ", 
round(objective_value(result), 2)))
#Error in objective_value(result) : object 'result' not found


When I remove the ggtitle line,


p +  geom_line(data = paths, aes(group = trip_id)) #+
#Error: Aesthetics must be either length 1 or the same as the data (14): 
x and y


This makes sense, the data argument has changed, trip_id is in data set 
paths, not in c1members2. So I have added x, y aesthetics to the 
geom_line call.


p +  geom_line(data = paths, aes(Longitude, Latitude, group = trip_id))


No errors. Is this it?


Hope this helps,

Rui Barradas


?s 13:28 de 19/05/20, Poling, William via R-help escreveu: