【发布时间】:2011-08-02 12:56:35
【问题描述】:
输入表
Patients Hospital Drug Response
1 AAA a Good
1 AAA a Bad
2 BBB a Bad
3 CCC b Good
4 CCC c Bad
5 DDD e undefined
输出文件
Patients Hospital Drug Response
1 AAA a 1
1 AAA a -1
2 BBB a -1
3 CCC b 1
4 CCC c -1
5 DDD e
如何将一列中的3个文本替换为数字和空白?
“响应列中的好”到“1” “响应列中的错误”为“-1” “响应列中未定义”到“”
数据:
structure(list(Patients = c(1L, 1L, 2L, 3L, 4L, 5L), Hospital = structure(c(1L,
1L, 2L, 3L, 3L, 4L), .Label = c("AAA", "BBB", "CCC", "DDD"), class = "factor"),
Drug = structure(c(1L, 1L, 1L, 2L, 3L, 4L), .Label = c("a",
"b", "c", "e"), class = "factor"), Response = structure(c(2L,
1L, 1L, 2L, 1L, 3L), .Label = c("Bad", "Good", "undefined"
), class = "factor")), .Names = c("Patients", "Hospital",
"Drug", "Response"), class = "data.frame", row.names = c(NA,
-6L))
【问题讨论】:
-
我认为 Gavin 输入了样本数据。