R Notes
R Notes
1
3
6
4
9
Trucks
2
5
4
5
12
Suvs
4
4
6
6
16
Line charts:
Define the cars vector with 5 values:
For 2 graphs:
Cars <- c(1,3,6,3,9)
Trucks <- c(2,5,4,5,12)
Plot(cars)
Lines (trucks)
Bar charts:
Cars <- c(1,3,6,4,9)
Barplot(cars)
Another way:
Autos_data <- read.table(c:/R/autos.dat, header=T,sep=\t)
Barplot(autos_data$cars, main=cars, xlab= Days, ylab=total,
Names.arg=c(Mon,tue,wed,thurs,fri),
Border=blue, density=c(10,20,30,40,50))
Another way:
Autos_data <- read.table(c:/R/autos.dat, header=T,sep=\t)
Barplot(as.matrix(autos_data), main=autos,ylab=total,beside=TRUE, col=rainbow(5))
Histograms:
Cars <- c(4,4,6,616)
Hist(suvs)
If u wanna get a random log-normal distribution:
R <- rlnorm(1000)
Hist( r )
If we want to show some distribution with axes:
R <- rlnorm(1000)
H <- hist(r, plot=F, breaks=c(seq(0,max(r )+1,.1)))
Plot(h$counts, log=xy, pch=20, col=blue, main=log-normal,
Xlab=Value, yab=frequency)
Pie charts:
Cars <- c(1,3,6,4,9)
Pie(cars)
Dot charts:
Autos_data <- read.table(c:/R/autos.dat, header=T,sep=\t)
Dotchart(t(autos_data))
Scatter plots:
Attach(cars)
Plot(wt,mpg, main=scatterplot
Boxplot(education$high)
C(1,2,3,4,5)
To assign to variable:
Fakedata <- c(1,2,3,4,5)
Fakedata[1] tells u accessing the data.
Fake1 <- c(a, a, a, a, a)
Cbind(fakedata, fake1)