I would capture the local environment,
xy <- data.frame(x=1:10,y=1:10)
plotfunc <- function(Data, YMul = 2){
.e <- environment()
ggplot(Data, aes(x = x, y = y*YMul), environment = .e) + geom_line()
}
plotfunc(xy)
More Related Contents:
- Show percent % instead of counts in charts of categorical variables
- How to add texture to fill colors in ggplot2
- Simpler population pyramid in ggplot2
- ggplot, facet, piechart: placing text in the middle of pie chart slices
- How to plot a function curve in R
- using stat_function and facet_wrap together in ggplot2 in R
- Error: package or namespace load failed for ggplot2 and for data.table
- How to install development version of R packages github repository
- How to add legend to ggplot manually? – R [duplicate]
- Line break when no data in ggplot2
- Combining Bar and Line chart (double axis) in ggplot2
- ggplot side by side geom_bar()
- R: ggplot2, can I set the plot title to wrap around and shrink the text to fit the plot?
- Stacked barplot with colour gradients for each bar
- ggplot – Multiple legends arrangement
- Expand spacing between tick marks on x axis
- How to fix the aspect ratio in ggplot?
- Increase resolution of color scale for values close to zero
- ggplot2 : Plot mean with geom_bar
- How to add different lines for facets
- Add number of observations per group in ggplot2 boxplot
- Add secondary X axis labels to ggplot with one X axis
- if else condition in ggplot to add an extra layer
- Remove space between bars ggplot2
- How can I add annotations below the x axis in ggplot2?
- Remove facet_wrap labels completely
- Different axis limits per facet in ggplot2
- SI prefixes in ggplot2 axis labels
- How to display emojis in ggplot2 using emo package in R?
- Relocating Alaska and Hawaii on thematic map of the USA with ggplot2