Try this: merge(m, v, by.x = 'c1', by.y = 0, all = TRUE, sort = FALSE)
On Wed, Sep 22, 2010 at 4:57 AM, Yuan Jian <jayuan2...@yahoo.com> wrote: > hi, > can anyone tell me how to merge a vector and a matrix? > > v=c(1,4,2) > > names(v)=c("e","r","t") > > m=matrix(c("r","t","r","s","e",5,6,7,8,9),nr=5) > > colnames(m)=c("c1","c2") > I want to do like > merge(v, m, by.x="names",by.y="c1") > I got error > Error in fix.by(by.x, x) : 'by' must specify valid column(s) > > thanks > 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. > > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[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.