line chart multiline chart in R


#####################################################################
#ln funtion
x<-sample(10)*3
x
y<-sample(10)*3
y
a<-lm(y~x)
a
summary(a)

#######################################################################
##predict (object,new data)
##object=formula already made
##newdata=new values
##ex.this height so this weight
#ln funtion
height<-c(100,200,125,136,165,170,102,103,108,111)
height
weight<-c(40,50,60,70,80,90,100,110,45,49)
weight
a<-lm(weight~height)
x<-data.frame(weight=11)
y<-data.frame(height=109)
res<-predict(a,y)
res
x
y
##find weight of persion with height 11
summary(a)




#######################################################
getwd()
height<-c(100,200,125,136,165,170,102,103,108,111)
height
weight<-c(40,50,60,70,80,90,100,110,45,49)
weight
a<-lm(weight~height)
png(file="linear.png")
plot(weight,height,col="blue",main="regression of height and weight",abline(lm(height~weight)),xlab = "weight",ylab = "height" )
dev.off()
#######################################################












#######################################
########PIE___CHART####################\
a<-c(10,15,65,72)
labels<-c("gujarat","panjab","chennai","kashmir")
a
labels
png(file="pie.png")
pie(a,labels)
dev.off()







###########################################
##########PIE WITH LABELS NORMAL###########
a<-c(10,15,65,72)
labels<-c("gujarat","panjab","chennai","kashmir")
a
labels
png(file="piee.png")
pie(a,labels,main="pie chart with color",col = rainbow(length(labels)))
dev.off()



#####################################################
##########pie with slice percentage with chart legend#

a<-c(10,15,65,72)
labels<-c("gujarat","panjab","chennai","kashmir")
per<-round(100*a/sum(a),1)
per
a
labels
png(file="pieeP.png")
pie(a,labels=per,main="pie chart with percentage",col = rainbow(length(labels)))
legend("topright",labels,fill = rainbow(length(a)),cex = 0.8)
dev.off()

#######################################################
#############3D PIE####################################
library(plotrix)
a<-c(10,15,65,72)
labels<-c("gujarat","panjab","chennai","kashmir")
png(file="piee3D.png",width = 800 ,bg = "orange")
pie3D(a,labels=labels,explode=0.5,main="pie chart with percentage",col = rainbow(length(labels)))
dev.off()


########################################################
##############Linechart in R############################
a<-c(10,15,65,72)
labels<-c("gujarat","panjab","chennai","kashmir")
png(file="linechart.png",width = 800 ,bg = "orange")
plot(a,type = "o",xlab = "value",ylab = "a",main="linechart",col = rainbow(length(labels)),pch=10,cex=2,lty=10)
dev.off()



########################################################
##############Linechart with multipleLines in single plot R############################
a<-c(80,15,80,72)
b<-c(60,20,60,12)
labels<-c("gujarat","panjab","chennai","kashmir")
png(file="multiline.png",width = 800 ,bg = "orange")
plot(a,type = "o",xlab = "value",ylab = "a",main="linechart",col = "blue",pch=15,cex=2,lty=10)
lines(b,type = "o",xlab = "value",ylab = "a",main="linechart",col = "blue",pch=10,cex=2,lty=10)
dev.off()




##############Linechart with multipleLines in single plot R############################
a<-c(10,11)
b<-sample(50)
labels<-c("gujarat","panjab","chennai","kashmir")
png(file="home.png",width = 800 ,bg = "orange")
plot(a,type = "o",xlab = "value",ylab = "a",main="linechart",col = "blue",pch=15,cex=2,lty=10)
a
lines(b,type = "o",xlab = "value",ylab = "a",main="linechart",col = "blue",pch=10,cex=2,lty=10)
dev.off()

Post a Comment

Previous Post Next Post