Friday, 13 September 2013

Add row to dataframe based on presence criteria

Add row to dataframe based on presence criteria

I am trying to find a way to add rows based on criteria in a data frame. I
essentially want to take a data frame and insert values that are missing.
Here is what I start with:
Plot Species Status
1A ABBI L
1A PIEN D
1B ABBI D
1B PIEN L
2A ABBI L
I would like the ability to search the Plot column for 1A, 2B and 3A.
Since 1A is present, there would be no action, but 2B and 2B would be
added to the data frame. For missing values, I will always want to enter
the Plot number and 0 for everything else. The end result looking like
this:
Plot Species Status
1A ABBI L
1A PIEN D
1B ABBI D
1B PIEN L
2A ABBI L
2B 0 0
3A 0 0
Thanks for your help!

No comments:

Post a Comment