I am a novice when it comes to R and have run in to quite a specific issue that I can't seem to find much help with online. It also doesn't help that asking questions in stack overflow doesn't seem that straightforward. So please bare with me.
To provide some context this is an incredibly large dataset, 250,000 records plus with 9 columns.
One of these columns is called 'Site_ID'.
I now have a huge dataset that is sorted by Site_ID and date. The issue that I have is that a Site ID often does not correspond to just one set of coordinates and what I want is to create a new column that gives a new Site ID when the location changes. As the GPS coordinates have a large amount of error associated with them, the only way to separate them is by essentially 'flagging' when a Site ID is 'deployed' and assigning the same Site ID to all the following records, until the next deploy occurs and then beginning that process again.
In pseudocode it would be something like....
NewColumn <- ifelse(Task_Type == "Deploy trap", assign int val, assign previous rows int val)
Please let me know if I can provide anymore, I have snapshots of data available, I am simply unsure of how to use the stackoverflow Ask a Question page effectively.
TRIALDATA$SITEIDDEPLOY = ifelse(TRIALDATA$Task_Type == 'Deploy trap', paste0(TRIALDATA$Site_ID, "_1"), TRIALDATA$Site_ID)
This code sample is what I used previously to achieve the data in the attached image.
Aucun commentaire:
Enregistrer un commentaire