I have a datable that needs to have some columns shift while the others need to stay in the same column. Is there a way to do this? I am also looking for an if statement where this will only happen if certain columns contain NULL (NA) values.
I have attached an excel of what I am trying to accomplish.
That is very challenging to do in R, as R works on columns: if the entries are in the wrong column that means something went very wrong in a step before!
How did you get this data? Is there any way that the original file has the data in the right columns, and it's the importing in Excel that messed it up?
If you really have no other choices, you can always "shift" columns by hardcoding everything:
I am importing a pdf and one of the column cells is blank. That is why it is impossible to fix the data beforehand. I have a workaround that works now using an if else statement, but wondering if there is a more permanent solution.
Additionally, I have a quibble with the way you posed your challenge;
If someone wished to use example data to test code against, they would type it out from your screenshot...
This is very unlikely to happen, and so it reduces the likelihood you will receive the help you desire.
Therefore please see this guide on how to reprex data. Key to this is use of either datapasta, or dput() to share your data as code