R语言学习第三天----数据框 因子 列表
来源:互联网 发布:自考,成考,远程网络 编辑:程序博客网 时间:2024/05/22 05:12
数据框:
data <- data.frame(col1,col2,)
数据框
patientID <- c(1,2,3,4)
age <- c(25,34,28,52)
diabetes <- c("Type1","Type2","Type3","Type2")
status <- c("poor","improved","Excellent","poor")
patientsData <- data.frame(patientID,age,diabetes,status)
//取出该列下的数据
patientsData[1:2]
patientsData[c("diabetes","status")]
patientsData$age :取出数据集中age的数值
head(mtcars)
mtcars$mpg
attach(mtcars):将mtcars的数据集添加到R的搜索路径中
mpg
detach(mtcars):将mecars从搜索路径中移除,并没有将mtcars数据框移除
with(mtcars,{l<-mpg l })
因子:
diabetes <- factor(diabetes)
列表
mylist <- list(object1,object2,....)
g <- "My first list"
h <- c(12,45,43,90)
j <- matrix(1:10,nrow=2)
k <- c("one","two","three")
mylist <- list(g,h,j,k)
mylist[[2]]
mylist <- list(stud.id=1234,stud.name="Tom",stud.marks=C(12,3,14,25,19))
mylist[[1]]
mylist
mode(mylist[[1]]):求出类型
mode(mylist[1])
mylist$stud.id
names(mylist)
names(mylist) <- c("id","name","marks")
mylist$parents <- c("Mama","Joe"):向列表中添加数据集
length(mylist)
mylist <- mylist[-4]: 删除第四个成分
other <- list(age=19,sex="male")
lst <- c(mylist,other):将两个列表进行合并
unlist() : 将列表中的元素转化为向量的形式
unlist(lst)
data <- data.frame(col1,col2,)
数据框
patientID <- c(1,2,3,4)
age <- c(25,34,28,52)
diabetes <- c("Type1","Type2","Type3","Type2")
status <- c("poor","improved","Excellent","poor")
patientsData <- data.frame(patientID,age,diabetes,status)
//取出该列下的数据
patientsData[1:2]
patientsData[c("diabetes","status")]
patientsData$age :取出数据集中age的数值
head(mtcars)
mtcars$mpg
attach(mtcars):将mtcars的数据集添加到R的搜索路径中
mpg
detach(mtcars):将mecars从搜索路径中移除,并没有将mtcars数据框移除
with(mtcars,{l<-mpg l })
因子:
diabetes <- factor(diabetes)
列表
mylist <- list(object1,object2,....)
g <- "My first list"
h <- c(12,45,43,90)
j <- matrix(1:10,nrow=2)
k <- c("one","two","three")
mylist <- list(g,h,j,k)
mylist[[2]]
mylist <- list(stud.id=1234,stud.name="Tom",stud.marks=C(12,3,14,25,19))
mylist[[1]]
mylist
mode(mylist[[1]]):求出类型
mode(mylist[1])
mylist$stud.id
names(mylist)
names(mylist) <- c("id","name","marks")
mylist$parents <- c("Mama","Joe"):向列表中添加数据集
length(mylist)
mylist <- mylist[-4]: 删除第四个成分
other <- list(age=19,sex="male")
lst <- c(mylist,other):将两个列表进行合并
unlist() : 将列表中的元素转化为向量的形式
unlist(lst)
0 0
- R语言学习第三天----数据框 因子 列表
- R语言学习备忘录(三):数组、矩阵、列表和数据框、因子的应用
- R语言基础:数组&列表&向量&矩阵&因子&数据框
- R数组、列表、数据框、因子
- 了解向量、因子、矩阵、数组、列表和数据框、时间序列(R语言)
- 初涉R语言第三天
- R语言学习(3)-列表和数据框
- 学习MySQL_第三天_语言基础&数据定义功能
- C语言学习第三天
- R语言学习(5)-字符串和因子
- R语言学习:数据结构5-因子
- R语言中的数据列表
- R语言--tapply,sapply(因子和列表的操作)
- 第二章第二节 R语言因子与列表
- R语言学习第五天----数据读取以及数据保存
- R语言学习之字符串学习和因子的学习
- c语言学习第三天(指针)
- C语言学习第三天结构体
- 手把手教你做音乐播放器(六)存储多首音乐
- JavaScript跨域总结和解决办法
- ARM與Cortex筆記
- Visual Studio 2010 中的 MSDN 帮助文档
- C语言宏中"#"和"##"的用法
- R语言学习第三天----数据框 因子 列表
- 今天JAVA入门开课了。。。
- C语言#define STR3 STR STR1 STR2的理解
- PAT 乙级 1006 换个格式输出整数
- 动态规划的方法求解斐波那契数列
- eclipse的new server里tomcat7.0根本点不动解决方案
- js中几种实用的跨域方法原理详解
- PullToRefresh实现下拉刷新和上拉加载更多的ListView
- Activity的加载模式