Nothing
knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(thinkr)
pattern by replacementScan a dataframe and return it with all occurencies of a pattern changed to replacement, keeping the same format.
dataset <- data.frame( col_a = as.factor(letters)[1:7], col_b = letters[1:7], col_c = 1:7, col_d = paste0(letters[1:7], letters[1:7]), stringsAsFactors = FALSE) # Show original dataset dataset # replace pattern replace_pattern(dataset, "a", 'XXX-')
Exact matching with argument exact
replace_pattern(dataset, "a", 'XXX-', exact = TRUE)
Test that the levels of a factor vec are all to be found in the character vector lev.
## returns TRUE because all levels of iris$species are in c("setosa", "versicolor", "virginica") is_likert(iris$Species, c("setosa", "versicolor", "virginica")) ## returns TRUE because all levels of iris$species are in c("setosa", "versicolor", "virginica", "banana"), even though there is actually no level "banana" # A message is printed is_likert(iris$Species, c("setosa", "versicolor", "virginica", "banana")) ## returns FALSE because the "virginica" level of iris$species is missing is_likert(iris$Species, c("setosa", "versicolor")) ## returns an error is_likert(iris$Species, c(1, 2)) ## returns no error as the numeric is coerced to a character. is_likert(iris$Species, c("setosa", 2))
Warnings: is-likert does not test whether the levels of
vecare a likert scale as in psychometry. See https://en.wikipedia.org/wiki/Likert_scale for example.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.