R error: number of items to replace is not a multiple of replacement length R

前端 未结 1 890
闹比i
闹比i 2021-01-23 15:38

I wrote the following code and got the error: number of items to replace is not a multiple of replacement length at code line:

 X_after[count, ] = c(censN1, cen         


        
相关标签:
1条回答
  • 2021-01-23 16:30

    Your problem lies in the fact that sub_samples = n_samples/3 is not a whole number.

    When you create a sample of fractional size it creates a sample of floor(size)

    length(rlnorm(1.5,1,1)) 
    ## [1] 1
    

    Thus, when you recombine your data length( c(censN1, censN2, censN3)) does not (necessarily) equal n_sample.

    Thus, you need a method for dealing with numbers of samples that are not divisible by 3.

    0 讨论(0)
提交回复
热议问题