如何在 R 中将 guid 指定为 row.names?
How to specify a guid as row.names in R?
给定一个数据集(针对问题进行了精简)
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
每一行都有一个 guid。
将带有 guid 的 id 列指定为 row.names 的正确方法是什么?
第一次尝试读取数据(否 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
给定一个数据集(针对问题进行了精简)
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
每一行都有一个 guid。
将带有 guid 的 id 列指定为 row.names 的正确方法是什么?
第一次尝试读取数据(否 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