向量的創建、拼接、轉frame
# 創建向量
a = c("qiaofen","ouyangfeng","wangyuyan","zhagnwuji","renyingying")
b = c(-1/0,1/0,100,100,100)
# 向量拼接
rab = rbind(a,b)
cab = cbind(a,b)
# 轉換成數據框
frab = data.frame(rab)
fcab = data.frame(cab)

生成數據框
# 通過data.frame函數生成數據框 c = data.frame(x = 1, y = 1:3)

數據框的引用(使用iris數據集示例)

# 選擇 Species列 =="setosa"的 的 前1-2列數據 v = iris[which(iris$Species == "setosa"),1:2] # 選擇 iris$Sepal.Width>3.7&iris$Species=="setosa" 的所有列(特征) w = iris[which(iris$Sepal.Width>3.7&iris$Species=="setosa"),] # Sepal.Width 特征中最大的值 所對應的樣本的信息 x= iris[which.max(iris$Sepal.Width),] # 得到 Petal.Length 列最小的那個值 y = iris[which.min(iris$Petal.Length),which(names(iris)=="Petal.Length")] # Species 這個特征的枚舉項都有誰 z = levels(iris$Species)


