Lock or protect data table in R

Is there one or more ways to lock or protect data.table, so that it can no longer be changed in place?

Say we have data.table:

dt <- data.table(id = 1, val="foo")
dt
#    id val
# 1:  1 foo

Can I then change dtto get the following behavior after?

dt[, val:="bar"]
# error or warning
dt
#    id val
# 1:  1 foo  ## unmodified

context

This happened because I have a data.tablesmall R package at work, which is widely used data.table. It contains some data.tables(translation tables), which, if they were accidentally changed by the user, can cause problems (incorrect translations). I was hoping that making the data “internal” (as defined here ) would allow this, but it is not.

data.table, data.frames, + casting data.table . , ( , / ), , .

+5
1

.

- (, R6), , , . . .

petals TeachingDemos.

, . , , .

, , , R.

/ , MD5sums, . , , MD5sum , .

data.tables, .Rdata, , . , (, ( get ::) , )).

+4

All Articles