[R] Making the plot window wider and using the predict function
PIKAL Petr
petr.pikal at precheza.cz
Fri Feb 15 15:23:46 CET 2013
Hi
>
>
> Hello,
>
> I am new to R and have a couple of questions. My data set contains the
> variables "Bwt" and "Hwt", which are bodyweight and heartweight,
> respectively, of a group of cats.
> With the following code, I am making two plots, both to be viewed in
> the same plot window in R:
>
> library(MASS)
> maleData <- subset(cats, Sex == "M")
> linreg0 <- lm(maleData$Hwt ~ maleData$Bwt)
The second question is answered by:
linreg0 <- lm(Hwt ~ Bwt, data=maleData)
after that your predict code works.
> par(mfrow=c(1,2))
> plot(maleData$Hwt ~ maleData$Bwt)
> plot(rstandard(linreg0) ~ fitted(linreg0))
>
> My problem is that the two plots end up all oblong and squashed,
> because the plot window doesn't have a size suited for having two plots
> next to one another. Can I tell R to adjust the plot window?
Can you use mouse for resizing?
Regards
Petr
>
> Also, I would like to do something along the lines of:
>
> newData <- data.frame(Bwt = 3.5)
> predict(linreg0,newData,interval="p")
>
> This doesn't work - my guess is that to R, "Bwt" is not a variable in
> maleData, but maleData$Bwt is. I could use an attach command, but is it
> possible to get this to work without doing so?
>
> Kind regards,
> Rasmus Hedegaard.
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
More information about the R-help
mailing list