[R] manipulating data of several columns simultaneously

Gerrit Eichner Gerrit.Eichner at math.uni-giessen.de
Wed Jan 18 14:11:29 CET 2012


Hello, Nerak,

maybe

rbind( NA, head( results, -1))

does what you want (for all columns at once)?

Hth,
Gerrit



On Wed, 18 Jan 2012, Nerak wrote:

> Dear all,
> I have a question concerning manipulating data of several columns of a 
> dataframe at the same time. I manage to do it for one column (with the 
> use of the specific name for this column). In each columns, I have 60 
> values. But I should reorganize the values (because I created this as an 
> output before and I want to compare it with an other dataset). I want 
> that the value on row 2 becomes the value of row 1, value 3 value 2 and 
> so on.  The first value would be NA.
>
> If I would do this for 1 column (with the name depth_1), I would do it 
> like this:
>
> for (t in 2:60)
> {
> results$depth[t]<-new$depth_1[t-1]
> }

[ ... snip ... ]



More information about the R-help mailing list