为了账号安全,请及时绑定邮箱和手机立即绑定

R语言基础

  • 数据结构
    查看全部
  • 创建矩阵: x <- matrix(1:6, nrow=3, ncol=2) dim(x) #查看维度 attributes(x) #查看属性 rbind(y1,y2)#上下拼接, cbind(y1,y2)#左右拼接 创建数数组: x <- array(1:24, dim = c(2,3,4))
    查看全部
  • 创建向量: x <- vector("character",length=10) x<-1:4 x<-c(1,2,3) 查看类型:class() 修改列名称:names()
    查看全部
  • #本章小结 1.如何构建子集 2.如何处理缺失值 3.如何进行向量化操作以及介绍向量化操作的作用
    查看全部
    1 采集 收起 来源:小结

    2017-06-12

  • 每一行(记录),每一列(变量)
    查看全部
    1 采集 收起 来源:处理缺失值

    2017-06-12

  • > x <-matrix(1:6, nrow=2, ncol=3) > x [,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6 > x[1,2] [1] 3 > x[2,3] [1] 6 > x[1,] [1] 1 3 5 > x[,3] [1] 5 6 > x[2,c(1,3)] [1] 2 6 > class(x[1,3]) [1] "integer" > x[1,2,drop = FALSE] [,1] [1,] 3 >
    查看全部
    1 采集 收起 来源:矩阵的子集

    2018-03-22

  • 枚举简单的说也是一种数据类型,只不过是这种数据类型只包含自定义的特定数据,它是一组有共同特性的数据的集合。举个例子,颜色也可以定义成枚举类型,它可以包含你定义的任何颜色,当需要的时候,只需要通过枚举调用即可,另外比如说季节(春夏秋冬)、星期(星期一到星期日)等等这些具有共同投特征的数据都可以定义枚举。
    查看全部
    1 采集 收起 来源:基本方法

    2017-06-11

  • 构建子集 基本方法
    查看全部
    1 采集 收起 来源:基本方法

    2017-06-11

  • > x <- Sys.time() > x [1] "2017-06-11 18:51:14 CST" > p <- POXITlt(x) Error: could not find function "POXITlt" > p <-as.POXITlt(x) Error: could not find function "as.POXITlt" > p <-as.POXITlt(x4) Error: could not find function "as.POXITlt" > p <-as.POSITlt(x4) Error: could not find function "as.POSITlt" > p <-as.POSIXlt(x4) > p <-as.POSIXlt(x) > p [1] "2017-06-11 18:51:14 CST" > class(x) [1] "POSIXct" "POSIXt" > p <-as.POSIXlt(x4) > p [1] "2018-06-11 UTC" > class(p) [1] "POSIXlt" "POSIXt" > names(unclass(p)) [1] "sec" "min" "hour" "mday" "mon" "year" "wday" "yday" "isdst" > p$sec [1] 0 > p$sec [1] 0 > p$min [1] 0 > as.POSIXct(x) [1] "2017-06-11 18:51:14 CST" > as.Date("2017-06-11") [1] "2017-06-11" > x5<- "jun 11,2017 22:38" > x5 [1] "jun 11,2017 22:38" > strptime(x5,”%M %D %Y %H %M") > strptime(x5,”%B %d,%Y %H:%M") > strptime function (x, format, tz = "") <bytecode: 0x075a66dc> <environment: namespace:base> > x1<- "jun 11,2017 22:38" > strptime(x5,”%B %d,%Y %H:%M") >
    查看全部
  • 数据结构
    查看全部
  • > x <- data() > x > x <- date() > x [1] "Sun Jun 11 14:13:57 2017" > class(x) [1] "character" > x2 <- sys,date() Error: unexpected ',' in "x2 <- sys," > x2 <- sys.date() Error: could not find function "sys.date" > x2 <- Sys.date() Error: could not find function "Sys.date" > x2 <- Sys.Date() > x2 [1] "2017-06-11" > x3 <- Sys.Date() > x3 [1] "2017-06-11" > class(x2) [1] "Date" > class(x2,x3) Error in class(x2, x3) : 2 arguments passed to 'class' which requires 1 > class(x3) [1] "Date" > x3 <- as.Date("2017-06-11") > x3 [1] "2017-06-11" > class(x3) [1] "Date" > weekdays(x3) [1] "星期日" > months(x3) [1] "六月" > quarters(x3) [1] "Q2" > julian(x3) [1] 17328 attr(,"origin") [1] "1970-01-01" > x4 <- as.Date("2018-06-11") > x4 <- as.Date("2015-06-11") > X3-X4 Error: object 'X3' not found > x4-x3 Time difference of -731 days > x3 <- as.Date("2017-06-11") > x4 <- as.Date("2018-06-11") > x4-x3 Time difference of 365 days > as.numeric(x4-x3) [1] 365 >
    查看全部
  • > df <- data.frame(id=c(1,2,3,4),names=c("a","b","c","d"),gender=c(TRUE,TRUE,FALSE,FALSE)) > df id names gender 1 1 a TRUE 2 2 b TRUE 3 3 c FALSE 4 4 d FALSE > nrow(df) [1] 4 > ncol(df) [1] 3 > df2 <- data.frame(id=c(1,2,3,4),score=c(70,80,90,100)) > df2 id score 1 1 70 2 2 80 3 3 90 4 4 100 > data.matrix(df2) id score [1,] 1 70 [2,] 2 80 [3,] 3 90 [4,] 4 100 > save.image("F:\\R-3.0.3\\src\\library\\windlgs\\src\\数据框.RData") >
    查看全部
  • NaN表示数字的缺失值,NA表示的范围更广。
    查看全部
  • > names(x2) <- c("a","b","c","d") > x2 a b c d 1 2 3 4 >
    查看全部
  • [1] NA 10 NA Warning message: NAs introduced by coercion >
    查看全部

举报

0/150
提交
取消
课程须知
本课程需要学员提前掌握 安装好R和Rstudio
老师告诉你能学到什么?
1、R语言的数据结构 2、构建数据子集 3、重要函数的使用

微信扫码,参与3人拼团

意见反馈 帮助中心 APP下载
官方微信
友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!