简体   繁体   English

如何将从其他Excel工作表中提取的数据合并到R中的一个最终Excel工作表中?

[英]How to merge data extracted from other excel sheets into one final excel sheet in r?

I need to make an final excel sheet which will contain inputs from other excel sheets. 我需要制作一个最终的Excel工作表,其中将包含其他Excel工作表的输入。 For the same I have extracted data based on some conditions and trying to merge them into one by using merge function but when I am doing so it's combining the extracted data alphabetically or in a weird way not one by one or in some order. 同样,我已经基于某些条件提取了数据,并尝试使用合并功能将它们合并为一个,但是当我这样做时,它是按字母顺序或以一种怪异的方式而不是一个接一个地或以某种顺序来合并提取的数据。 I want the extracted data in order. 我想要按顺序提取数据。 PS Using R shiny to upload the files and extracting the data but not able to merge them. PS使用R Shiny上传文件并提取数据,但无法合并它们。

To efficiently read the files, you can use the fread() function from library data.table . 为了有效地读取文件,可以使用库data.tablefread()函数。

library(data.table)
df1 = fread("file1.xlxs")
df2 = fread("file2.xlxs")

To preserve the row order while joining 2 data frames, you can use the join() function from library plyr . 要在连接2个数据帧时保留行顺序,可以使用库plyrjoin()函数。

library(plyr)
df = join(df1,df2)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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