Name <- c("Luke Skywalker", "Darth Vader", "Leia Organa" , "Beru Whitesun Iars", "Biggs Darklighter" , "Anakin Skywalker" , "Han Solo" , "Palpatine" , "Boba Fett" , "Lando Calrissian" , " Lobot" , "Nien Nunb" , "Jar Jar Binks" , "Roos Tarpals" , "Gregar Typho", "Poggle the Lesser" , "Barriss Offee")
Height <- c(172, 202, 150, 165, 183, 188, 180, 170, 183, 177, 175, 160, 196, 224, 185, 183, 166)
Mass <- c(77, 136, 49, 75, 84, 84, 80, 75, 78.2, 79, 79, 68, 66, 82, 85, 80, 50)
Homeworld <- c("Tatooine", "Tatooine" , "Others" , "Tatooine" , "Tatooine" , "Tatooine" , "Others" , "Naboo" , "Others" , "Others" , "Others" , "Others", "Naboo" , "Naboo" , "Naboo" , "Others" , "Mirial" )
Species <- c("Human" , "Human" , "Human" , "Human" , "Human" , "Human" , "Human" ,"Human" , "Human" , "Human", "Human", "Sullustan" , "Gungan" , "Gungan" , "Human" , "Geonosian" , "Mirialan")
length(Name)
## [1] 17
length(Height)
## [1] 17
length(Mass)
## [1] 17
length(Homeworld)
## [1] 17
length(Species)
## [1] 17
starwars <-data.frame( Name , Height , Mass , Homeworld , Species)
starwars
## Name Height Mass Homeworld Species
## 1 Luke Skywalker 172 77.0 Tatooine Human
## 2 Darth Vader 202 136.0 Tatooine Human
## 3 Leia Organa 150 49.0 Others Human
## 4 Beru Whitesun Iars 165 75.0 Tatooine Human
## 5 Biggs Darklighter 183 84.0 Tatooine Human
## 6 Anakin Skywalker 188 84.0 Tatooine Human
## 7 Han Solo 180 80.0 Others Human
## 8 Palpatine 170 75.0 Naboo Human
## 9 Boba Fett 183 78.2 Others Human
## 10 Lando Calrissian 177 79.0 Others Human
## 11 Lobot 175 79.0 Others Human
## 12 Nien Nunb 160 68.0 Others Sullustan
## 13 Jar Jar Binks 196 66.0 Naboo Gungan
## 14 Roos Tarpals 224 82.0 Naboo Gungan
## 15 Gregar Typho 185 85.0 Naboo Human
## 16 Poggle the Lesser 183 80.0 Others Geonosian
## 17 Barriss Offee 166 50.0 Mirial Mirialan
##In order to create a bar graph, I will look for qualitative data
str(starwars)
## 'data.frame': 17 obs. of 5 variables:
## $ Name : chr "Luke Skywalker" "Darth Vader" "Leia Organa" "Beru Whitesun Iars" ...
## $ Height : num 172 202 150 165 183 188 180 170 183 177 ...
## $ Mass : num 77 136 49 75 84 84 80 75 78.2 79 ...
## $ Homeworld: chr "Tatooine" "Tatooine" "Others" "Tatooine" ...
## $ Species : chr "Human" "Human" "Human" "Human" ...
unique(starwars$Homeworld)
## [1] "Tatooine" "Others" "Naboo" "Mirial"
unique(starwars$Species)
## [1] "Human" "Sullustan" "Gungan" "Geonosian" "Mirialan"
species.frq <- table(starwars$Species)
species.frq
##
## Geonosian Gungan Human Mirialan Sullustan
## 1 2 12 1 1
barplot(species.frq,
main = "Star Wars Characters' Species",
ylab = "Frequency",
xlab = "Species",
col = "#b5179e",
border = "#f72585",
space = 1.5,
ylim = c(0, 13))
str(starwars)
## 'data.frame': 17 obs. of 5 variables:
## $ Name : chr "Luke Skywalker" "Darth Vader" "Leia Organa" "Beru Whitesun Iars" ...
## $ Height : num 172 202 150 165 183 188 180 170 183 177 ...
## $ Mass : num 77 136 49 75 84 84 80 75 78.2 79 ...
## $ Homeworld: chr "Tatooine" "Tatooine" "Others" "Tatooine" ...
## $ Species : chr "Human" "Human" "Human" "Human" ...
hist(starwars$Height,
main = " Histogram of Star Wars Characters' Height",
xlab = "Height",
ylab = "Counts" ,
col = "#c0fdff",
border = "#5465ff",
xlim = c(150, 230) ,
ylim = c(0, 6),
labels =T)
boxplot(starwars$Mass,
main = "Boxplot of Star Wars Characters' Mass",
ylab = "Mass",
ylim = c(60, 100),
col = "#274c77",
border = "#a3cef1")
A data.frame was created named starwars. The data table has 17 rows and 5 columns. There are 5 variables: Name (character), Height (integer), Mass (numeric), Homeworld (character), Species (character). I checked the length and the structure of the data frame. I created a bar graph uses species because species is qualitative data and I created the frequency. The formula for bar graph is bargraph(). Then using height I created the histogram. The formula for histogram is hist(). I used mass for the boxplot and the formula is boxplot(). Mass and height are quantitative data (true numeric number).