User Tools

Site Tools


r:graphics

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
r:graphics [2016/12/02 09:57] – [e.g. 1] hkimscilr:graphics [2017/11/27 09:57] (current) – [Adding Confidence Intervals to a Bar Chart] hkimscil
Line 230: Line 230:
 F-statistic: 5.756 on 4 and 45 DF,  p-value: 0.0007904 F-statistic: 5.756 on 4 and 45 DF,  p-value: 0.0007904
  
 +> plot(LifeCycleSavings)
 > plot(lm.SR) > plot(lm.SR)
 </code> </code>
 +
 +{{:r:LifeCycleSavings.jpeg}}
 {{:R:regression_model.png}} {{:R:regression_model.png}}
  
Line 418: Line 421:
 +         names.arg=c("May", "Jun", "Jul", "Aug", "Sep"), +         names.arg=c("May", "Jun", "Jul", "Aug", "Sep"),
 +         ylab="Temp (deg. F)")</code> +         ylab="Temp (deg. F)")</code>
-{{:R:barplot_heights.png}}+{{:R:barplot_heights.2.png}}
  
 ====== Adding Confidence Intervals to a Bar Chart ====== ====== Adding Confidence Intervals to a Bar Chart ======
Line 429: Line 432:
 </code> </code>
  
-<code>tmean <- tapply(Temp, list(as.factor(Month)), mean)  # mean for each month +<code>tmean <- tapply(Temp, list(as.factor(Month)), mean)   
-tsd <- tapply(Temp, list(as.factor(Month)),sd)  # sd for each month +# mean for each month 
-tse <- tsd/sqrt(length(Temp))  # se for each month+tsd <- tapply(Temp, list(as.factor(Month)),sd)   
 +# sd for each month 
 +tse <- tsd/sqrt(length(Temp))   
 +# se for each month
  
 lower <- tmean - 1.96*tse lower <- tmean - 1.96*tse
Line 940: Line 946:
 {{:R:using_maps_R.png}} {{:R:using_maps_R.png}}
  
-<code> +<code>par(mfrow=c(22)) 
-+z <- 2 * volcano        # Exaggerate the relief 
-# Comment: +<- 10 * (1:nrow(z))   # 10 meter spacing (S to N
-+<10 * (1:ncol(z))   # 10 meter spacing (E to W) 
-# An example of a one-off image drawn using the grid system. +# Don't draw the grid lines :  border NA 
-+par(mar=rep(0, 4)) 
-# The code is somewhat modular and general, with functions +persp(x, y, ztheta = 135phi 30col = "light grey", scale = FALSE
-# for producing different shapes, but the sizes and +      ltheta -120shade 0.75border = NAbox = FALSE
-# locations used in this particular image assume a 2:1 aspect ratio. +mtext("persp()"side=3line=-2
-+par(mar=c(3320.5)) 
-# The gradient-fill background (dark at the top to lighter at the  +# Note that  example(trees)  shows more sensible plots! 
-# bottom) is achieved by filling multiple overlapping polygons with +<- nrow(trees) 
-# slowly changing shades of grey. +attach(trees
-+# Girth is diameter in inches 
- +symbols(HeightVolume, circles=Girth/24, inches=FALSE
- +        main="", xlab=""ylab="", bg=grey(Girth/max(Girth))) 
-pushViewport(viewport(xscale=c(01), yscale=c(0.5, 1), +mtext("symbols()"side=3line=0.5
-             clip=TRUE)) +par(mar=rep(0.54)
-              +contour(xyzasp=1labcex=0.35axes=FALSE
-res <- 50 +rect(0, 0870, 620
-for (i in 1:res+mtext("contour()", side=3, line=-1.5
-  grid.rect(y=1 - (i-1)/res, just="top", +image(x, y, z, asp=1, col=grey(0.5 + 1:12/24), xlab="", ylab=""axes=FALSE
-            gp=gpar(col=NULL, fill=grey(0.5*i/res))) +rect(min(x)-5, min(y)-5max(x)+5max(y)+5
- +mtext("image()", side=3line=-1.5)
-moon <- function(x, y, size) { +
-  angle <- seq(-9090length=50)/180*pi +
-  x1 <- x + size*cos(angle) +
-  y1 <- y + size*sin(angle) +
-  mod <- 0.8 +
-  x2 <- x + mod*(x1 - x) +
-  grid.polygon(c(x1rev(x2)), c(y1, rev(y1)), +
-               default.unit="native", +
-               gp=gpar(col=NULLfill="white")) +
-+
- +
-moon(.1.9.03+
- +
-star <- function(xysize{ +
-  x1 <- c(x          x + size*.1x + size*.5x + size*.1, +
-          x,           x - size*.1, x - size*.5, x - size*.1+ .05 +
-  y1 <- c(y - size,    y - size*.1, y,           y + size*.1, +
-          y + size*.7, y + size*.1, y,           y - size*.1+ .05 +
-  grid.polygon(x1y1,  +
-               default.unit="native", +
-               gp=gpar(col=NULLfill="white")) +
-+
- +
-star(.5, .7, .02+
-star(.8, .9, .02) +
-star(.72, .74, .02) +
-star(.62.88, .02+
- +
-grid.circle(runif(20, .21), runif(20.61)r=.002, +
-            default.unit="native", +
-            gp=gpar(col=NULL, fill="white")) +
- +
-hill <- function(height=0.1col="black"{ +
-  n <- 100 +
-  x <- seq(0, 1length=n+
-  y1 <- sin(runif(1+ x*2*pi) +
-  y2 <sin(runif(1) + x*4*pi) +
-  y3 <- sin(runif(1) + x*8*pi) +
-  y <- 0.6 + height*((y1 + y2 + y3)/3+
-  grid.polygon(c(x, rev(x)), c(y, rep(0, n)), +
-               default.unit="native", +
-               gp=gpar(col=NULLfill=col)+
-+
- +
-hill() +
- +
-rdir <function(n+
-  sample(seq(-4545, length=10), n)/180*pi +
-+
- +
-grid.text("Once upon a time ...", +
-          x=.15, y=.51, just="bottom", +
-          default.unit="native", +
-          gp=gpar(col="white", fontface="italic"fontsize=10)) +
- +
-popViewport() +
- +
-grid.rect()+
  
  
 </code> </code>
-{{:R:clip_art.png}}+{{:R:poly_graph.png}}
  
r/graphics.txt · Last modified: 2017/11/27 09:57 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki