New Variable by Observation

Hi all, I am new to coding and R coding. I am trying to create a new Variable 'Newid',by Observation. This is the code I used. What am I doing wrong

If you want to assign the numbers from 1 to 17842 to the column Newid, try

d1$Newid <- 1:17842

d1[1:17842] would be the first 17842 columns of d1, which is not what you want.

1 Like

it actually worked!Thank you so much

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.