subsetting {swfscDAS} | R Documentation |
Subsetting objects created using swfscDAS
Description
Subsetting das_dfr
or das_df
objects
Usage
## S3 method for class 'das_dfr'
x[i, j, ..., drop = TRUE]
## S3 replacement method for class 'das_dfr'
x$name <- value
## S3 replacement method for class 'das_dfr'
x[i, j, ...] <- value
## S3 replacement method for class 'das_dfr'
x[[i]] <- value
## S3 method for class 'das_df'
x[i, j, ..., drop = TRUE]
## S3 replacement method for class 'das_df'
x$name <- value
## S3 replacement method for class 'das_df'
x[i, j, ...] <- value
## S3 replacement method for class 'das_df'
x[[i]] <- value
Arguments
x |
object of class |
i , j , ... |
elements to extract or replace, see |
drop |
logical, see |
name |
A literal character string or ..., see |
value |
A suitable replacement value, see |
Details
When subsetting a das_dfr
or das_df
object, henceforth a das_
object,
using any of the functions described in [.data.frame
,
then then the das_
class is simply dropped and the object is of class data.frame
.
This is because of the strict format requirements of das_
objects;
it is likely that a subsetted das_
object will not have
the format required by subsequent swfscDAS functions,
and thus it is safest to drop the das_
class.
If a data frame is passed to downstream swfscDAS
functions that require a das_
object,
then they will attempt to coerce the object to the necessary das_
class
See as_das_dfr
and as_das_df
for more details.
Examples
y <- system.file("das_sample.das", package = "swfscDAS")
y.read <- das_read(y)
# All return a data frame:
class(y.read[1:10, ])
class(y.read[, 1:10])
y.df <- y.read
y.df[, 1] <- "a"
class(y.df)
y.df <- y.read
y.df$Event <- "a"
class(y.df)
y.df <- y.read
y.df[["Event"]] <- "a"
class(y.df)