# How to create a vector with equivalent spacing between its consecutive elements in R?

I was wondering how to create a vector with equivalent spacing between its consecutive elements in R? In Matlab, I can do [start:step:end].

Also if I want to plot a function with analytical form, do I have to evaluate the function on some sample points in its domain and plot these pair of points? Is there a R function that can take the function form and a set in its domain as arguments, and plot the graph of the function on the set?

Thanks and regards!

-

1. Use seq as suggested by ars
2. For example, plot(sin, -pi, 2*pi).
-
Oh neat, I didn't know plot could do that. –  ars Oct 1 '10 at 0:31
Thanks! In examples like plot(sin, -pi, 2*pi), is there a default spacing for sampling the range in domain? –  Tim Oct 1 '10 at 1:16
The default is 101 points. See help(plot.function). –  Rob Hyndman Oct 1 '10 at 1:21
didn't know as well... hehe thanks –  RockScience Nov 9 '10 at 15:35
seq(from, to, by)

or ?seq for help.