Basic skills in R: Installation, activation and use of R packages
Installing packages from Github
Various people in the world create a growing number of R packages and host them on Github. We present a simple example of using such packages: we install, activate and use the package
edatools
(EDA stands for Exploratory Data Analysis) created by Robert Kabacoff and hosted on Github.
> install.packages("remotes")
> remotes::install_github("rkabacoff/edatools") # install edatools from Github
This downloads the package from GitHub and installs it in your default R library. The package edatools
has one main function called contents()
that collects information about a data frame, and functions print()
and plot()
to display the results. See the example below.
> library(edatools) # activate edatools > df_info <- contents(happiness) # use edatools > print(df_info) Data frame: happiness 460 observations and 11 variables size: 0.1 Mb pos varname type n_unique n_miss pct_miss 1 ID* character 460 0 0.000 2 Date Date 12 0 0.000 3 Sex factor 2 0 0.000 4 Race factor 8 92 0.200 5 Age integer 73 46 0.100 6 Education factor 13 23 0.050 7 Income numeric 415 46 0.100 8 IQ numeric 45 322 0.700 9 Zip character 10 0 0.000 10 Children integer 11 0 0.000 11 Happy ordered 6 18 0.039 > plot(df_info)
Unlock full access