简体   繁体   中英

R convert data into a vector

I have an object (Seurat object) an I need to get certain data out of it

> sc@misc[["colors"]][["seurat_clusters"]]
          0           1           2           3           4           5           6           7 
"#CC0C00FF" "#5C88DAFF" "#84BD00FF" "#FFCD00FF" "#7C878EFF" "#00B5E2FF" "#00AF66FF" "#CC0C00B2" 

This data is needed as an vector but I don't know how to pull "#CC0C00FF" "#5C88DAFF" etc. out of it.

In order to hand this data to the next function, the result should look like this:

> vec
[1] "#CC0C00FF" "#5C88DAFF" "#84BD00FF"

Thanks in advance!

Solved it, I'm pretty disappointed by myself: because I didn't know this function existed:

> as.vector(sc@misc[["colors"]][["seurat_clusters"]])
[1] "#CC0C00FF" "#5C88DAFF" "#84BD00FF" "#FFCD00FF" "#7C878EFF" "#00B5E2FF" "#00AF66FF" "#CC0C00B2"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM