Learn R Programming

metatools (version 0.2.0)

drop_unspec_vars: Drop Unspecified Variables

Description

This function drops all unspecified variables. It will throw and error if the dataset does not contain all expected variables.

Usage

drop_unspec_vars(dataset, metacore, dataset_name = deprecated())

Value

Dataset with only specified columns

Arguments

dataset

Dataset to change

metacore

metacore object that only contains the specifications for the dataset of interest.

dataset_name

[Deprecated] Optional string to specify the dataset. This is only needed if the metacore object provided hasn't already been subsetted.
Note: Deprecated in version 0.2.0. The dataset_name argument will be removed in a future release. Please use metacore::select_dataset to subset the metacore object to obtain metadata for a single dataset.

Examples

Run this code
library(metacore)
library(haven)
library(dplyr)
load(metacore_example("pilot_ADaM.rda"))
spec <- metacore %>% select_dataset("ADSL")
data <- read_xpt(metatools_example("adsl.xpt")) %>%
  select(USUBJID, SITEID) %>%
  mutate(foo = "Hello")
drop_unspec_vars(data, spec)

Run the code above in your browser using DataLab