Plotting discrete user-defined function in R set.seed(123)
x <- rnorm(10000,0,2);
s2 <- function(n) (1/(length(x[1:n])-1)*sum((x[1:n]-mean(x[1:n]))^2))^(1/2) 
m <- function(n) 1/n*sum(x[1:n])

I want to plot s2 and m, i. e. (n,s2(n)) and (n,m(n)) for 1<=n<=N, where N is some fixed value, i. e. N=1000, and the n's are integers. I want them to be in the same coordinante system. How can I do that?

You can use sapplyas follows
set.seed(123)
x <- rnorm(10000,0,2);
s2 <- function(n) 
  (1/(length(x[1:n])-1)*sum((x[1:n]-mean(x[1:n]))^2))^(1/2)
m <- function(n) 1/n*sum(x[1:n])

xx <- 1:10000
f_s <- sapply(xx, s2)
f_m <- sapply(xx, m)

plot(xx, f_s, ylim=c(-3,3))
points(xx, f_m, col=2)

