Comparing two lists with R

No, not list() lists.

a <- data.frame(name=old$NAME)
a$status <- "old"
b <- data.frame(name=allfields[allfields$StateAbbre=="ND",]$name)
b$status <- "new"

both<-merge(a,b,by="name",all=T)

Make two data frames, one for each list, create a column identifying each one (new or old), then join on the common column (name).

Output:

Example output from comparing to lists in R using a merge().
Example output from comparing to lists in R using a merge().

See also: http://stackoverflow.com/questions/17598134/compare-two-lists-in-r/17599048#17599048

Leave a Reply

Your email address will not be published. Required fields are marked *