I have some dataframe, bonusdataframe3, where I want divide every 200 rows by a different value. For example, when I run the code:
bonusdf<-reactive({
req(bonusdataframe3())
bonuscc0<-data.frame(hours=c(), conc=c())
for(n in 1:nrow(iondat())-4){
dxframe<-data.frame(hours=out()[[1]], conc=(bonusdataframe3()$conc[(n-1)*201:n*201]))/unlist(cindat()[2,n+6:nrow(iondat())]))
bonuscc0<-rbind(bonuscc0, dxframe)
}
bonuscc0
})
I get the error
Warning: Error in data.frame: arguments imply differing number of rows: 201, 0
Which is really strange to me because the code
bonusdf<-reactiveValues()
bonusdf2<-reactive({
req(bonusdataframe3())
bonusdf<-bonusdataframe3()
bonusdf$conc<-bonusdataframe3()$conc[0:201]/unlist(cindat()[2,6])
bonusdf
})
Gives me what I want. bonusdataframe3()$conc[0:201]
gives me the first 200 entries and I can divide them by unlist(cindat()[2,6])
.
nrow(iondat()-4)
gives me the values I want, in this case it's just 1, so the for loop is going from 1:1 which should just iterate over one, once.
Does anyone know where I am going wrong here? Why is my loop empty?