Publications by Forester
Leap years
A quick function that when provided a numeric vector of years returns a boolean vector where TRUE == Leap year.is.leapyear=function(year){ #http://en.wikipedia.org/wiki/Leap_year return(((year %% 4 == 0) & (year %% 100 != 0)) | (year %% 400 == 0)) } Related To leave a comment for the author, please follow the link and comment on...
526 sym R (142 sym/1 pcs)
ISO week
I am working with a model that produces estimates of snow water equivalent through time. Because I deal with large spatial extents, I decided to have the model produce weekly averages. The problem with this is knowing which file to access for a given date. The snow files are saved using an ISO-8061 week number (I had no idea how many ...
1737 sym R (2452 sym/1 pcs)
Quantitative Ecology 2010-11-10 14:56:00
At last… I have been suffering with XEmacs displaying odd characters instead of the quotation marks that are used in R help files. This was driving me up the wall because it makes the files (and R output in general) very hard to read; however, I finally diagnosed the problem: Xemacs was not recognizing UTF-8 encoding. Below is a quo...
2765 sym
RStudio and X2Go
After a recent system upgrade (to Linux Mint LMDE), I was no longer able to run RStudio through the remote desktop application X2Go. It turns out that this is due to a problem with the Qt libraries (see this website). As suggested here, I just deleted all the Qt libraries used by RStudio:sudo rm /usr/lib/rstudio/bin/libQt* and ...
815 sym R (40 sym/1 pcs)
Sample uniformly within a fixed radius.
I was asked how to do this today and thought that I would share the answer: ## Sample points uniformly within a fixed radius nrand=1000 maxstep=10 ## Sample data ## NB: To get a truly uniform sample over the circle, you must ## sample the square of the distance and then transform back. tempdat<-data.frame(X0=0,Y0=0, bearing0...
493 sym R (1056 sym/1 pcs) 2 img
Recursively search for text in R scripts.
Often I find myself needing to search for .R or or .Rmd files in which I have used a specific function. There are a variety of searches that you can do; however, I wanted something that would work recursively at the command line of a Linux or Mac terminal. I found the answer here and have modified it a bit so that it works as a functi...
1009 sym R (367 sym/2 pcs)