Code Comments

Code Comments

Tips and short tutorials on various programming technologies

Code Comments RSS Feed
 
 
 
 

Archive for R

Graph of pch Plotting Symbols in R

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 »

How to Run an R Script from the Command Line

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 »

Dynamically Invoke a Function in R

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 »

How to List Files in a Directory Using Wildcards in R

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 »

How to Do a String Join in R

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 »

Modifying Text Size of Axis Labels in R

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 »

What Is the R Statistical Package?

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 »

Rotate Axis Names on X-Axis in R

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 »