Reputation: 64044
Suppose I have the following data:
1415967_at 56258
1415968_a_at 20249
1415963_at 20249
1415966_a_at 16483
How can I obtain the following data structure:
$`1415967_at`
[1]56258
$`1415968_a_at`
[1]20249
$`1415963_at`
[1]20249
$`1415966_a_at`
[1]16483
I'm stuck with the following code:
dat <- read.table("http://dpaste.com/1484733/plain/")
#...???
Upvotes: 2
Views: 44
Reputation: 81713
You can try as.list
:
setNames(as.list(dat[[2]]), dat[[1]])
# $`1415967_at`
# [1] 56258
#
# $`1415968_a_at`
# [1] 20249
#
# $`1415963_at`
# [1] 20249
#
# $`1415966_a_at`
# [1] 16483
Upvotes: 1