let's make the graph i did in class last week.
MAKE A PLAN OF WHAT I WANT IT TO LOOK LIKE.
start data:
put in excel
"" around words
numbers for Dem and Repub are guessed (no other real way).
want to get neutral
want to order in some way
create a table in r:
make a long list in the order that i want
create a table: http://www.cyclismo.org/tutorial/R/tables.html
label the table the way i want it to be: colnames(), rownames()
set it up in r and see what happens
...did we mess it up? check a basic barplot to look at it:
http://www.statmethods.net/graphs/bar.html
did it do what we wanted it to?
colors and legends and random oh my!
how to make an awesome graph in r (the trials and tribulations of Mundt in making that graph)
http://www.stats.bris.ac.uk/R/doc/contrib/refcard.pdf
stretch the ylim to accomodate the legend (or just make one in illustrator)
las=2
NOTHING WORKS PERFECT THE FIRST TIME.
after an hour ++:
barplot(a.m3, col=c("blue","white","red"), main="What Y'all Drivin?!", legend=rownames(a.m3), ylim=c(0,180), las=2, cex.names=0.8)
...at least, that's how it worked for me last time...
Gender vs. Scary Movies:
get data in excel
export as .csv
table(columns, rows)
what can we do with this?
http://www.cyclismo.org/tutorial/R/tables.html
...residual tables? PERCENTS!
Let's import some libraries:
http://www.r-bloggers.com/r-tutorial-series-labeling-data-points-on-a-plot/
...hey look, textxy()
doesn't work for us the first time we try to use it
have to import the "calibrate" package
and then load it!
let's try it on our car data--what does their code look like, and how do I make mine like theirs?
can I just mark one point? (haven't tried this yet, let's try together)
how is this useful?
http://cran.r-project.org/web/packages/available_packages_by_name.html
...hey let's look at ggplot2
import
look at this info here: http://ggplot2.org/resources/the-grammar.r
let's try some things and see what it does....THE WORLD IS FOR EXPLORING.
looks like there's a lot powerful here. i haven't messed around with it much
...hey let's import maps
what examples do they give us?
What do we want to do?
?map()
install RcolorBrewer
again, examples at end give us a hint!
make a map of vermont:
mypalette<-brewer.pal(7,"Greens")
image(1:7,1,as.matrix(1:7),col=mypalette,xlab="Greens (sequential)", ylab="",xaxt="n",yaxt="n",bty="n")
map('state',c('vermont'),col=mypalette)
http://vermont.hometownlocator.com/census/index.cfm
data...?
and now for the final thing we can do:
http://xkcd.com/710/
function(x)
{
i = 0
tops = x
while(x>1) {
if (x%%2==1)
{
x=3*x+1
i=i+1
tops = max(tops, x)
}
if (x%%2==0)
{
x=x/2
i=i+1
}
}
print(i)
print(tops)
iteration=c(iteration,i)
maxvalue=c(maxvalue,tops)
}