[R] rbind help

James W. MacDonald jmacdon at med.umich.edu
Tue May 12 18:52:20 CEST 2009

Hi Mike,

MikSmith wrote:
> Hi
> I have a dataset of orientation and elevation in a dataframe which I am
> plotting in circular. Orientation is on the range 0-360, however I need to
> reduce this to 0-180 as the values over 180 are not necessarily correct. I
> can do
> striae$orientation[striae$orientation>180]-180)
> to extract these values, but I then want to combine them back in to the
> original dataframe (with the elevation values). I assume rbind is the thing
> to use and have tried something like:
> test <- rbind((striae$orientation[striae$orientation>180]-180),
> (striae$orientation[striae$orientation<=180]))

I would do the conversion in place:

striae$orientation <- ifelse(striae$orientation > 108, 
striae$orientation - 180, striae$orientation)



> Not being a regular R user I suspect the syntax is easy when you know it!!
> Any help much appreciated.
> Best wishes
> mike

James W. MacDonald, M.S.
Douglas Lab
University of Michigan
Department of Human Genetics
5912 Buhl
1241 E. Catherine St.
Ann Arbor MI 48109-5618

More information about the R-help mailing list