Skip to contents

Take the output from a call to make_banners or a file path where an Excel sheet is saved and upload to Google Drive location of choice.

Usage

upload_banners(
  banners.output = NULL,
  file.path = NULL,
  drive.file.name = NULL,
  drive.folder.path,
  drive.overwrite = TRUE
)

Arguments

banners.output

output list from a call to make_banners(). Must specify either this or file.path.

file.path

local file path to save banners as .xlsx file. Must specify either this or banners.output.

drive.file.name

name of Google Drive sheets file. Must specify this if inputting a banners.output and file.path is not specified (in which case the default name is the same as file.path).

drive.folder.path

folder path in Google Drive to upload banners spreadsheet.

drive.overwrite

if drive.folder.path is specified, whether or not to overwrite/update file in Google Drive if it already exists; otherwise upload the file with the same name but an updated timestamp.

Examples

data(ev22)
if (FALSE) { ## not run
# Prepare data for banners
ev22.coded = ev22 %>%
  let(
    ## code/label categorical variables
    age3 = recode(age,
                  "18-34" = 18 %thru% 34 ~ 1, 
                  "35-64" = 35 %thru% 64 ~ 2, 
                  "65+"   = 65 %thru% hi ~ 3),
    gender  = recode(gender,
                     "Male"   = 1 ~ 1,
                     "Female" = 2 ~ 2),
    income3 = recode(as.numeric(income),
                     "<$50k"     = 1 %thru% 3 ~ 1,
                     "$50k-100k" = 4 %thru% 5 ~ 2,
                     ">$100k"    = 6 %thru% 7 ~ 3,
                     "No answer" = 8 ~ 4),
    educ2 = recode(as.numeric(education),
                   "<HS-College" = 1 %thru% 4 ~ 1,
                   ">College"    = 5 %thru% 6 ~ 2),
    purchase = recode(purchase,
                      "Purchased new"                            = 1 ~ 1,
                      "Purchased used (non-certified pre-owned)" = 2 ~ 2,
                      "Purchased used (certified pre-owned)"     = 3 ~ 3,
                      "Leased new"                               = 4 ~ 4,
                      "Leased used"                              = 5 ~ 5,
                      "Other"                                    = 6 ~ 6),
    vehage = recode(vehage,
                    "Less than 1 year old"   = 1 ~ 1,
                    "1 - 2 years old"        = 2 ~ 2,
                    "3 - 5 years old"        = 3 ~ 3,
                    "6 - 10 years old"       = 4 ~ 4,
                    "More than 10 years old" = 5 ~ 5),
    vehcost = recode(vehcost,
                     "Under $5,000"      = 1 ~ 1,
                     "$5,000 - $9,999"   = 2 ~ 2,
                     "$10,000 - $19,999" = 3 ~ 3,
                     "$20,000 - $29,999" = 4 ~ 4,
                     "$30,000 - $39,999" = 5 ~ 5,
                     "$40,000 - $49,999" = 6 ~ 6,
                     "$50,000 - $59,999" = 7 ~ 7,
                     "$60,000 or more"   = 8 ~ 8),
    ## label multi-response variables
    ## note: make sure to re-code dichotomous "one-hot encoded" columns into distinct level
    ev_heard_1 = recode(ev_heard_1, "Audi e-tron" = 1 ~ 1),
    ev_heard_2 = recode(ev_heard_2, "BMW i3" = 1 ~ 2),
    ev_heard_3 = recode(ev_heard_3, "Cadillac LYRIQ" = 1 ~ 3),
    ev_heard_4 = recode(ev_heard_4, "Chevrolet Bolt" = 1 ~ 4),
    ev_heard_5 = recode(ev_heard_5, "Faraday Future" = 1 ~ 5),
    ev_heard_6 = recode(ev_heard_6, "Fisker" = 1 ~ 6),
    ev_heard_7 = recode(ev_heard_7, "Hyundai Electric" = 1 ~ 7),
    ev_heard_8 = recode(ev_heard_8, "Jaguar I-Pace" = 1 ~ 8),
    ev_heard_9 = recode(ev_heard_9, "Kia Niro EV" = 1 ~ 9),
    ev_heard_10 = recode(ev_heard_10, "Lucid Motors" = 1 ~ 10),
    
    mech_factors_1 = recode(mech_factors_1, "Price / affordability" = 1 ~ 1),
    mech_factors_2 = recode(mech_factors_2, "Convenience" = 1 ~ 2),
    mech_factors_3 = recode(mech_factors_3, "Trust / relationship" = 1 ~ 3),
    mech_factors_4 = recode(mech_factors_4, "Availability" = 1 ~ 4),
    
    sub_services_1 = recode(sub_services_1, "In-car internet" = 1 ~ 1),
    sub_services_2 = recode(sub_services_1, "Remote car start capability" = 1 ~ 2),
    sub_services_3 = recode(sub_services_1, "Live traffic / navigation" = 1 ~ 3),
    sub_services_4 = recode(sub_services_1, "In-vehicle safety and security" = 1 ~ 4),
    sub_services_5 = recode(sub_services_1, "Multiple driver profiles" = 1 ~ 5),
    sub_services_6 = recode(sub_services_1, "Cloud dash cam monitoring" = 1 ~ 6),
    sub_services_7 = recode(sub_services_1, "Car software updates" = 1 ~ 7),
    sub_services_8 = recode(sub_services_1, "AI- and self-driving capabilities" = 1 ~ 8),
    sub_services_9 = recode(sub_services_1, "Car-only media and streaming services" = 1 ~ 9),
    sub_services_10 = recode(sub_services_1, "Heated seats" = 1 ~ 10)
  ) %>%
  apply_labels(gender         = "Gender",
               age3           = "Age: 3 categories",
               educ2          = "Education",
               income3        = "Income",
               vehage         = "How old is your main vehicle?",
               vehcost        = "In total, how much did you pay to buy or lease your main vehicle?",
               purchase       = "How did you purchase or lease your main vehicle?",
               ## note: for multiresponse variables, only need to name one column
               ev_heard_1     = "Which of the following electric vehicles have you heard of?",
               mech_factors_1 = "Select the top 3 factors that are most important to you when selecting an auto repair provider:",
               sub_services_1 = "Which of the following services would you be willing to pay a recurring subscription for in a car?") 
# Make and save banners
ev22.banners <- ev22.coded %>%
  make_banners(row.vars            = list("purchase","vehage","ev_heard*",c("mech_factors_1","mech_factors_2","mech_factors_3","mech_factors_4")), 
               col.vars            = list("age3","educ2",c("sub_services_1","sub_services_2","sub_services_3","sub_services_4")), 
               weight.var          = "weight_genpop", 
               date.var            = "response_date", 
               total.row.position  = "below", 
               preview             = TRUE) %>%
  write_banners(file.path          = "ev22.xlsx",
                file.overwrite     = TRUE,
                title              = "Electric Vehicles Study",
                logo               = "mntv") %>%
  upload_banners(drive.overwrite   = TRUE,
                 drive.file.name   = "EV Study Crosstabs",
                 drive.folder.path = "https://drive.google.com/drive/u/1/folders/XXXX")
}