The curve function in base R
问题 Sorry this might be basic but I am a newbie. I will be making lots of curves so some advice will be useful for me. I have a function which I want to plot: f <- function(x) sum(4*sin(x*seq(1,21,2))/(pi*seq(1,21,2))) using curve(f, -pi, pi, n=100) Unfortunately ,this does not work for me. Please advise. Thanks 回答1: You function isn't vectorized. At the moment it will only take a single scalar input and output a single return value. curve expects that it should be able to feed in a vector of the