Learn R Programming

spongebob (version 0.4.0)

tospongebob: SpongeBob-Case Conversion : sPOngEBOb-CasE cOnVErsIoN

Description

tospongebob is an S3 generic function for converting text in R objects to Mocking SpongeBob case. The core method for character vectors will return the input character vector with case-converted elements. For other objects, it will attempt to appropriately find text and convert them.

tospongebob IS an S3 gENErIC FunCtIoN fOR cOnveRtIng Text IN r obJEcts To MocKinG SpOnGEbob CasE. tHe cOrE MEtHOd FoR CharActEr VECtorS wIll RetURN tHe INPuT chARaCTer VEcTOr WItH cASe-cONVeRTed ELeMenTS. foR oThER objECTs, iT wIlL aTtemPT tO APprOPrIAtELy fInd tEXt aNd cONvERT tHEm.

Usage

tospongebob(x, ...)

Arguments

x

object with text to be converted to Mocking SpongeBob case.

...

onlY hERe tO sATisFy R CMd CHeCk.

Value

object with its text converted to Mocking SpongeBob case. ObjECt WiTH iTS tEXt CONvErTeD TO mOCkinG SponGEBob CasE.

Details

This section describes the (non-exported) S3 methods in more detail.

The core tospongebob.character method takes an input character vector and returns the same vector with its elements converted to Mocking SpongeBob case. Names of the vector are also converted unless parameter convert.names = FALSE. This method is then leveraged by all other methods.

The default tospongebob.default method will iterate through any elements of list-like objects and attempt to convert those. It will also convert the names of the object unless parameter convert.names = FALSE. NULL values are passed through as NULL.

Additional S3 methods for the following classes have been implemented:

tospongebob.array

: convert data and dimnames of an array

tospongebob.data.frame

: convert row names, column names, and convertible columns of a data.frame

tospongebob.environment

: create a copy of an environment with its objects converted

tospongebob.factor

: convert levels of factor vectors

tospongebob.fortune

: convert the content of a fortunes::fortune object

tospongebob.function

: deparse function into a character vector, convert, and then combine into one string block

tospongebob.ggplot

: convert text labels in ggplot2::ggplot object

matrix

: convert data and dimnames of a matrix

tospongebob.table

: convert data and dimnames of a table

Examples

Run this code
# NOT RUN {
tospongebob("SpongeBob-Case Conversion")
tospongebob(c("S3 generic function", "Mocking SpongeBob case"))

tospongebob(packageDescription("base"))

df <- head(datasets::CO2)
tospongebob(df)

tospongebob(summary(df))

nicktoons <- list(
    spongebob = list(
        episodes = c("Help Wanted", "Reef Blower", "Tea at the Treedome"),
        characters = c("SpongeBob", "Patrick", "Squidward", "Sandy")
    ),
    hey_arnold = list(
        episodes = c("Downtown as Fruits", "Eugene's Bike"),
        characters = c("Arnold", "Gerald", "Helga")
    )
)
tospongebob(nicktoons)
# }

Run the code above in your browser using DataLab