# Install and load necessary libraries
#install.packages("knitr")
#install.packages("kableExtra")
library(knitr)
library(kableExtra)
library(dplyr)
library(here)
library(ggplot2)
# Import CSV file
file_path <- here("Final Landscape Transition Survey.csv")  # Update with the correct path
raw_data <- read.csv(file_path, stringsAsFactors = FALSE)
# Drop some variables
drop <- c("Collector.ID", "IP.Address", "Email.Address", "First.Name", "Last.Name", "Custom.Data.1")
raw_data <- raw_data %>% select(-one_of(drop))
tabulate_and_style <- function(data,column_name,table_title) {
  # Exclude First Row
  data_subset <- data[-1, ]
  # Tabulate values of column 
  tabulated_values <- table(data_subset[[column_name]])
  # Convert to DF
  tabulated_df <- as.data.frame(tabulated_values)
  # Names in table 
  colnames(tabulated_df) <- c("Value", "Count")
  # Create and style the table
  styled_table <- kable(tabulated_df, format = "html", col.names = c("Value", "Count"), digits = 0) %>%
    kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"), full_width = F) %>%
    column_spec(1, bold = TRUE) %>%
    add_header_above(setNames(ncol(tabulated_df), table_title))
  
  return(styled_table)
}
tabulate_and_style(raw_data, "Which.best.describes.your.professional.role.", "Professional Role")
Professional Role
Value Count
I manage a business property. 19
I manage properties like apartments or homeowners associations. 21
I own a business property. 30
I work at or own a company that does landscaping or irrigation. 32
I work for a government agency that deals with parks or local areas. 16
I work for a non-profit organization. 9
I’m a consultant or work for a company that helps with outdoor water projects. 9
I’m part of a homeowners association or similar group. 10
Other (please specify) 21
tabulate_and_style(raw_data, "X", "Other Profession")
Other Profession
Value Count
146
Adu owner 1
Business owner 1
Cloud SaaS AI/ML Platform for Landscape Irrigation Management 1
Duplex owner/manager 1
Health care 1
I am the owner of an Irrigation Consulting Business 1
I design landscapes and irrigation to meet WELO 1
I own a few rental properties that are in property 1
I work at a utility 1
I work for a company that provides electronic monitoring 1
I’m a homeowner in Bend Historic District 1
Milti-family owner 1
Multi unit 1
None of the above 1
Own small rental property 1
Regional water provider 1
Researcher 1
retired 1
Retired 1
we lease a building 1
Work at a company not in these industries 1
tabulate_and_style(raw_data, "What.state.", "What State")
What State
Value Count
45
Alabama 2
Arizona 9
California 17
Colorado 4
Connecticut 1
Delaware 1
Florida 9
Georgia 3
Illinois 1
Indiana 1
Maine 1
New Hampshire 1
New Jersey 2
New York 1
Oregon 58
Texas 5
Utah 4
Virginia 1
Washington 1