小编Moh*_*ohr的帖子

如何索引R中列表对象的元素

我正在执行以下操作以导入一些txt表并将它们保存为列表:

# set working directory - the folder where all selection tables are stored
hypo_selections<-list.files() # change object name according to each species
hypo_list<-lapply(hypo_selections,read.table,sep="\t",header=T) # change object name according to each species
Run Code Online (Sandbox Code Playgroud)

我想访问一个特定的元素,比如说hypo_list [1].由于每个元素代表一个表,我应该如何获取访问特定单元格(行和列)?

我想做类似的事情:

a<-hypo_list[1]

a[1,2]
Run Code Online (Sandbox Code Playgroud)

但是我收到以下错误消息:

Error in a[1, 2] : incorrect number of dimensions
Run Code Online (Sandbox Code Playgroud)

有一个聪明的方法吗?

提前致谢!

indexing r list lapply read.table

20
推荐指数
1
解决办法
8万
查看次数

标签 统计

indexing ×1

lapply ×1

list ×1

r ×1

read.table ×1