For as.data.frame, when there is no attached data.frame the result will be a data.frame with 0 columns but an appropriate number of rows, named by the objects in the neuronlist.

data.frame<- methods set the data frame attached to an object. At present this is only used for neuronlist objects.

# S3 method for neuronlist
as.data.frame(x, row.names = names(x), optional = FALSE, ...)

data.frame(x) <- value

# S3 method for neuronlist
data.frame(x) <- value

Arguments

x

neuronlist to convert

row.names

row names (defaults to names of objects in neuronlist, which is nearly always what you want.)

optional

ignored in this method

...

additional arguments passed to data.frame (see examples)

value

The new data.frame to be attached to x

Value

for as.data.frame.neuronlist, a data.frame with length(x) rows, named according to names(x) and containing the columns from the attached data.frame, when present. for data.frame<-.neuronlist, a neuronlist with the attached data.frame.

Examples

head(as.data.frame(kcs20))
#>                                       gene_name          Name  idid soma_side
#> FruMARCM-M001205_seg002 FruMARCM-M001205_seg002  fru-M-500112  1024         L
#> GadMARCM-F000122_seg001 GadMARCM-F000122_seg001 Gad1-F-900005 10616         L
#> GadMARCM-F000050_seg001 GadMARCM-F000050_seg001 Gad1-F-100010  8399         R
#> GadMARCM-F000142_seg002 GadMARCM-F000142_seg002 Gad1-F-300043 10647         L
#> FruMARCM-F000270_seg001 FruMARCM-F000270_seg001  fru-F-400045  9758         L
#> FruMARCM-F001115_seg002 FruMARCM-F001115_seg002  fru-F-300059  6182         R
#>                         flipped    Driver Gender        X         Y         Z
#> FruMARCM-M001205_seg002   FALSE  fru-Gal4      M 361.4849  95.04480  84.10259
#> GadMARCM-F000122_seg001   FALSE Gad1-Gal4      F 367.8332 105.86755  94.73446
#> GadMARCM-F000050_seg001    TRUE Gad1-Gal4      F 382.8279  61.73213  97.28057
#> GadMARCM-F000142_seg002   FALSE Gad1-Gal4      F 349.5917  78.18986  96.69280
#> FruMARCM-F000270_seg001   FALSE  fru-Gal4      F 387.5236 114.80344  87.84156
#> FruMARCM-F001115_seg002    TRUE  fru-Gal4      F 352.0216 121.72034 100.52308
#>                                        exemplar cluster  idx  type
#> FruMARCM-M001205_seg002 FruMARCM-M001205_seg002       9  156 gamma
#> GadMARCM-F000122_seg001 GadMARCM-F000122_seg001      70 1519 gamma
#> GadMARCM-F000050_seg001 GadMARCM-F000050_seg001      57 1132    ab
#> GadMARCM-F000142_seg002 GadMARCM-F000142_seg002      71 1535  apbp
#> FruMARCM-F000270_seg001 FruMARCM-F000270_seg001      64 1331    ab
#> FruMARCM-F001115_seg002 FruMARCM-F001115_seg002      44  795    ab

# add additional variables
str(as.data.frame(kcs20, i=seq(kcs20), abc=LETTERS[seq(kcs20)]))
#> 'data.frame':	20 obs. of  16 variables:
#>  $ gene_name: chr  "FruMARCM-M001205_seg002" "GadMARCM-F000122_seg001" "GadMARCM-F000050_seg001" "GadMARCM-F000142_seg002" ...
#>  $ Name     : chr  "fru-M-500112" "Gad1-F-900005" "Gad1-F-100010" "Gad1-F-300043" ...
#>  $ idid     : num  1024 10616 8399 10647 9758 ...
#>  $ soma_side: Factor w/ 3 levels "L","M","R": 1 1 3 1 1 3 3 3 3 3 ...
#>  $ flipped  : logi  FALSE FALSE TRUE FALSE FALSE TRUE ...
#>  $ Driver   : chr  "fru-Gal4" "Gad1-Gal4" "Gad1-Gal4" "Gad1-Gal4" ...
#>  $ Gender   : chr  "M" "F" "F" "F" ...
#>  $ X        : num  361 368 383 350 388 ...
#>  $ Y        : num  95 105.9 61.7 78.2 114.8 ...
#>  $ Z        : num  84.1 94.7 97.3 96.7 87.8 ...
#>  $ exemplar : Factor w/ 96 levels "5HT1bMARCM-M000076_seg001",..: 60 78 76 79 41 45 59 82 6 63 ...
#>  $ cluster  : int  9 70 57 71 64 44 16 61 52 12 ...
#>  $ idx      : int  156 1519 1132 1535 1331 795 268 1265 898 190 ...
#>  $ type     : Factor w/ 3 levels "ab","apbp","gamma": 3 3 1 2 1 1 1 2 2 1 ...
#>  $ i        : int  1 2 3 4 5 6 7 8 9 10 ...
#>  $ abc      : chr  "A" "B" "C" "D" ...
# stop character columns being turned into factors
newdf <- as.data.frame(kcs20, i=seq(kcs20), abc=LETTERS[seq(kcs20)], 
  stringsAsFactors=FALSE)
str(newdf)
#> 'data.frame':	20 obs. of  16 variables:
#>  $ gene_name: chr  "FruMARCM-M001205_seg002" "GadMARCM-F000122_seg001" "GadMARCM-F000050_seg001" "GadMARCM-F000142_seg002" ...
#>  $ Name     : chr  "fru-M-500112" "Gad1-F-900005" "Gad1-F-100010" "Gad1-F-300043" ...
#>  $ idid     : num  1024 10616 8399 10647 9758 ...
#>  $ soma_side: Factor w/ 3 levels "L","M","R": 1 1 3 1 1 3 3 3 3 3 ...
#>  $ flipped  : logi  FALSE FALSE TRUE FALSE FALSE TRUE ...
#>  $ Driver   : chr  "fru-Gal4" "Gad1-Gal4" "Gad1-Gal4" "Gad1-Gal4" ...
#>  $ Gender   : chr  "M" "F" "F" "F" ...
#>  $ X        : num  361 368 383 350 388 ...
#>  $ Y        : num  95 105.9 61.7 78.2 114.8 ...
#>  $ Z        : num  84.1 94.7 97.3 96.7 87.8 ...
#>  $ exemplar : Factor w/ 96 levels "5HT1bMARCM-M000076_seg001",..: 60 78 76 79 41 45 59 82 6 63 ...
#>  $ cluster  : int  9 70 57 71 64 44 16 61 52 12 ...
#>  $ idx      : int  156 1519 1132 1535 1331 795 268 1265 898 190 ...
#>  $ type     : Factor w/ 3 levels "ab","apbp","gamma": 3 3 1 2 1 1 1 2 2 1 ...
#>  $ i        : int  1 2 3 4 5 6 7 8 9 10 ...
#>  $ abc      : chr  "A" "B" "C" "D" ...
data.frame(kcs20)=newdf