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

read_vc(), write_vc(), rm_data(): default root #6

Merged
merged 14 commits into from
Feb 1, 2019
Merged

Conversation

florisvdh
Copy link
Collaborator

Borrowed code from write_vc() in order to make read_vc() throw an equally understandable error when the 'root' argument is not specified. Review carefully though; I'm not familiar with error handling and such.

BTW, why not setting a default for the root argument, like "."?

@ThierryO ThierryO added this to the Version 0.1 milestone Dec 3, 2018
@ThierryO ThierryO added the enhancement New feature or request label Dec 3, 2018
Copy link
Member

@ThierryO ThierryO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion. Can you make the minor changes and update the documentation? Use 'Install and restart' in RStudio and then 'Check package'. If the checks fail on documentation issue, then tick the 'Generate documentation with Roxygen box' in the 'Build configuration'.

The package is currently under review, so I have to keep the master stable for a while.

R/read_vc.R Outdated Show resolved Hide resolved
@ThierryO ThierryO assigned ThierryO and florisvdh and unassigned ThierryO Dec 3, 2018
@florisvdh
Copy link
Collaborator Author

Some changes have been committed, and have also been applied to the rm_data() function. Some unit tests have been added. This PR is relative to the develop branch, not master.

@codecov-io
Copy link

codecov-io commented Dec 4, 2018

Codecov Report

Merging #6 into develop will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           develop     #6   +/-   ##
======================================
  Coverage      100%   100%           
======================================
  Files            7      7           
  Lines          340    355   +15     
======================================
+ Hits           340    355   +15
Impacted Files Coverage Δ
R/recent_commit.R 100% <ø> (ø) ⬆️
R/read_vc.R 100% <100%> (ø) ⬆️
R/write_vc.R 100% <100%> (ø) ⬆️
R/rm_data.R 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update baeb9ed...5480c33. Read the comment docs.

@florisvdh florisvdh changed the title read_vc: appropriate error when root is missing read_vc(), write_vc(), rm_data(): default root Jan 25, 2019
R/write_vc.R Outdated
root = ".",
sorting = sorting,
override = FALSE,
optimize = TRUE,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ThierryO There is a problem here, how to fix this? While the intention is to set defaults for override and optimize, i.e. the part that says

definition = function(
x, file, root, sorting, override = FALSE, optimize = TRUE, ...)

, the if (missing(root)) part, if evaluated as TRUE, returns the write_vc function with override and optimize set to fixed values: these values now overrule the values originally set by the user.

So, when doing something like mydataframe %>% write_vc(file = "myfilename", sorting = mysortingvector, override = TRUE), while the file already existed and the sorting of the file has changed, I nevertheless get following error:

Error: old data has different variable types or sorting, use override = TRUE

from the traceback in RStudio:

14.
stop(call. = FALSE, "old data has different variable types or sorting, use override = TRUE") at write_vc.R#213
13.
compare_meta(metadata, old_metadata) at write_vc.R#146
12.
write_vc(x = x, file = file, root = ".", sorting = sorting, override = FALSE, optimize = TRUE, ...) at write_vc.R#30
11.
write_vc(x = x, file = file, root = ".", sorting = sorting, override = FALSE, optimize = TRUE, ...) at write_vc.R#43
10.
write_vc(., file = "myfilename", sorting = mysortingvector, override = TRUE) at write_vc.R#30
9.
write_vc(., file = "myfilename", sorting = mysortingvector, override = TRUE)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same problem is probably present in the rm_data() function

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when you call a function recursively, you need to pass the arguments rather than hard coding defaults.

R/write_vc.R Outdated
file = file,
root = ".",
sorting = sorting,
override = FALSE,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use override = override and optimize = optimize

R/rm_data.R Outdated
){
if (missing(root)) {
return(rm_data(root = ".",
path = NULL,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use path = path, type = type and recursive = recursive

@ThierryO ThierryO merged commit 0c643de into develop Feb 1, 2019
@ThierryO ThierryO deleted the read_vc branch February 1, 2019 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants