我在R studio中遇到以下代码的错误。搜索了几天后,我无法找到解决方案。任何帮助表示赞赏!
for(i in 1:nrow(newData)){
#find the week that it corresponds to
rowsToReplace = newData$date == unique(cleanMovieData$releaseDate[i])
#find the rank 1 and rank 2 movie in that week
releaseWeek1 = cleanMovieData$releaseWeekEarnings [which(cleanMovieData$releaseRank[i] == 1)]
releaseWeek2 = cleanMovieData$releaseWeekEarnings [which(cleanMovieData$releaseRank[i] == 2)]
#take the log revenue in those weeks and compare
logReleaseCompare = log(releaseWeek1) - log(releaseWeek2)
newData$releaseBoxOfficeDiff[rowsToReplace] = logReleaseCompare
}