You may work in groups of 2 or 3 for this assignment. You task is to create an R package with the following elements/features:
The package must be maintained on github and installable with
devtools::install_github(<account>/<package>)
where <account>
is a github user account and <package>
is the name of your package.
In particular, the package name and github repo name should be the same. (That’s a pretty standard convention in the R community.)
You will submit your assignment by filling out this form which will ask you for the names of your team members, the account name, and your package name.
Be sure to test that installation with devtools::install_github()
does indeed work.
Use informative commit messages.
You can avoid merge messes if you (a) stay in good communication with your team mates and (b) commit/push/pull frequently.
You may either add all team members as collaborators or use pull requests to combine work from different people. Your choice.
Your package must include a function called df_apply()
.
The argument list of this function should be df_apply(.data, .f, .condition, .else, ...)
where
.data
– a data frame (or ?? are there are things that could work here? Be sure to document.).f
– a function.condition
– a function – the default should TRUE for numeric columns and false for other columns.else
– a function to apply when .condition()
evaluates to FALSE – what should the default value be?...
– additional arguments that will be passed to .f()
df_apply()
should apply the function .f()
to each column of .data
for which .condition(column)
evaluates to TRUE and the function .else()
to the other columns.
See these slides for more details about writing such a function.
Your package must include the data used in your plotly projects.
The raw data should be located in data-raw/
in some format that is easy to read into R (csv, Excel, etc.), along with an R script that reads in the data and does any post-processing you need.
Use usethis::use_data()
Turn each of your plotly presentations into a package vignette.
Use usethis::use_vignette()
or usethis::use_article()
to get things started. That will put things in the right place, make necessary edits to DESCRIPTION
, and make some changes to your .gitignore
.
Feel free to make modifications to your plotly presentations if you like. It doesn’t need to be an exact copy.
Often package vignettes are used to show how to do something in R, so include a version that shows your R code or has a way to toggle this.
Everything in your package must be appropriately documented using roxygen2
.
Be sure to include an examples section for your function and for your data sets.
The examples section for the data sets might show one plot you can make from your data set or create some interesting numerical summary, or something like that.
The examples section for df_apply()
should show several interesting applications of the function. To do this, you will need some data frames. You can either use the data sets already in your package (from your plotly projects) or add additional data sets to the package that are useful for demonstrating df_apply()
.
Any time you use a function from another package…
Be sure to fully specify it with ::
This is good practice because it avoids possible ambiguity when multiple packages use the same names and it helps with code maintenance.
Be sure to include the appropriate import statement with
#` @importFrom
This does not apply to vignettes or examples where you might use library()
or if (require())
to indicate the packages needed. But do not include either of those in package code.
Be sure to include unit tests for df_apply()
.
Among your tests, includes tests to make sure that you can do things like in exerise 21.9.3.3 of R for Data Science. Note: the context in the exercise is slightly different because it refers to a more specific funciton – one that produces column summaries. But you should be able to create column summaries using df_apply()
as well. (This might be good to include as an example in your documentation as well.)
What other things should you test?
Your package should pass devtools::check()
without errors** (and without unnecessary warnings).
devtools::check()
using a button in the Build tab in RStudio.Create a {pkgdown} site for you package hosted at https://account.github.io/package
.
usethis::use_pkgdown()
or use_pkgdown_github_pages()
helpful.Use Github’s issue tracking to manage your work.
Issues are very helpful for bigger or longer-term projects, so it is good to learn how they work.
You don’t have to go crazy here, but you should have at least one issue assigned to each team member.
Note: if you include #1
in your commit message, your commit will be linked to issue 1 (etc for other issues) when you push to github.
Note: If you inlcude Closes #1
in your commit message, the issue will be closed when you push your commit to github.