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 want to create a new column containing the square root of the user id, and another new column containing a hash of the user id. So I do this:
df_mutated <- df %>%
mutate(sqrt_uid = sqrt(uid), hashed_uid = digest(uid))
... where digest() comes from the digest package.
While the square root appears to work, the digest function returns the same value for each user id.
> head(df_mutated)
uid sqrt_uid hashed_uid
1 14070210 3751.028 f8c4b39403e57d85cd1698d2353954d0
2 14080815 3752.441 f8c4b39403e57d85cd1698d2353954d0
3 14091420 3753.854 f8c4b39403e57d85cd1698d2353954d0
This is weird to me. Without dplyr, the digest() function returns different values for different inputs. What am I not understanding about dplyr?
Thanks