R functions (Q)

The list of new R functions introduced in this Research question lab component are below:

Function_name Package_name Use
as.data.frame base To force an object to a data frame
as.formula base/stats To specify a model formula, e.g., formula for an outcome model
confint base/stats To estimate the confidence interval for model parameters
degf survey To see the degrees of freedom for a survey design object
describe DescTools To see the summary statistics of variables
exp base Exponentials
glm base/stats To run generalized linear models
lapply base To apply a function over a list, e.g., to see the summary of a list of variables or to convert a list of categorical variables to factor variables. A similar function is `sapply`. lapply and sapply have the same functionality. The main difference is that sapply attempts to convert the result into a vector or matrix, while lapply returns a list.
length base To see the length of an object, e.g., number of elements/observations of a variable
plot_missing DataExplorer To plot the profile of missing values, e.g., the percentage of missing per variable
publish Publish To show/publish regression tables
Reduce base To combine multiple objects, e.g., datasets
round base To round numeric values
saveRDS base To save a single R object. Similarly, readDRS will read an R object
skim skimr To see the summary statistics of variables
svydesign survey To create a design for the survey data analysis
svyglm survey To run design-adjusted generalized linear models
unique base To see the number of unique elements
weights base/stats To extract model weights, e.g., see the weights from a pre-specified survey design

For more information, visit the resources mentioned earlier.