mydata <- read.csv("~/Desktop/Fall 2014/Programming 2014/test.csv", stringsAsFactors=FALSE, header=TRUE)
library(dplyr)
##
## Attaching package: 'dplyr'
##
## The following objects are masked from 'package:stats':
##
## filter, lag
##
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
library(tidyr)
This set calls in the functions that I will need, including my data that I will be working with.
mydata_long <- mydata %>%
gather(Title, Year, Format, Origin, Type)
I was interested in filtering to see when space games became really popular.
mydata_long <- mydata %>%
filter(Type == "space")
ggplot(data = mydata, aes(x = Year, stat="")) + geom_bar()
## stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.
This doesn’t seem right though…I’m not sure what I did wrong, but this seems to be a graph of types by year alone.
mydata_long <- mydata_long %>%
filter(Type == "space")
ggplot(data = mydata, aes(x = Year, stat="")) + geom_bar()
## stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.
mydata %>%
select(Year,Origin,Type)
## Year Origin Type
## 1 1958 us sport
## 2 1962 us space
## 3 1971 us space
## 4 1972 us sport
## 5 1973 us puzzle
## 6 1974 us sport
## 7 1974 us conflict
## 8 1975 us/jp conflict
## 9 1975 us sport
## 10 1976 us puzzle
## 11 1976 us sport
## 12 1977 us conflict
## 13 1978 us sport
## 14 1978 us sport
## 15 1979 us space
## 16 1979 jp space
## 17 1979 us space
## 18 1979 us sport
## 19 1979 us platforming
## 20 1979 jp space
## 21 1980 us fantasy
## 22 1980 us puzzle
## 23 1980 us space
## 24 1980 jp puzzle
## 25 1980 us conflict
## 26 1980 us space
## 27 1981 us puzzle
## 28 1981 us puzzle
## 29 1981 us space
## 30 1981 us puzzle
## 31 1981 jp platforming
## 32 1981 jp platforming
## 33 1981 us space
## 34 1981 us x-rated
## 35 1981 us fantasy
## 36 1981 us fantasy
## 37 1981 us conflict
## 38 1982 us adaptation
## 39 1982 jp puzzle
## 40 1982 jp puzzle
## 41 1982 us conflict
## 42 1982 jp platforming
## 43 1982 us sport
## 44 1982 us conflict
## 45 1982 us space
## 46 1982 us fantasy
## 47 1982 us x-rated
## 48 1982 us x-rated
## 49 1982 jp space
## 50 1982 us space
## 51 1982 us x-rated
## 52 1982 us adaptation
## 53 1982 us fantasy
## 54 1982 us platforming
## 55 1982 us puzzle
## 56 1982 us adaptation
## 57 1982 jp space
## 58 1982 jp adaptation
## 59 1982 us x-rated
## 60 1982 us x-rated
## 61 1982 us x-rated
## 62 1983 us conflict
## 63 1983 us adaptation
## 64 1983 us adaptation
## 65 1983 us fantasy
## 66 1983 us adaptation
## 67 1983 us x-rated
## 68 1983 us adaptation
## 69 1984 us adaptation
## 70 1984 us space
## 71 1986 us x-rated
## 72 1986 jp platforming
mydata %>%
filter(Type=="fantasy", Format=="coin-operated")
## Title Year Format Origin Type
## 1 tron 1982 coin-operated us fantasy
## 2 dragon's lair 1983 coin-operated us fantasy
mydata %>%
arrange(Title)
## Title Year Format Origin
## 1 adventure 1979 home us
## 2 asteroids 1979 coin-operated us
## 3 asteroids deluxe 1981 coin-operated us
## 4 atari basketball 1978 coin-operated us
## 5 atari football 1978 coin-operated us
## 6 bachelor party 1982 home us
## 7 battlezone 1980 coin-operated us
## 8 beat em and eat em 1982 home us
## 9 breakout 1976 coin-operated us
## 10 buck rogers and planet of zoom 1982 coin-operated jp
## 11 burning desire 1982 home us
## 12 castle wolfenstein 1981 computer us
## 13 cathouse blues 1982 home us
## 14 centipede 1981 coin-operated us
## 15 chuck norris superkicks 1983 home us
## 16 combat 1977 home us
## 17 communist mutants from space 1982 home us
## 18 computer space 1971 coin-operated us
## 19 crash n' score 1975 coin-operated us
## 20 custer's revenge 1982 home us
## 21 death race 1976 coin-operated us
## 22 defender 1980 coin-operated us
## 23 dig dug 1982 coin-operated jp
## 24 donkey kong 1981 coin-operated jp
## 25 dragon's lair 1983 coin-operated us
## 26 et 1982 home us
## 27 frogger 1981 coin-operated jp
## 28 galaxian 1979 coin-operated jp
## 29 gi joe: cobra strike 1983 home us
## 30 gotcha 1973 coin-operated us
## 31 gran trak 10 1974 coin-operated us
## 32 gun fight 1975 coin-operated us/jp
## 33 halloween 1983 home us
## 34 joust 1982 coin-operated us
## 35 jungle hunt 1982 coin-operated jp
## 36 kaboom! 1981 home us
## 37 knight on the town 1982 home us
## 38 leather goddess of phobos 1986 computer us
## 39 lunar lander 1979 coin-operated us
## 40 missile command 1980 coin-operated us
## 41 mr do! 1982 coin-operated jp
## 42 ms pac-man 1981 coin-operated us
## 43 mystery house 1980 computer us
## 44 nfl football 1979 coin-operated us
## 45 nightstalker 1982 home us
## 46 pac-man 1980 coin-operated jp
## 47 pitfall! 1982 home us
## 48 pole position 1982 coin-operated us
## 49 pong 1972 coin-operated us
## 50 q*bert 1982 coin-operated us
## 51 softporn adventure 1981 computer us
## 52 space ace 1984 coin-operated us
## 53 space invaders 1979 coin-operated jp
## 54 spacewar 1962 computer us
## 55 star trek: strategic operations simulator 1982 coin-operated jp
## 56 star wars: empire strikes back 1982 home us
## 57 star wars: jedi arena 1983 home us
## 58 star wars: return of the jedi 1983 home us
## 59 star wars: the arcade game 1984 coin-operated us
## 60 super mario bros 1986 home jp
## 61 swordquest 1982 home us
## 62 tank 1974 coin-operated us
## 63 tempest 1981 coin-operated us
## 64 tennis for two 1958 computer us
## 65 texas chainsaw massacre 1982 home us
## 66 tron 1982 coin-operated us
## 67 ultima 1981 computer us
## 68 ulysses and the golden fleece 1981 computer us
## 69 wizard and the princess 1980 computer us
## 70 x-man 1983 home us
## 71 yar's revenge 1982 home us
## 72 zaxxon 1982 coin-operated jp
## Type
## 1 platforming
## 2 space
## 3 space
## 4 sport
## 5 sport
## 6 x-rated
## 7 conflict
## 8 x-rated
## 9 puzzle
## 10 space
## 11 x-rated
## 12 conflict
## 13 x-rated
## 14 puzzle
## 15 conflict
## 16 conflict
## 17 space
## 18 space
## 19 sport
## 20 x-rated
## 21 sport
## 22 space
## 23 puzzle
## 24 platforming
## 25 fantasy
## 26 adaptation
## 27 platforming
## 28 space
## 29 adaptation
## 30 puzzle
## 31 sport
## 32 conflict
## 33 adaptation
## 34 conflict
## 35 platforming
## 36 puzzle
## 37 x-rated
## 38 x-rated
## 39 space
## 40 space
## 41 puzzle
## 42 puzzle
## 43 puzzle
## 44 sport
## 45 fantasy
## 46 puzzle
## 47 platforming
## 48 sport
## 49 sport
## 50 puzzle
## 51 x-rated
## 52 space
## 53 space
## 54 space
## 55 adaptation
## 56 adaptation
## 57 adaptation
## 58 adaptation
## 59 adaptation
## 60 platforming
## 61 conflict
## 62 conflict
## 63 space
## 64 sport
## 65 adaptation
## 66 fantasy
## 67 fantasy
## 68 fantasy
## 69 fantasy
## 70 x-rated
## 71 space
## 72 space
library(stringr)
mydata %>%
mutate(space_game = str_detect (Title,"asteroids"))
## Title Year Format Origin
## 1 tennis for two 1958 computer us
## 2 spacewar 1962 computer us
## 3 computer space 1971 coin-operated us
## 4 pong 1972 coin-operated us
## 5 gotcha 1973 coin-operated us
## 6 gran trak 10 1974 coin-operated us
## 7 tank 1974 coin-operated us
## 8 gun fight 1975 coin-operated us/jp
## 9 crash n' score 1975 coin-operated us
## 10 breakout 1976 coin-operated us
## 11 death race 1976 coin-operated us
## 12 combat 1977 home us
## 13 atari basketball 1978 coin-operated us
## 14 atari football 1978 coin-operated us
## 15 lunar lander 1979 coin-operated us
## 16 space invaders 1979 coin-operated jp
## 17 asteroids 1979 coin-operated us
## 18 nfl football 1979 coin-operated us
## 19 adventure 1979 home us
## 20 galaxian 1979 coin-operated jp
## 21 wizard and the princess 1980 computer us
## 22 mystery house 1980 computer us
## 23 defender 1980 coin-operated us
## 24 pac-man 1980 coin-operated jp
## 25 battlezone 1980 coin-operated us
## 26 missile command 1980 coin-operated us
## 27 kaboom! 1981 home us
## 28 ms pac-man 1981 coin-operated us
## 29 asteroids deluxe 1981 coin-operated us
## 30 centipede 1981 coin-operated us
## 31 donkey kong 1981 coin-operated jp
## 32 frogger 1981 coin-operated jp
## 33 tempest 1981 coin-operated us
## 34 softporn adventure 1981 computer us
## 35 ultima 1981 computer us
## 36 ulysses and the golden fleece 1981 computer us
## 37 castle wolfenstein 1981 computer us
## 38 et 1982 home us
## 39 mr do! 1982 coin-operated jp
## 40 dig dug 1982 coin-operated jp
## 41 joust 1982 coin-operated us
## 42 jungle hunt 1982 coin-operated jp
## 43 pole position 1982 coin-operated us
## 44 swordquest 1982 home us
## 45 yar's revenge 1982 home us
## 46 tron 1982 coin-operated us
## 47 bachelor party 1982 home us
## 48 beat em and eat em 1982 home us
## 49 buck rogers and planet of zoom 1982 coin-operated jp
## 50 communist mutants from space 1982 home us
## 51 custer's revenge 1982 home us
## 52 texas chainsaw massacre 1982 home us
## 53 nightstalker 1982 home us
## 54 pitfall! 1982 home us
## 55 q*bert 1982 coin-operated us
## 56 star wars: empire strikes back 1982 home us
## 57 zaxxon 1982 coin-operated jp
## 58 star trek: strategic operations simulator 1982 coin-operated jp
## 59 burning desire 1982 home us
## 60 knight on the town 1982 home us
## 61 cathouse blues 1982 home us
## 62 chuck norris superkicks 1983 home us
## 63 gi joe: cobra strike 1983 home us
## 64 halloween 1983 home us
## 65 dragon's lair 1983 coin-operated us
## 66 star wars: return of the jedi 1983 home us
## 67 x-man 1983 home us
## 68 star wars: jedi arena 1983 home us
## 69 star wars: the arcade game 1984 coin-operated us
## 70 space ace 1984 coin-operated us
## 71 leather goddess of phobos 1986 computer us
## 72 super mario bros 1986 home jp
## Type space_game
## 1 sport FALSE
## 2 space FALSE
## 3 space FALSE
## 4 sport FALSE
## 5 puzzle FALSE
## 6 sport FALSE
## 7 conflict FALSE
## 8 conflict FALSE
## 9 sport FALSE
## 10 puzzle FALSE
## 11 sport FALSE
## 12 conflict FALSE
## 13 sport FALSE
## 14 sport FALSE
## 15 space FALSE
## 16 space FALSE
## 17 space TRUE
## 18 sport FALSE
## 19 platforming FALSE
## 20 space FALSE
## 21 fantasy FALSE
## 22 puzzle FALSE
## 23 space FALSE
## 24 puzzle FALSE
## 25 conflict FALSE
## 26 space FALSE
## 27 puzzle FALSE
## 28 puzzle FALSE
## 29 space TRUE
## 30 puzzle FALSE
## 31 platforming FALSE
## 32 platforming FALSE
## 33 space FALSE
## 34 x-rated FALSE
## 35 fantasy FALSE
## 36 fantasy FALSE
## 37 conflict FALSE
## 38 adaptation FALSE
## 39 puzzle FALSE
## 40 puzzle FALSE
## 41 conflict FALSE
## 42 platforming FALSE
## 43 sport FALSE
## 44 conflict FALSE
## 45 space FALSE
## 46 fantasy FALSE
## 47 x-rated FALSE
## 48 x-rated FALSE
## 49 space FALSE
## 50 space FALSE
## 51 x-rated FALSE
## 52 adaptation FALSE
## 53 fantasy FALSE
## 54 platforming FALSE
## 55 puzzle FALSE
## 56 adaptation FALSE
## 57 space FALSE
## 58 adaptation FALSE
## 59 x-rated FALSE
## 60 x-rated FALSE
## 61 x-rated FALSE
## 62 conflict FALSE
## 63 adaptation FALSE
## 64 adaptation FALSE
## 65 fantasy FALSE
## 66 adaptation FALSE
## 67 x-rated FALSE
## 68 adaptation FALSE
## 69 adaptation FALSE
## 70 space FALSE
## 71 x-rated FALSE
## 72 platforming FALSE
mydata %>%
group_by(Type) %>% summarize(Type_Count = n()) %>% arrange(desc(Type_Count))
## Source: local data frame [8 x 2]
##
## Type Type_Count
## 1 space 15
## 2 puzzle 10
## 3 adaptation 9
## 4 sport 9
## 5 x-rated 9
## 6 conflict 8
## 7 fantasy 6
## 8 platforming 6
mydata %>%
group_by(Year) %>%
summarize(Games_Per_Year = n()) %>%
arrange(Games_Per_Year)
## Source: local data frame [17 x 2]
##
## Year Games_Per_Year
## 1 1958 1
## 2 1962 1
## 3 1971 1
## 4 1972 1
## 5 1973 1
## 6 1977 1
## 7 1974 2
## 8 1975 2
## 9 1976 2
## 10 1978 2
## 11 1984 2
## 12 1986 2
## 13 1979 6
## 14 1980 6
## 15 1983 7
## 16 1981 11
## 17 1982 24
mydata <- read.csv("~/Desktop/Fall 2014/Programming 2014/test.csv", stringsAsFactors=FALSE, header=TRUE)
mydata %>%
group_by(Type) %>%
summarize(First_Instance= min(Year))
## Source: local data frame [8 x 2]
##
## Type First_Instance
## 1 adaptation 1982
## 2 conflict 1974
## 3 fantasy 1980
## 4 platforming 1979
## 5 puzzle 1973
## 6 space 1962
## 7 sport 1958
## 8 x-rated 1981
mydata %>%
group_by(Year) %>%
summarize(Games_Per_Year = n()) %>%
arrange(Games_Per_Year)
## Source: local data frame [17 x 2]
##
## Year Games_Per_Year
## 1 1958 1
## 2 1962 1
## 3 1971 1
## 4 1972 1
## 5 1973 1
## 6 1977 1
## 7 1974 2
## 8 1975 2
## 9 1976 2
## 10 1978 2
## 11 1984 2
## 12 1986 2
## 13 1979 6
## 14 1980 6
## 15 1983 7
## 16 1981 11
## 17 1982 24
mydata %>%
arrange(Title)
## Title Year Format Origin
## 1 adventure 1979 home us
## 2 asteroids 1979 coin-operated us
## 3 asteroids deluxe 1981 coin-operated us
## 4 atari basketball 1978 coin-operated us
## 5 atari football 1978 coin-operated us
## 6 bachelor party 1982 home us
## 7 battlezone 1980 coin-operated us
## 8 beat em and eat em 1982 home us
## 9 breakout 1976 coin-operated us
## 10 buck rogers and planet of zoom 1982 coin-operated jp
## 11 burning desire 1982 home us
## 12 castle wolfenstein 1981 computer us
## 13 cathouse blues 1982 home us
## 14 centipede 1981 coin-operated us
## 15 chuck norris superkicks 1983 home us
## 16 combat 1977 home us
## 17 communist mutants from space 1982 home us
## 18 computer space 1971 coin-operated us
## 19 crash n' score 1975 coin-operated us
## 20 custer's revenge 1982 home us
## 21 death race 1976 coin-operated us
## 22 defender 1980 coin-operated us
## 23 dig dug 1982 coin-operated jp
## 24 donkey kong 1981 coin-operated jp
## 25 dragon's lair 1983 coin-operated us
## 26 et 1982 home us
## 27 frogger 1981 coin-operated jp
## 28 galaxian 1979 coin-operated jp
## 29 gi joe: cobra strike 1983 home us
## 30 gotcha 1973 coin-operated us
## 31 gran trak 10 1974 coin-operated us
## 32 gun fight 1975 coin-operated us/jp
## 33 halloween 1983 home us
## 34 joust 1982 coin-operated us
## 35 jungle hunt 1982 coin-operated jp
## 36 kaboom! 1981 home us
## 37 knight on the town 1982 home us
## 38 leather goddess of phobos 1986 computer us
## 39 lunar lander 1979 coin-operated us
## 40 missile command 1980 coin-operated us
## 41 mr do! 1982 coin-operated jp
## 42 ms pac-man 1981 coin-operated us
## 43 mystery house 1980 computer us
## 44 nfl football 1979 coin-operated us
## 45 nightstalker 1982 home us
## 46 pac-man 1980 coin-operated jp
## 47 pitfall! 1982 home us
## 48 pole position 1982 coin-operated us
## 49 pong 1972 coin-operated us
## 50 q*bert 1982 coin-operated us
## 51 softporn adventure 1981 computer us
## 52 space ace 1984 coin-operated us
## 53 space invaders 1979 coin-operated jp
## 54 spacewar 1962 computer us
## 55 star trek: strategic operations simulator 1982 coin-operated jp
## 56 star wars: empire strikes back 1982 home us
## 57 star wars: jedi arena 1983 home us
## 58 star wars: return of the jedi 1983 home us
## 59 star wars: the arcade game 1984 coin-operated us
## 60 super mario bros 1986 home jp
## 61 swordquest 1982 home us
## 62 tank 1974 coin-operated us
## 63 tempest 1981 coin-operated us
## 64 tennis for two 1958 computer us
## 65 texas chainsaw massacre 1982 home us
## 66 tron 1982 coin-operated us
## 67 ultima 1981 computer us
## 68 ulysses and the golden fleece 1981 computer us
## 69 wizard and the princess 1980 computer us
## 70 x-man 1983 home us
## 71 yar's revenge 1982 home us
## 72 zaxxon 1982 coin-operated jp
## Type
## 1 platforming
## 2 space
## 3 space
## 4 sport
## 5 sport
## 6 x-rated
## 7 conflict
## 8 x-rated
## 9 puzzle
## 10 space
## 11 x-rated
## 12 conflict
## 13 x-rated
## 14 puzzle
## 15 conflict
## 16 conflict
## 17 space
## 18 space
## 19 sport
## 20 x-rated
## 21 sport
## 22 space
## 23 puzzle
## 24 platforming
## 25 fantasy
## 26 adaptation
## 27 platforming
## 28 space
## 29 adaptation
## 30 puzzle
## 31 sport
## 32 conflict
## 33 adaptation
## 34 conflict
## 35 platforming
## 36 puzzle
## 37 x-rated
## 38 x-rated
## 39 space
## 40 space
## 41 puzzle
## 42 puzzle
## 43 puzzle
## 44 sport
## 45 fantasy
## 46 puzzle
## 47 platforming
## 48 sport
## 49 sport
## 50 puzzle
## 51 x-rated
## 52 space
## 53 space
## 54 space
## 55 adaptation
## 56 adaptation
## 57 adaptation
## 58 adaptation
## 59 adaptation
## 60 platforming
## 61 conflict
## 62 conflict
## 63 space
## 64 sport
## 65 adaptation
## 66 fantasy
## 67 fantasy
## 68 fantasy
## 69 fantasy
## 70 x-rated
## 71 space
## 72 space
mydata %>%
filter(Type=="fantasy", Format=="coin-operated")
## Title Year Format Origin Type
## 1 tron 1982 coin-operated us fantasy
## 2 dragon's lair 1983 coin-operated us fantasy