This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.
In this report, we analyze the results of a survey conducted on employees within a company. The survey captures data related to employee satisfaction, work-life balance, and other important factors.
library(tidyverse) library(knitr) library(dplyr) survey <- read.csv(“survey.csv”)
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(echo = TRUE)
In this report, we analyze the results of a survey conducted on employees within a company. The survey captures data related to employee satisfaction, work-life balance, and other important factors.
{r setup_data, include=FALSE} library(tidyverse) library(knitr) library(dplyr) survey <- read.csv(“survey.csv”)
summary_stats <- survey %>% summarise( mean_satisfaction = mean(satisfaction, na.rm = TRUE), sd_satisfaction = sd(satisfaction, na.rm = TRUE) ) summary_stats
ggplot(survey, aes(x = satisfaction)) + geom_histogram(binwidth = 1, fill = “blue”, color = “black”) + labs(title = “Distribution of Employee Satisfaction”, x = “Satisfaction Score”, y = “Count”)
correlation <- cor(survey\(satisfaction, survey\)work_life_balance, use = “complete.obs”) correlation
satisfaction_by_dept <- survey %>% group_by(department) %>% summarise(mean_satisfaction = mean(satisfaction, na.rm = TRUE)) %>% arrange(desc(mean_satisfaction))
kable(satisfaction_by_dept)
By ensuring all chunks have unique names (like setup_data, task1_summary, etc.), this error should be resolved.