Hello I am trying to select a subset of lists from a list of lists (df_list) by using the names() position. Below is an example of how to lists look when I use names(df_list). What is the proper way to subset say the first 5 lists?
df_list
[1] "2006-Fall" "2006-Summer" "2007-Fall" "2007-Summer" "2008-Fall"
[6] "2008-Summer" "2009-Fall" "2009-Summer" "2010-Summer" "2011-Spring"
[11] "2011-Summer" "2012-Fall" "2012-Spring" "2012-Summer" "2013-Summer"
[16] "2014-Summer"
You can index lists in R using the square brackets:
to_select <- names(df_list)[1:5] # get the first 5 names
df_list[to_select] # returns a list of 5 lists
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.