I'm using the dplyrs
function left_join
to combine two data.frames.
Now I would like to manually join them by using the rownames
in the left data.frame and the appropriate column name in the right data.frame of left_join
, but I get the error:
Error: unexpected '=' in "dplyr::left_join(x.tsummary, sto.info, by = c(rownames(x.tsummary) ="
My code
> dplyr::left_join(x.tsummary, sto.info, by = c(rownames(x.tsummary) = 'Symbol'))
Is this even possible? In the documentation it says that I should specify column names, but it would be great if I could join on rownames for the left data.frame.
dplyr
now recommends to use tibble::rownames_to_column
( dplyr
also has a function add_rownames
, which is deprecated in favor of tibble::rownames_to_column
). For example:
library(tibble)
library(dplyr)
left_join(rownames_to_column(x.tsummary), sto.info, by = ("rowname" = "Symbol"))
Does this help?
dplyr::left_join(x.tsummary %>%
mutate(Symbol = rownames(x.tsummary)),
sto.info,
by = 'Symbol')
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.