2

I'm new to R and need a bit of help. Basically, I have microarray data in a data frame and would like to append to the column name. Columns are named: A, B, C, etc.

[user] > names(first.df)

[1] "A" "B" "C" "D"

Another data frame identifies each factor (A, B, C, etc.) as "good" or "bad"

[user] > second.df

[1] A good

B bad

C bad

D good

Is there any way to add the "good"/"bad" to the column header of the first data frame?

[user] > names(first.df)

[1] "A-good" "B-bad" "C-bad" "D-good"

I've tried isolating names to their own data frame (e.g. names(first.df) <- c(names(first.df), second.df[,2]) and merging with no luck. Any advice?

4

1 に答える 1

3

There are a couple ways to do it. Here's a quick way:

  paste(names(first.df), second.df, sep="-")
于 2012-10-07T02:18:46.540 に答える