查找跨越R中多CSV文件的最大列值

问题描述 投票:1回答:1

谢谢您阅读此篇。

我试图找到一列来自全国各地2个CSV文件中的数据(见下面的文件为例)的最大值。

不知道如何找到一个特定列的最大值(TP)

r csv minimax
1个回答
1
投票

合并两个文件,并找到最大。

df1 <- read.csv("Path to the file1", header=T, sep=",")
df2 <- read.csv("Path to the file2", header=T, sep=",")
data <- rbind(df1,df2)
max(data['temp'])

万一你有很多的文件,

setwd('Path of the folder that contains the files')   
filenames <- list.files(full.names=TRUE)
data <- lapply(filenames,function(i){read.csv(i)})
df <- do.call(rbind.data.frame, data)
max(df['temp'])
© www.soinside.com 2019 - 2024. All rights reserved.