Skip to content
Prev 76893 / 398502 Next

data manipulation

Hi,

This may not be the best solution, but at least it's
easy to see what i'm doing, assume that your data set
is called "data":

# remove the 4th column
data1 = data[,-4]

# remove the 3rd column
data2 = data[,-3]

# use cbind to add an extra column with only X1 
#elements
data1 = cbind(data1, array("X1", nrow(data1), 1)

# use cbind to add an extra column with only X2
#elements
data2 = cbind(data2, array("X2", nrow(data2), 1)

# use rbind to add them together as rows
data3 = rbind(data1, data2)

# rename the names of the columns
colnames(data3) <- c("ID", "time", "X", "type")

# show output
data3

The only thing I couldn't figure out is how to sort
the data set per row, perhaps someone else could help
us out on this?

Martin
--- Marc Bernard <bernarduse1 at yahoo.fr> wrote:

            
______________________________________________________
Click here to donate to the Hurricane Katrina relief effort.