Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R check reveals unresolved code issues #1019

Open
schuemie opened this issue Dec 16, 2022 · 4 comments
Open

R check reveals unresolved code issues #1019

schuemie opened this issue Dec 16, 2022 · 4 comments

Comments

@schuemie
Copy link
Member

R check (in develop) currently shows these code issues. I would resolve all of them. Most are probably nonsense, but if you don't fix those you won't see the ones that aren't:

* checking R code for possible problems ... NOTE
appendNewRows: no visible binding for global variable ‘primaryKey’
appendNewRows: no visible binding for global variable ‘columnName’
checkAndFixDuplicateRows: no visible binding for global variable
  ‘primaryKey’
checkAndFixDuplicateRows: no visible binding for global variable
  ‘columnName’
checkFixColumnNames: no visible binding for global variable ‘optional’
checkFixColumnNames: no visible binding for global variable
  ‘columnName’
combineConceptSetsFromCohorts: no visible binding for global variable
  ‘cohortId’
combineConceptSetsFromCohorts: no visible binding for global variable
  ‘cohortName’
combineConceptSetsFromCohorts: no visible binding for global variable
runConceptSetDiagnostics: no visible binding for global variable
  ‘conceptId’
runConceptSetDiagnostics: no visible binding for global variable
  ‘sourceConceptId’
runConceptSetDiagnostics: no visible binding for global variable
  ‘conceptCount’
runConceptSetDiagnostics: no visible binding for global variable
  ‘conceptSubjects’
runConceptSetDiagnostics : getBreakdownIndexEvents: no visible binding
  for global variable ‘domain’
runConceptSetDiagnostics : getBreakdownIndexEvents: no visible binding
  for global variable ‘cohortId’
runConceptSetDiagnostics : getBreakdownIndexEvents: no visible binding
  for global variable ‘conceptSetId’
runConceptSetDiagnostics : getBreakdownIndexEvents: no visible binding
  for global variable ‘uniqueConceptSetId’
runConceptSetDiagnostics : getBreakdownIndexEvents: no visible binding
  for global variable ‘conceptCount’
runConceptSetDiagnostics: no visible binding for global variable
  ‘codesetId’
uploadResults : uploadTable: no visible binding for global variable
  ‘columnName’
uploadResults : uploadTable : uploadChunk: no visible binding for
  global variable ‘emptyIsNa’
uploadResults : uploadTable : uploadChunk: no visible binding for
  global variable ‘dataType’
uploadResults : uploadTable : uploadChunk: no visible binding for
  global variable ‘columnName’
writeToCsv.tbl_Andromeda: no visible binding for global variable
  ‘cohortId’
writeToCsv.tbl_Andromeda : processChunk: no visible binding for global
  variable ‘cohort_id’
Undefined global functions or variables:
  ageGroup averageValue calendarInterval checksum codesetId cohort_id
  cohortDefinitionId cohortEntries cohortId cohortName cohortSubjects
  columnName comparatorChecksum comparatorCohortId comparatorId
  conceptCount conceptId conceptSetExpression conceptSetId
  conceptSubjects covariateId dataType domain emptyIsNa endDay
  installed.packages isRequired isVocabularyTable optional p
  periodBegin periodEnd primaryKey referent_concept_id sd seriesType
  sourceConceptId standardDeviation startDay sumValue tableName
  targetChecksum targetCohortId timeId uniqueConceptSetId
Consider adding
  importFrom("stats", "sd")
  importFrom("utils", "installed.packages")
to your NAMESPACE file.
@azimov
Copy link
Collaborator

azimov commented Dec 19, 2022

So this is a bit of an annoying one. The tidyselect package started throwing warnings for using .data$ in dplyr calls, removing these now creates this problem. It is possible to overcome this by adding a statement like cohortId <- NULL at the top of each function, so it looks like there is a local binding for the variable but, to me, this makes the code less readable.

@schuemie
Copy link
Member Author

I think you should just use quotes? So

data %>%
  select(.data$field)

becomes

data %>%
  select("field")

Which shouldn't trigger R check warnings.

@azimov
Copy link
Collaborator

azimov commented Dec 21, 2022

So this works for inside select statements, but not inside filter, mutate etc - there the field is interpreted as a string

@schuemie
Copy link
Member Author

schuemie commented Oct 2, 2023

So for dplyr select and rename statements you should use quotes, and all other dplyr statements need .data$ to avoid R check notes.

There are also other notes and warnings in R check that can quite easily be resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants