Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
arunsrinivasan opened this issue Jun 8, 2014 · 0 comments
Labels

Comments

@arunsrinivasan
Copy link
Member

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
Labels
Projects
None yet
Development

No branches or pull requests

1 participant