How can I plot a generic sin curve in R? Based on the answer of this post, I tried:
x <- seq(0,pi,length.out=100)
y <- sin(x)
plot(x,y,type="l")
Actually what I really would is this graph, produced by gnuplot
:
plot sin(x) linestyle 1
Furthermore, I would like to know why gnuplot
produces a graph even if I do not assign any value to the variable x
. Does it have a preassigned value or something else?
To graph the sine function, we mark the angle along the horizontal x axis, and for each angle, we put the sine of that angle on the vertical y-axis. The result, as seen above, is a smooth curve that varies from +1 to -1. Curves that follow this shape are called 'sinusoidal' after the name of the sine function.
Calculate sine of a value in R Programming – sin() Functionsin() function in R Language is used to calculate the sine value of the numeric value passed to it as argument.
pi
is just one half of a sine curve... add more pi
so you will get more curves...
x <- seq(0,8*pi,length.out=100)
y <- sin(x)
plot(x,y,type="l")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With