I would like to convert a list as follows:
list(structure(c(16L, 17L, 71L, 87L, 113L, 120L, 127L, 128L,
144L, 177L, 207L, 213L), .Names = c("246653_at", "246897_at",
"251347_at", "252988_at", "255528_at", "256535_at", "257203_at",
"257582_at", "258807_at", "261509_at", "265050_at", "265672_at")))
into a character object:
c("246653_at", "246897_at", "251347_at", "252988_at", "255528_at",
"256535_at", "257203_at", "257582_at", "258807_at", "261509_at",
"265050_at", "265672_at")
I tried using
as.character(fin[1])
which gives me
[1] "c(16, 17, 71, 87, 113, 120, 127, 128, 144, 177, 207, 213)"
I referred to this stack overflow post but couldn't solve it.
To convert List to Vector in R, use the unlist() function. The unlist() function simplifies to produce a vector by preserving all atomic components.
Converting a List to Vector in R Language – unlist() Function. unlist() function in R Language is used to convert a list to vector. It simplifies to produce a vector by preserving all components.
To convert elements of a Vector to Strings in R, use the toString() function. The toString() is an inbuilt R function used to produce a single character string describing an R object.
If your object is x
:
> names(unlist(x))
[1] "246653_at" "246897_at" "251347_at" "252988_at" "255528_at" "256535_at"
[7] "257203_at" "257582_at" "258807_at" "261509_at" "265050_at" "265672_at"
Or just...
names(fin[[1]])
[1] "246653_at" "246897_at" "251347_at" "252988_at" "255528_at" "256535_at"
[7] "257203_at" "257582_at" "258807_at" "261509_at" "265050_at" "265672_at"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With