如何在R中将列表列中的某个值更改为NA?
我想将 V3 列的 -1 值更改为 NA,但不知道如何...
library(dplyr)
set.seed(94756)
mat1 <- matrix(sample(seq(-1,100, 0.11),50,replace = TRUE),ncol = 5)
mat1 <- as.data.frame(mat1)
mat1[8,3] <- -1
mat1[1,3] <- -1
mat1[5,3] <- -1
mat2 <- matrix(sample(seq(-1,100, 0.11),50, replace = TRUE),ncol = 5)
mat2 <- as.data.frame(mat2)
mat2[8,3] <- -1
mat2[1,3] <- -1
mat2[5,3] <- -1
mat3 <- matrix(sample(seq(-1,100, 0.11), 50,replace = TRUE),ncol = 5)
mat3 <- as.data.frame(mat2)
mat3[2,3] <- -1
mat3[4,3] <- -1
mat3[8,3] <- -1
data <- list(mat1, mat2, mat3)
有人可以帮忙吗? 提前致谢。
I would like to change -1 value of my V3 column into NA, but don't know how...
library(dplyr)
set.seed(94756)
mat1 <- matrix(sample(seq(-1,100, 0.11),50,replace = TRUE),ncol = 5)
mat1 <- as.data.frame(mat1)
mat1[8,3] <- -1
mat1[1,3] <- -1
mat1[5,3] <- -1
mat2 <- matrix(sample(seq(-1,100, 0.11),50, replace = TRUE),ncol = 5)
mat2 <- as.data.frame(mat2)
mat2[8,3] <- -1
mat2[1,3] <- -1
mat2[5,3] <- -1
mat3 <- matrix(sample(seq(-1,100, 0.11), 50,replace = TRUE),ncol = 5)
mat3 <- as.data.frame(mat2)
mat3[2,3] <- -1
mat3[4,3] <- -1
mat3[8,3] <- -1
data <- list(mat1, mat2, mat3)
Can anyone help please?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用此代码:
You can use this code: