r = getOption("repos")
r["CRAN"] = "http://cran.us.r-project.org"
options(repos = r)
install.packages("tidyverse")
## Installing package into 'C:/Users/NCC-1701D/AppData/Local/R/win-library/4.2'
## (as 'lib' is unspecified)
## package 'tidyverse' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\NCC-1701D\AppData\Local\Temp\RtmpQrlCu8\downloaded_packages
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(readr)
Raw_SteakData <- read_csv("https://raw.githubusercontent.com/johnnyboy1287/SteakPreference/main/steak-risk-survey.csv")
## Rows: 551 Columns: 15
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (14): Consider the following hypothetical situations: <br>In Lottery A, ...
## dbl (1): RespondentID
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
RawDataFrame <- data.frame(Raw_SteakData)
require("knitr")
## Loading required package: knitr
require("ggplot2")
## Loading required package: ggplot2
SteakDataSubset <- RawDataFrame[3:552,c(9,10,11,12)]
names(SteakDataSubset) [2] <- paste("Steak Preference")
names(SteakDataSubset) [3] <- paste("Gender")
names(SteakDataSubset) [4] <- paste("Age")
##Subsetting the data to only include those who eat steak and age and gender
NewSteakSubset <- SteakDataSubset %>%
filter(Do.you.eat.steak.== "Yes") %>%
filter(Gender %in% c("Male", "Female"))
#glimpse(NewSteakSubset)
unique(NewSteakSubset$Gender)
## [1] "Male" "Female"
#NewSteakSubset <- SteakDataSubset[SteakDataSubset$Gender == "Yes",]
library(ggplot2)
ggplot(NewSteakSubset, aes(`Steak Preference`, fill=Gender)) +
geom_bar()