R/clean_reweighted_contexts.R

Defines functions clean_reweighted_contexts

Documented in clean_reweighted_contexts

#' Combine, reshape, and rename reweighted work contexts data
#'
#' This function appends the reweighted annual years of O-NET work contexts data and reshapes to produce one observation per year and occupation.
#'
#' @param frames A list object of data frames containing the annual, reweighed measures of work contexts
#'
#'
#' @return Produces a panel database of occupations over 16 years, with 56 work contexts
#' @export
clean_reweighted_contexts <- function(frames=NULL) {

  data <- dplyr::bind_rows(frames)
  data <- as.data.table(data) %>% filter(year >= 2007)

  reshaped <- reshape(data=data,
                      idvar=c("onetsoc2010code","year"),
                      timevar= "element",
                      v.names=c("data_L"),
                      direction="wide",
                      sep="")

  reshaped.label <- reshaped %>%
    dplyr::rename("context_L1"  = "data_LConsequence of Error",
                  "context_L2"  = "data_LContact With Others",
                  "context_L3"  = "data_LCoordinate or Lead Others",
                  "context_L4"  = "data_LCramped Work Space, Awkward Positions",
                  "context_L5"  = "data_LDeal With External Customers",
                  "context_L6"  = "data_LDeal With Physically Aggressive People",
                  "context_L7"  = "data_LDeal With Unpleasant or Angry People",
                  "context_L8"  = "data_LDegree of Automation",
                  "context_L9"  = "data_LElectronic Mail",
                  "context_L10" = "data_LExposed to Contaminants",
                  "context_L11" = "data_LExposed to Disease or Infections",
                  "context_L12" = "data_LExposed to Hazardous Conditions",
                  "context_L13" = "data_LExposed to Hazardous Equipment",
                  "context_L14" = "data_LExposed to High Places",
                  "context_L15" = "data_LExposed to Minor Burns, Cuts, Bites, or Stings",
                  "context_L16" = "data_LExposed to Radiation",
                  "context_L17" = "data_LExposed to Whole Body Vibration",
                  "context_L18" = "data_LExtremely Bright or Inadequate Lighting",
                  "context_L19" = "data_LFace-to-Face Discussions",
                  "context_L20" = "data_LFreedom to Make Decisions",
                  "context_L21" = "data_LFrequency of Decision Making",
                  "context_L22" = "data_LFrequency of Conflict Situations",
                  "context_L23" = "data_LImpact of Decisions on Co-workers or Company Results",
                  "context_L24" = "data_LImportance of Being Exact or Accurate",
                  "context_L25" = "data_LImportance of Repeating Same Tasks",
                  "context_L26" = "data_LIn an Enclosed Vehicle or Equipment",
                  "context_L27" = "data_LIn an Open Vehicle or Equipment",
                  "context_L28" = "data_LIndoors, Environmentally Controlled",
                  "context_L29" = "data_LIndoors, Not Environmentally Controlled",
                  "context_L30" = "data_LLetters and Memos",
                  "context_L31" = "data_LLevel of Competition",
                  "context_L32" = "data_LOutdoors, Exposed to Weather",
                  "context_L33" = "data_LOutdoors, Under Cover",
                  "context_L34" = "data_LPace Determined by Speed of Equipment",
                  "context_L35" = "data_LPhysical Proximity",
                  "context_L36" = "data_LPublic Speaking",
                  "context_L37" = "data_LResponsibility for Outcomes and Results",
                  "context_L38" = "data_LResponsible for Others' Health and Safety",
                  "context_L39" = "data_LSounds, Noise Levels Are Distracting or Uncomfortable",
                  "context_L40" = "data_LSpend Time Bending or Twisting the Body",
                  "context_L41" = "data_LSpend Time Climbing Ladders, Scaffolds, or Poles",
                  "context_L42" = "data_LSpend Time Keeping or Regaining Balance",
                  "context_L43" = "data_LSpend Time Kneeling, Crouching, Stooping, or Crawling",
                  "context_L44" = "data_LSpend Time Making Repetitive Motions",
                  "context_L45" = "data_LSpend Time Sitting",
                  "context_L46" = "data_LSpend Time Standing",
                  "context_L47" = "data_LSpend Time Using Your Hands to Handle, Control, or Feel Objects, Tools, or Controls",
                  "context_L48" = "data_LSpend Time Walking and Running",
                  "context_L49" = "data_LStructured versus Unstructured Work",
                  "context_L50" = "data_LTelephone",
                  "context_L51" = "data_LTime Pressure",
                  "context_L52" = "data_LVery Hot or Cold Temperatures",
                  "context_L53" = "data_LWear Common Protective or Safety Equipment such as Safety Shoes, Glasses, Gloves, Hearing Protection, Hard Hats, or Life Jackets",
                  "context_L54" = "data_LWear Specialized Protective or Safety Equipment such as Breathing Apparatus, Safety Harness, Full Protection Suits, or Radiation Protection",
                  "context_L55" = "data_LWork With Work Group or Team")


  return(reshaped.label)

}
djmorris1989/onetmappinguk documentation built on June 14, 2020, 10:04 a.m.