我如何将Exsist列用作样本ID
我将Excel文件进口了一个看起来像这样的动物数据:
AnimalId | 性 | 体重 | 区 |
---|---|---|---|
AB1 | 1 | 3.45 | 4 |
AB2 | 1 | 2.98 | 4 |
AB3 | 2 | 3.22 | 5 |
AB4 | 2 | 3.01 | 5 |
我想用我的第一列(Animaid)用作Rownames。
我已经搜索了一个答案,但是大多数问题介绍了新列的创建,该列是Rownames列。我实际上感到愚蠢地来到这里问这个。我的目的是使用GGPLOT2创建PCA图,这要求我将数据框架的格式以GGPLOTS2识别的格式。
I imported an excel file with animal data that looks something like this:
AnimalID | Sex | Body Weight | District |
---|---|---|---|
AB1 | 1 | 3.45 | 4 |
AB2 | 1 | 2.98 | 4 |
AB3 | 2 | 3.22 | 5 |
AB4 | 2 | 3.01 | 5 |
I want to use to use my first column(AnimaID) as rownames.
I've searched for an answer but most questions address the creation of a new column that then becomes the rownames column. I actually feel stupid coming on here and asking this. My aim is to create a pca plot using ggplot2, and that requires me to have the dataframe in the format that ggplots2 recognizes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可能的解决方案,在
基本r
中:或使用
tidyverse
:A possible solution, in
base R
:Or using
tidyverse
:另一个
base
选项:输出:
Another
base
option:Output: