简体   繁体   中英

Unicity of values in R

I need some help with R. I'm not an expert and just began using it.

I need to check the unicity of values in a table and would like to know how I can do that.

Let say I have a contractID and a contractNumber in the data frame Contract2008 I would like to make sure that there is only 1 contractNumber by Contract ID. I did this :

DT <- data.table(contract2008)
DT[, .(number_of_distinct_numcontract = length(unique("contractNumeber"))), by = "ContractID"]

Is this the right way to do it?

Thank you for your help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM