R: Subset a huxtable

[.huxtable {huxtable} | R Documentation

## Subset a huxtable

### Description

Subset a huxtable

### Usage

    ## S3 method for class 'huxtable'
    x[i, j, drop = FALSE]

    ## S3 replacement method for class 'huxtable'
    x[i, j] <- value

    ## S3 replacement method for class 'huxtable'
    x$name <- value

    ## S3 replacement method for class 'huxtable'
    x[[i, j]] <- value

### Arguments

`x` | A huxtable.
`i` | Rows to select.
`j, name` | Columns to select.
`drop` | Not used.
`value` | A matrix, data frame, huxtable or similar object.

### Details

`[` always returns a new huxtable object, while `$` and `[[` simply return a vector of data. For the replacement function `[<-`, if `value` is a huxtable, then its cell properties will be copied into `x`. In addition, if `value` fills up an entire column, then column properties will be copied into the replaced columns of `x`, and if it fills up an entire row, then row properties will be copied into the replaced rows of `x`. Replacement functions `$<-` and `[[<-` simply change the data without affecting other properties.

### Value

A huxtable.

### Examples

    ht <- huxtable(a = 1:3, b = letters[1:3])
    ht[1:2,]
    ht[,1]
    ht$a
    ## Not run:
    rowspan(ht)[2,1] <- 2
    ht[1:2,] # generates a warning

    ## End(Not run)
    ht <- huxtable(a = 1:3, b = 1:3)
    ht2 <- huxtable(10:11, 12:13)
    bold(ht2) <- TRUE
    ht[2:3,] <- ht2
    ht
    bold(ht)

[Package huxtable version 3.0.0 Index]