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)

#  match.fun: Extract a Function Specified by Name

##  Description

When called inside functions that take a function as argument, extract the
desired function object while avoiding undesired matching to objects of other
types.

##  Usage

    
    
    match.fun(FUN, descend = TRUE)

##  Arguments

FUN

item to match as function: a function, symbol or character string. See
‘Details’.

descend

logical; control whether to search past non-function objects.

##  Value

A function matching ` FUN ` or an error is generated.

##  Bugs

The ` descend ` argument is a bit of misnomer and probably not actually needed
by anything. It may go away in the future.

It is impossible to fully foolproof this. If one ` attach ` es a list or data
frame containing a length-one character vector with the same name as a
function, it may be used (although namespaces will help).

##  Details

` match.fun ` is not intended to be used at the top level since it will
perform matching in the _parent_ of the caller.

If ` FUN ` is a function, it is returned. If it is a symbol (for example,
enclosed in backquotes) or a character vector of length one, it will be looked
up using ` get ` in the environment of the parent of the caller. If it is of
any other mode, it is attempted first to get the argument to the caller as a
symbol (using ` substitute ` twice), and if that fails, an error is declared.

If ` descend = TRUE ` , ` match.fun ` will look past non-function objects with
the given name; otherwise if ` FUN ` points to a non-function object then an
error is generated.

This is used in base functions such as ` [ apply
](/link/apply?package=base&version=3.6.2) ` , ` [ lapply
](/link/lapply?package=base&version=3.6.2) ` , ` [ outer
](/link/outer?package=base&version=3.6.2) ` , and ` [ sweep
](/link/sweep?package=base&version=3.6.2) ` .

##  See Also

` [ match.arg ](/link/match.arg?package=base&version=3.6.2) ` , ` [ get
](/link/get?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%2Fmatch.fun&utm_source=r-docs&utm_medium=docs&utm_term=match.fun&utm_content=run_example_in_workspace)

    
    
    # NOT RUN {
    # Same as get("*"):
    match.fun("*")
    # Overwrite outer with a vector
    outer <- 1:5
    try(match.fun(outer, descend = FALSE)) #-> Error:  not a function
    match.fun(outer) # finds it anyway
    is.function(match.fun("outer")) # as well
    # }
    

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%2Fmatch.fun&utm_source=r-docs&utm_medium=docs&utm_term=match.fun&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)

#  Colon: Colon Operator

##  Description

Generate regular sequences.

##  Usage

    
    
    from:to
       a:b

##  Arguments

from

starting value of sequence.

to

(maximal) end value of the sequence.

a, b

` [ factor ](/link/factor?package=base&version=3.6.2) ` s of the same length.

##  Value

For numeric arguments, a numeric vector. This will be of type ` [ integer
](/link/integer?package=base&version=3.6.2) ` if ` from ` is integer-valued
and the result is representable in the  R  integer type, otherwise of type `
"double" ` (aka ` [ mode ](/link/mode?package=base&version=3.6.2) ` ` " [
numeric ](/link/numeric?package=base&version=3.6.2) " ` ).

For factors, an unordered factor with levels labelled as ` la:lb ` and ordered
lexicographically (that is, ` lb ` varies fastest).

##  Details

The binary operator ` : ` has two meanings: for factors ` a:b ` is equivalent
to ` [ interaction ](/link/interaction?package=base&version=3.6.2) (a, b) `
(but the levels are ordered and labelled differently).

For other arguments ` from:to ` is equivalent to ` seq(from, to) ` , and
generates a sequence from ` from ` to ` to ` in steps of ` 1 ` or ` -1 ` .
Value ` to ` will be included if it differs from ` from ` by an integer up to
a numeric fuzz of about ` 1e-7 ` . Non-numeric arguments are coerced
internally (hence without dispatching methods) to numeric---complex values
will have their imaginary parts discarded with a warning.

##  References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S Language_ .
Wadsworth & Brooks/Cole. (for numeric arguments: S does not have ` : ` for
factors.)

##  See Also

` [ seq ](/link/seq?package=base&version=3.6.2) ` (a _generalization_ of `
from:to ` ).

As an alternative to using ` : ` for factors, ` [ interaction
](/link/interaction?package=base&version=3.6.2) ` .

For ` : ` used in the formal representation of an interaction, see ` [ formula
](/link/formula?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%2FColon&utm_source=r-docs&utm_medium=docs&utm_term=Colon&utm_content=run_example_in_workspace)

    
    
    # NOT RUN {
    1:4
    pi:6 # real
    6:pi # integer
    
    f1 <- gl(2, 3); f1
    f2 <- gl(3, 2); f2
    f1:f2 # a factor, the "cross"  f1 x f2
    # }
    

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%2FColon&utm_source=r-docs&utm_medium=docs&utm_term=Colon&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)

#  range: Range of Values

##  Description

` range ` returns a vector containing the minimum and maximum of all the given
arguments.

##  Usage

    
    
    range(…, na.rm = FALSE)
    
    # S3 method for default
    range(…, na.rm = FALSE, finite = FALSE)

##  Arguments

…

any ` [ numeric ](/link/numeric?package=base&version=3.6.2) ` or character
objects.

na.rm

logical, indicating if ` [ NA ](/link/NA?package=base&version=3.6.2) ` 's
should be omitted.

finite

logical, indicating if all non-finite elements should be omitted.

##  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

` range ` 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.

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

If ` finite ` is ` TRUE ` , the minimum and maximum of all finite values is
computed, i.e., ` finite = TRUE ` _includes_ ` na.rm = TRUE ` .

A special situation occurs when there is no (after omission of ` NA ` s)
nonempty argument left, see ` [ min ](/link/min?package=base&version=3.6.2) `
.

##  References

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

##  See Also

` [ min ](/link/min?package=base&version=3.6.2) ` , ` [ max
](/link/max?package=base&version=3.6.2) ` .

The ` [ extendrange ](/link/extendrange?package=base&version=3.6.2) () `
utility in package  grDevices  .

##  Examples

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

    
    
    # NOT RUN {
    (r.x <- range(stats::rnorm(100)))
    diff(r.x) # the SAMPLE range
    
    x <- c(NA, 1:3, -1:1/0); x
    range(x)
    range(x, na.rm = TRUE)
    range(x, finite = TRUE)
    # }
    

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%2Frange&utm_source=r-docs&utm_medium=docs&utm_term=range&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

[ micropan  (version  1.0  ) ](/packages/micropan/versions/1.0)

#  getAccessions: Collecting contig accession numbers

##  Description

Retrieving the accession numbers for all contigs from a master record GenBank
file.

##  Usage

    
    
    getAccessions(master.record.accession)

##  Arguments

master.record.accession

The accession number (single text) to a master record GenBank file having the
WGS entry specifying the accession numbers to all contigs of the WGS genome.

##  Value

A character vector where each element is a text listing the accession numbers
separated by commas. Each vector element will contain no more than 500
accession numbers, see ` [ entrezDownload
](/link/entrezDownload?package=micropan&version=1.0) ` for details on this.
The vector returned by ` [ getAccessions
](/link/getAccessions?package=micropan&version=1.0) ` is typically used as
input to ` [ entrezDownload
](/link/entrezDownload?package=micropan&version=1.0) ` .

##  Details

In order to download a WGS genome (draft genome) using ` [ entrezDownload
](/link/entrezDownload?package=micropan&version=1.0) ` you will need the
accession number of every contig. This is found in the master record GenBank
file, which is available for every WGS genome. ` [ getAccessions
](/link/getAccessions?package=micropan&version=1.0) ` will extract these from
the GenBank file and return them in the apropriate way to be used by ` [
entrezDownload ](/link/entrezDownload?package=micropan&version=1.0) ` .

##  See Also

` [ entrezDownload ](/link/entrezDownload?package=micropan&version=1.0) ` .

##  Examples

[ Run this code
](https://www.datacamp.com/datalab/preview?_tag=rdocs&rdocsPath=packages%2Fmicropan%2Fversions%2F1.0%2Ftopics%2FgetAccessions&utm_source=r-docs&utm_medium=docs&utm_term=getAccessions&utm_content=run_example_in_datalab)

    
    
    # The master record accession for the WGS genome Mycoplasma genitalium, strain G37
    acc <- getAccessions("AAGX00000000")
    # Then we use this to download all contigs and save them in the same fasta file
    entrezDownload( acc, out.file="Mycoplasma_genitalium_G37.fsa" )
    

Run the code above in your browser using  [ DataLab
](https://www.datacamp.com/datalab/preview?_tag=rdocs&rdocsPath=packages%2Fmicropan%2Fversions%2F1.0%2Ftopics%2FgetAccessions&utm_source=r-docs&utm_medium=docs&utm_term=getAccessions&utm_content=run_example_in_datalab)

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)

#  Primitive: Look Up a Primitive Function

##  Description

` .Primitive ` looks up by name a ‘primitive’ (internally implemented)
function.

##  Usage

    
    
    .Primitive(name)

##  Arguments

name

name of the  R  function.

##  Details

The advantage of ` .Primitive ` over ` [ .Internal
](/link/.Internal?package=base&version=3.6.2) ` functions is the potential
efficiency of argument passing, and that positional matching can be used where
desirable, e.g.in ` [ switch ](/link/switch?package=base&version=3.6.2) ` .
For more details, see the ‘R Internals Manual’.

All primitive functions are in the base namespace.

This function is almost never used: ` `name` ` or, more carefully, ` [ get
](/link/get?package=base&version=3.6.2) (name, envir = baseenv()) ` work
equally well and do not depend on knowing which functions are primitive (which
does change as  R  evolves).

##  See Also

` [ is.primitive ](/link/is.primitive?package=base&version=3.6.2) ` showing
that primitive functions come in two types ( ` [ typeof
](/link/typeof?package=base&version=3.6.2) ` ), ` [ .Internal
](/link/.Internal?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%2FPrimitive&utm_source=r-docs&utm_medium=docs&utm_term=Primitive&utm_content=run_example_in_workspace)

    
    
    # NOT RUN {
    mysqrt <- .Primitive("sqrt")
    c
    .Internal # this one *must* be primitive!
    `if` # need backticks
    # }
    

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%2FPrimitive&utm_source=r-docs&utm_medium=docs&utm_term=Primitive&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

[ micropan  (version  1.0  ) ](/packages/micropan/versions/1.0)

#  xzcompress: xz (un)compress a file

##  Description

xz (un)compress a file

##  Usage

    
    
    xzcompress(filename, destname=sprintf("%s.xz", filename), temporary=FALSE, skip=FALSE, overwrite=FALSE, remove=TRUE, BFR.SIZE=1e+07, compression=6, ...) xzuncompress(filename, destname=gsub("[.]xz$", "", filename, ignore.case = TRUE), temporary=FALSE, skip=FALSE, overwrite=FALSE, remove=TRUE, BFR.SIZE=1e+07, ...)

##  Arguments

filename

Pathname of input file.

destname

Pathname of output file.

temporary

If ` [ TRUE ](/link/TRUE?package=micropan&version=1.0&to=base%3Alogical) ` ,
the output file is created in a temporary directory.

skip

If ` [ TRUE ](/link/TRUE?package=micropan&version=1.0&to=base%3Alogical) ` and
the output file already exists, the output file is returned as is.

overwrite

If ` [ TRUE ](/link/TRUE?package=micropan&version=1.0&to=base%3Alogical) ` and
the output file already exists, the file is silently overwritting, otherwise
an exception is thrown (unless ` skip ` is ` [ TRUE
](/link/TRUE?package=micropan&version=1.0&to=base%3Alogical) ` ).

remove

If ` [ TRUE ](/link/TRUE?package=micropan&version=1.0&to=base%3Alogical) ` ,
the input file is removed afterward, otherwise not.

BFR.SIZE

The number of bytes read in each chunk.

compression

The compression level used (1-9).

...

Not used.

##  Value

Returns the pathname of the output file. The number of bytes processed is
returned as an attribute.

##  Details

These functions are adapted from the ` R.utils ` package from gzip to xz.
Internally ` xzfile() ` (see ` [ connections
](/link/connections?package=micropan&version=1.0&to=base) ` ) is used to read
(write) chunks to (from) the xz file. If the process is interrupted before
completed, the partially written output file is automatically removed.

##  Examples

[ Run this code
](https://www.datacamp.com/datalab/preview?_tag=rdocs&rdocsPath=packages%2Fmicropan%2Fversions%2F1.0%2Ftopics%2Fxzcompress&utm_source=r-docs&utm_medium=docs&utm_term=xzcompress&utm_content=run_example_in_datalab)

    
    
      cat(file="foo.txt", "Hello world!")
    
      xzcompress("foo.txt")
      print(file.info("foo.txt.xz"))
    
      xzuncompress("foo.txt.xz")
      print(file.info("foo.txt"))
    
      file.remove("foo.txt")
    

Run the code above in your browser using  [ DataLab
](https://www.datacamp.com/datalab/preview?_tag=rdocs&rdocsPath=packages%2Fmicropan%2Fversions%2F1.0%2Ftopics%2Fxzcompress&utm_source=r-docs&utm_medium=docs&utm_term=xzcompress&utm_content=run_example_in_datalab)

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)

#  by: Apply a Function to a Data Frame Split by Factors

##  Description

Function ` by ` is an object-oriented wrapper for ` [ tapply
](/link/tapply?package=base&version=3.6.2) ` applied to data frames.

##  Usage

    
    
    by(data, INDICES, FUN, …, simplify = TRUE)

##  Arguments

data

an  R  object, normally a data frame, possibly a matrix.

INDICES

a factor or a list of factors, each of length ` nrow(data) ` .

FUN

a function to be applied to (usually data-frame) subsets of ` data ` .

…

further arguments to ` FUN ` .

simplify

logical: see ` [ tapply ](/link/tapply?package=base&version=3.6.2) ` .

##  Value

An object of class ` "by" ` , giving the results for each subset. This is
always a list if ` simplify ` is false, otherwise a list or array (see ` [
tapply ](/link/tapply?package=base&version=3.6.2) ` ).

##  Details

A data frame is split by row into data frames subsetted by the values of one
or more factors, and function ` FUN ` is applied to each subset in turn.

For the default method, an object with dimensions (e.g., a matrix) is coerced
to a data frame and the data frame method applied. Other objects are also
coerced to a data frame, but ` FUN ` is applied separately to (subsets of)
each column of the data frame.

##  See Also

` [ tapply ](/link/tapply?package=base&version=3.6.2) ` , ` [ simplify2array
](/link/simplify2array?package=base&version=3.6.2) ` . ` [ ave
](/link/ave?package=base&version=3.6.2) ` also applies a function block-wise.

##  Examples

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

    
    
    # NOT RUN {
    require(stats)
    by(warpbreaks[, 1:2], warpbreaks[,"tension"], summary)
    by(warpbreaks[, 1],   warpbreaks[, -1],       summary)
    by(warpbreaks, warpbreaks[,"tension"],
       function(x) lm(breaks ~ wool, data = x))
    
    ## now suppose we want to extract the coefficients by group
    tmp <- with(warpbreaks,
                by(warpbreaks, tension,
                   function(x) lm(breaks ~ wool, data = x)))
    sapply(tmp, coef)
    # }
    

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%2Fby&utm_source=r-docs&utm_medium=docs&utm_term=by&utm_content=run_example_in_workspace)

Powered by  [ DataCamp ](https://www.datacamp.com/)
](/link/dyn.load?package=base&version=3.6.2) ` for comments
about diagnostic messages which may be seen on Windows.

` library.dynam.unload ` is designed for use in ` [ .onUnload
](/link/.onUnload?package=base&version=3.6.2) ` : it unloads the DLL and
updates the value of ` .dynLibs() `

` .dynLibs ` is used for getting (with no argument) or setting the DLLs which
are currently loaded by packages (using ` library.dynam ` ).

##  References

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

##  See Also

` [ getLoadedDLLs ](/link/getLoadedDLLs?package=base&version=3.6.2) ` for
information on ` "DLLInfo" ` and ` "DLLInfoList" ` objects.

` [ .onLoad ](/link/.onLoad?package=base&version=3.6.2) ` , ` [ library
](/link/library?package=base&version=3.6.2) ` , ` [ dyn.load
](/link/dyn.load?package=base&version=3.6.2) ` , ` [ .packages
](/link/.packages?package=base&version=3.6.2) ` , ` [ .libPaths
](/link/.libPaths?package=base&version=3.6.2) `

` [ SHLIB ](/link/SHLIB?package=base&version=3.6.2) ` for how to create
suitable DLLs.

##  Examples

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

    
    
    # NOT RUN {
    ## Which DLLs were dynamically loaded by packages?
    library.dynam()
    
    ## More on library.dynam.unload() :
    # }
    # NOT RUN {
    require(nlme)
    nlme:::.onUnload # shows library.dynam.unload() call
    detach("package:nlme")  # by default, unload=FALSE ,  so,
    tail(library.dynam(), 2)# nlme still there
    
    ## How to unload the DLL ?
    ## Best is to unload the namespace,  unloadNamespace("nlme")
    ## If we need to do it separately which should be exceptional:
    pd.file <- attr(packageDescription("nlme"), "file")
    library.dynam.unload("nlme", libpath = sub("/Meta.*", '', pd.file))
    tail(library.dynam(), 2)# 'nlme' is gone now
    unloadNamespace("nlme") # now gives warning
    # }
    

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%2Flibrary.dynam&utm_source=r-docs&utm_medium=docs&utm_term=library.dynam&utm_content=run_example_in_workspace)

Powered by  [ DataCamp ](https://www.datacamp.com/)
low
on the Windows version of this help page. What happens on a FAT or SMB-mounted
file system is OS-specific.)

File arguments with a marked encoding (see ` [ Encoding
](/link/Encoding?package=base&version=3.6.2) ` are if possible translated to
the native encoding, except on Windows where Unicode file operations are used
(so marking as UTF-8 can be used to access file paths not in the native
encoding on suitable file systems).

##  See Also

` [ file.info ](/link/file.info?package=base&version=3.6.2) ` , ` [
file.access ](/link/file.access?package=base&version=3.6.2) ` , ` [ file.path
](/link/file.path?package=base&version=3.6.2) ` , ` [ file.show
](/link/file.show?package=base&version=3.6.2) ` , ` [ list.files
](/link/list.files?package=base&version=3.6.2) ` , ` [ unlink
](/link/unlink?package=base&version=3.6.2) ` , ` [ basename
](/link/basename?package=base&version=3.6.2) ` , ` [ path.expand
](/link/path.expand?package=base&version=3.6.2) ` .

` [ dir.create ](/link/dir.create?package=base&version=3.6.2) ` .

` [ Sys.glob ](/link/Sys.glob?package=base&version=3.6.2) ` to expand
wildcards in file specifications.

` [ file_test ](/link/file_test?package=base&version=3.6.2) ` , ` [
Sys.readlink ](/link/Sys.readlink?package=base&version=3.6.2) ` (for
‘symlink’s).

[ https://en.wikipedia.org/wiki/Hard_link
](https://en.wikipedia.org/wiki/Hard_link) and [
https://en.wikipedia.org/wiki/Symbolic_link
](https://en.wikipedia.org/wiki/Symbolic_link) for the concepts of links and
their limitations.

##  Examples

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

    
    
    # NOT RUN {
    cat("file A\n", file = "A")
    cat("file B\n", file = "B")
    file.append("A", "B")
    file.create("A") # (trashing previous)
    file.append("A", rep("B", 10))
    if(interactive()) file.show("A") # -> the 10 lines from 'B'
    file.copy("A", "C")
    dir.create("tmp")
    file.copy(c("A", "B"), "tmp")
    list.files("tmp") # -> "A" and "B"
    setwd("tmp")
    file.remove("A") # the tmp/A file
    file.symlink(file.path("..", c("A", "B")), ".")
                         # |--> (TRUE,FALSE) : ok for A but not B as it exists already
    setwd("..")
    unlink("tmp", recursive = TRUE)
    file.remove("A", "B", "C")
    # }
    

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%2Ffiles&utm_source=r-docs&utm_medium=docs&utm_term=files&utm_content=run_example_in_workspace)

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