Re: [R] Sin curve question

2021-07-25 Thread Erich Subscriptions
With ggplot tibble(x=0:180,y=sin(deg2rad(x))) |> ggplot(aes(x=x,y=y)) + geom_line() + scale_x_continuous(breaks=seq(0,180,30)) + labs(x="x",y="sin(x)", title="sin(x) vs x\nx is in degrees") > On 26.07.2021, at 01:52, Erich Subscriptions > wrote: > > plot(function(x)sin(deg2ra

Re: [R] Sin curve question

2021-07-25 Thread Erich Subscriptions
plot(function(x)sin(deg2rad(x)),0,180) > On 24.07.2021, at 20:41, Thomas Subia via R-help wrote: > > library(ggplot2) > library(REdaS) > copdat$degrees <- c(0,45,90,135,180) > copdat$radians <- deg2rad(copdat$degrees) > copdat$sin_x <- sin(copdat$radians) > > ggplot(copdat,aes(x=degrees,y=sin_

Re: [R] Sin curve question

2021-07-24 Thread Rui Barradas
Hello, You can use stat_function, it will take care of all the details, all you have to do is to pass xlim. library(ggplot2) library(cowplot) ggplot() + stat_function(fun = sin, xlim = c(0, pi)) + xlab("x") + ylab("sin(x)") + scale_x_continuous(breaks = seq(0, pi, pi/6), labels = seq

Re: [R] Sin curve question

2021-07-24 Thread Jeff Newmiller
This is not excel-help, but to the best of my knowledge Excel interpolates with splines when you select curved point interpolation. R, being primarily a science tool rather than a business tool, assumes you want to be precise about how new points are to be interpolated between original data poi

Re: [R] Sin curve question

2021-07-24 Thread Spencer Graves
plot(sin, to=pi) # also works but with x labeled in radians. # With x axis labeled in degrees plot(sin, to=pi, axes=FALSE) axis(2) lbls <- seq(0, 180, 30) axis(1, pi*lbls/180, lbls) This can probably be done in ggplot2, but I don't know how off the top of my head. Hope this he

Re: [R] Sin curve question

2021-07-24 Thread Eric Berger
Alternatively with base graphics N <- 500 ## number of points (arbitrary) degrees <- seq(from=0,to=180,length=N) degreesToRadians <- function(d) { pi * d / 180.0} ## vectorIzed! plot(x=degrees,y=sin(degreesToRadians(degrees)),type='l', xlab="x",ylab="sin(x)",main="sin(x) vs x\nx is in degree

Re: [R] Sin curve question

2021-07-24 Thread Sorkin, John
Try something like the following copdat$degrees <- c(1:180) John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine Baltimore VA Medical Center 10 North Greene Street GRECC (

[R] Sin curve question

2021-07-24 Thread Thomas Subia via R-help
Colleagues, Here is my code which plots sin(x) vs x, for angles between 0 and 180 degrees. library(ggplot2) library(REdaS) copdat$degrees <- c(0,45,90,135,180) copdat$radians <- deg2rad(copdat$degrees) copdat$sin_x <- sin(copdat$radians) ggplot(copdat,aes(x=degrees,y=sin_x))+ geom_point(size =