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.

tospongebob(x, ...)

# S3 method for array
tospongebob(x, ...)

# S3 method for factor
tospongebob(x, ...)

# S3 method for fortune
tospongebob(x, ...)

# S3 method for environment
tospongebob(x, ...)

# S3 method for function
tospongebob(x, ...)

# S3 method for ggplot
tospongebob(x, ...)

# S3 method for matrix
tospongebob(x, ...)

# S3 method for table
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

tospongebob("SpongeBob-Case Conversion")
#> [1] "sPOngEbob-CaSE cOnveRSioN"
tospongebob(c("S3 generic function", "Mocking SpongeBob case"))
#> [1] "S3 geNEric FuncTioN" "moCkiNg SPOnGEbob CASe"
tospongebob(packageDescription("base"))
#> PacKaGe: Base #> vERsioN: 3.5.2 #> PrIORiTY: bAse #> tiTLE: The r BAsE PaCKAgE #> aUThOR: r coRE teaM ANd ConTRIbUTOrs WORldWIDe #> mAIntaINEr: r CORe TEAm <r-cOre@R-prOJect.Org> #> deSCrIPtIoN: bASe r fUnCtIoNs. #> liCEnse: PaRt OF R 3.5.2 #> SUgGEsts: mEtHodS #> BUIlt: R 3.5.2; ; 2019-01-13 04:26:18 UTc; uNIx #> #> -- File: /usr/local/Cellar/r/3.5.2_2/lib/R/library/base/Meta/package.rds
df <- head(datasets::CO2) tospongebob(df)
#> plAnt TypE TReAtmeNT cOnC uPTaKe #> 1 QN1 QuEbEC nOnCHillED 95 16.0 #> 2 QN1 QuEbEC nOnCHillED 175 30.4 #> 3 QN1 QuEbEC nOnCHillED 250 34.8 #> 4 QN1 QuEbEC nOnCHillED 350 37.2 #> 5 QN1 QuEbEC nOnCHillED 500 35.3 #> 6 QN1 QuEbEC nOnCHillED 675 39.2
tospongebob(summary(df))
#> PlanT TYpE TReATmenT conC UpTaKE #> Qn1 :6 quEBEc :6 NoNCHilLEd:6 MIN. : 95.0 miN. :16.00 #> qN2 :0 MisSisSiPPi:0 ChILlED :0 1St qU.:193.8 1sT qu.:31.50 #> Qn3 :0 MEdiaN :300.0 meDIan :35.05 #> qc1 :0 meAn :340.8 MEAn :32.15 #> QC3 :0 3RD qU.:462.5 3Rd QU.:36.73 #> QC2 :0 MAx. :675.0 MaX. :39.20 #> (othEr):0
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)
#> $SPoNGeBOb #> $SPoNGeBOb$EpisOdes #> [1] "HELp WANtEd" "Reef BlOWeR" "tEa at ThE TReeDOmE" #> #> $SPoNGeBOb$chaRaCterS #> [1] "sPoNGEbob" "PAtRicK" "squIdwARD" "SAnDy" #> #> #> $HEy_ArnOld #> $HEy_ArnOld$ePIsODeS #> [1] "dOwnTOwN AS frUitS" "EuGENe'S biKe" #> #> $HEy_ArnOld$ChaRACtERs #> [1] "aRnOlD" "GeRaLd" "HelGa" #> #>