Skip to content
Back to formatted view

Raw Message

Message-ID: <000601ce6438$b1a7e680$14f7b380$@jacobs@figurestofacts.be>
Date: 2013-06-08T11:09:49Z
From: Bert Jacobs
Subject: Add blank rows to a dataframe

Hi,

I have a vector that looks like this:
RowSel <-c(0,1,0,1,2,3,0,5,5)

Now I want to select rows from a specific dataframe DF based on that vector
like this:
SubDF <- DF[RowSel,]

So this works fine, but I was wondering how I could add blank rows add the
locations in the vector where there is a zero:
So the final dataframe should look like this:

SubDF
[1] blank row
[2] row 1
[3] blank row
[4] row 1 
[5] row 2
[6] row 3
[7] blank row
[8] row 5
[9] row 5

Do I have to use a loop for this or does there exist a straight forward
function option.

Thx,
Bert