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
cbind inherents order by its argument order.
User your first column(s) as your first argument
cbind(fst_col , df)
fst_col df_col1 df_col2
1 0 0.2 -0.1
2 0 0.2 -0.1
3 0 0.2 -0.1
4 0 0.2 -0.1
5 0 0.2 -0.1
cbind(df, last_col)
df_col1 df_col2 last_col
1 0.2 -0.1 0
2 0.2 -0.1 0
3 0.2 -0.1 0
4 0.2 -0.1 0
5 0.2 -0.1 0