[R] Help for an absolutely r-noob

strampe strampe at gmx.de
Thu Sep 16 14:45:40 CEST 2010


Hello together, 

I am an absolute noob in R and therefore I need help urgently. I have
received a script from my tutor with plot functions in it. However, I can'
manage to adapt these plots. 
The hole script is as follows:



setwd("E:/")
##### (1) Read data ###

dat <- read.table("Komfort_Tatsaechliche_ID_Versuchsreihe_1.txt",
header=TRUE,
  sep="\t", dec=",")                      # tab-getrennte Textdatei
names(dat) <- c("id", "resp", "amp")
dat$id  <- factor(dat$id)       # kategoriale Variablen als Faktor
definieren
dat$amp <- as.numeric(gsub("^([0-9]),([0-9]+) Nm$", "\\1.\\2", dat$amp))

##### (2) Explorative plots #####

library(lattice)
xyplot(resp ~ amp|id, dat, type=c("g","p","smooth"))

##### (3) MIXED-EFFECTS REGRESSION MODELS #####

library(nlme) 
lme1  <- lme(resp ~ amp, dat, ~1|id, method="ML")
lme2  <- lme(resp ~ amp + I(amp^2), dat, ~1|id, method="ML")
lme2a <- lme(resp ~ amp + I(amp^2), dat, ~amp|id, method="ML")
lme3  <- lme(resp ~ amp + I(amp^2) + I(amp^3), dat, ~1|id, method="ML")
lme5  <- lme(resp ~ factor(amp), dat, ~1|id, method="ML")

anova(lme1, lme2)
anova(lme2, lme3, lme5)

summary(lme2)

##### (4)  observed vs. predicted data #####

plot(augPred(lme2, ~amp, level=0:1))

xvar <- seq(0, 0.4, len=50)
plot(predict(lme2, data.frame(amp=xvar), level=0) ~ xvar, type="l")
# points()   # adding mean




 
I marked the important plot with boldface. I would like to adapt the Y axis
on a value of -2 to +2. 

Moreover, I want to add the means of the the responses (resp) of each
amp-value. My tutor already add a line "# points()" for this but I'm not
sure how to complement this line.

And the last problem: How do I change the axis labels? 

I am glad about every constructive input. 
Please apologize my bad english.

Strampe

-- 
View this message in context: http://r.789695.n4.nabble.com/Help-for-an-absolutely-r-noob-tp2542119p2542119.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list