Skip to content

makeFrontier() throws uninformative error if dataset is tibble #32

@bfifield

Description

@bfifield

This package and method are great, thanks for implementing it to make it easy to use!

makeFrontier() will throw an error about the treatment not being 0/1 or TRUE/FALSE when dataset is a tibble, even if the treatment is in fact 0/1. If the dataset is converted to data.frame(), the error goes away, but it took a bit of experimenting to figure that out. Either automatic conversion of tbl to data.frame(), or a more informative warning message would be a big help.

library(tidyverse)
library(MatchingFrontier)

## Make data - t is 0/1
df_tst <- tibble(t = rbinom(100, c(0, 1), .5), 
                 X1 = rnorm(100), 
                 X2 = rnorm(100), 
                 y = rnorm(100))

## Should error with: 
## "Error: In makeFrontier(), the treatment must be either 0/1 (integers) or "TRUE"/"FALSE" (logical)."
makeFrontier(dataset = df_tst, treatment = "t", outcome = "y", match.on = c("X1", "X2"))

## Should run after converting to dataframe
makeFrontier(dataset = as.data.frame(df_tst), treatment = "t", outcome = "y", match.on = c("X1", "X2"))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions