I understand that magrittr::inset() should be able to assign a vector to a new column in the data frame (as opposed to extract() ). But I do not understand how the syntax should work.
Let's say I have an example with a toy:
df = data.frame( id = 1:26, letter = letters) newvalue = rnorm(26)
I would like to add newvalue as a new column in df in the magrittr chain. I am assuming something like:
df %>% inset('new_column_name', newvalue)
But this does not work, apparently because I do not quite understand what the syntax should look like for [<- (for which inset() is an alias).
Beyond the magrittr chain, I could do:
df['new_column_name'] <- newvalue
But my question is how to do this in a chain where I have already performed various and different operations.
source share