mteb/BrightProStackoverflowRetrieval huggingface dataset:
[ RDocumentation ](/)

Moon  [ ](https://github.com/datacamp/rdocumentation-2.0) [ Learn R
](https://www.datacamp.com/learn/r)

Search all packages and functions

[ base  (version  3.6.2  ) ](/packages/base/versions/3.6.2)

#  format.info: format(.) Information

##  Description

Information is returned on how ` [ format
](/link/format?package=base&version=3.6.2) (x, digits, nsmall) ` would be
formatted.

##  Usage

    
    
    format.info(x, digits = NULL, nsmall = 0)

##  Arguments

x

an atomic vector; a potential argument of ` [ format
](/link/format?package=base&version=3.6.2) (x, …) ` .

digits

how many significant digits are to be used for numeric and complex ` x ` . The
default, ` NULL ` , uses ` [ getOption
](/link/getOption?package=base&version=3.6.2) ("digits") ` .

nsmall

(see ` [ format ](/link/format?package=base&version=3.6.2) (…, nsmall) ` ).

##  Value

An ` [ integer ](/link/integer?package=base&version=3.6.2) ` ` [ vector
](/link/vector?package=base&version=3.6.2) ` of length 1, 3 or 6, say ` r ` .

For logical, integer and character vectors a single element, the width which
would be used by ` format ` if ` width = NULL ` .

For numeric vectors:

r[1]

    

width (in characters) used by ` format(x) `

r[2]

    

number of digits after decimal point.

r[3]

    

in ` 0:2 ` ; if \\(\ge\\) ` 1 ` , _exponential_ representation would be used,
with exponent length of ` r[3]+1 ` .

For a complex vector the first three elements refer to the real parts, and
there are three further elements corresponding to the imaginary parts.

##  See Also

` [ format ](/link/format?package=base&version=3.6.2) ` (notably about `
digits >= 16 ` ), ` [ formatC ](/link/formatC?package=base&version=3.6.2) ` .

##  Examples

[ Run this code
](https://app.datacamp.com/workspace/preview?_tag=rdocs&rdocsPath=packages%2Fbase%2Fversions%2F3.6.2%2Ftopics%2Fformat.info&utm_source=r-docs&utm_medium=docs&utm_term=format.info&utm_content=run_example_in_workspace)

    
    
    # NOT RUN {
    dd <- options("digits") ; options(digits = 7) #-- for the following
    format.info(123)   # 3 0 0
    format.info(pi)    # 8 6 0
    format.info(1e8)   # 5 0 1 - exponential "1e+08"
    format.info(1e222) # 6 0 2 - exponential "1e+222"
    
    x <- pi*10^c(-10,-2,0:2,8,20)
    names(x) <- formatC(x, width = 1, digits = 3, format = "g")
    cbind(sapply(x, format))
    t(sapply(x, format.info))
    
    ## using at least 8 digits right of "."
    t(sapply(x, format.info, nsmall = 8))
    
    # Reset old options:
    options(dd)
    # }
    

Run the code above in your browser using  [ DataCamp Workspace
](https://app.datacamp.com/workspace/preview?_tag=rdocs&rdocsPath=packages%2Fbase%2Fversions%2F3.6.2%2Ftopics%2Fformat.info&utm_source=r-docs&utm_medium=docs&utm_term=format.info&utm_content=run_example_in_workspace)

Powered by  [ DataCamp ](https://www.datacamp.com/)
[ RDocumentation ](/)

Moon  [ ](https://github.com/datacamp/rdocumentation-2.0) [ Learn R
](https://www.datacamp.com/learn/r)

Search all packages and functions

[ base  (version  3.6.2  ) ](/packages/base/versions/3.6.2)

#  startsWith: Does String Start or End With Another String?

##  Description

Determines if entries of ` x ` start or end with string (entries of) ` prefix
` or ` suffix ` respectively, where strings are recycled to common lengths.

` startsWith() ` is equivalent to but much faster than

    
    
    substring(x, 1, nchar(prefix)) == prefix

or also

    
    
    grepl("^<prefix>", x)

where ` prefix ` is not to contain special regular expression characters.

##  Usage

    
    
    startsWith(x, prefix)
      endsWith(x, suffix)

##  Arguments

x

vector of ` [ character ](/link/character?package=base&version=3.6.2) ` string
whose “starts” are considered.

prefix, suffix

` [ character ](/link/character?package=base&version=3.6.2) ` vector (often of
length one).

##  Value

A ` [ logical ](/link/logical?package=base&version=3.6.2) ` vector, of “common
length” of ` x ` and ` prefix ` (or ` suffix ` ), i.e., of the longer of the
two lengths unless one of them is zero when the result is also of zero length.
A shorter input is recycled to the output length.

##  Details

The code has an optimized branch for the most common usage in which ` prefix `
or ` suffix ` is of length one, and is further optimized in a UTF-8 or 8-byte
locale if that is an ASCII string.

##  See Also

` [ grepl ](/link/grepl?package=base&version=3.6.2) ` , ` [ substring
](/link/substring?package=base&version=3.6.2) ` ; the partial string matching
functions ` [ charmatch ](/link/charmatch?package=base&version=3.6.2) ` and `
[ pmatch ](/link/pmatch?package=base&version=3.6.2) ` solve a different task.

##  Examples

[ Run this code
](https://app.datacamp.com/workspace/preview?_tag=rdocs&rdocsPath=packages%2Fbase%2Fversions%2F3.6.2%2Ftopics%2FstartsWith&utm_source=r-docs&utm_medium=docs&utm_term=startsWith&utm_content=run_example_in_workspace)

    
    
    # NOT RUN {
    startsWith(search(), "package:") # typically at least two FALSE, nowadays often three
    
    x1 <- c("Foobar", "bla bla", "something", "another", "blu", "brown",
            "blau bl<U+00FC>ht der Enzian")# non-ASCII
    x2 <- cbind(
          startsWith(x1, "b"),
          startsWith(x1, "bl"),
          startsWith(x1, "bla"),
            endsWith(x1, "n"),
            endsWith(x1, "an"))
    rownames(x2) <- x1; colnames(x2) <- c("b", "b1", "bla", "n", "an")
    x2
    # }
    

Run the code above in your browser using  [ DataCamp Workspace
](https://app.datacamp.com/workspace/preview?_tag=rdocs&rdocsPath=packages%2Fbase%2Fversions%2F3.6.2%2Ftopics%2FstartsWith&utm_source=r-docs&utm_medium=docs&utm_term=startsWith&utm_content=run_example_in_workspace)

Powered by  [ DataCamp ](https://www.datacamp.com/)
[ RDocumentation ](/)

Moon  [ ](https://github.com/datacamp/rdocumentation-2.0) [ Learn R
](https://www.datacamp.com/learn/r)

Search all packages and functions

[ base  (version  3.6.2  ) ](/packages/base/versions/3.6.2)

#  mean: Arithmetic Mean

##  Description

Generic function for the (trimmed) arithmetic mean.

##  Usage

    
    
    mean(x, …)
    
    # S3 method for default
    mean(x, trim = 0, na.rm = FALSE, …)

##  Arguments

x

An  R  object. Currently there are methods for numeric/logical vectors and [
date ](/link/date?package=base&version=3.6.2&to=%3DDates) , [ date-time
](/link/date-time?package=base&version=3.6.2) and [ time interval
](/link/time%20interval?package=base&version=3.6.2) objects. Complex vectors
are allowed for ` trim = 0 ` , only.

trim

the fraction (0 to 0.5) of observations to be trimmed from each end of ` x `
before the mean is computed. Values of trim outside that range are taken as
the nearest endpoint.

na.rm

a logical value indicating whether ` NA ` values should be stripped before the
computation proceeds.

…

further arguments passed to or from other methods.

##  Value

If ` trim ` is zero (the default), the arithmetic mean of the values in ` x `
is computed, as a numeric or complex vector of length one. If ` x ` is not
logical (coerced to numeric), numeric (including integer) or complex, `
NA_real_ ` is returned, with a warning.

If ` trim ` is non-zero, a symmetrically trimmed mean is computed with a
fraction of ` trim ` observations deleted from each end before the mean is
computed.

##  References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S Language_ .
Wadsworth & Brooks/Cole.

##  See Also

` [ weighted.mean ](/link/weighted.mean?package=base&version=3.6.2) ` , ` [
mean.POSIXct ](/link/mean.POSIXct?package=base&version=3.6.2) ` , ` [ colMeans
](/link/colMeans?package=base&version=3.6.2) ` for row and column means.

##  Examples

[ Run this code
](https://app.datacamp.com/workspace/preview?_tag=rdocs&rdocsPath=packages%2Fbase%2Fversions%2F3.6.2%2Ftopics%2Fmean&utm_source=r-docs&utm_medium=docs&utm_term=mean&utm_content=run_example_in_workspace)

    
    
    # NOT RUN {
    x <- c(0:10, 50)
    xm <- mean(x)
    c(xm, mean(x, trim = 0.10))
    # }
    

Run the code above in your browser using  [ DataCamp Workspace
](https://app.datacamp.com/workspace/preview?_tag=rdocs&rdocsPath=packages%2Fbase%2Fversions%2F3.6.2%2Ftopics%2Fmean&utm_source=r-docs&utm_medium=docs&utm_term=mean&utm_content=run_example_in_workspace)

Powered by  [ DataCamp ](https://www.datacamp.com/)
[ RDocumentation ](/)

Moon  [ ](https://github.com/datacamp/rdocumentation-2.0) [ Learn R
](https://www.datacamp.com/learn/r)

Search all packages and functions

[ base  (version  3.6.2  ) ](/packages/base/versions/3.6.2)

#  prod: Product of Vector Elements

##  Description

` prod ` returns the product of all the values present in its arguments.

##  Usage

    
    
    prod(…, na.rm = FALSE)

##  Arguments

…

numeric or complex or logical vectors.

na.rm

logical. Should missing values be removed?

##  Value

The product, a numeric (of type ` "double" ` ) or complex vector of length
one. **NB:** the product of an empty set is one, by definition.

##  S4 methods

This is part of the S4 ` [ Summary
](/link/Summary?package=base&version=3.6.2&to=%3DS4groupGeneric) ` group
generic. Methods for it must use the signature ` x, …, na.rm ` .

##  Details

If ` na.rm ` is ` FALSE ` an ` NA ` value in any of the arguments will cause a
value of ` NA ` to be returned, otherwise ` NA ` values are ignored.

This is a generic function: methods can be defined for it directly or via the
` [ Summary ](/link/Summary?package=base&version=3.6.2&to=%3DS3groupGeneric) `
group generic. For this to work properly, the arguments ` … ` should be
unnamed, and dispatch is on the first argument.

Logical true values are regarded as one, false values as zero. For historical
reasons, ` NULL ` is accepted and treated as if it were ` numeric(0) ` .

##  References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S Language_ .
Wadsworth & Brooks/Cole.

##  See Also

` [ sum ](/link/sum?package=base&version=3.6.2) ` , ` [ cumprod
](/link/cumprod?package=base&version=3.6.2) ` , ` [ cumsum
](/link/cumsum?package=base&version=3.6.2) ` .

‘ [ plotmath ](/link/plotmath?package=base&version=3.6.2) ’ for the use of `
prod ` in plot annotation.

##  Examples

[ Run this code
](https://app.datacamp.com/workspace/preview?_tag=rdocs&rdocsPath=packages%2Fbase%2Fversions%2F3.6.2%2Ftopics%2Fprod&utm_source=r-docs&utm_medium=docs&utm_term=prod&utm_content=run_example_in_workspace)

    
    
    # NOT RUN {
    print(prod(1:7)) == print(gamma(8))
    # }
    

Run the code above in your browser using  [ DataCamp Workspace
](https://app.datacamp.com/workspace/preview?_tag=rdocs&rdocsPath=packages%2Fbase%2Fversions%2F3.6.2%2Ftopics%2Fprod&utm_source=r-docs&utm_medium=docs&utm_term=prod&utm_content=run_example_in_workspace)

Powered by  [ DataCamp ](https://www.datacamp.com/)
[ RDocumentation ](/)

Moon  [ ](https://github.com/datacamp/rdocumentation-2.0) [ Learn R
](https://www.datacamp.com/learn/r)

Search all packages and functions

[ base  (version  3.6.2  ) ](/packages/base/versions/3.6.2)

#  write: Write Data to a File

##  Description

The data (usually a matrix) ` x ` are written to file ` file ` . If ` x ` is a
two-dimensional matrix you need to transpose it to get the columns in ` file `
the same as those in the internal representation.

##  Usage

    
    
    write(x, file = "data",
          ncolumns = if(is.character(x)) 1 else 5,
          append = FALSE, sep = " ")

##  Arguments

x

the data to be written out, usually an atomic vector.

file

a ` [ connection ](/link/connection?package=base&version=3.6.2) ` , or a
character string naming the file to write to. If ` "" ` , print to the
standard output connection.

When ` [ .Platform ](/link/.Platform?package=base&version=3.6.2) $OS.type !=
"windows" ` , and it is ` "|cmd" ` , the output is piped to the command given
by ` cmd ` .

ncolumns

the number of columns to write the data in.

append

if ` TRUE ` the data ` x ` are appended to the connection.

sep

a string used to separate columns. Using ` sep = "\t" ` gives tab delimited
output; default is ` " " ` .

##  References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S Language_ .
Wadsworth & Brooks/Cole.

##  See Also

` write ` is a wrapper for ` [ cat ](/link/cat?package=base&version=3.6.2) ` ,
which gives further details on the format used.

` [ save ](/link/save?package=base&version=3.6.2) ` for writing any  R
objects, ` [ write.table ](/link/write.table?package=base&version=3.6.2) ` for
data frames, and ` [ scan ](/link/scan?package=base&version=3.6.2) ` for
reading data.

##  Examples

[ Run this code
](https://app.datacamp.com/workspace/preview?_tag=rdocs&rdocsPath=packages%2Fbase%2Fversions%2F3.6.2%2Ftopics%2Fwrite&utm_source=r-docs&utm_medium=docs&utm_term=write&utm_content=run_example_in_workspace)

    
    
    # NOT RUN {
    # create a 2 by 5 matrix
    x <- matrix(1:10, ncol = 5)
    
    fil <- tempfile("data")
    # the file data contains x, two rows, five cols
    # 1 3 5 7 9 will form the first row
    write(t(x), fil)
    if(interactive()) file.show(fil)
    unlink(fil) # tidy up
    
    # Writing to the "console" 'tab-delimited'
    # two rows, five cols but the first row is 1 2 3 4 5
    write(x, "", sep = "\t")
    # }
    

Run the code above in your browser using  [ DataCamp Workspace
](https://app.datacamp.com/workspace/preview?_tag=rdocs&rdocsPath=packages%2Fbase%2Fversions%2F3.6.2%2Ftopics%2Fwrite&utm_source=r-docs&utm_medium=docs&utm_term=write&utm_content=run_example_in_workspace)

Powered by  [ DataCamp ](https://www.datacamp.com/)
[ RDocumentation ](/)

Moon  [ ](https://github.com/datacamp/rdocumentation-2.0) [ Learn R
](https://www.datacamp.com/learn/r)

Search all packages and functions

[ base  (version  3.6.2  ) ](/packages/base/versions/3.6.2)

#  droplevels: Drop Unused Levels from Factors

##  Description

The function ` droplevels ` is used to drop unused levels from a ` [ factor
](/link/factor?package=base&version=3.6.2) ` or, more commonly, from factors
in a data frame.

##  Usage

    
    
    # S3 method for factor
    droplevels(x, exclude = if(anyNA(levels(x))) NULL else NA, …)
    # S3 method for data.frame
    droplevels(x, except, exclude, …)

##  Arguments

x

an object from which to drop unused factor levels.

exclude

passed to ` [ factor ](/link/factor?package=base&version=3.6.2) () ` ; factor
levels which should be excluded from the result even if present. Note that
this was _implicitly_ ` NA ` in  R  <= 3.3.1 which did drop ` NA ` levels even
when present in ` x ` , contrary to the documentation. The current default is
compatible with ` x[ , drop=TRUE] ` .

…

further arguments passed to methods

except

indices of columns from which _not_ to drop levels

##  Value

` droplevels ` returns an object of the same class as ` x `

##  Details

The method for class ` "factor" ` is currently equivalent to ` factor(x,
exclude=exclude) ` . For the data frame method, you should rarely specify `
exclude ` “globally” for all factor columns; rather the default uses the same
factor-specific ` exclude ` as the factor method itself.

The ` except ` argument follow the usual indexing rules.

##  See Also

` [ subset ](/link/subset?package=base&version=3.6.2) ` for subsetting data
frames. ` [ factor ](/link/factor?package=base&version=3.6.2) ` for definition
of factors. ` [ drop ](/link/drop?package=base&version=3.6.2) ` for dropping
array dimensions. ` [ drop1 ](/link/drop1?package=base&version=3.6.2) ` for
dropping terms from a model. ` [ [.factor
](/link/%5B.factor?package=base&version=3.6.2) ` for subsetting of factors.

##  Examples

[ Run this code
](https://app.datacamp.com/workspace/preview?_tag=rdocs&rdocsPath=packages%2Fbase%2Fversions%2F3.6.2%2Ftopics%2Fdroplevels&utm_source=r-docs&utm_medium=docs&utm_term=droplevels&utm_content=run_example_in_workspace)

    
    
    # NOT RUN {
    aq <- transform(airquality, Month = factor(Month, labels = month.abb[5:9]))
    aq <- subset(aq, Month != "Jul")
    table(           aq $Month)
    table(droplevels(aq)$Month)
    # }
    

Run the code above in your browser using  [ DataCamp Workspace
](https://app.datacamp.com/workspace/preview?_tag=rdocs&rdocsPath=packages%2Fbase%2Fversions%2F3.6.2%2Ftopics%2Fdroplevels&utm_source=r-docs&utm_medium=docs&utm_term=droplevels&utm_content=run_example_in_workspace)

Powered by  [ DataCamp ](https://www.datacamp.com/)
[ RDocumentation ](/)

Moon  [ ](https://github.com/datacamp/rdocumentation-2.0) [ Learn R
](https://www.datacamp.com/learn/r)

Search all packages and functions

[ base  (version  3.6.2  ) ](/packages/base/versions/3.6.2)

#  diff: Lagged Differences

##  Description

Returns suitably lagged and iterated differences.

##  Usage

    
    
    diff(x, …)
    
    # S3 method for default
    diff(x, lag = 1, differences = 1, …)
    
    # S3 method for POSIXt
    diff(x, lag = 1, differences = 1, …)
    
    # S3 method for Date
    diff(x, lag = 1, differences = 1, …)

##  Arguments

x

a numeric vector or matrix containing the values to be differenced.

lag

an integer indicating which lag to use.

differences

an integer indicating the order of the difference.

…

further arguments to be passed to or from methods.

##  Value

If ` x ` is a vector of length ` n ` and ` differences = 1 ` , then the
computed result is equal to the successive differences ` x[(1+lag):n] -
x[1:(n-lag)] ` .

If ` difference ` is larger than one this algorithm is applied recursively to
` x ` . Note that the returned value is a vector which is shorter than ` x ` .

If ` x ` is a matrix then the difference operations are carried out on each
column separately.

##  Details

` diff ` is a generic function with a default method and ones for classes ` "
[ ts ](/link/ts?package=base&version=3.6.2) " ` , ` " [ POSIXt
](/link/POSIXt?package=base&version=3.6.2) " ` and ` " [ Date
](/link/Date?package=base&version=3.6.2) " ` .

` [ NA ](/link/NA?package=base&version=3.6.2) ` 's propagate.

##  References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S Language_ .
Wadsworth & Brooks/Cole.

##  See Also

` [ diff.ts ](/link/diff.ts?package=base&version=3.6.2) ` , ` [ diffinv
](/link/diffinv?package=base&version=3.6.2) ` .

##  Examples

[ Run this code
](https://app.datacamp.com/workspace/preview?_tag=rdocs&rdocsPath=packages%2Fbase%2Fversions%2F3.6.2%2Ftopics%2Fdiff&utm_source=r-docs&utm_medium=docs&utm_term=diff&utm_content=run_example_in_workspace)

    
    
    # NOT RUN {
    diff(1:10, 2)
    diff(1:10, 2, 2)
    x <- cumsum(cumsum(1:10))
    diff(x, lag = 2)
    diff(x, differences = 2)
    
    diff(.leap.seconds)
    # }
    

Run the code above in your browser using  [ DataCamp Workspace
](https://app.datacamp.com/workspace/preview?_tag=rdocs&rdocsPath=packages%2Fbase%2Fversions%2F3.6.2%2Ftopics%2Fdiff&utm_source=r-docs&utm_medium=docs&utm_term=diff&utm_content=run_example_in_workspace)

Powered by  [ DataCamp ](https://www.datacamp.com/)
[ RDocumentation ](/)

Moon  [ ](https://github.com/datacamp/rdocumentation-2.0) [ Learn R
](https://www.datacamp.com/learn/r)

Search all packages and functions

[ base  (version  3.6.2  ) ](/packages/base/versions/3.6.2)

#  name: Names and Symbols

##  Description

A ‘name’ (also known as a ‘symbol’) is a way to refer to  R  objects by name
(rather than the value of the object, if any, bound to that name).

` as.name ` and ` as.symbol ` are identical: they attempt to coerce the
argument to a name.

` is.symbol ` and the identical ` is.name ` return ` TRUE ` or ` FALSE `
depending on whether the argument is a name or not.

##  Usage

    
    
    as.symbol(x)
    is.symbol(x)
    
    as.name(x)
    is.name(x)

##  Arguments

x

object to be coerced or tested.

##  Value

For ` as.name ` and ` as.symbol ` , an  R  object of type ` "symbol" ` (see `
[ typeof ](/link/typeof?package=base&version=3.6.2) ` ).

For ` is.name ` and ` is.symbol ` , a length-one logical vector with value `
TRUE ` or ` FALSE ` .

##  Details

Names are limited to 10,000 bytes (and were to 256 bytes in versions of  R
before 2.13.0).

` as.name ` first coerces its argument internally to a character vector (so
methods for ` as.character ` are not used). It then takes the first element
and provided it is not ` "" ` , returns a symbol of that name (and if the
element is ` NA_character_ ` , the name is ` `NA` ` ).

` as.name ` is implemented as ` [ as.vector
](/link/as.vector?package=base&version=3.6.2) (x, "symbol") ` , and hence will
dispatch methods for the generic function ` as.vector ` .

` is.name ` and ` is.symbol ` are [ primitive
](/link/primitive?package=base&version=3.6.2) functions.

##  References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S Language_ .
Wadsworth & Brooks/Cole.

##  See Also

` [ call ](/link/call?package=base&version=3.6.2) ` , ` [ is.language
](/link/is.language?package=base&version=3.6.2) ` . For the internal object
mode, ` [ typeof ](/link/typeof?package=base&version=3.6.2) ` .

` [ plotmath ](/link/plotmath?package=base&version=3.6.2) ` for another use of
‘symbol’.

##  Examples

[ Run this code
](https://app.datacamp.com/workspace/preview?_tag=rdocs&rdocsPath=packages%2Fbase%2Fversions%2F3.6.2%2Ftopics%2Fname&utm_source=r-docs&utm_medium=docs&utm_term=name&utm_content=run_example_in_workspace)

    
    
    # NOT RUN {
    an <- as.name("arrg")
    is.name(an) # TRUE
    mode(an)   # name
    typeof(an) # symbol
    # }
    

Run the code above in your browser using  [ DataCamp Workspace
](https://app.datacamp.com/workspace/preview?_tag=rdocs&rdocsPath=packages%2Fbase%2Fversions%2F3.6.2%2Ftopics%2Fname&utm_source=r-docs&utm_medium=docs&utm_term=name&utm_content=run_example_in_workspace)

Powered by  [ DataCamp ](https://www.datacamp.com/)
[ RDocumentation ](/)

Moon  [ ](https://github.com/datacamp/rdocumentation-2.0) [ Learn R
](https://www.datacamp.com/learn/r)

Search all packages and functions

[ base  (version  3.6.2  ) ](/packages/base/versions/3.6.2)

#  xtfrm: Auxiliary Function for Sorting and Ranking

##  Description

A generic auxiliary function that produces a numeric vector which will sort in
the same order as ` x ` .

##  Usage

    
    
    xtfrm(x)

##  Arguments

x

an  R  object.

##  Value

A numeric (usually integer) vector of the same length as ` x ` .

##  Details

This is a special case of ranking, but as a less general function than ` [
rank ](/link/rank?package=base&version=3.6.2) ` is more suitable to be made
generic. The default method is similar to ` rank(x, ties.method = "min",
na.last = "keep") ` , so ` NA ` values are given rank ` NA ` and all tied
values are given equal integer rank.

The ` [ factor ](/link/factor?package=base&version=3.6.2) ` method extracts
the codes.

The default method will unclass the object if ` [ is.numeric
](/link/is.numeric?package=base&version=3.6.2) (x) ` is true but otherwise
make use of ` == ` and ` > ` methods for the class of ` x[i] ` (for integers `
i ` ), and the ` is.na ` method for the class of ` x ` , but might be rather
slow when doing so.

This is an [ internal generic
](/link/internal%20generic?package=base&version=3.6.2) [ primitive
](/link/primitive?package=base&version=3.6.2) , so S3 or S4 methods can be
written for it.

##  See Also

` [ rank ](/link/rank?package=base&version=3.6.2) ` , ` [ sort
](/link/sort?package=base&version=3.6.2) ` , ` [ order
](/link/order?package=base&version=3.6.2) ` .

Powered by  [ DataCamp ](https://www.datacamp.com/)