-
NaN表示数字的缺失值,NA表示的范围更广。查看全部
-
因子factor:用来处理分类数据的。可以理解为整数向量+标签(label)(优于整数向量,每个数字有自己具体的含义)。常用于线性模型。 分类数据可分为有序与无序。 创建因子: ①因子名字 <- factor(c()) #在c中依次因子包含的内容female,male,female,male... ②因子名字 <- factor(c(),levels=c()) #可通过levels设定基线水平 查看因子:table(因子名字) 去掉标签:unclass(因子名字)查看全部
-
"x <- factor(c("female","female","male","male","female") x" > x <- factor(c("female","female","male","male","female")) > x [1] female female male male female Levels: female male > y <- factor(c("female","female","male","male","female"),levels("male","female")) Error in levels("male", "female") : unused argument ("female") > y <- factor(c("female","female","male","male","female"),levels = c("male","female")) > y [1] female female male male female Levels: male female > table(x) x female male 3 2 > uclass(x) Error: could not find function "uclass" > unclass(x) [1] 1 1 2 2 1 attr(,"levels") [1] "female" "male" > class(unclass(x)) [1] "integer" > save.image("F:\\R-3.0.3\\src\\library\\windlgs\\src\\1.RData") >查看全部
-
> l <- list("a",2,4L,5+6i,TRUE) > l [[1]] [1] "a" [[2]] [1] 2 [[3]] [1] 4 [[4]] [1] 5+6i [[5]] [1] TRUE > l2 <- lisy(a=1,b=2,c=3) Error: could not find function "lisy" > l2 <- list(a=1,b=2,c=3) > l2 $a [1] 1 $b [1] 2 $c [1] 3 > l3 <- list(c(1,2,3),c(4,5,6,7)) > l3 [[1]] [1] 1 2 3 [[2]] [1] 4 5 6 7 > x <- matrix(1:6,nrow=2,ncol=3) > x [,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6 > dimnames(x) <- list(c("a","b"),c("c","d","e")) > x c d e a 1 3 5 b 2 4 6 > save.image("F:\\R-3.0.3\\src\\library\\windlgs\\src\\1.RData") >查看全部
-
> x <- array(1:24,dim = c(4,6)) > x [,1] [,2] [,3] [,4] [,5] [,6] [1,] 1 5 9 13 17 21 [2,] 2 6 10 14 18 22 [3,] 3 7 11 15 19 23 [4,] 4 8 12 16 20 24 > x <- array(1:24,dim = c(2,3,4)) > x , , 1 [,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6 , , 2 [,1] [,2] [,3] [1,] 7 9 11 [2,] 8 10 12 , , 3 [,1] [,2] [,3] [1,] 13 15 17 [2,] 14 16 18 , , 4 [,1] [,2] [,3] [1,] 19 21 23 [2,] 20 22 24 >查看全部
-
创建矩阵查看全部
-
> x <- 2+2 > x [1] 4 > x <- matrix( nrow = 3 ,ncol = 2) > x [,1] [,2] [1,] NA NA [2,] NA NA [3,] NA NA > x <- matrix(10:15, nrow = 3 ,ncol = 2) > x [,1] [,2] [1,] 10 13 [2,] 11 14 [3,] 12 15 >查看全部
-
> 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 >查看全部
-
R对象的属性查看全部
-
大小写敏感查看全部
-
> x<-1 > x [1] 1 > class(x) [1] "numeric" >查看全部
-
数据结构 5种基本类型查看全部
-
矩阵结构查看全部
-
tapplya:对向量的子集进行操作 tapply(参数):tapply(向量、因子/因子列表,函数/函数名)查看全部
举报
0/150
提交
取消