I would like to assign category labels based on rowID. Basically, I have a dataset that spans 23 hours tracking the movement of zebrafish larvae and I want to indicate that the 5 minutes period after the larvae is placed in the machine and the 5 minutes period after light condition changes (light to dark, dark to light etc.) is considered a "HABITUATION" period. Movement in any other times is considered a "NON-HABITUATION" period. I have assigned a rowID to every single second of data in the data frame and are using the row-ID ranges to indicate "HABITUATION" periods and "NON-HABITUATION" periods. However my code doesn't work- I keep getting this error " Error in if (as.numeric(data_long$rowID) > 37650 & as.numeric(data_long$rowID) < : the condition has length > 1".
What am I doing wrong?
Please see my code below, thank you very much!
enter code heredata_long$CONDITIONS_2<- ifelse(as.numeric(data_long$rowID) <301){
print("HABITUATION")
} else{
if(as.numeric(data_long$rowID) > 37650 & as.numeric(data_long$rowID) < 37952){
print("HABITUATION")
} else{
if(as.numeric(data_long$rowID) > 71880 & as.numeric(data_long$rowID) < 72182){
print("HABITUATION")
}
else{
print("NOT HABITUATION")
}
}