I’ve recently started using ggplot2 in addition to lattice (see this post that I made a while ago, explaining how I got into using lattice in the first place). Hint: when using ggplot2, you’ll need to use of the reshape2 package (also written by the amazing Hadley Wickham) to get your data into a form that ggplot2 works best with. Another thing that you’ll want to think about when using ggplo2 is factor levels.

Continue reading

Firstly, start off your table in http://www.tablesgenerator.com/. Tables Generator will do a lot for you. Its most useful features are importing from .csv and merging cells. The Booktabs table style (alternative to default table style from the menu) looks a bit nicer and is “publication quality”. Note that publication quality tables should not contain vertical lines. Code #1 is the code from Tables Generator with the addition of caption, label and Latex document begin-end (so it’s compilable).

Continue reading

This is a short note based on this. Answer in short: Because different formulas are used to calculate the R-squared of a linear regression, depending on whether it has an intercept or not. R2 for a linear model that has an intercept: , where y is the variable that the linear model is trying to predict (the response variable), y^ is the predicted value and y- is the mean value of the response variable.

Continue reading

I don’t know if it’s good or bad, but I like when the files I’m working with are in the working directory (so instead of using pathnames to my files I can just type filename or ./filename). But to avoid copying data and wasting space, symbolic links are the way to go. The command for that is: ln -s target_file sym_link, where -s stands for “symbolic” (just ln would create a hard link)

Continue reading

NCO:ncap2 is the function to do it: ncap2 -s 'new_var=var1+var2' in_filename.nc out_filename.nc The output file will have all of the variables that exist in the input file as well as the new_var. Add -O if your input and output files are the same (overwrite). I do not know what the -s stands for. BUT the new_var will have the same long_name as the first variable used for summing (i.e. it could make some things a bit confusing).

Continue reading

Author's picture

Riinu Pius (Ots)

if it aint broke, you’re outdated

Senior Data Manager

Edinburgh, UK