Closed randrescastaneda closed 1 year ago
Hi @tonyfujs ,
I Improved the functionalities of these features, following the recommendation of Hadley Wickham in here. It passed all the checks.
Best,
HI @tonyfujs ,
Thank you so much for your comment. I apologize for not including a more detailed explanation in my PR. I am planning to write a vignette about this feature, but for now, this is briefly how it works and the rational behind.
The main objective of display_aux()
is to show the user all the auxiliary tables available in pip and giving them the ability to download them by just clicking on their names (ala Stata). Given that, on the one hand, you need to bind any object to a name to keep it in the environment and, on the other, R CMD check
complains when you assign something to the global environment, I needed to find a way to make the object accessible to the user.
So, the solution was the following: I added the option assign_tb
to get_aux()
, which, If TRUE, assigns the requested auxiliary table to the .pip
environment. If FALSE, it behaves as usual. So, display_aux()
is just a wrapper around get_aux()
with assign_tb = TRUE
. Now, what I did not mention in my PR is that I added the function call_aux()
to call the tables in .pip
. In this way, you have the best of both words:
call_aux()
assign_tb
option and call_aux
are a powerful idea for developers who need to keep their environments clean.
library(pipr)
display_aux()
aux versions
countries
country coverage
country list
cpi
decomposition
dictionary
framework
gdp
incgrp coverage
indicators
interpolated means
missing data
pce
pop
pop region
poverty lines
ppp
region coverage
regions
survey means
display_aux() call
get_aux("gdp", assign_tb = TRUE, force = TRUE)
call_aux("gdp")
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
tb <- c("cpi", "ppp", "pop") lapply(tb, get_aux, assign_tb = TRUE, force = TRUE)
call_aux()
call_aux("pop")
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
<sup>Created on 2023-02-03 with [reprex v2.0.2](https://reprex.tidyverse.org)</sup>
Hi @tonyfujs ,
As agreed, I have updated the messages of display_aux()
and call_aux()
so that the user knows what to do and I have drafted a short vignette explaining how to use these new features and the .pip
env. Please, let me know if you have any question.
Best,
hi @tonyfujs ,
This functions is part of some of the features that are available in the Stata wrapper but are still not available in the R wrapper. Basically what what this does is that, instead of just displaying a data frame with the names of the auxiliary tables, it will display a clickable list that will retrieve the table that the user wants. The argument
assign_tb
isFALSE
by default, so it won't to anything to the .pip env but it is character orTRUE
it will create an object with the desired auxiliary table in the .pip env. We can talk about it in more detail next week. For now, the package is working as before. This addition does not modify in any sense the output or performance of theget_aux()
function.the .pip environment is hidden environment, child to the Global Env, in which we can store any pip object. I have several ideas of why this could extremely useful, specially for advanced users.
Best,