服务热线
178 0020 3020
将工作目录改到D:/R语言学习资料/R group task 3
3.1
getwd()
data = read.table("Revenue chart.txt",header=T)
x <- data$Month
y <- data$Revenue
png("Revenue Chart.png",width=480,height=480)
barplot(y,xlab="Month",ylab="Revenue",main="Revenue Chart",col="blue",names.arg=x)
dev.off()
3.2
M <- c("Jan", "Feb", "Mar", "Apr", "May", "Jun")
part1 <- c(2,4,1,6,5,2)
part2 <- c(2,5,2,7,6,2)
part3 <- c(3,3,1,7,5,6)
png("Revenue Chart-2.png")
barplot(rbind(part1,part2,part3),
names.arg = M,
xlab = "Month",
ylab = "Revenue",
main = "Revenue chart",
col = c("yellow","green", "red")
)
legend("topleft",c("part1","part2","part3"),fill = c("yellow","green", "red"))
dev.off()
附件