如何使用 apply 排除列
我想排除/复制列表中列表中多个数据帧的行/列。 该代码还不能运行。也许这里有人知道该怎么做。
Zelllysate_extr <- list()
#defining the list
Zelllysate_extr$X0809P3_extr <- X0809P3_extr
#defining the list within the list
X0809P3_extr = lapply(Zelllysate_colr[["X0809P3"]], function(x) {
as.data.frame(x) <- Zelllysate_colr[["X0809P3_colr"]][2:1500, 1 & 3:4]
return(x)
})
#defining the list for the dataframes to place in; 2:1500, 1 & 3:4 are the rows and columns to copy
谢谢
I want to exclude/copy rows/columns of multiple dataframes within a list in a list.
The code doesn't work yet. Maybe somebody here knows what to do.
Zelllysate_extr <- list()
#defining the list
Zelllysate_extr$X0809P3_extr <- X0809P3_extr
#defining the list within the list
X0809P3_extr = lapply(Zelllysate_colr[["X0809P3"]], function(x) {
as.data.frame(x) <- Zelllysate_colr[["X0809P3_colr"]][2:1500, 1 & 3:4]
return(x)
})
#defining the list for the dataframes to place in; 2:1500, 1 & 3:4 are the rows and columns to copy
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要尝试迭代列表,而是迭代列表的长度。
您不需要
return
或将值设置为等于lapply
中的值。大多数情况下, dput(head(dataObject)) 的输出就足够了,但我认为您正在使用列表列表,因此可能不足以查看结构。
Instead of trying to iterate over the list, iterate over the length of the list.
You don't need a
return
or to set the value equal to something inlapply
.Most of the time the output from
dput(head(dataObject))
is enough, but I think you're working with lists of lists, so that might not be enough to see the structure.