按行标记两个单独的数据框,然后将它们合并到同一列下的一个数据框中,但保留行标签

Labelling two separate data frames by row and then merging them into one data frame under the same column but with row labels preserved

我有两个数据集,我们称它们为

A: 1, 3, 5, 6, 3

B: 2, 4, 7, 9, 8

其中AB中的数字代表时间

我想将 row 中 A 中的所有数字标记为“正数” B 中的所有数字都被 row.

标记为“负”

然后我想将 A 和 B 合并到一个名为“时间”的列下的单个数据框中,但它们必须保留其对应数字的行名称“正”/“负”,以便我可以绘制两者进入生存地块

我猜你正在寻找这样的数据框:

A <- data.frame(time = c(1, 3, 5, 6, 3), status= "positive")
B <- data.frame(time = c(2, 4, 7, 9, 8), status= "negative")

rbind(A, B)

输出:

   time   status
1     1 positive
2     3 positive
3     5 positive
4     6 positive
5     3 positive
6     2 negative
7     4 negative
8     7 negative
9     9 negative
10    8 negative