Archive for the 'R' Category
Let’s say you are creating a barplot in R. Sometimes you want to label the bars below the X axis. But sometimes you might also want to put a label above the bars. This is pretty easy to do but a little hidden. Below is a working example based on randomly generated data that illustrates [...] Read more »
April 27th, 2010 | Posted in R | No Comments
I was trying to install some packages in R recently that depended on the XML package. I used the nifty install.packages() command, but I was getting an error:
“cannot find xml2-config”
This error was preventing these other packages from being installed properly. It turns out that I needed to install a library called libxml2-dev. In my case, [...] Read more »
April 22nd, 2010 | Posted in Linux, R | No Comments
I’m using the R statistical package and the ROCR package within that. Both of these are free and very flexible. Sometimes with that flexibility comes ambiguity as to what you should do to accomplish a relatively simple task. I am doing a data-mining (machine-learning) project in which I predict a cancer patient’s prognosis. The algorithms [...] Read more »
April 9th, 2010 | Posted in R, Statistics | No Comments
In the R statistical package, you have various ways of representing and packaging data. The most simple is in a single variable. More complex representations include vectors, lists, matrices, and data frames. An even more complex representation is S4 Classes, which are intended to simulate object-oriented programming in R.
I was using an R package that [...] Read more »
April 9th, 2010 | Posted in R, Statistics | No Comments
In R, you can plot a variety of symbols when you are plotting points on a graph. The default is a hollow circle. But it is very flexible. To do this, you use the pch parameter when you create a plot. You can find information in the help files (?pch), but it only describes the [...] Read more »
December 4th, 2009 | Posted in R | No Comments
I’m writing this post because I just spent a couple of hours banging my head against the wall, trying to figure out how to run an R script from the command line. It was working if I simply ran it at the command line. But when I try to run the same command from Java [...] Read more »
August 12th, 2009 | Posted in Java, R | 1 Comment
One way the R programming language has been described is that it is a functional programming language. Whether it would be called this by purists, I don’t know. But part of what this means is that all functions are treated as objects. So you can pass functions around very easily. This might sound strange, but [...] Read more »
August 11th, 2009 | Posted in R, Reflection, Tip | No Comments
Let’s say you have a directory with files matching a certain pattern (and others that don’t), and you want to find all the files that match that pattern in R. It’s pretty easy to do this, but it’s not super straightforward to figure it out from the help. Below is the simple answer. But you [...] Read more »
July 27th, 2009 | Posted in R | No Comments
Let’s say you have a list of values in a vector. And you want to be able to convert that into a delimited string. In some languages (such as Python), you can do this easily with the join method. But how would you do this in R?
This can be done with the paste function. The [...] Read more »
June 29th, 2009 | Posted in R | 3 Comments
When you create a plot in R, you can easily modify the text size of the labels on the axes using the cex.lab property. This stands for “character expansion of labels.” For this value, you specify a relative size (compared to the default) that you want the text to be. The following code shows how [...] Read more »
February 26th, 2009 | Posted in R, Statistics | No Comments
R is an open source statistical package that can be used to do complex analyses and produce publication quality graphics. It’s home page is at http://www.r-project.org.
This tool is very powerful but sometimes hard to figure out how to do simple things. For this reason, I will be posting some tips as I encounter such situations. Read more »
August 26th, 2008 | Posted in R | No Comments
You use one of the par parameters to do this. For example:
x = c(3,4,2,5)
names(x) = c(“ABC”, “DEF”, “GHI”, “JKL”)
barplot(x, las=”2″)
See also: What Is the R Statistical Package Read more »
August 26th, 2008 | Posted in R | No Comments