Plot function line on scatter plot R -
i have function eq = function(x){x*2} for line plot on scatter plot in r. my attempt follows (have not posted data, not runnable, syntacticly equivalent): plot(per_class$input_kb, per_class$kb, col="red", ylab="peak memory usage (kb)", xlab="input data (kb)", main="peak memory per input size") which give me plot. try lines(eq,y=null) however, error. error in as.double(y) : cannot coerce type 'closure' vector of type 'double' is there way plot function on plot in r (ideally without ggplot2)? or have make data frame representing function...seems kinda hacked. when plotting function, can either use lines or use curve . the error arising because lines requires vector (or matrix) arguments (type 'double' in error message) , feeding function (type 'closure'). the curve function designed directly plotting functions , may preferable. below example of plotting 2 functions estimate s...