##data:state.x77[,3]and state.x77[,5] #t=6.8479,df=48,p-value=1.258e-08 #alternative hypothesis:true correlation is not equal to 0 #95 percent confidence interval: #0.52792800.8207295 #sample estimates: cor #0.7029752 #可得结果p-value远小于0.05,故拒绝原假设,相关系数不为0 #结果会给95 percent confidence interval置信区间 R绘图输人数据 散点图:x和y两个坐标数据直方图:因子热力图:数据矩阵 example("heatmap") # #heatmp>require(graphics);require(grDevices) #heatmp>x <-as.matrix(mtcars) 料# #heatmp>rc <-rainbow(nrow(x),start =0,end =.3) 架起 #heatmp>cc <-rainbow(ncol(x),start =0,end =.3) 样排 #heatmp>hv <-heatmap(x,col=cm.colors(256),scale="column", ##heatmp+ RowSideColors =rc,ColSideColors =cc,margins =c(5,10), xlab-"specification variables",ylab "Car Models", ##heatmp+ main "heatmap(<Mtcars data>,...,scale =\"column\")")
## data: state.x77[, 3] and state.x77[, 5] ## t = 6.8479, df = 48, p-value = 1.258e-08 ## alternative hypothesis: true correlation is not equal to 0 ## 95 percent confidence interval: ## 0.5279280 0.8207295 ## sample estimates: ## cor ## 0.7029752 # 可得结果 p-value 远小于 0.05,故拒绝原假设,相关系数不为 0 # 结果会给 95 percent confidence interval 置信区间 R 绘图输入数据 散点图:x 和 y 两个坐标数据直方图:因子热力图:数据矩阵 …… example("heatmap") ## ## heatmp> require(graphics); require(grDevices) ## ## heatmp> x <- as.matrix(mtcars) ## ## heatmp> rc <- rainbow(nrow(x), start = 0, end = .3) ## ## heatmp> cc <- rainbow(ncol(x), start = 0, end = .3) ## ## heatmp> hv <- heatmap(x, col = cm.colors(256), scale = "column", ## heatmp+ RowSideColors = rc, ColSideColors = cc, margins = c(5,10), ## heatmp+ xlab = "specification variables", ylab = "Car Models", ## heatmp+ main = "heatmap(<Mtcars data>, ..., scale = \"column\")") 11
heatmap(<Mtcars data≥,,scale="column") h142E s Europa 360 ord Pantera omet orabou 石后9眉三碧信昌置是昌 specification variables #heatmp>utils:str(hv)#the two re-ordering index vectors #List of 4 #$rowInd:int[1:32]31171615525292476 #$co1Ind:1nt[1:11]298116510714. ##$Rowv NULL ##$Colv NULL #heatmp>##no column dendrogram (nor reordering)at all: #heatmp>heatmap(x,Colv NA,col =cm.colors(256),scale ="column" ##heatmp+ RowSideColors =rc,margins =c(5,10), xlab="specification variables",ylab "Car Models" ##heatmp+ main ="heatmap(<Mtcars data>,...,scale =\"column\")")
cyl am vs carb wt drat gear qsec mpg hp disp specification variables Maserati Bora Lincoln Continental Hornet Sportabout Ford Pantera L Duster 360 Hornet 4 Drive Dodge Challenger Merc 450SE Honda Civic Fiat X1−9 Ferrari Dino Mazda RX4 Merc 280C Lotus Europa Volvo 142E Porsche 914−2 Car Models heatmap(<Mtcars data>, ..., scale = "column") ## ## heatmp> utils::str(hv) # the two re-ordering index vectors ## List of 4 ## $ rowInd: int [1:32] 31 17 16 15 5 25 29 24 7 6 ... ## $ colInd: int [1:11] 2 9 8 11 6 5 10 7 1 4 ... ## $ Rowv : NULL ## $ Colv : NULL ## ## heatmp> ## no column dendrogram (nor reordering) at all: ## heatmp> heatmap(x, Colv = NA, col = cm.colors(256), scale = "column", ## heatmp+ RowSideColors = rc, margins = c(5,10), ## heatmp+ xlab = "specification variables", ylab = "Car Models", ## heatmp+ main = "heatmap(<Mtcars data>, ..., scale = \"column\")") 12
heatmap(<Mtcars data>,...,scale ="column") 登云目是兽宝昌9后唐目 specification variables ##heatmp>##Don't show: #heatmp>##no row dendrogram (nor reordering)at all: #heatmp>heatmap(x,Rowv NA,col =cm.colors(256),scale ="column", #heatmp+ ColSideColors =cc,margins=c(5,10), #heatmp+ xlab ="xlab",ylab "ylab")#no main
mpg cyl disp hp drat wt qsec vs am gear carb specification variables Maserati Bora Chrysler Imperial Lincoln Continental Cadillac Fleetwood Hornet Sportabout Pontiac Firebird Ford Pantera L Camaro Z28 Duster 360 Valiant Hornet 4 Drive AMC Javelin Dodge Challenger Merc 450SLC Merc 450SE Merc 450SL Honda Civic Toyota Corolla Fiat X1−9 Fiat 128 Ferrari Dino Merc 240D Mazda RX4 Mazda RX4 Wag Merc 280C Merc 280 Lotus Europa Merc 230 Volvo 142E Datsun 710 Porsche 914−2 Toyota Corona Car Models heatmap(<Mtcars data>, ..., scale = "column") ## ## heatmp> ## Don't show: ## heatmp> ## no row dendrogram (nor reordering) at all: ## heatmp> heatmap(x, Rowv = NA, col = cm.colors(256), scale = "column", ## heatmp+ ColSideColors = cc, margins = c(5,10), ## heatmp+ xlab = "xlab", ylab = "ylab") # no main 13
a 百后9员岁兽意单星足君 xlab #heatmp>##End(Don't show) ##heatmp>##"no nothing" #heatmp>heatmap(x,Rowv NA,Colv NA,scale ="column", #heatmp+ main ="heatmap(+,NA,NA)-=image(t(x))")
cyl am vs carb wt drat gear qsec mpg hp disp xlab Mazda RX4 Mazda RX4 Wag Datsun 710 Hornet 4 Drive Hornet Sportabout Valiant Duster 360 Merc 240D Merc 230 Merc 280 Merc 280C Merc 450SE Merc 450SL Merc 450SLC Cadillac Fleetwood Lincoln Continental Chrysler Imperial Fiat 128 Honda Civic Toyota Corolla Toyota Corona Dodge Challenger AMC Javelin Camaro Z28 Pontiac Firebird Fiat X1−9 Porsche 914−2 Lotus Europa Ford Pantera L Ferrari Dino Maserati Bora Volvo 142E ylab ## ## heatmp> ## End(Don't show) ## heatmp> ## "no nothing" ## heatmp> heatmap(x, Rowv = NA, Colv = NA, scale = "column", ## heatmp+ main = "heatmap(*, NA, NA) ~= image(t(x))") 14
heatmap(",NA,NA)~=image(t(x)) Maserati Bora Porsche 914-2 Pontiac Firebird AMC Javelin Toyota Corona Honda Civic Chrysler Imperial Merc 450SL Merc280C Merc 230 Duster360 Hornet Sportabout Datsun 710 Mazda RX4 昼香宫是碧多兽9后喜目 #heatmp>round(Ca <-cor(attitude),2) rating complaints privileges learning raises critical advance #rating 1.00 0.83 0.43 0.62 0.59 0.16 0.16 #complaints 0.83 1.00 0.56 0.60 0.67 0.19 #privileges 0.43 0.56 1.00 0.49 0.45 0.15 ##learning 0.62 0.60 0.49 1.00 0.64 0.12 ##raises 0.59 0.67 045 0.64 1.0 0.38 8 #critical 0.16 0.19 0.15 0.12 0.38 1.00 #advance 0.16 0.22 0.34 0.53 0.57 0.28 1.00 样排 #heatmp>symnum(Ca)#simple graphic 样拼 rt cm p l rs cr a #rating ##complaints 1 #privileges ##learning ##raises ·,1 #critical 1 #advance 1 #attr(,"legend")
mpg cyl disp hp drat wt qsec vs am gear carb Mazda RX4 Datsun 710 Hornet Sportabout Duster 360 Merc 230 Merc 280C Merc 450SL Cadillac Fleetwood Chrysler Imperial Honda Civic Toyota Corona AMC Javelin Pontiac Firebird Porsche 914−2 Ford Pantera L Maserati Bora heatmap(*, NA, NA) ~= image(t(x)) ## ## heatmp> round(Ca <- cor(attitude), 2) ## rating complaints privileges learning raises critical advance ## rating 1.00 0.83 0.43 0.62 0.59 0.16 0.16 ## complaints 0.83 1.00 0.56 0.60 0.67 0.19 0.22 ## privileges 0.43 0.56 1.00 0.49 0.45 0.15 0.34 ## learning 0.62 0.60 0.49 1.00 0.64 0.12 0.53 ## raises 0.59 0.67 0.45 0.64 1.00 0.38 0.57 ## critical 0.16 0.19 0.15 0.12 0.38 1.00 0.28 ## advance 0.16 0.22 0.34 0.53 0.57 0.28 1.00 ## ## heatmp> symnum(Ca) # simple graphic ## rt cm p l rs cr a ## rating 1 ## complaints + 1 ## privileges . . 1 ## learning , . . 1 ## raises . , . , 1 ## critical . 1 ## advance . . . 1 ## attr(,"legend") 15