I have a dataframe with several columns and would like to add a new column and name it according to a previous variable. For example:
df <- data.frame(\"A
Try [ instead of $:
[
$
> df[, Variable] <- NA > df A B C 1 1 a NA 2 2 c NA 3 3 d NA 4 4 b NA