r - 在嵌套的df中使用地图提取数据
问题描述
我有一个数据框nested_df
sample condition data
1 hbr_2d treated <tibble [2,806 x 3]>
2 hbr_3d treated <tibble [2,757 x 3]>
3 hbr_ev treated <tibble [2,752 x 3]>
4 hct_2d treated <tibble [2,756 x 3]>
5 hct_3d treated <tibble [2,743 x 3]>
6 hct_ev treated <tibble [2,731 x 3]>
7 pbr_2d treated <tibble [2,502 x 3]>
8 pbr_3d treated <tibble [2,674 x 3]>
9 pbr_ev treated <tibble [2,661 x 3]>
10 pmf_2d treated <tibble [2,598 x 3]>
11 pmf_3d treated <tibble [2,599 x 3]>
12 pmf_ev treated <tibble [2,469 x 3]>
nested_df$data
[[1]]
protein value presence
1 A0A024QYZ9 16.8 Yes
2 A0A024QZ21 15.1 Yes
3 A0A024QZ72 15.0 Yes
4 A0A024QZA8 19.0 Yes
5 A0A024QZB1 13.7 Yes
6 A0A024QZK9 19.1 Yes
7 A0A024QZV7 19.8 Yes
8 A0A024R023 16.2 Yes
9 A0A024R032 18.0 Yes
10 A0A024R0G5 11.1 Yes
我想逐行拉出列表protein
。sample
预期结果:
[[hbr_2d]]
[1] "A0A024QYZ9" "A0A024QZ21" "A0A024QZ72" "A0A024QZA8" "A0A024QZB1" "A0A024QZK9" "A0A024QZV7"
[8] "A0A024R023" "A0A024R032"
[[hbr_3d]]
[1] "A0A024QYZ9" "A0A024QZ21" "A0A024QZ72" "A0A024QZA8" "A0A024QZB1" "A0A024QZK9" "A0A024QZV7"
[8] "A0A024R023" "A0A024R032"
我曾尝试使用map
诸如地图之类的方法,但这不起作用。
map(nested_df, ~.x[] %>% pull())
Error in UseMethod("pull") :
no applicable method for 'pull' applied to an object of class "character"
我应该如何编码?感谢你的帮助。
解决方案
推荐阅读
- .net - Epplus 使用 TFS 连接创建 Excel
- python - 在 Redis 上存储和访问复杂 JSON 对象的最快和最佳方式
- javascript - jsReport不通过javascript读取数据
- ios - iOS AudioQueue 播放 AAC 数据总是延迟 2-3 秒
- perl - 使用 XML::LibXML 和 Perl 查找/替换值
- bash - 如何将命令的输出提供给提示符?
- android - 文本输入 EditText 数字不起作用?仅显示“abcxyz”之类的字符,并且还需要避免在edittext(TextInputLayout)中使用数字和符号
- javascript - 使用 JavaScript 切换 CSS 类 - 错误
- javascript - javascript中的移动按钮
- php - readdir while循环未执行