You are on page 1of 2

R Console Page 1

> #DV in R
> #draw a scatter plot for the fallowing data
> sales<-c(10,12,11,15,10,16,20)
> adc<-c(2,3,3,4,3,5,6)
> length(sales)
[1] 7
> length(adc)
[1] 7
> cor(sales,adc)
[1] 0.9652782
> #plot() for scatter plot
> plot(adc,sales,pch=17)
> plot(adc,sales,pch=17,col='blue')
> plot(adc,sales,pch=17,col='blue',type='l')
> plot(adc,sales,pch=17,col='blue',type='p')
> plot(adc,sales,pch=17,col='blue',type='b')
> years<-2016:2022
> plot(adc,sales,pch=17,col='red',type='b')
> plot(years,sales,pch=17,col='red',type='b')
>
> #line chart
> plot(years,sales,pch=17,col='green',type='l')
> lines(years,adc,sales,pch=17,col='red',type='l')
> plot(years,sales,pch=17,col='green',type='b')
> lines(years,adc,sales,pch=17,col='red',type='b')
> lines(years,sales,pch=17,col='red',type='l')
>
> #histogram
> salary<-0:40
> salary<-(10,11,10,12,12,13,16,14,13,19,20,15,16,19
,20,14)
Error: unexpected ',' in "salary<-(10,"
> salary<-(10,11,12,12,13,16,14,13,19,20,15,16,19,20
,14)
Error: unexpected ',' in "salary<-(10,"
> salary<-c(10,11,12,12,13,16,14,13,19,20,15,16,19,2
0,14)
> hist(salary)
> salary<-c(10,11,10,12,12,13,16,14,13,19,20,15,16,1
9,20,14)
R Console Page 2

> hist(salary)
> hist(salary,breaks=5)
> hist(salary,breaks=7)
> hist(salary,breaks=3)
> hist(salary,breaks=10)
> hist(salary,breaks=4)
> hist(salary,breaks=5)
> hist(salary,breaks=6)
> hist(salary,breaks=7)
> hist(salary,breaks=8)
> hist(salary,breaks=11)
> #breaks is used for the we can adjust the classes
> plot(years,sales,col='green',type='b')
> adc
[1] 2 3 3 4 3 5 6
> plot(years,sales,col='red',type='b',ylim=c(0,30))
> lines(years,adc,col='green',type='b')
>

You might also like