catcont包的说明书
- 格式:pdf
- 大小:82.15 KB
- 文档页数:7
Package‘catcont’
October12,2022
TitleTest,Identify,SelectandMutateCategoricalorContinuous
Values
Version0.5.0
Date2018-06-23
DescriptionMethodsandutilitiesfortesting,identifying,selectingand
mutatingobjectsascategoricalorcontinoustypes.Thesefunctionsworkonboth
atomicvectorsaswellasrecursiveobjects:data.frames,data.tables,
tibbles,lists,etc..
URLhttps://github.com/decisionpatterns/catcont
http://www.decisionpatterns.com
BugReportshttps://github.com/decisionpatterns/catcont/issues
DependsR(>=3.3.0)
Suggeststestthat,data.table(>=1.10.0)
Importsdplyr(>=0.7.0)
LicenseGPL-2|fileLICENSE
EncodingUTF-8
LazyDatatrue
RoxygenNote6.0.1.9000
RepositoryCRAN
NeedsCompilationno
AuthorChristopherBrown[aut,cre],
DecisionPatterns[cph]
MaintainerChristopherBrown<********************************>
Date/Publication2018-06-2507:43:03UTC
Rtopicsdocumented:
cat_cont...........................................2
mutate_if_cat........................................4
select_cat..........................................5
12cat_cont
Index7
cat_contcategoricalorcontinuousvariables
Description
Thesefunctionsfacilitateworkingwithvariablesascategoricalorcontinousratherthanlogical,
integer,numeric,factor,character,..
Usage
cat_cont(x)
is_cat(x)
##DefaultS3method:
is_cat(x)
##S3methodforclassordered
is_cat(x)
##S3methodforclassfactor
is_cat(x)
##S3methodforclasslogical
is_cat(x)
is_cont(x)
##DefaultS3method:
is_cont(x)
##S3methodforclasslogical
is_cont(x)
##S3methodforclassfactor
is_cont(x)
##S3methodforclassordered
is_cont(x)
which_cat(x,...,names=FALSE)
which_cont(x,...,names=FALSE)cat_cont3
Arguments
xobject
...argumentspassedtootherfunctions.
nameslogical;whethertoreturnthenamesofthevariablesinsteadoftheirindex?
Details
Thesefunctionsareusedtotestandidentifywhich/ifavariableorvariablesarecategoricalor
continuos.is_catandis_conttakesinglevariablearguments.
Mostly,thecategoricalandcontinuosassessmentisstraight-forward.Continuousvariablesare
respresentedbyinteger,doubleorcomplextypes.Allothertypesarecategorical.Therearea
fewopinionatedexceptions:
•factorsarecategorical(thoughtyped’integer’)
•orderedfactorsare(thoughtyped’integer’)
•logicalarecategorical
Forsimplicity,itisassumedthatavectorcannotbesimultaneouscategoricalandcontinous,though
insomecases(e.g.orderedfactors)thismaybethecase.
Value
cat_contreturnsanamedcharacterwithvalueseither"cat"or"cont".Ifxisaatomicvector,
asinglestringisgiven.Ifxisrecursive,a"cat"/"cont"valueisgivenforeachelement.Names
correspondtothenamesoftheelement.
is_catandis_contreturnlogical.
which_catandwhich.contreportwhichvariablesinanobjectarecategoricalandcontinuous.By
default,intergerindicesarereturn.Ifnames=TRUE,thenamesofthevariablesarereturnedinstead.
SeeAlso
•base::typeof()
•base::is.numeric()methods::is()
•base::which()
Examples
data(iris)cat_cont(iris)
is_cat(letters)#TRUEis_cat(factor(letters))#TRUEis_cat(TRUE)#TRUEis_cat(FALSE)#TRUEis_cat(1:10)#FALSEis_cat(rnorm(10))#FALSE4mutate_if_cat
is_cat(Sys.Date())#FALSEis_cat(complex(1,2))#FALSE
is_cont(letters)#FALSEis_cont(factor(letters))#FALSEis_cont(TRUE)#FALSEis_cont(FALSE)#FALSEis_cont(1:10)#TRUEis_cont(rnorm(10))#TRUEis_cont(Sys.Date())#TRUEis_cont(complex(1,2))#TRUE
which_cat(iris)which_cat(iris,names=TRUE)
which_cont(iris)which_cont(iris,names=TRUE)
mutate_if_catmutate_if_cat,mutate_if_cont
Description
mutatesonlycategorical|continuouscolumns
Usage
mutate_if_cat(.tbl,.funs,...)
##DefaultS3method:
mutate_if_cat(.tbl,.funs,...)
##S3methodforclassdata.table
mutate_if_cat(.tbl,.funs,...)
mutate_if_cont(.tbl,.funs,...)
##DefaultS3method:
mutate_if_cont(.tbl,.funs,...)
##S3methodforclassdata.table
mutate_if_cont(.tbl,.funs,...)
Arguments
.tbltable
.funsfunctionsseedplyr::mutate_if()
...additionalparametersselect_cat5
Details
Mutatescategoricalorcontinuouscolumns.
Thedata.tablevariantsdothisas
Value
Anobjectofclass.tblinwithcolumnsmutatedaccordingto.funs
SeeAlso
Similartodplyr::mutate_if()
Examples
data(iris)
##Notrun:iris%>%mutate_if_cat(as.character)
library(data.table)setDT(iris)class(iris$Species)iris%>%mutate_if_cat(as.character)class(iris1$Species)#characterclass(iris2)
iris%>%mutate_if_cont(add,2)
##End(Notrun)
select_catselect_cat,select_cont
Description
Selectcolumnsbytype
Usage
select_cat(.data)
##DefaultS3method:
select_cat(.data)
##S3methodforclassdata.table
select_cat(.data)