r <-list() for (i in 1:pnum) { r[1] <- new_regimen( amt = amt[[i]],…
- User
r <-list() for (i in 1:pnum) { r[1] <- new_regimen( amt = amt[[i]], times=c(0:n[[i]]-1)*median_interval, cmt=1, type="infusion" )Warning messages: 1: In r[1] <- new_regimen(amt = amt[[1]], times = c(0:n[[1]] - 1) * : 被替换的项目不是替换值长度的倍数 }how to fix
- Assistant
The error message "被替换的项目不是替换值长度的倍数" (which is in Chinese and translates to "The replaced item is not a multiple of the replacement value length") suggests that there is a mismatch in the lengths of the objects being assigned.
In this case, the issue seems to be with the assignment
r[1] <- new_regimen(...). Ther[1]element is being replaced with the output ofnew_regimen(), but it seems that the length of the output is not compatible with the length ofr[1].To fix this issue, you can try changing the assignment to
r[[1]] <- new_regimen(...). This will store the output ofnew_regimen()as a single element list inr[1]. This way, the length of the output will match the length of the assigned object.Here is the updated code:
r <- list() for (i in 1:pnum) { r[[1]] <- new_regimen( amt = amt[[i]], times = c(0:n[[i]]-1) * median_interval, cmt = 1, type = "infusion" ) }Note that I have changed
r[1]tor[[1]]in the assignment line. - User
r <-list() for (i in 1:pnum) { r[i] <- new_regimen( amt = amt[[i]], times=c(0:n[[i]]-1)*median_interval, cmt=1, type="infusion" ) }Warning messages: 1: In r[i] <- new_regimen(amt = amt[[i]], times = c(0:n[[i]] - 1) * : 被替换的项目不是替换值长度的倍数
- Assistant
The error message "被替换的项目不是替换值长度的倍数" (which is in Chinese and translates to "The replaced item is not a multiple of the replacement value length") suggests that there is a mismatch in the lengths of the objects being assigned.
In this case, the issue seems to be with the assignment
r[i] <- new_regimen(...). Ther[i]element is being replaced with the output ofnew_regimen(), but it seems that the length of the output is not compatible with the length ofr[i].To fix this issue, you can try changing the assignment to
r[[i]] <- new_regimen(...). This will store the output ofnew_regimen()as a single element list inr[i]. This way, the length of the output will match the length of the assigned object.Here is the updated code:
r <- list() for (i in 1:pnum) { r[[i]] <- new_regimen( amt = amt[[i]], times = c(0:n[[i]]-1) * median_interval, cmt = 1, type = "infusion" ) }Note that I have changed
r[i]tor[[i]]in the assignment line.