R: print line when column value matches value from other file -


in r, have list of 11 dataframes named list1. every dataframe has same structure:

names    col2    col3  name1   1       10 name2   2       22 name4   3       40 

i have dataframe called table1 looking this

names    col4    col5 name1    ...     ... name2    ...     ... name3    ...     ... 

now want take subset of original 11 dataframes. each dataframe want print lines there match between values in 'names' column of dataframe , names column in table1. in case, new dataframe should this

names    col2    col3 name1    1       10 name2    2       22 

all new dataframe should appended again in list2. work lapply , match function?

mylist2 <- lapply(mylist1,      function(...){     match(...)     } 

you can this

required.list =  lapply(list1, function(x) subset(x, names %in% table1$names)) 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -