I made these for loops but they are taking to long to run because of the size of my data. Is there anyway to rewrite my for loops for it to do the same thing but take less time
for (i in 1:length(dataSL_desktop$usid)) {
usID <- dataSL_desktop$usid[i]
dates <- seq(as.Date(dataSL_desktop$endTimeStamp[i])-30, by = "day", length = 30)
x <- rep(0,30)
for (k in 1:length(datadesktop$Date)) {
for (j in 1:length(dates)) {
if (datadesktop$usID[k] == usID & dates[j] == datadesktop$Date[k] ) {
x[j] <- datadesktop$Visits[k]
}
}
}
}