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:
- Why is
$<-.data.frame not being called directly since there is no $<-.tbl_df?
- 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.