Skip to content

Need to implement $<-.tbl_df for clearer warning when trying a partial update of a missing column #199

@sainathadapa

Description

@sainathadapa

This question is related to this stackoverflow question: http://stackoverflow.com/questions/39041115/fixing-a-multiple-warning-unknown-column

The following code produces a warning: (from stackoverflow answer)

library(tibble)
tibble_df <- tibble(id = c(1:3), name = c("mary", "jill","steve"))
tibble_df$test <- 'aa'
tibble_df$age[tibble_df$name == "mary"] <- 47
> Warning message:
> Unknown column 'age'

The warning arises ultimately from the check_names_df function, which is called within the $.tbl_df function. From what I understand the $.tbl_df, $<-.data.frame functions are being called in that order for the last step in the above example.

My questions are:

  1. Why is $<-.data.frame not being called directly since there is no $<-.tbl_df?
  2. Whenever df$col2[df$col1 == 'something'] <- val style is used, a warning is produced now. Do you think this style should be discouraged, since the warning is basically indirectly asking people to not use style like this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions