You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Actually, my advice would be to save this for a separate PR. I did a quick search and there are many instances of transform() in PEcAn which will all likely result in a similar problem of undefined global variables. It would probably easier to change them all at once when you've got the fix pattern figured out.
transform() is similar to dplyr::mutate() but doesn't have a way of avoiding the 'undefined global variables' CRAN check error. The help file for transform() explicitly says to not use it in programming.
For example, transform(iris, Sepal.Length = Sepal.Length * 2) will result in an undefined global variable Sepal.Length. With dplyr's .data pronoun this can be avoided: dplyr::mutate(iris, Sepal.Length = .data$Sepal.Length * 2)
The text was updated successfully, but these errors were encountered:
Most uses of transform can be rewritten (sometimes much more wordily!) as explicit assignments to column names inside an explicitly named dataframe: new_data <- transform(data_with_tediously_long_name, some_column = some_other_column * 2) => new_data <- data_with_tediously_long_name; new_data$some_column <- new_data$some_other_column * 2
Originally posted by @Aariq in #2956 (comment)
transform()
is similar todplyr::mutate()
but doesn't have a way of avoiding the 'undefined global variables' CRAN check error. The help file fortransform()
explicitly says to not use it in programming.For example,
transform(iris, Sepal.Length = Sepal.Length * 2)
will result in an undefined global variableSepal.Length
. Withdplyr
's.data
pronoun this can be avoided:dplyr::mutate(iris, Sepal.Length = .data$Sepal.Length * 2)
The text was updated successfully, but these errors were encountered: