How to add variables and reorder variables

Hello R experts,
I am new to R. I have a data like this
itemid bpar
ABC022 1.3578
ABC351 0.7895
ABC623 1.0546
ABC356 0.8674

There are 100 rows of my data. I want to make this data look like the following
1 1PL 1 1.3578 NA NA
2 1PL 1 0.7895 NA NA
3 1PL 1 1.0546 NA NA
.100 1PL 1 0.8674 NA NA

Please help.

You could be interesting in this book to get more used to how data manipulation can be achieved efficiently

Some pointers with dplyr

  • you can add columns using mutate()
  • you can rename you column using rename()

You can do many other thing to prepare you data.

You can get access to tutorials too:

Look at Rstudio Primers for example.

Hope it helps.

Thanks much for the help!
Very much appreciated!

1 Like

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