"0","# create rebus objects for character string parsing"
"0","separators <- char_class(""./ "")"
"0","sq_dimensions <- one_or_more(DGT) %R% optional(one_or_more(DGT)) %R% optional(separators) %R% optional(one_or_more(DGT)) %R% optional(one_or_more(DGT)) %R% ""x"" %R% one_or_more(DGT) %R% optional(one_or_more(DGT)) %R% optional(separators) %R% optional(one_or_more(DGT)) %R% optional(one_or_more(DGT))"
"0","# extract dimensions"
"0","dimension_calc_extract <- str_extract_all(raw_data_summary_sheet$dimensions, sq_dimensions, simplify = T) %>%"
"0","   str_split(""x"", n = 2, simplify = T)"
"0","# create a new data frame using the extraction object"
"0","dimension_product <- data.frame(dimension_calc_extract[1:length(raw_data_summary_sheet$dimensions),1:2], stringsAsFactors = F)"
"0","# convert vector class and add units"
"0","dimension_product[,1] <- as.numeric(dimension_product[,1])"
"0","dimension_product[,2] <- as.numeric(dimension_product[,2])"
"0","dimension_product$dim_units <- raw_data_summary_sheet$dimensional_units"
"0","# multiply dimensions and convert units where necessary"
"0","dimension_product <- dimension_product %>%"
"0","   mutate(sq_dim = dimension_product[,1] * dimension_product[,2]) %>%"
"0","   mutate(sq_dim_units = case_when("
"0","      dim_units == ""in"" ~ ""sq_in"","
"0","      dim_units == ""ft"" ~ ""sq_ft"")"
"0","   ) %>%"
"0","   mutate(sq_ft_dim = case_when("
"0","      sq_dim_units == ""sq_in"" ~ sq_dim/144,"
"0","      sq_dim_units == ""sq_ft"" ~ sq_dim)"
"0","   )"
"0","# clean up workspace"
"0","rm(dimension_calc_extract)"
"0","rm(sq_dimensions)"
"0","# don't delete dimension_product because it is needed to calculate plywood and osb weight"
