How can multiple tables be imported into R?
In R language, you can input multiple tables using the following method:
- Read each table file one by one using the read.table() function.
table1 <- read.table("table1.csv", header=TRUE, sep=",")
table2 <- read.table("table2.csv", header=TRUE, sep=",")
- Use the read.csv() function to read each CSV file individually.
table1 <- read.csv("table1.csv")
table2 <- read.csv("table2.csv")
- Use the read_excel() function to read each Excel file one by one (you need to install the “readxl” package).
library(readxl)
table1 <- read_excel("table1.xlsx")
table2 <- read_excel("table2.xlsx")
- Read each Excel file one by one using the data.table() function (package “data.table” must be installed).
library(data.table)
table1 <- fread("table1.csv")
table2 <- fread("table2.csv")
Please note that the above methods assume that the file name, file path, and other specifications are correctly indicated, and that the file format matches the requirements of the reading function.