Not doing basic math correctly within Tibble object

Here's the code:

calculate counterfactual outcome

ms_counterfactual <- tibble(
YEAR = c("1995", "2000"),
eligible_counterfactual = c("Eligible (Counterfactual)", "Eligible (Counterfactual)"),
LABFORCE_counterfactual = as.numeric(tg95, tg95 - (cg95 - cg00)))

Here's my values:
tg95 = 0.738
cg95 = 0.580
cg00 = 0.549

When doing this tg95 - (cg95 - cg00) in the console, it gives me 0.7071108
When creating the Tibble object up above, it gives me the same value as tg95.

A tibble: 2 × 3

YEAR eligible_counterfactual LABFORCE_counterfactual

1 1995 Eligible (Counterfactual) 0.738
2 2000 Eligible (Counterfactual) 0.738

You have a missing c() when you create LABFORCE_counterfactual. This should work:

ms_counterfactual <- tibble(
    YEAR = c("1995", "2000"),
    eligible_counterfactual = c("Eligible (Counterfactual)", "Eligible (Counterfactual)"),
    LABFORCE_counterfactual = c(tg95, tg95 - (cg95 - cg00))
)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.