Hi Ruser
I'm trying to replicate some SAS code. I have to add a spline to my
longitudinal spaghetti plot.
I have the plot, but I can't add the spline, a overall trend line. In
the SAS code they use the command 'I=SM50S' and I would prefer
something similar. I?m using R 2.10.1 on windows XP?
I have made this working example.
tolerance.pp <- read.table("http://www.ats.ucla.edu/stat/R/examples/alda/tolerance1_pp.txt
", sep=",", header=T)
# install.packages("lattice", dep = T)
library(lattice)
xyplot(tolerance ~ age, groups = id, data=tolerance.pp, type = "l")
This is where I want to add a overall spline.
Hope someone out there can figure this out.
Thanks
Eric
add spline to longitudinal data - preferably similar to SAS's 'I=SM50S' routine
5 messages · Eric Fail, Dylan Beaudette, Dennis Murphy
On Mon, Jan 18, 2010 at 3:25 PM, Eric Fail <e at it.dk> wrote:
Hi Ruser
I'm trying to replicate some SAS code. I have to add a spline to my
longitudinal spaghetti plot.
I have the plot, but I can't add the spline, a overall trend line. In the
SAS code they use the command ? 'I=SM50S' and I would prefer something
similar. I?m using R 2.10.1 on windows XP?
I have made this working example.
tolerance.pp <-
read.table("http://www.ats.ucla.edu/stat/R/examples/alda/tolerance1_pp.txt",
sep=",", header=T)
# install.packages("lattice", dep = T)
library(lattice)
xyplot(tolerance ~ age, groups = id, data=tolerance.pp, type = "l")
Hi,
How about something like:
# your data
tolerance.pp <-
read.table("http://www.ats.ucla.edu/stat/R/examples/alda/tolerance1_pp.txt",
sep=",", header=T)
# almost works...
xyplot(tolerance ~ age, groups = id, data=tolerance.pp, type = c('l','smooth'))
see ?panel.loess for more ideas
Cheers,
Dylan
This is where I want to add a overall spline. Hope someone out there can figure this out. Thanks Eric
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100118/07e2167d/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100118/7fe41056/attachment.pl>
12 days later
Dear list A week ago Dennis Murphy helped me out by showing me some nice ggplot2 tricks . Now I got stuck in a new problem that I can't solve (I have ordered the ggplot2-book). My problem is that I can't add my spline (or geom_smooth) and at the same time control the grid (using scale_x_continuous), they seem to overwrite each other. I have continued the working example from my last question (http://n4.nabble.com/add-spline-to-longitudinal-data-preferably-similar-to-SAS-s-I-SM50S-routine-td1017138.html ) ############ example start ############ tolerance.pp <- read.table("http://www.ats.ucla.edu/stat/R/examples/alda/tolerance1_pp.txt ", sep=",", header=T) # install.packages("ggplot2", dep = T) library(ggplot2) plot <- ggplot(tolerance.pp, aes(age, tolerance, group = id)) + geom_line() plot + geom_smooth(aes(group = male, colour = male), size = 1, se = FALSE) plot + scale_x_continuous(breaks = c(10, 12, 13, 15)) # plot + scale_x_continuous(limits = c(9, 16)) ############ example end ############ I have added the 'plot + scale_x_continuous(limits = c(9, 16)) ' since this seem to conflict as well. Thanks in advance! Eric