I want to add a colume to a data frame by some rules, in stata the command is "gen" or "egen" ,but what is it in R?