r:graphics
                Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| r:graphics [2016/12/02 09:44] – [E.G.] hkimscil | r:graphics [2017/11/27 09:57] (current) – [Adding Confidence Intervals to a Bar Chart] hkimscil | ||
|---|---|---|---|
| Line 201: | Line 201: | ||
| title(" | title(" | ||
| {{: | {{: | ||
| + | |||
| + | ===== e.g. 2 ===== | ||
| + | |||
| + | < | ||
| + | lm.SR <- lm(sr ~ pop15 + pop75 + dpi + ddpi, data = LifeCycleSavings) | ||
| + | |||
| + | > summary(lm.SR) | ||
| + | |||
| + | Call: | ||
| + | lm(formula = sr ~ pop15 + pop75 + dpi + ddpi, data = LifeCycleSavings) | ||
| + | |||
| + | Residuals: | ||
| + | Min      1Q  Median | ||
| + | -8.2422 -2.6857 -0.2488 | ||
| + | |||
| + | Coefficients: | ||
| + | Estimate Std. Error t value Pr(> | ||
| + | (Intercept) 28.5660865 | ||
| + | pop15 | ||
| + | pop75 | ||
| + | dpi | ||
| + | ddpi | ||
| + | --- | ||
| + | Signif. codes: | ||
| + | |||
| + | Residual standard error: 3.803 on 45 degrees of freedom | ||
| + | Multiple R-squared: | ||
| + | F-statistic: | ||
| + | |||
| + | > plot(LifeCycleSavings) | ||
| + | > plot(lm.SR) | ||
| + | </ | ||
| + | |||
| + | {{: | ||
| + | {{: | ||
| + | |||
| ====== Plotting All Variables Against All Other Variables ====== | ====== Plotting All Variables Against All Other Variables ====== | ||
| < | < | ||
| Line 385: | Line 421: | ||
| + | + | ||
| + | + | ||
| - | {{: | + | {{: | 
| ====== Adding Confidence Intervals to a Bar Chart ====== | ====== Adding Confidence Intervals to a Bar Chart ====== | ||
| Line 396: | Line 432: | ||
| </ | </ | ||
| - | < | + | < | 
| - | tsd <- tapply(Temp, | + | # mean for each month | 
| - | tse <- tsd/ | + | tsd <- tapply(Temp, | 
| + | # sd for each month | ||
| + | tse <- tsd/ | ||
| + | # se for each month | ||
| lower <- tmean - 1.96*tse | lower <- tmean - 1.96*tse | ||
| Line 433: | Line 472: | ||
| plot(pressure, | plot(pressure, | ||
| {{: | {{: | ||
| + | |||
| + | < | ||
| + | > y <- rnorm(20) | ||
| + | > plot(y, type=" | ||
| + | > plot(y, type=" | ||
| + | > plot(y, type=" | ||
| + | > plot(y, type=" | ||
| + | ></ | ||
| + | {{: | ||
| ====== Plotting Multiple Datasets ====== | ====== Plotting Multiple Datasets ====== | ||
| < | < | ||
| Line 897: | Line 945: | ||
| symbols(-.13, | symbols(-.13, | ||
| {{: | {{: | ||
| + | |||
| + | < | ||
| + | z <- 2 * volcano | ||
| + | x <- 10 * (1: | ||
| + | y <- 10 * (1: | ||
| + | # Don't draw the grid lines : border = NA | ||
| + | par(mar=rep(0, | ||
| + | persp(x, y, z, theta = 135, phi = 30, col = "light grey", scale = FALSE, | ||
| + | ltheta = -120, shade = 0.75, border = NA, box = FALSE) | ||
| + | mtext(" | ||
| + | par(mar=c(3, | ||
| + | # Note that  example(trees) | ||
| + | N <- nrow(trees) | ||
| + | attach(trees) | ||
| + | # Girth is diameter in inches | ||
| + | symbols(Height, | ||
| + | main="", | ||
| + | mtext(" | ||
| + | par(mar=rep(0.5, | ||
| + | contour(x, y, z, asp=1, labcex=0.35, | ||
| + | rect(0, 0, 870, 620) | ||
| + | mtext(" | ||
| + | image(x, y, z, asp=1, col=grey(0.5 + 1:12/24), xlab="", | ||
| + | rect(min(x)-5, | ||
| + | mtext(" | ||
| + | |||
| + | |||
| + | </ | ||
| + | {{: | ||
r/graphics.1480641268.txt.gz · Last modified:  by hkimscil
                
                