[R] how to smooth a line in a graph

Roger D. Peng rpeng at stat.ucla.edu
Thu May 29 20:25:00 CEST 2003


You may be interested in spline().  For example:

x <- 1:5
y <- c(1,3,4, 2.5,2)
plot(x, y)
sp <- spline(x, y, n = 50)
lines(sp)

-roger

Rado Bonk wrote:
> Hi R-users,
> 
> I have a line graph made by plot(). The line is very similar to
> hyperbola, and consists of 5 points. How can I make it look smooth?
> 
> Thanks,
> 
> Rado 
>




More information about the R-help mailing list