Problems importing functions with @importFrom pkg funIs there a built-in function for finding the mode?Grouping functions (tapply, by, aggregate) and the *apply familyAccess lapply index names inside FUNFunction to clear the console in R and RStudioimport vs importFrom in NAMESPACE fileR: selective import with importFrom: namespace issuesHow can I view the source code for a function?Rstudio Roxygen2 @importFrom parsing function headerImport one function in R package (without importFrom)how to @importFrom data.table within r package function
Is a diamond sword feasible?
Drawing perpendicular lines, filling areas
What did Rocket give Hawkeye in "Avengers: Endgame"?
The lexical root of the perfect tense forms differs from the lexical root of the infinitive form
Is the homebrew weapon attack cantrip 'Arcane Strike' balanced?
How does Howard Stark know this?
How are one-time password generators like Google Authenticator different from having two passwords?
What food production methods would allow a metropolis like New York to become self sufficient
Was the Highlands Ranch shooting the 115th mass shooting in the US in 2019
Why does "decimal.TryParse()" always return 0 for the input string "-1" in the below code?
Does Lawful Interception of 4G / the proposed 5G provide a back door for hackers as well?
How to make a language evolve quickly?
Why do unstable nuclei form?
Why does a C.D.F need to be right-continuous?
Was there a contingency plan in place if Little Boy failed to detonate?
As programers say: Strive to be lazy
Why does the Earth follow an elliptical trajectory rather than a parabolic one?
Does the 500 feet falling cap apply per fall, or per turn?
Is there enough time to Planar Bind a creature conjured by a one hour duration spell?
What are the ramifications of setting ARITHABORT ON for all connections in SQL Server?
Guns in space with bullets that return?
Is a vertical stabiliser needed for straight line flight in a glider?
Limit of an integral vs Limit of the integrand
How to select certain lines (n, n+4, n+8, n+12...) from the file?
Problems importing functions with @importFrom pkg fun
Is there a built-in function for finding the mode?Grouping functions (tapply, by, aggregate) and the *apply familyAccess lapply index names inside FUNFunction to clear the console in R and RStudioimport vs importFrom in NAMESPACE fileR: selective import with importFrom: namespace issuesHow can I view the source code for a function?Rstudio Roxygen2 @importFrom parsing function headerImport one function in R package (without importFrom)how to @importFrom data.table within r package function
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm currently trying to develop my first R package and run into a following problem.
I have a DESCRIPTION file where all needed packages are listed under Imports like suggested by Hadley Wickham in his book. I'm using @importFrom dplyr select
to load a function, for internal use.
By running devtools::document()
I get an error:
Error in select(paths_original, household_id = H_ID, person_id = P_ID, :
could not find function "select"
Would be great, if someone could help me to understand my mistake.
Thanks in advance!
EDIT:
DESCRIPTION
Package: first_package
Title: first package
Version: 0.0.0.9000
Description: first package
Depends:
R (>= 3.5.2)
Imports:
foreign (>= 0.8.71),
plyr (>= 1.8.4),
dplyr (>= 0.7.7),
leaflet (>= 2.0.2),
sf (>= 0.7.1),
rgeos (>= 0.4.2),
geosphere (>= 1.5.7),
sp (>= 1.3.1),
rgdal (>= 1.3.6),
mapview (>= 2.6.0),
lwgeom (>= 0.1.6),
roxygen2
License: BSD 2-Clause + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.0
function:
get_clear_df_paths <- function(paths_original)
clean_paths <- select(paths_original,
household_id = H_ID,
person_id = P_ID,
household_person_id = HP_ID,
weekday = ST_WOTAG,
month = ST_MONAT,
holiday = feiertag,
season = saison,
regular_job_related_path = W_RBW,
path_purpose = W_ZWECK,
starting_point = W_SO2,
start_time_hour = W_SZS,
start_time_min = W_SZM,
arrival_next_day = W_FOLGETAG,
arrival_time_hour = W_AZS,
arrival_time_min = W_AZM,
path_length = wegkm,
path_length_imp = wegkm_imp,
path_duration_min = wegmin,
path_duration_min_imp = wegmin_imp,
main_vehicle = hvm,
car_driver = pkw_fmf,
vehicle_car = W_VM_G,
vehicle_carsharing = W_VM_H,
district = stt_mun)
imports.R
#' @importFrom plyr revalue
#' @importFrom dplyr select
#' @importFrom foreign read.spss
NULL
NAMESPACE
# Generated by roxygen2: do not edit by hand
importFrom(dplyr,select)
importFrom(foreign,read.spss)
importFrom(plyr,revalue)
public gist link with relevant code snippets:
https://gist.github.com/bgrt/b7d32cb3aa0bb128f276bad86c89bdd4
r
migrated from stats.stackexchange.com Mar 23 at 10:50
This question came from our site for people interested in statistics, machine learning, data analysis, data mining, and data visualization.
|
show 9 more comments
I'm currently trying to develop my first R package and run into a following problem.
I have a DESCRIPTION file where all needed packages are listed under Imports like suggested by Hadley Wickham in his book. I'm using @importFrom dplyr select
to load a function, for internal use.
By running devtools::document()
I get an error:
Error in select(paths_original, household_id = H_ID, person_id = P_ID, :
could not find function "select"
Would be great, if someone could help me to understand my mistake.
Thanks in advance!
EDIT:
DESCRIPTION
Package: first_package
Title: first package
Version: 0.0.0.9000
Description: first package
Depends:
R (>= 3.5.2)
Imports:
foreign (>= 0.8.71),
plyr (>= 1.8.4),
dplyr (>= 0.7.7),
leaflet (>= 2.0.2),
sf (>= 0.7.1),
rgeos (>= 0.4.2),
geosphere (>= 1.5.7),
sp (>= 1.3.1),
rgdal (>= 1.3.6),
mapview (>= 2.6.0),
lwgeom (>= 0.1.6),
roxygen2
License: BSD 2-Clause + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.0
function:
get_clear_df_paths <- function(paths_original)
clean_paths <- select(paths_original,
household_id = H_ID,
person_id = P_ID,
household_person_id = HP_ID,
weekday = ST_WOTAG,
month = ST_MONAT,
holiday = feiertag,
season = saison,
regular_job_related_path = W_RBW,
path_purpose = W_ZWECK,
starting_point = W_SO2,
start_time_hour = W_SZS,
start_time_min = W_SZM,
arrival_next_day = W_FOLGETAG,
arrival_time_hour = W_AZS,
arrival_time_min = W_AZM,
path_length = wegkm,
path_length_imp = wegkm_imp,
path_duration_min = wegmin,
path_duration_min_imp = wegmin_imp,
main_vehicle = hvm,
car_driver = pkw_fmf,
vehicle_car = W_VM_G,
vehicle_carsharing = W_VM_H,
district = stt_mun)
imports.R
#' @importFrom plyr revalue
#' @importFrom dplyr select
#' @importFrom foreign read.spss
NULL
NAMESPACE
# Generated by roxygen2: do not edit by hand
importFrom(dplyr,select)
importFrom(foreign,read.spss)
importFrom(plyr,revalue)
public gist link with relevant code snippets:
https://gist.github.com/bgrt/b7d32cb3aa0bb128f276bad86c89bdd4
r
migrated from stats.stackexchange.com Mar 23 at 10:50
This question came from our site for people interested in statistics, machine learning, data analysis, data mining, and data visualization.
1
Why not just usedplyr::select
?
– NelsonGon
Mar 23 at 11:25
1
Could you copy paste your code and add it to the question? Also add a GitHub or other link to the function?
– NelsonGon
Mar 23 at 11:32
1
@NelsonGon's latest comment it dead on: This is not reproducible as is. We cannot tell you where your problem is if we cannot see your code.
– duckmayr
Mar 23 at 11:33
1
This seems... bizarre. I have an easily mocked up minimal example showing that this approach should work. I have to imagine there's some outside factor we're not seeing. What versions of R, devtools, roxygen2, and dplyr do you have?
– duckmayr
Mar 23 at 11:46
1
I added the gist link to the OP... I yet don't have any documentation for the functions. but at this point, seems to me its kind of irrelevant, because I think I'm missing something R relevant, because I'm new to the language and package development...
– Bagrat
Mar 23 at 12:08
|
show 9 more comments
I'm currently trying to develop my first R package and run into a following problem.
I have a DESCRIPTION file where all needed packages are listed under Imports like suggested by Hadley Wickham in his book. I'm using @importFrom dplyr select
to load a function, for internal use.
By running devtools::document()
I get an error:
Error in select(paths_original, household_id = H_ID, person_id = P_ID, :
could not find function "select"
Would be great, if someone could help me to understand my mistake.
Thanks in advance!
EDIT:
DESCRIPTION
Package: first_package
Title: first package
Version: 0.0.0.9000
Description: first package
Depends:
R (>= 3.5.2)
Imports:
foreign (>= 0.8.71),
plyr (>= 1.8.4),
dplyr (>= 0.7.7),
leaflet (>= 2.0.2),
sf (>= 0.7.1),
rgeos (>= 0.4.2),
geosphere (>= 1.5.7),
sp (>= 1.3.1),
rgdal (>= 1.3.6),
mapview (>= 2.6.0),
lwgeom (>= 0.1.6),
roxygen2
License: BSD 2-Clause + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.0
function:
get_clear_df_paths <- function(paths_original)
clean_paths <- select(paths_original,
household_id = H_ID,
person_id = P_ID,
household_person_id = HP_ID,
weekday = ST_WOTAG,
month = ST_MONAT,
holiday = feiertag,
season = saison,
regular_job_related_path = W_RBW,
path_purpose = W_ZWECK,
starting_point = W_SO2,
start_time_hour = W_SZS,
start_time_min = W_SZM,
arrival_next_day = W_FOLGETAG,
arrival_time_hour = W_AZS,
arrival_time_min = W_AZM,
path_length = wegkm,
path_length_imp = wegkm_imp,
path_duration_min = wegmin,
path_duration_min_imp = wegmin_imp,
main_vehicle = hvm,
car_driver = pkw_fmf,
vehicle_car = W_VM_G,
vehicle_carsharing = W_VM_H,
district = stt_mun)
imports.R
#' @importFrom plyr revalue
#' @importFrom dplyr select
#' @importFrom foreign read.spss
NULL
NAMESPACE
# Generated by roxygen2: do not edit by hand
importFrom(dplyr,select)
importFrom(foreign,read.spss)
importFrom(plyr,revalue)
public gist link with relevant code snippets:
https://gist.github.com/bgrt/b7d32cb3aa0bb128f276bad86c89bdd4
r
I'm currently trying to develop my first R package and run into a following problem.
I have a DESCRIPTION file where all needed packages are listed under Imports like suggested by Hadley Wickham in his book. I'm using @importFrom dplyr select
to load a function, for internal use.
By running devtools::document()
I get an error:
Error in select(paths_original, household_id = H_ID, person_id = P_ID, :
could not find function "select"
Would be great, if someone could help me to understand my mistake.
Thanks in advance!
EDIT:
DESCRIPTION
Package: first_package
Title: first package
Version: 0.0.0.9000
Description: first package
Depends:
R (>= 3.5.2)
Imports:
foreign (>= 0.8.71),
plyr (>= 1.8.4),
dplyr (>= 0.7.7),
leaflet (>= 2.0.2),
sf (>= 0.7.1),
rgeos (>= 0.4.2),
geosphere (>= 1.5.7),
sp (>= 1.3.1),
rgdal (>= 1.3.6),
mapview (>= 2.6.0),
lwgeom (>= 0.1.6),
roxygen2
License: BSD 2-Clause + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.0
function:
get_clear_df_paths <- function(paths_original)
clean_paths <- select(paths_original,
household_id = H_ID,
person_id = P_ID,
household_person_id = HP_ID,
weekday = ST_WOTAG,
month = ST_MONAT,
holiday = feiertag,
season = saison,
regular_job_related_path = W_RBW,
path_purpose = W_ZWECK,
starting_point = W_SO2,
start_time_hour = W_SZS,
start_time_min = W_SZM,
arrival_next_day = W_FOLGETAG,
arrival_time_hour = W_AZS,
arrival_time_min = W_AZM,
path_length = wegkm,
path_length_imp = wegkm_imp,
path_duration_min = wegmin,
path_duration_min_imp = wegmin_imp,
main_vehicle = hvm,
car_driver = pkw_fmf,
vehicle_car = W_VM_G,
vehicle_carsharing = W_VM_H,
district = stt_mun)
imports.R
#' @importFrom plyr revalue
#' @importFrom dplyr select
#' @importFrom foreign read.spss
NULL
NAMESPACE
# Generated by roxygen2: do not edit by hand
importFrom(dplyr,select)
importFrom(foreign,read.spss)
importFrom(plyr,revalue)
public gist link with relevant code snippets:
https://gist.github.com/bgrt/b7d32cb3aa0bb128f276bad86c89bdd4
r
r
edited Mar 23 at 12:06
Bagrat
asked Mar 23 at 10:44
BagratBagrat
12
12
migrated from stats.stackexchange.com Mar 23 at 10:50
This question came from our site for people interested in statistics, machine learning, data analysis, data mining, and data visualization.
migrated from stats.stackexchange.com Mar 23 at 10:50
This question came from our site for people interested in statistics, machine learning, data analysis, data mining, and data visualization.
1
Why not just usedplyr::select
?
– NelsonGon
Mar 23 at 11:25
1
Could you copy paste your code and add it to the question? Also add a GitHub or other link to the function?
– NelsonGon
Mar 23 at 11:32
1
@NelsonGon's latest comment it dead on: This is not reproducible as is. We cannot tell you where your problem is if we cannot see your code.
– duckmayr
Mar 23 at 11:33
1
This seems... bizarre. I have an easily mocked up minimal example showing that this approach should work. I have to imagine there's some outside factor we're not seeing. What versions of R, devtools, roxygen2, and dplyr do you have?
– duckmayr
Mar 23 at 11:46
1
I added the gist link to the OP... I yet don't have any documentation for the functions. but at this point, seems to me its kind of irrelevant, because I think I'm missing something R relevant, because I'm new to the language and package development...
– Bagrat
Mar 23 at 12:08
|
show 9 more comments
1
Why not just usedplyr::select
?
– NelsonGon
Mar 23 at 11:25
1
Could you copy paste your code and add it to the question? Also add a GitHub or other link to the function?
– NelsonGon
Mar 23 at 11:32
1
@NelsonGon's latest comment it dead on: This is not reproducible as is. We cannot tell you where your problem is if we cannot see your code.
– duckmayr
Mar 23 at 11:33
1
This seems... bizarre. I have an easily mocked up minimal example showing that this approach should work. I have to imagine there's some outside factor we're not seeing. What versions of R, devtools, roxygen2, and dplyr do you have?
– duckmayr
Mar 23 at 11:46
1
I added the gist link to the OP... I yet don't have any documentation for the functions. but at this point, seems to me its kind of irrelevant, because I think I'm missing something R relevant, because I'm new to the language and package development...
– Bagrat
Mar 23 at 12:08
1
1
Why not just use
dplyr::select
?– NelsonGon
Mar 23 at 11:25
Why not just use
dplyr::select
?– NelsonGon
Mar 23 at 11:25
1
1
Could you copy paste your code and add it to the question? Also add a GitHub or other link to the function?
– NelsonGon
Mar 23 at 11:32
Could you copy paste your code and add it to the question? Also add a GitHub or other link to the function?
– NelsonGon
Mar 23 at 11:32
1
1
@NelsonGon's latest comment it dead on: This is not reproducible as is. We cannot tell you where your problem is if we cannot see your code.
– duckmayr
Mar 23 at 11:33
@NelsonGon's latest comment it dead on: This is not reproducible as is. We cannot tell you where your problem is if we cannot see your code.
– duckmayr
Mar 23 at 11:33
1
1
This seems... bizarre. I have an easily mocked up minimal example showing that this approach should work. I have to imagine there's some outside factor we're not seeing. What versions of R, devtools, roxygen2, and dplyr do you have?
– duckmayr
Mar 23 at 11:46
This seems... bizarre. I have an easily mocked up minimal example showing that this approach should work. I have to imagine there's some outside factor we're not seeing. What versions of R, devtools, roxygen2, and dplyr do you have?
– duckmayr
Mar 23 at 11:46
1
1
I added the gist link to the OP... I yet don't have any documentation for the functions. but at this point, seems to me its kind of irrelevant, because I think I'm missing something R relevant, because I'm new to the language and package development...
– Bagrat
Mar 23 at 12:08
I added the gist link to the OP... I yet don't have any documentation for the functions. but at this point, seems to me its kind of irrelevant, because I think I'm missing something R relevant, because I'm new to the language and package development...
– Bagrat
Mar 23 at 12:08
|
show 9 more comments
2 Answers
2
active
oldest
votes
I hate to add this because it is "Not an answer," and will update it to include an answer soon or remove it. However, I believe it may be helpful to demonstrate that OP's basic approach should work, so I created a minimal example package importing the apparent problem function.
First I set up the package structure:
library(devtools)
create_package("funImport", rstudio = FALSE)
use_package("dplyr")
use_gpl3_license("X")
I then added one file to R/
containing the following:
#' Select wrapper
#'
#' @param .data A tbl
#' @param ... Variable names to select
#'
#' @return The selected variables
#' @export
Select <- function(.data, ...)
return(select(.data, ...))
#' @importFrom dplyr select
NULL
I was then able to document()
, install()
and check()
no problem:
document()
# Updating funImport documentation
# Updating roxygen version in /home/jb/funImport/DESCRIPTION
# Writing NAMESPACE
# Loading funImport
# Writing NAMESPACE
# Writing Select.Rd
install()
# Output omitted
check()
# Some output omitted
# ── R CMD check results ─────────────────────────────── funImport 0.0.0.9000 ────
# Duration: 48.2s
#
# 0 errors ✔ | 0 warnings ✔ | 0 notes ✔
I was also able to use the function no problem:
library(funImport)
tbl <- tibble::tibble(x = 1:10, y = letters[1:10])
tbl
# # A tibble: 10 x 2
# x y
# <int> <chr>
# 1 1 a
# 2 2 b
# 3 3 c
# 4 4 d
# 5 5 e
# 6 6 f
# 7 7 g
# 8 8 h
# 9 9 i
# 10 10 j
Select(tbl, x)
# # A tibble: 10 x 1
# x
# <int>
# 1 1
# 2 2
# 3 3
# 4 4
# 5 5
# 6 6
# 7 7
# 8 8
# 9 9
# 10 10
use_x
seem to have been moved tousethis
.
– NelsonGon
Mar 23 at 12:04
1
@NelsonGon Sure, but if you attachdevtools
, it also attachedusethis
– duckmayr
Mar 23 at 12:05
1
@NelsonGon See here: github.com/r-lib/devtools/blob/…
– duckmayr
Mar 23 at 12:06
add a comment |
Created a dummy package to test and this works. You need to have your functions documented as shown below. Also, please have a way fo providing global binding for some variables in your functions.
#' Some paths
#' @description some paths
#' @param paths_original Some path
#' @importFrom dplyr select
#' @export
get_clear_df_paths <- function(paths_original)
clean_paths <- select(paths_original,
household_id = H_ID,
person_id = P_ID,
household_person_id = HP_ID,
weekday = ST_WOTAG,
month = ST_MONAT,
holiday = feiertag,
season = saison,
regular_job_related_path = W_RBW,
path_purpose = W_ZWECK,
starting_point = W_SO2,
start_time_hour = W_SZS,
start_time_min = W_SZM,
arrival_next_day = W_FOLGETAG,
arrival_time_hour = W_AZS,
arrival_time_min = W_AZM,
path_length = wegkm,
path_length_imp = wegkm_imp,
path_duration_min = wegmin,
path_duration_min_imp = wegmin_imp,
main_vehicle = hvm,
car_driver = pkw_fmf,
vehicle_car = W_VM_G,
vehicle_carsharing = W_VM_H,
district = stt_mun)
Steps:
library(devtools)
library(roxygen2)
create("SODummypkg")
document("SODummypkg")
check("SODummypkg")
Outcome: Ignore the warning(for purposes of this answer). At least the error doesn't show up.
-- R CMD check results ---------------------------------------------- SODummypkg 0.0.0.9000 ----
Duration: 1m 10.7s
> checking DESCRIPTION meta-information ... WARNING
Dependence on R version '3.5.3' not with patchlevel 0
0 errors √ | 1 warning x | 0 notes √
not sure how to use this to solve my problem... sorry if I missed something.
– Bagrat
Mar 23 at 13:14
1
@Bagrat Try to document one of your functions as shown here. Also document all your functions.
– NelsonGon
Mar 23 at 13:44
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55312924%2fproblems-importing-functions-with-importfrom-pkg-fun%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I hate to add this because it is "Not an answer," and will update it to include an answer soon or remove it. However, I believe it may be helpful to demonstrate that OP's basic approach should work, so I created a minimal example package importing the apparent problem function.
First I set up the package structure:
library(devtools)
create_package("funImport", rstudio = FALSE)
use_package("dplyr")
use_gpl3_license("X")
I then added one file to R/
containing the following:
#' Select wrapper
#'
#' @param .data A tbl
#' @param ... Variable names to select
#'
#' @return The selected variables
#' @export
Select <- function(.data, ...)
return(select(.data, ...))
#' @importFrom dplyr select
NULL
I was then able to document()
, install()
and check()
no problem:
document()
# Updating funImport documentation
# Updating roxygen version in /home/jb/funImport/DESCRIPTION
# Writing NAMESPACE
# Loading funImport
# Writing NAMESPACE
# Writing Select.Rd
install()
# Output omitted
check()
# Some output omitted
# ── R CMD check results ─────────────────────────────── funImport 0.0.0.9000 ────
# Duration: 48.2s
#
# 0 errors ✔ | 0 warnings ✔ | 0 notes ✔
I was also able to use the function no problem:
library(funImport)
tbl <- tibble::tibble(x = 1:10, y = letters[1:10])
tbl
# # A tibble: 10 x 2
# x y
# <int> <chr>
# 1 1 a
# 2 2 b
# 3 3 c
# 4 4 d
# 5 5 e
# 6 6 f
# 7 7 g
# 8 8 h
# 9 9 i
# 10 10 j
Select(tbl, x)
# # A tibble: 10 x 1
# x
# <int>
# 1 1
# 2 2
# 3 3
# 4 4
# 5 5
# 6 6
# 7 7
# 8 8
# 9 9
# 10 10
use_x
seem to have been moved tousethis
.
– NelsonGon
Mar 23 at 12:04
1
@NelsonGon Sure, but if you attachdevtools
, it also attachedusethis
– duckmayr
Mar 23 at 12:05
1
@NelsonGon See here: github.com/r-lib/devtools/blob/…
– duckmayr
Mar 23 at 12:06
add a comment |
I hate to add this because it is "Not an answer," and will update it to include an answer soon or remove it. However, I believe it may be helpful to demonstrate that OP's basic approach should work, so I created a minimal example package importing the apparent problem function.
First I set up the package structure:
library(devtools)
create_package("funImport", rstudio = FALSE)
use_package("dplyr")
use_gpl3_license("X")
I then added one file to R/
containing the following:
#' Select wrapper
#'
#' @param .data A tbl
#' @param ... Variable names to select
#'
#' @return The selected variables
#' @export
Select <- function(.data, ...)
return(select(.data, ...))
#' @importFrom dplyr select
NULL
I was then able to document()
, install()
and check()
no problem:
document()
# Updating funImport documentation
# Updating roxygen version in /home/jb/funImport/DESCRIPTION
# Writing NAMESPACE
# Loading funImport
# Writing NAMESPACE
# Writing Select.Rd
install()
# Output omitted
check()
# Some output omitted
# ── R CMD check results ─────────────────────────────── funImport 0.0.0.9000 ────
# Duration: 48.2s
#
# 0 errors ✔ | 0 warnings ✔ | 0 notes ✔
I was also able to use the function no problem:
library(funImport)
tbl <- tibble::tibble(x = 1:10, y = letters[1:10])
tbl
# # A tibble: 10 x 2
# x y
# <int> <chr>
# 1 1 a
# 2 2 b
# 3 3 c
# 4 4 d
# 5 5 e
# 6 6 f
# 7 7 g
# 8 8 h
# 9 9 i
# 10 10 j
Select(tbl, x)
# # A tibble: 10 x 1
# x
# <int>
# 1 1
# 2 2
# 3 3
# 4 4
# 5 5
# 6 6
# 7 7
# 8 8
# 9 9
# 10 10
use_x
seem to have been moved tousethis
.
– NelsonGon
Mar 23 at 12:04
1
@NelsonGon Sure, but if you attachdevtools
, it also attachedusethis
– duckmayr
Mar 23 at 12:05
1
@NelsonGon See here: github.com/r-lib/devtools/blob/…
– duckmayr
Mar 23 at 12:06
add a comment |
I hate to add this because it is "Not an answer," and will update it to include an answer soon or remove it. However, I believe it may be helpful to demonstrate that OP's basic approach should work, so I created a minimal example package importing the apparent problem function.
First I set up the package structure:
library(devtools)
create_package("funImport", rstudio = FALSE)
use_package("dplyr")
use_gpl3_license("X")
I then added one file to R/
containing the following:
#' Select wrapper
#'
#' @param .data A tbl
#' @param ... Variable names to select
#'
#' @return The selected variables
#' @export
Select <- function(.data, ...)
return(select(.data, ...))
#' @importFrom dplyr select
NULL
I was then able to document()
, install()
and check()
no problem:
document()
# Updating funImport documentation
# Updating roxygen version in /home/jb/funImport/DESCRIPTION
# Writing NAMESPACE
# Loading funImport
# Writing NAMESPACE
# Writing Select.Rd
install()
# Output omitted
check()
# Some output omitted
# ── R CMD check results ─────────────────────────────── funImport 0.0.0.9000 ────
# Duration: 48.2s
#
# 0 errors ✔ | 0 warnings ✔ | 0 notes ✔
I was also able to use the function no problem:
library(funImport)
tbl <- tibble::tibble(x = 1:10, y = letters[1:10])
tbl
# # A tibble: 10 x 2
# x y
# <int> <chr>
# 1 1 a
# 2 2 b
# 3 3 c
# 4 4 d
# 5 5 e
# 6 6 f
# 7 7 g
# 8 8 h
# 9 9 i
# 10 10 j
Select(tbl, x)
# # A tibble: 10 x 1
# x
# <int>
# 1 1
# 2 2
# 3 3
# 4 4
# 5 5
# 6 6
# 7 7
# 8 8
# 9 9
# 10 10
I hate to add this because it is "Not an answer," and will update it to include an answer soon or remove it. However, I believe it may be helpful to demonstrate that OP's basic approach should work, so I created a minimal example package importing the apparent problem function.
First I set up the package structure:
library(devtools)
create_package("funImport", rstudio = FALSE)
use_package("dplyr")
use_gpl3_license("X")
I then added one file to R/
containing the following:
#' Select wrapper
#'
#' @param .data A tbl
#' @param ... Variable names to select
#'
#' @return The selected variables
#' @export
Select <- function(.data, ...)
return(select(.data, ...))
#' @importFrom dplyr select
NULL
I was then able to document()
, install()
and check()
no problem:
document()
# Updating funImport documentation
# Updating roxygen version in /home/jb/funImport/DESCRIPTION
# Writing NAMESPACE
# Loading funImport
# Writing NAMESPACE
# Writing Select.Rd
install()
# Output omitted
check()
# Some output omitted
# ── R CMD check results ─────────────────────────────── funImport 0.0.0.9000 ────
# Duration: 48.2s
#
# 0 errors ✔ | 0 warnings ✔ | 0 notes ✔
I was also able to use the function no problem:
library(funImport)
tbl <- tibble::tibble(x = 1:10, y = letters[1:10])
tbl
# # A tibble: 10 x 2
# x y
# <int> <chr>
# 1 1 a
# 2 2 b
# 3 3 c
# 4 4 d
# 5 5 e
# 6 6 f
# 7 7 g
# 8 8 h
# 9 9 i
# 10 10 j
Select(tbl, x)
# # A tibble: 10 x 1
# x
# <int>
# 1 1
# 2 2
# 3 3
# 4 4
# 5 5
# 6 6
# 7 7
# 8 8
# 9 9
# 10 10
edited Mar 23 at 12:04
answered Mar 23 at 12:02
duckmayrduckmayr
8,63311530
8,63311530
use_x
seem to have been moved tousethis
.
– NelsonGon
Mar 23 at 12:04
1
@NelsonGon Sure, but if you attachdevtools
, it also attachedusethis
– duckmayr
Mar 23 at 12:05
1
@NelsonGon See here: github.com/r-lib/devtools/blob/…
– duckmayr
Mar 23 at 12:06
add a comment |
use_x
seem to have been moved tousethis
.
– NelsonGon
Mar 23 at 12:04
1
@NelsonGon Sure, but if you attachdevtools
, it also attachedusethis
– duckmayr
Mar 23 at 12:05
1
@NelsonGon See here: github.com/r-lib/devtools/blob/…
– duckmayr
Mar 23 at 12:06
use_x
seem to have been moved to usethis
.– NelsonGon
Mar 23 at 12:04
use_x
seem to have been moved to usethis
.– NelsonGon
Mar 23 at 12:04
1
1
@NelsonGon Sure, but if you attach
devtools
, it also attached usethis
– duckmayr
Mar 23 at 12:05
@NelsonGon Sure, but if you attach
devtools
, it also attached usethis
– duckmayr
Mar 23 at 12:05
1
1
@NelsonGon See here: github.com/r-lib/devtools/blob/…
– duckmayr
Mar 23 at 12:06
@NelsonGon See here: github.com/r-lib/devtools/blob/…
– duckmayr
Mar 23 at 12:06
add a comment |
Created a dummy package to test and this works. You need to have your functions documented as shown below. Also, please have a way fo providing global binding for some variables in your functions.
#' Some paths
#' @description some paths
#' @param paths_original Some path
#' @importFrom dplyr select
#' @export
get_clear_df_paths <- function(paths_original)
clean_paths <- select(paths_original,
household_id = H_ID,
person_id = P_ID,
household_person_id = HP_ID,
weekday = ST_WOTAG,
month = ST_MONAT,
holiday = feiertag,
season = saison,
regular_job_related_path = W_RBW,
path_purpose = W_ZWECK,
starting_point = W_SO2,
start_time_hour = W_SZS,
start_time_min = W_SZM,
arrival_next_day = W_FOLGETAG,
arrival_time_hour = W_AZS,
arrival_time_min = W_AZM,
path_length = wegkm,
path_length_imp = wegkm_imp,
path_duration_min = wegmin,
path_duration_min_imp = wegmin_imp,
main_vehicle = hvm,
car_driver = pkw_fmf,
vehicle_car = W_VM_G,
vehicle_carsharing = W_VM_H,
district = stt_mun)
Steps:
library(devtools)
library(roxygen2)
create("SODummypkg")
document("SODummypkg")
check("SODummypkg")
Outcome: Ignore the warning(for purposes of this answer). At least the error doesn't show up.
-- R CMD check results ---------------------------------------------- SODummypkg 0.0.0.9000 ----
Duration: 1m 10.7s
> checking DESCRIPTION meta-information ... WARNING
Dependence on R version '3.5.3' not with patchlevel 0
0 errors √ | 1 warning x | 0 notes √
not sure how to use this to solve my problem... sorry if I missed something.
– Bagrat
Mar 23 at 13:14
1
@Bagrat Try to document one of your functions as shown here. Also document all your functions.
– NelsonGon
Mar 23 at 13:44
add a comment |
Created a dummy package to test and this works. You need to have your functions documented as shown below. Also, please have a way fo providing global binding for some variables in your functions.
#' Some paths
#' @description some paths
#' @param paths_original Some path
#' @importFrom dplyr select
#' @export
get_clear_df_paths <- function(paths_original)
clean_paths <- select(paths_original,
household_id = H_ID,
person_id = P_ID,
household_person_id = HP_ID,
weekday = ST_WOTAG,
month = ST_MONAT,
holiday = feiertag,
season = saison,
regular_job_related_path = W_RBW,
path_purpose = W_ZWECK,
starting_point = W_SO2,
start_time_hour = W_SZS,
start_time_min = W_SZM,
arrival_next_day = W_FOLGETAG,
arrival_time_hour = W_AZS,
arrival_time_min = W_AZM,
path_length = wegkm,
path_length_imp = wegkm_imp,
path_duration_min = wegmin,
path_duration_min_imp = wegmin_imp,
main_vehicle = hvm,
car_driver = pkw_fmf,
vehicle_car = W_VM_G,
vehicle_carsharing = W_VM_H,
district = stt_mun)
Steps:
library(devtools)
library(roxygen2)
create("SODummypkg")
document("SODummypkg")
check("SODummypkg")
Outcome: Ignore the warning(for purposes of this answer). At least the error doesn't show up.
-- R CMD check results ---------------------------------------------- SODummypkg 0.0.0.9000 ----
Duration: 1m 10.7s
> checking DESCRIPTION meta-information ... WARNING
Dependence on R version '3.5.3' not with patchlevel 0
0 errors √ | 1 warning x | 0 notes √
not sure how to use this to solve my problem... sorry if I missed something.
– Bagrat
Mar 23 at 13:14
1
@Bagrat Try to document one of your functions as shown here. Also document all your functions.
– NelsonGon
Mar 23 at 13:44
add a comment |
Created a dummy package to test and this works. You need to have your functions documented as shown below. Also, please have a way fo providing global binding for some variables in your functions.
#' Some paths
#' @description some paths
#' @param paths_original Some path
#' @importFrom dplyr select
#' @export
get_clear_df_paths <- function(paths_original)
clean_paths <- select(paths_original,
household_id = H_ID,
person_id = P_ID,
household_person_id = HP_ID,
weekday = ST_WOTAG,
month = ST_MONAT,
holiday = feiertag,
season = saison,
regular_job_related_path = W_RBW,
path_purpose = W_ZWECK,
starting_point = W_SO2,
start_time_hour = W_SZS,
start_time_min = W_SZM,
arrival_next_day = W_FOLGETAG,
arrival_time_hour = W_AZS,
arrival_time_min = W_AZM,
path_length = wegkm,
path_length_imp = wegkm_imp,
path_duration_min = wegmin,
path_duration_min_imp = wegmin_imp,
main_vehicle = hvm,
car_driver = pkw_fmf,
vehicle_car = W_VM_G,
vehicle_carsharing = W_VM_H,
district = stt_mun)
Steps:
library(devtools)
library(roxygen2)
create("SODummypkg")
document("SODummypkg")
check("SODummypkg")
Outcome: Ignore the warning(for purposes of this answer). At least the error doesn't show up.
-- R CMD check results ---------------------------------------------- SODummypkg 0.0.0.9000 ----
Duration: 1m 10.7s
> checking DESCRIPTION meta-information ... WARNING
Dependence on R version '3.5.3' not with patchlevel 0
0 errors √ | 1 warning x | 0 notes √
Created a dummy package to test and this works. You need to have your functions documented as shown below. Also, please have a way fo providing global binding for some variables in your functions.
#' Some paths
#' @description some paths
#' @param paths_original Some path
#' @importFrom dplyr select
#' @export
get_clear_df_paths <- function(paths_original)
clean_paths <- select(paths_original,
household_id = H_ID,
person_id = P_ID,
household_person_id = HP_ID,
weekday = ST_WOTAG,
month = ST_MONAT,
holiday = feiertag,
season = saison,
regular_job_related_path = W_RBW,
path_purpose = W_ZWECK,
starting_point = W_SO2,
start_time_hour = W_SZS,
start_time_min = W_SZM,
arrival_next_day = W_FOLGETAG,
arrival_time_hour = W_AZS,
arrival_time_min = W_AZM,
path_length = wegkm,
path_length_imp = wegkm_imp,
path_duration_min = wegmin,
path_duration_min_imp = wegmin_imp,
main_vehicle = hvm,
car_driver = pkw_fmf,
vehicle_car = W_VM_G,
vehicle_carsharing = W_VM_H,
district = stt_mun)
Steps:
library(devtools)
library(roxygen2)
create("SODummypkg")
document("SODummypkg")
check("SODummypkg")
Outcome: Ignore the warning(for purposes of this answer). At least the error doesn't show up.
-- R CMD check results ---------------------------------------------- SODummypkg 0.0.0.9000 ----
Duration: 1m 10.7s
> checking DESCRIPTION meta-information ... WARNING
Dependence on R version '3.5.3' not with patchlevel 0
0 errors √ | 1 warning x | 0 notes √
edited Mar 23 at 13:41
answered Mar 23 at 12:36
NelsonGonNelsonGon
4,8514934
4,8514934
not sure how to use this to solve my problem... sorry if I missed something.
– Bagrat
Mar 23 at 13:14
1
@Bagrat Try to document one of your functions as shown here. Also document all your functions.
– NelsonGon
Mar 23 at 13:44
add a comment |
not sure how to use this to solve my problem... sorry if I missed something.
– Bagrat
Mar 23 at 13:14
1
@Bagrat Try to document one of your functions as shown here. Also document all your functions.
– NelsonGon
Mar 23 at 13:44
not sure how to use this to solve my problem... sorry if I missed something.
– Bagrat
Mar 23 at 13:14
not sure how to use this to solve my problem... sorry if I missed something.
– Bagrat
Mar 23 at 13:14
1
1
@Bagrat Try to document one of your functions as shown here. Also document all your functions.
– NelsonGon
Mar 23 at 13:44
@Bagrat Try to document one of your functions as shown here. Also document all your functions.
– NelsonGon
Mar 23 at 13:44
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55312924%2fproblems-importing-functions-with-importfrom-pkg-fun%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Why not just use
dplyr::select
?– NelsonGon
Mar 23 at 11:25
1
Could you copy paste your code and add it to the question? Also add a GitHub or other link to the function?
– NelsonGon
Mar 23 at 11:32
1
@NelsonGon's latest comment it dead on: This is not reproducible as is. We cannot tell you where your problem is if we cannot see your code.
– duckmayr
Mar 23 at 11:33
1
This seems... bizarre. I have an easily mocked up minimal example showing that this approach should work. I have to imagine there's some outside factor we're not seeing. What versions of R, devtools, roxygen2, and dplyr do you have?
– duckmayr
Mar 23 at 11:46
1
I added the gist link to the OP... I yet don't have any documentation for the functions. but at this point, seems to me its kind of irrelevant, because I think I'm missing something R relevant, because I'm new to the language and package development...
– Bagrat
Mar 23 at 12:08