Skip to content
Back to formatted view

Raw Message

Message-ID: <CABsGe_wKOzPs6Cp5DGzTxs4QW7sgUK_Q3ktOUxXn8-KJ7QmAqw@mail.gmail.com>
Date: 2013-01-11T12:46:56Z
From: Johannes Radinger
Subject: split & rbind (cast) dataframe

Hi,

I would like to split dataframe based on one colum and want
to connect the two dataframes by rows (like rbind). Here a small example:

# The orgininal dataframe
df1 <- data.frame(col1 = c("A","A","B","B"),col2 = c(1:4), col3 = c(1:4))

# The datafame how it could look like
df2 <- data.frame(A.col2 = c(1,2), A.col3 = c(1,2), B.col2 = c(3,4),
B.col3 = c(3,4))

I think I already did a similar procedure sometime ago with the
cast() command from reshape-package but I cant remember correctly...
...maybe someone can point me to the correct formula...

Best

/johannes