Hello, how to merge a data.frame and a matrix by one column in the data.frame and rownames of the matrix? df <- data.frame(col1=c("kk","yy","kk"),col2=c(6,4,3)) > df col1 col2 1 kk 6 2 yy 4 3 kk 3 m<-matrix(c(3,8,56,9), nrow=2, dimnames = list(c("aa","kk"),c("col1","col2"))) > m col1 col2 aa 3 56 kk 8 9
the result is expected as col1.x col2.x col1.y col2.y kk 6 8 9 kk 3 8 9 Yuan Jian [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.