Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 替换数据帧列中的值_R - Fatal编程技术网

R 替换数据帧列中的值

R 替换数据帧列中的值,r,R,通过将标签指定为“d”,使用因子方法 a 1 1 2 2 3 1 4 2 5 2 6 1 到目前为止你试过什么?现在你只是给我们模糊的指示,而不是展示你到目前为止做了什么&你需要什么帮助。 a 1 1 2 2 3 1 4 2 5 2 6 1 b$a <- factor(b$a, levels = c('F', 'M'), labels = d)) setNames(d, c("F", "M"))[as.character(b$a)]

通过将
标签
指定为“d”,使用
因子
方法

  a
1 1
2 2
3 1
4 2
5 2
6 1

到目前为止你试过什么?现在你只是给我们模糊的指示,而不是展示你到目前为止做了什么&你需要什么帮助。
  a
1 1
2 2
3 1
4 2
5 2
6 1
b$a <- factor(b$a, levels = c('F', 'M'), labels = d))
setNames(d, c("F", "M"))[as.character(b$a)]