如何在R中将guid指定为row.names

  • 本文关键字:row names guid 中将 guid
  • 更新时间 :
  • 英文 :


给定一个数据集(为问题剥离)

id  activated   jobtitle    organisation    
11CE0982-B213-4140-B7FA-0000632D9B49    2013-05-30 06:40:00.000 NULL    Apple   
DFC75899-2335-48AC-BF30-00010AF58424    2014-05-29 23:47:55.807 Acting CIO  Care Connect
BC45E973-4AE4-4405-A62C-000373D2755C    2013-09-05 22:29:00.000 NULL        NULL    

我可以导入数据文件并使用

将其转换为数据帧
users_for_dashboard_view <- read.delim("/source/dashboard/users_for_dashboard_view.txt", na.strings="NULL")
users_for_dashboard_dataframe <- data.frame( users_for_dashboard_view, stringsAsFactors = default.stringsAsFactors())
但是,我想使用id字段作为row.names当我这样做
users_for_dashboard_dataframe <- data.frame( users_for_dashboard_view, row.names = id, stringsAsFactors = default.stringsAsFactors())

失败
Error in data.frame(users_for_dashboard_view, row.names = id, stringsAsFactors = default.stringsAsFactors()) : 
  row names supplied are of the wrong length

每一行都有一个向导。

使用guids作为row.names来指定id列的正确方法是什么?

第一次尝试读取数据(no row.names=F)

users_for_dashboard_view <- read.delim("Neues Textdokument.txt", na.strings="NULL")
rownames(users_for_dashboard_view)<-users_for_dashboard_view$id
users_for_dashboard_view$id <- NULL

相关内容

  • 没有找到相关文章

最新更新