Learn R Programming

rgoogleclassroom (version 1.0.0)

extract_meta: Extract meta fields from a tag

Description

Extract meta fields from a tag

Usage

extract_meta(tags)

Value

A named vector indicating the field and entry associated with it.

Arguments

tags

A single tag or vector of tags to extract the fields from.

Examples

Run this code
if (FALSE) {

### Simple example
tag <- "{quiz, id: quiz_name_here, attempts: 10}"

# Extract metadata tags
meta <- extract_meta(tag)

### Example using a file
quiz_path <- good_quiz_path()
quiz_lines <- readLines(quiz_path)

# Put this in a data.frame so we can identify the content
quiz_df <- parse_quiz_df(quiz_lines)

# Extract the tags
tags <- quiz_df %>%
  dplyr::filter(type == "tag") %>%
  dplyr::pull("original")

# Extract metadata tags
meta <- extract_meta(tags)
}

Run the code above in your browser using DataLab