简体   繁体   中英

extracting geneids from a sequence

I have an object in R which saves a list of geneids and sequences.

$`140545`

[1] 

"GAAACATCCGAGGCTGGAGTGAGCCACGCGGAGGAGGAAGAACAGCCCGAGCTCACAGGGGCGGGGAAGAGTTCTAGCTCGCGACAGCCC"

$`57187`

[1] 

"CGGGCAGAGACGCTCCTCACTTTCCAGACTGGGCAGCCAGGCAGAGGGGCTCCTCACATCCCAGACGATGGGCGGCCAGGCAGAGAGGCTC"

I want to only store the ids in an object. eg How will I achieve it in R

[1] 140545

[2] 57187

I am extremely new to R

ids <- names(your_list_object)

However, note that the ids will be saved as characters. So, if you want them numerically, you may have to use ids <- as.numeric(names(your_list_object)) .

Also, R generally provides many easy ways to extract 'names' attributes from objects. For example look at ?names, ?rownames, ?colnames, ?dimnames etc.

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