Reputation: 2703
In setting the scales of my ggplot, I need to specify max
and min
values.
Now everything works fine if I specify the path directly (e.g x$column
), but I would like it to take an argument containing the path, how can this be achieved?
Code
SMAcolName <- colnames(ov.indicators)[grep("SMAPrice", names(ov.indicators))]
SMAsourceName <- paste0("ov.indicactors$", SMAcolName)
line.SMAsqrmPrice <- ggplot(data = fortify(ov.indicators), aes_string( x = "published", y = SMAcolName )) +
geom_line() +
scale_y_continuous(breaks = c(seq(10000, max(SMAsourceName, na.rm = TRUE), by = 5000) )) +
The above code gives an error, but demonstrates what I'm trying to achieve.
Upvotes: 0
Views: 79
Reputation: 4807
I think you want max(ov.indicators[,"SMAcolName"], na.rm=TRUE)
.
The trick here is that you don't need to use the $
notation. I'm assuming that ov.indicators is a data.frame or a matrix (or a 2D array). That assumption is based on your use of colnames
.
Upvotes: 1