用R语言读取文本文件并求出每一列的最大值、最小值、中位值等,将其在屏幕中输?

如题所述

首先,要使用 R 语言读取文本文件,你可以使用 read.table 函数:
data <- read.table("filename.txt", header = TRUE)
然后,要求出每一列的最大值、最小值、中位值,你可以使用 apply 函数:
# Get the maximum value for each column
apply(data, 2, max)
# Get the minimum value for each column
apply(data, 2, min)
# Get the median for each column
apply(data, 2, median)
最后,将计算结果输出到屏幕,可以使用 print 函数:
print(result)
温馨提示:答案为网友推荐,仅供参考
相似回答
大家正在搜