This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.

Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Cmd+Shift+Enter.

myDataGig <- read.csv(file="/Users/benosowski/Downloads/Gig.csv")
 num_records <- nrow(myDataGig)
variables <- ncol(myDataGig)

variable_names <- names(myDataGig)

 cat("Number of Records:", num_records, "\n")
## Number of Records: 604
 cat("Variables in the Dataset:", paste(variables, collapse = ", "), "\n")
## Variables in the Dataset: 4
mean_wage <- mean(myDataGig$HourlyWage, na.rm = TRUE)

 median_wage <- median(myDataGig$HourlyWage, na.rm = TRUE)

 max_wage <- max(myDataGig$HourlyWage, na.rm = TRUE)

 min_wage <- min(myDataGig$HourlyWage, na.rm = TRUE)

cat("Mean Hourly Wage:", mean_wage, "\n")
## Mean Hourly Wage: 40.12287
cat("Median Hourly Wage:", median_wage, "\n")
## Median Hourly Wage: 41.91
 cat("Maximum Hourly Wage:", max_wage, "\n")
## Maximum Hourly Wage: 51
 cat("Minimum Hourly Wage:", min_wage, "\n")
## Minimum Hourly Wage: 24.28
mean_wage <- mean(myDataGig$HourlyWage, na.rm = TRUE)

 median_wage <- median(myDataGig$HourlyWage, na.rm = TRUE)

 max_wage <- max(myDataGig$HourlyWage, na.rm = TRUE)

 min_wage <- min(myDataGig$HourlyWage, na.rm = TRUE)

 cat("Mean Hourly Wage:", round(mean_wage, 2), "\n")
## Mean Hourly Wage: 40.12
 cat("Median Hourly Wage:", median_wage, "\n")
## Median Hourly Wage: 41.91
 cat("Maximum Hourly Wage:", max_wage, "\n")
## Maximum Hourly Wage: 51
 cat("Minimum Hourly Wage:", min_wage, "\n")
## Minimum Hourly Wage: 24.28
 missing_values <- sum(is.na(myDataGig))

 cat("Number of Missing Values in Gig.csv:", missing_values, "\n")
## Number of Missing Values in Gig.csv: 8
 rows_with_missing <- myDataGig[apply(myDataGig, 1, function(row) any(is.na(row))), ]

 print(rows_with_missing)
##     EmployeeID HourlyWage     Industry        Job
## 10          10         NA Construction Accountant
## 34          34         NA Construction  Sales Rep
## 59          59         NA   Automotive Accountant
## 81          81         NA Construction  Sales Rep
## 104        104         NA Construction Consultant
## 177        177         NA Construction Programmer
## 224        224         NA Construction Programmer
## 597        597         NA Construction Programmer
missing_records <- which(is.na(myDataGig$HourlyWage) | is.na(myDataGig$Industry) | is.na(myDataGig$Job))

 print(myDataGig[missing_records, ])
##     EmployeeID HourlyWage     Industry        Job
## 10          10         NA Construction Accountant
## 34          34         NA Construction  Sales Rep
## 59          59         NA   Automotive Accountant
## 81          81         NA Construction  Sales Rep
## 104        104         NA Construction Consultant
## 177        177         NA Construction Programmer
## 224        224         NA Construction Programmer
## 597        597         NA Construction Programmer
 omissionData <- na.omit(myDataGig)

 original_count <- nrow(myDataGig)
 omitted_count <- nrow(omissionData)

 cat("Number of observations before omitting:", original_count, "\n")
## Number of observations before omitting: 604
 cat("Number of observations after omitting:", omitted_count, "\n")
## Number of observations after omitting: 596
 HourlyWageMean <- mean(myDataGig$HourlyWage, na.rm = TRUE)

 myDataGig$HourlyWage[is.na(myDataGig$HourlyWage)] <- HourlyWageMean

 missing_values_replaced <- sum(myDataGig$HourlyWage == HourlyWageMean)
 total_missing_values <- sum(is.na(myDataGig$HourlyWage))

 cat("Number of missing values before imputation:", total_missing_values, "\n")
## Number of missing values before imputation: 0
 cat("Number of missing values after imputation:", 0, "\n")
## Number of missing values after imputation: 0
 cat("Number of observations with HourlyWage equal to its mean value:", missing_values_replaced, "\n")
## Number of observations with HourlyWage equal to its mean value: 8
 automotive_high_wage_count <- length(which(myDataGig$Industry == "Automotive" & myDataGig$HourlyWage > 30))

 cat("Number of employees working in the automotive industry and earning more than $30 per hour:", automotive_high_wage_count, "\n")
## Number of employees working in the automotive industry and earning more than $30 per hour: 181

Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Cmd+Option+I.

When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Cmd+Shift+K to preview the HTML file).

The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.