Reputation: 127
The data frame I have is
rows probes
3 244903_at
4 244904_at
6 244906_at
12 244912_at
13 244913_at
20 244920_s_at
21 244921_s_at
23 244923_s_at
26 244924_at
and wanted to convert it as follows:
structure(c(3L, 4L, 6L, 12L, 13L, 20L, 21L, 23L, 24L, 26L), .Names = c("244903_at",
"244904_at", "244906_at", "244912_at", "244913_at", "244920_s_at",
"244921_s_at", "244923_s_at", "244924_at"))
I tried using
df<-as.vector(df)
but it gives me only a character vector and not a named integer one.
Upvotes: 0
Views: 83
Reputation: 57686
So, you want to get the rows
column of your data frame and give it probes
as the names?
x <- setNames(df$rows, df$probes)
or
x <- structure(df$rows, names=as.character(df$probes))
Upvotes: 1