Skip to content

[R-Forge #4934] unname(DT) throws an error (error cannot be caught with try() ) #97

Description

@arunsrinivasan

Submitted by: Ricardo Saporta; Assigned to: Arun ; R-Forge link

I searched around for unname data.table and found this thread from v1.8.1

http://r.789695.n4.nabble.com/unname-does-not-work-with-data-table-anymore-td4521647.html

I'm encountering the following error in 1.8.11 and 1.8.10.

DT <- data.table(A = rep(LETTERS, 3), B = seq(78))
unname(DT)

data.frame analogous

DF <- data.frame(A = rep(LETTERS, 3), B = seq(78))
unname(DF)

Extra problem is that try does not catch the error:

inherits(try(unname(DT)), "try-error")

[1] FALSE

I thought the error might be just in print.data.table
Z <- unname(DT) # no error

but then again, maybe not:
setnames(Z, c("A", "B"))

Using setattr can put things back to normal

setattr(Z, "names", c("A", "B"))
Z

is it possible that the error is only

occurrenting when there are more than 20 rows?

unname( DT [1:21] ) # Error (21 rows)
unname( DT [2:22] ) # Error (21 rows)
unname( DT [2:21] ) # No Error (20 rows)

unname( DT [30:50] ) # Error (21 rows)
unname( DT [30:49] ) # No Error (20 rows)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions