How to add a new variable to an existing data frame, but I want to add to the front not end. eg. my dataframe is
b c d
1 2 3
1 2 3
1 2 3
I
The previous answers show 3 approaches
Let me show #4 approach "By using "cbind" and "rename" that works for my case
df <- data.frame(b = c(1, 1, 1), c = c(2, 2, 2), d = c(3, 3, 3))
new_column = c(0, 0, 0)
df <- cbind(new_column, df)
colnames(df)[1] <- "a"