knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(inteRact) library(actdata) library(tidyverse) library(here)
Step 1: Load data, select events
#get US 2015 dictionary us_2015 <- epa_subset(dataset = "usfullsurveyor2015") #make a dataframe of events set.seed(129) events <- tibble(actor_modifier = sample(us_2015$term[us_2015$component == "modifier"], 50), actor = sample(us_2015$term[us_2015$component == "identity"], 50), behavior = sample(us_2015$term[us_2015$component == "behavior"], 50), object = sample(us_2015$term[us_2015$component == "identity"], 50))
Step 2: Reshape the dataframe to have EPA values
analysis_df <- reshape_events_df(events, df_format = "wide", dictionary_key = "usfullsurveyor2015", dictionary_gender = "average")
Step 3: Nest your dataframe by event id and indicate the equation you will be using for your calculations - must be in the format "{equation_key}_{gender}" with the equation key coming from the actdata package.
nested_analysis <- analysis_df %>% ungroup() %>% nest_by(event_id) %>% mutate(equation_key = "us2010", equation_gender = "average")
Step 4: Run some calculations
deflection <- nested_analysis %>% mutate(d = get_deflection(d = data, equation_key = equation_key, equation_gender = equation_gender))
start_time <- Sys.time() multiple_functions <- nested_analysis %>% mutate(d = get_deflection(d = data, equation_key = equation_key, equation_gender = equation_gender), ti = list(transient_impression(d = data, equation_key = equation_key, equation_gender = equation_gender)), actor_reidentified = list(reidentify_actor(d = data, equation_key = equation_key, equation_gender = equation_gender))) end_time <- Sys.time()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.