neuronlist-dataframe-methods {nat}R Documentation

Methods for working with the dataframe attached to a neuronlist

Description

[.neuronlist and [<-.neuronlist behave like the corresponding base methods ([.data.frame, [<-.data.frame) allowing extraction or replacement of parts of the data.frame attached to the neuronlist.

droplevels Remove redundant factor levels in dataframe attached to neuronlist

with Evaluate expression in the context of dataframe attached to a neuronlist

head Return the first part of data.frame attached to neuronlist

tail Return the last part of data.frame attached to neuronlist

Usage

## S3 method for class 'neuronlist'
x[i, j, drop]

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

## S3 method for class 'neuronlist'
droplevels(x, except = NULL, ...)

## S3 method for class 'neuronlist'
with(data, expr, ...)

## S3 method for class 'neuronlist'
head(x, ...)

## S3 method for class 'neuronlist'
tail(x, ...)

Arguments

x

A neuronlist object

i, j

elements to extract or replace. Numeric or character or, for [ only, empty. Numeric values are coerced to integer as if by as.integer. See [.data.frame for details.

drop

logical. If TRUE the result is coerced to the lowest possible dimension. The default is to drop if only one column is left, but not to drop if only one row is left.

value

A suitable replacement value: it will be repeated a whole number of times if necessary and it may be coerced: see the Coercion section. If NULL, deletes the column if a single column is selected.

except

indices of columns from which not to drop levels

...

Further arguments passed to default methods (and usually ignored)

data

A neuronlist object

expr

The expression to evaluate

Value

the attached dataframe with levels dropped (NB not the neuronlist)

See Also

[.data.frame, @seealso [<-.data.frame

droplevels

with

head

tail

Other neuronlist: *.neuronlist(), is.neuronlist(), neuronlistfh(), neuronlist(), nlapply(), read.neurons(), write.neurons()

Examples

## treat kcs20 as data.frame
kcs20[1, ]
kcs20[1:3, ]
kcs20[, 1:4]
kcs20[, 'soma_side']
# alternative to as.data.frame(kcs20)
kcs20[, ]

## can also set columns
kcs13=kcs20[1:3]
kcs13[,'side']=as.character(kcs13[,'soma_side'])
head(kcs13)
# or parts of columns
kcs13[1,'soma_side']='R'
kcs13['FruMARCM-M001205_seg002','soma_side']='L'
# remove a column
kcs13[,'side']=NULL
all.equal(kcs13, kcs20[1:3])

# can even replace the whole data.frame like this
kcs13[,]=kcs13[,]
all.equal(kcs13, kcs20[1:3])

## get row/column names of attached data.frame 
# (unfortunately implementing ncol/nrow is challenging)
rownames(kcs20)
colnames(kcs20)

[Package nat version 1.8.24 Index]