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

Conflict with lubridate::here() #37

Closed
jasonpott opened this issue Oct 14, 2019 · 2 comments · Fixed by #43
Closed

Conflict with lubridate::here() #37

jasonpott opened this issue Oct 14, 2019 · 2 comments · Fixed by #43
Labels
documentation tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day

Comments

@jasonpott
Copy link

I have been trying to use here() within a project where I am importing data from an online Research database.

I have then attempt to use here() within the saveRDS() function e.g.

saveRDS(mydfname, file= here("02_data", "mydfname.rda"))

This would ensure I have a local copy of the data for if I need to work on the project but I am offline.

When I execute the code my data import runs as expected, but the saveRDS function returns the following error

Error in here("02_data", "mydfname.rda") : unused arguments ("02_data", "mydfname.rda")

I have searched the issues listed here and online but have not found any other reports of this issue.

My work around is that I am having to input the file directory in full for saveRDS() but here is working for file calls using readRDS() and source()

I may be missing something simple so excuse my ignorance if that is the case.

@krlmlr
Copy link
Member

krlmlr commented Jan 30, 2020

It looks like lubridate::here() is the core of the problem. We could use better documentation for the causes and possible solutions:

library(here)
#> here() starts at /tmp/RtmpcFhpW6/reprex44ae186a5ab3
library(lubridate)
#> 
#> Attaching package: 'lubridate'
#> The following object is masked from 'package:here':
#> 
#>     here
#> The following object is masked from 'package:base':
#> 
#>     date

here("02_data", "mydfname.rda")
#> Error in here("02_data", "mydfname.rda"): unused arguments ("02_data", "mydfname.rda")

Created on 2020-01-30 by the reprex package (v0.3.0)

I can propose two solutions: {conflicted} or here::here()

conflicted

library(here)
#> here() starts at /tmp/RtmpcFhpW6/reprex44ae6dbee44f
library(lubridate)
#> 
#> Attaching package: 'lubridate'
#> The following object is masked from 'package:here':
#> 
#>     here
#> The following object is masked from 'package:base':
#> 
#>     date
library(conflicted)

here("02_data", "mydfname.rda")
#> Error: [conflicted] `here` found in 2 packages.
#> Either pick the one you want with `::` 
#> * lubridate::here
#> * here::here
#> Or declare a preference with `conflict_prefer()`
#> * conflict_prefer("here", "lubridate")
#> * conflict_prefer("here", "here")
conflict_prefer("here", "here")
#> [conflicted] Will prefer here::here over any other package
here("02_data", "mydfname.rda")
#> [1] "/tmp/RtmpcFhpW6/reprex44ae6dbee44f/02_data/mydfname.rda"

Created on 2020-01-30 by the reprex package (v0.3.0)

here::here()

library(here)
#> here() starts at /tmp/RtmpcFhpW6/reprex44ae3787be7b
library(lubridate)
#> 
#> Attaching package: 'lubridate'
#> The following object is masked from 'package:here':
#> 
#>     here
#> The following object is masked from 'package:base':
#> 
#>     date

here::here("02_data", "mydfname.rda")
#> [1] "/tmp/RtmpcFhpW6/reprex44ae3787be7b/02_data/mydfname.rda"

Created on 2020-01-30 by the reprex package (v0.3.0)

@krlmlr krlmlr added documentation tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day labels Jan 30, 2020
@krlmlr krlmlr changed the title saveRDS() error with here() Conflict with lubridate::here() Jan 31, 2020
krlmlr pushed a commit that referenced this issue Feb 12, 2020
- Update documentation to address conflict with `lubridate::here()` (#37, @nzgwynn).
@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants