This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
# Land Management Program
QLDD<-read.csv("https://raw.githubusercontent.com/tuyenhavan/Statistics/master/Qldd.done2.csv",header=T,sep=";")
# Check the first six rows of the dataset
head(QLDD)
# import tidyverse library
library(tidyverse)
# Get first five columns
year<- QLDD %>% select(A1:A5)
# Check the first five rows
head(year)
# Covert first five columns into rows
year1<- year %>% tidyr::gather(Year, Values,A1:A5)
head(year1)
# Convert charactor into factor
year1$Year<-as.factor(year1$Year)
str(year1)
'data.frame': 150 obs. of 2 variables:
$ Year : Factor w/ 5 levels "A1","A2","A3",..: 1 1 1 1 1 1 1 1 1 1 ...
$ Values: int 12 14 12 11 10 12 10 10 8 10 ...
# Sum the total of each candidate for each year
sum(year1$Values[year1=="A1"])
[1] 395
sum(year1$Values[year1=="A2"])
[1] 407
sum(year1$Values[year1=="A3"])
[1] 422
sum(year1$Values[year1=="A4"])
[1] 430
sum(year1$Values[year1=="A5"])
[1] 419
table(vitri2)
Values
Place 1 2 3
B1 1 20 9
B10 3 21 6
B11 2 25 3
B2 5 16 9
B3 1 18 11
B4 2 19 9
B5 7 18 5
B6 4 25 1
B7 4 19 7
B8 8 20 2
B9 3 21 6
C1 2 22 6
C10 4 20 6
C11 13 16 1
C12 2 23 5
C13 2 23 5
C14 1 24 5
C15 2 20 8
C16 3 15 12
C17 4 20 6
C18 2 23 5
C19 0 25 5
C2 7 19 4
C20 3 19 8
C21 5 21 4
C22 3 26 1
C23 5 17 8
C24 2 21 7
C25 5 19 6
C26 0 25 5
C27 0 22 8
C28 1 23 6
C29 1 20 9
C3 4 22 4
C30 0 21 9
C31 3 14 13
C32 1 20 9
C33 0 18 12
C34 0 19 11
C4 5 15 10
C5 1 16 13
C6 4 9 16
C7 1 15 14
C8 7 16 7
C9 2 15 13
D1 0 21 9
D2 0 19 11
D3 2 18 10
D4 1 23 6
D5 0 20 10
F1 2 22 6
F2 2 20 8
F3 15 12 3