Appreciate any help on this, I am relatively new to R and stackoverflow.
Here is some sample code to work with for my problem, it is from a database of injured workers.
Area <- c("Connecticut", "Maine", "Massachusetts", "New Hampshire")
X2004 <- c(0,1,4,1)
X2005 <- c(1,0,6,2)
df1 <- data.frame(Area, X2004, X2005)
I would like to write a simple script that takes a number of injured workers and returns the "Area" and year in which a specific number of officers were killed. E.g "6" would return X2005 and Massachusetts, and 1 would return X2004 Connecticut and X2005 Maine. Along the lines of Vlookup in Excel.
The closer to base R the better, I am doing this as part of an exercise on indexing. I haven't found any solutions with tidyverse either.
Thanks in advance for your help, I'm sure there is a clear solution just beyond my reach!