better or dead!

"Any time you encounter a small annoyance in your daily computer life, think about how you could write a program to help solve that problem. Any time you find something interesting that you want to experiment with, do it. Play with new concepts and tools and languages, as much as possible. Get into the mentality that a day/week/month in which you have not learned something interesting is a failure. But most of all: write code. Every day, even if it's just a regular expression to search through your email history or something. Do something programming-ish as often as you can."

Hippocrates (c. 400BC):
"Ars longa, vita brevis, occasio praeceps, experimentum periculosum, iudicium difficile"
"Life is short, [the] craft long, opportunity fleeting, experiment treacherous, judgment difficult."

back to base

transform e.g. head(airquality) head(transform(airquality, Ozone = -Ozone)) # makes Ozone negative head(transform(airquality, new = -Ozone, Temp = (Temp-32)/1.8)) # creates a new column called 'new' with negative ozone values and changes the values of the Temp column # example of subset one <- subset(bnames, sex == "boy" & year == 2008) one$rank <- rank(-one$percent, ties.method = "first") # or one <- transform(one, rank = rank(-percent, ties.method = "first")) # the use of minus means the rank values go from 1,2,3.. instead of 1000,999,998... # Fine for one year at a time, to do all at once: # Split pieces <- split(bnames, list(bnames$sex, bnames$year)) # Apply results <- vector("list", length(pieces)) for(i in seq_along(pieces)) { piece <- pieces[[i]] piece <- transform(piece, rank = rank(-percent, ties.method = "first")) results[[i]] <- piece } # Combine result <- do.call("rbind", results) # Or equivalently bnames <- ddply(bnames, c("sex", "year"), transform, rank = rank(-percent, ties.method = "first"))

Another thing often forgotten sometimes useful

log2-fold-changes are contained in fit2$coefficients.

R history

So again, something I have been meaning to look into: R history. By default only 512 lines are saved. Often I like to tinker with something until I get worked out exactly what I want to do, so saving a perfect script from the word go is not an option. So: Sys.setenv(R_HISTSIZE = Inf) *should* save all of my history, which I can then export, edit and save as a .R file.

Google is amazing.

Have been meaning to look this up for ages: how to set the cran mirror permanently.

Graphics

This is general, not just R specific, and I always forget the reasons so posted here: jpeg and pngs are raster graphics that do not scale well without becoming pixellated, whereas pdfs are vector graphics that will scale well.