R语言数据框分类求最大值

Python012

R语言数据框分类求最大值,第1张

使用data.frame函数就可以初始化一个Data Frame。比如我们要初始化一个student的Data Frame其中包含ID和Name还有Gender以及Birthdate,那么代码为:

student<-data.frame(ID=c(11,12,13),Name=c("Devin","Edward","Wenli"),Gender=c("M","M","F"),Birthdate=c("1984-12-29","1983-5-6","1986-8-8”))

另外也可以使用read.table() read.csv()读取一个文本文件,返回的也是一个Data Frame对象。读取数据库也是返回Data Frame对象。

which语句

Description

Give the TRUE indices of a logical object, allowing for array indices.

Usage

which(x, arr.ind = FALSE, useNames = TRUE)

arrayInd(ind, .dim, .dimnames = NULL, useNames = FALSE)