# Nicholas Horton, nhorton@smith.edu # Sat Mar 19 09:18:26 EDT 2011 # What proportion of the US is within a mile of a road? # CAUSE Activity webinar nsamp = 50 # enough to keep students busy for a class period long = -runif(nsamp, min=65, max=130) lat = runif(nsamp,min=25,max=50) data = cbind(sample=1:nsamp, latitude=round(lat, 4), longitude=round(long, 4), incontinent=c(rep(NA, nsamp)), within1mile=c(rep(NA, nsamp)), location=character(nsamp), notes=character(nsamp)) write.csv(data,file="roadless.csv") # note filename is different to prevent inadvertent clobbering! ds = read.csv("myroadless.csv", stringsAsFactors=FALSE) table(ds$incontinent) table(ds$location[ds$incontinent==0]) table(ds$location[ds$incontinent==1]) smallds = subset(ds, incontinent==1) rm(ds) table(smallds$within1mile) # need to substitute values here for k (# of successes) # and n (# of trials) #binom.test(k, n)