1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| rm(list=ls())
speed=cars$speed;speed dist=cars$dist;dist summary(speed) summary(dist) mean(speed) mean(dist)
summary(trees) summary(chickwts) summary(cars)
library(MASS) summary(Cars93)
library(UsingR)
ls()
getwd() setwd("/Users/zerohertz")
getwd()
summary(cars) mean(speed) mean(cars$speed)
str(cars) cars[1,2] summary(cars) attach(cars) mean(cars$speed) sd(cars$dist) mean(speed) sd(dist) detach(cars)
save.image()
x=c(1,3,5,4,3,3) y=c("one","two","three") z=c(TRUE,TRUE,FALSE,F)
y1=y[c(1,3)];y1
gender=c("m","f","m","f");gender str(gender) f.gender=factor(gender);f.gender str(f.gender) summary(f.gender) f.gender2=factor(gender,order=TRUE,level=c("m",'f')) str(f.gender2) summary(f.gender2)
str(Cars93)
a=matrix(1:9,nrow=3);a b=matrix(1:9,nrow=3,byrow=TRUE);b c=matrix(1:100,nrow=100);c cnames=c("c1","c2","c3");cnames rnames=c("r1","r2","r3");rnames z=matrix(1:9,nrow=3,dimnames=list(rnames,cnames));z
a[2,3] a[1,] a[,2] mean(a[,2]) mean(a) sum(a)
d=1:24 dim(d)=c(4,3,2);d
a1=c(1,2,3,4) a2=c('f','m','f','m') a12=data.frame(a1,a2);a12 a123=data.frame(age=a1,gender=a2);a123 a_add=data.frame(age=30,gender='f');a_add a12t=rbind(a123,a_add);a12t
length(a12t) dim(a12t) str(a12t)
|