Category Archives: R

R filter rows based on an element

I need to separate a matrix based on the existence of an element in a row.  I will end up with two matrices: the first will not contain the element on any of its rows and the second will contain … Continue reading

Posted in PhD, R | Leave a comment

Remove defined variables from R environment

When I am debugging a piece of code I usually do it inside the R-terminal.  It’s nice to do things this way because you can poke at things when something goes wrong.  The only disadvantage is that you mush “refresh” … Continue reading

Posted in PhD, R | Leave a comment

R : Finding the ordering index vector

The ordering index vector is a vector that contains indices of another vector.  It’s basically the other vector, but ordered (decreasing or increasing).  Instead of having the values it has the indices :)  I spent close to an hour to … Continue reading

Posted in commands, R | 3 Comments

Curious rounding in R

Sometimes R has a misleading way of displaying values.  Check out this series of commands: > 1111+.5 [1] 1111.5 > 11111+.5 [1] 11111.5 > 111111+.5 [1] 111111.5 > 1111111+.5 [1] 1111112 > 11111111+.5 [1] 11111112 At first I thought that … Continue reading

Posted in commands, PhD, R | Leave a comment

Adjusting point size in R plots.

The trick here is to manage the pch and cex arguments in the plot function.  You can look at more information on these arguments in ?plot, ?par and ?points in the R environment (search for cex and pch).  In general … Continue reading

Posted in commands, R | Leave a comment

How to output an eps figure in R

If you are executing a plot command in a R script it should default to generating a pdf document with your plot.  This is really cool because you don’t really have to think about how to show what you have … Continue reading

Posted in commands, PhD, R | Leave a comment