Skip to content

Instantly share code, notes, and snippets.

@apinstein
Created December 27, 2016 18:31
Show Gist options
  • Save apinstein/917346f203b68d06df7a19e4ed52a2f5 to your computer and use it in GitHub Desktop.
Save apinstein/917346f203b68d06df7a19e4ed52a2f5 to your computer and use it in GitHub Desktop.

Revisions

  1. apinstein renamed this gist Dec 27, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. apinstein created this gist Dec 27, 2016.
    35 changes: 35 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    is_established_customerF <- function(customer_segment, credits_purchased) {
    print(typeof(customer_segment)) # prints only once?

    established_customer_threshold <- 100000000 # infinitely large
    customer_segment <- as.character(customer_segment)
    if (customer_segment == "multiple_photographer_company") {
    established_customer_threshold <- 3000
    } else if (customer_segment == "in_house_photography_department") {
    established_customer_threshold <- 1000
    } else if (customer_segment == "full_time_single_re_photographer") {
    established_customer_threshold <- 1000
    } else if (customer_segment == "part_time_single_re_photographer") {
    print("matched PT")

    established_customer_threshold <- 350
    } else if (customer_segment == "real_estate_agent") {
    print("matched RE")

    established_customer_threshold <- 150
    }

    # prints N times?
    print(paste(customer_segment, credits_purchased, ">", established_customer_threshold, credits_purchased > established_customer_threshold))

    return(credits_purchased > established_customer_threshold)
    }

    data[1:50][is_established_customerF(customer_segment, tx_cum_amount) == TRUE]

    ###
    output
    ###
    expect the `established_customer_threshold` to be different for these rows...
    [20] "real_estate_agent 300 > 150 TRUE"
    [21] "full_time_single_re_photographer NA > 150 NA"