> (a_list <- list(c(1,1,2,5,14,42),month.abb,matrix(c(3,-8,1,-3),nrow=2),asin))[[1]][1] 1 1 2 5 14 42[[2]][1] "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"[[3]][,1] [,2][1,] 3 1[2,] -8 -3[[4]]function (x) .Primitive("asin")
> names(a_list) <- c("catalan","month","involutary","arcsin")> a_list$catalan[1] 1 1 2 5 14 42$month[1] "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"$involutary[,1] [,2][1,] 3 1[2,] -8 -3$arcsinfunction (x) .Primitive("asin")
> length(a_list)[1] 4
> dim(a_list)NULL
> a_vector <- c(1,6,7,8)> as.list(a_vector)[[1]][1] 1[[2]][1] 6[[3]][1] 7[[4]][1] 8
> (a_data_frame <- data.frame(x=letters[1:5],y=rnorm(5),z=runif(5)>0.5))x y z1 a 0.47620421 TRUE2 b -0.04279112 FALSE3 c 1.49076637 FALSE4 d -0.41444402 TRUE5 e -1.03173668 TRUE
> t(a_data_frame)[,1] [,2] [,3] [,4] [,5]x "a" "b" "c" "d" "e"y " 0.47620421" "-0.04279112" " 1.49076637" "-0.41444402" "-1.03173668"z " TRUE" "FALSE" "FALSE" " TRUE" " TRUE"
> (a_data_frame <- data.frame(x=letters[1:5],y=rnorm(5),z=runif(5)>0.5))x y z1 a -0.17804129 FALSE2 b -1.28864149 FALSE3 c -0.99590504 FALSE4 d 0.01776164 FALSE5 e 1.37784685 FALSE> (another_data_frame <- data.frame(z=rlnorm(5),y=sample(5),x=letters[3:7]))z y x1 2.6574401 4 c2 3.3455939 3 d3 0.4205031 1 e4 3.3006536 5 f5 1.7008018 2 g> rbind(a_data_frame,another_data_frame)x y z1 a -0.17804129 0.00000002 b -1.28864149 0.00000003 c -0.99590504 0.00000004 d 0.01776164 0.00000005 e 1.37784685 0.00000006 c 4.00000000 2.65744017 d 3.00000000 3.34559398 e 1.00000000 0.42050319 f 5.00000000 3.300653610 g 2.00000000 1.7008018> cbind(a_data_frame,another_data_frame)x y z z y x1 a -0.17804129 FALSE 2.6574401 4 c2 b -1.28864149 FALSE 3.3455939 3 d3 c -0.99590504 FALSE 0.4205031 1 e4 d 0.01776164 FALSE 3.3006536 5 f5 e 1.37784685 FALSE 1.7008018 2 g
原文地址:http://blog.csdn.net/luoyhang003/article/details/38343649