a1 <- c(3,-1.5,3*10^-8)
a1
a2 <- seq(-1,by=5,length=10)
a2
x <- rnorm(100,2,1)
x
mean(x)
sum(x)
var(x)
b1 <- tail(x,10)
b1
b2 <- x[x<1&x>=0]
b2
which(x<0)
从概念上讲,两者都属于逻辑运算符,但是用起来还是有一些区别,大致的区别就是:
c1 <- c(1,0,1,0)
c2 <- c(1,0,0,1)
c3 <- c(0,0,1,0)
c1&&c2
c1&c2
c1&&c3
c1&c3
E <- matrix(seq(1,by=2,length=12),ncol = 4,byrow = TRUE)
E
F <- matrix(seq(1,by=2,length=12),ncol = 4,byrow = FALSE)
F
画一个堆叠条形图
a <- read.table("sales.csv",header = T,row.names = 1,sep=',')
b <- cbind(a[,1]/sum(a[,1]),a[,2]/sum(a[,2]),a[,3]/sum(a[,3]))
colnames(b) <- colnames(a)
rownames(b) <- rownames(a)
barplot(b,horiz = T,col=c("red","orange","yellow","green","blue"))
label <- c("Seattle","London","Tokyo","Berlin","Mumbai")
legend(0,4.15,label,horiz = T,title = "City",title.col = 'black'
,text.col = "grey",text.font = 3,box.col = "white",cex=0.6,
pch=15,col=c("red","orange","yellow","green","blue"),xpd=T,bty='n')
data1 <- file.choose()
E <- matrix(seq(1,by=2,length=12),ncol = 4,byrow = TRUE)
E
apply(E,1,sum)