You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
df<- DataFrame(X=1:26, Y=letters)
out<- split(df, rep(1:4, length.out=nrow(df)))
colnames(out)
## CharacterList of length 4## [[1]] X Y## [[2]] X Y## [[3]] X Y## [[4]] X Y
I just want a character vector of column names, so I might think of doing colnames(out)[[1]], but this fails for zero-length:
colnames(out[0])[[1]]
## NULL
The only safe way I can think of is:
colnames(unlist(out))
## [1] "X" "Y"
This is already somewhat unintuitive, but becomes a 3-liner if I want to change the column names:
df<- unlist(out)
colnames(df) <- c("x", "y")
out2<- relist(df, out) # is metadata in 'out' retained in 'out2'?
So it would be nice to have a dedicated getter/setter for CSDFLs - following the columnMetadata example:
columnNames(out)
## [1] "X" "Y"
columnNames(out) <- c("x", "y")
The text was updated successfully, but these errors were encountered:
Good point. I get the mcols() vs. columnMetadata() distinction, but colnames() and columnNames() look like synonyms. Perhaps sharedColumnNames() instead? Feel free to submit a PR.
Consider:
I just want a character vector of column names, so I might think of doing
colnames(out)[[1]]
, but this fails for zero-length:The only safe way I can think of is:
This is already somewhat unintuitive, but becomes a 3-liner if I want to change the column names:
So it would be nice to have a dedicated getter/setter for CSDFLs - following the
columnMetadata
example:The text was updated successfully, but these errors were encountered: