简体   繁体   中英

R, Merge data frames by column 0

I've got 2 data frames containing timeseries(the time is not coded but there is time variable in column 0).The time variable in column zero doesn't allow to me to merge data frames. The data looks like this: TVC1 AND TVC2 (these are only 2 data frames out of 20)

在此输入图像描述 在此输入图像描述

How can I create time variable or define column zero as time variable to merge the 20 data frames? Thanks,

there is a simple way to convert row names into the 1st column of your data using data.table

library(data.table)
setDT(df, keep.rownames = TRUE)[]

我们可以将数据集放在list ,然后与Reduce merge

Reduce(function(...) merge(..., by = "row.names"), mget(paste0("TVC", 1:20)))

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM