Here\'s a data frame containing a column of user ids:
> head(df)
uid
1 14070210
2 14080815
3 14091420
For the sake of argument, I
The digest()
function isn't vectorized. So if you pass in a vector, you get one value for the whole vector rather than a digest for each element of the vector. Since it returns one value, that value is recycled for each row of your data.frame. You can create your own vectorized version
vdigest <- Vectorize(digest)
df %>% mutate(sqrt_uid = sqrt(uid), hashed_uid = vdigest(uid))
# uid sqrt_uid hashed_uid
# 1 14070210 3751.028 cc90019421220a24f75b5ed5daec36ff
# 2 14080815 3752.441 9f7f643940b692dd9c7effad439547e8
# 3 14091420 3753.854 89e6666fdfdbfb532b2d7940def9d47d
which matches what you get when you pass in each vector element individually
digest(df$uid[1])
# [1] "cc90019421220a24f75b5ed5daec36ff"
digest(df$uid[3])
# [1] "89e6666fdfdbfb532b2d7940def9d47d"