rinruby icon indicating copy to clipboard operation
rinruby copied to clipboard

replacement has length zero

Open kumarsaurabh20 opened this issue 11 years ago • 1 comments

I am receiving an error "Error in norm_val[i, ] <- dummy : replacement has length zero" with the following code: R.eval <<-EOF

columns <- matrix(0, length(probes), count)

 for (i in c(1:count)) {
     if (i == 1) { columns <- cbind(get(paste0("col",i))) } 
     else { columns <- cbind(columns, get(paste0("col",i))) }    
     }

norm_val <- matrix(0, length(norm_probes), ncol(columns) - 1)

    for (i in 1:length(norm_probes)) {
    dummy <- columns[norm_probes[i] == columns[,1],]
    print(dummy)
    dummy <- dummy[-1]
    print(dummy)
    norm_val[i,] <- dummy
    }

EOF

 return R.pull "norm_val"

I dont know where to ask this question as its very particular with RinRuby. The code is working fine in R terminal.

Here it says: print('RINRUBY.EVAL.FLAG') Matrix[[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]

this matrix is suppose to be filled with values but its coming empty?? Is there a limit in integer or character sizes which we pass to R from Ruby??

complete code is here, just incase you need it: https://github.com/kumarsaurabh20/PlotApp/blob/master/app/controllers/uploads_controller.rb

kumarsaurabh20 avatar May 02 '14 14:05 kumarsaurabh20

I will take a look at this. Thanks for reporting El may 2, 2014 10:30 a.m., "JstRoRR" [email protected] escribió:

I am receiving an error "Error in norm_val[i, ] <- dummy : replacement has length zero" with the following code: R.eval <<-EOF

columns <- matrix(0, length(probes), count)

for (i in c(1:count)) { if (i == 1) { columns <- cbind(get(paste0("col",i))) } else { columns <- cbind(columns, get(paste0("col",i))) } }

norm_val <- matrix(0, length(norm_probes), ncol(columns) - 1)

for (i in 1:length(norm_probes)) {
dummy <- columns[norm_probes[i] == columns[,1],]
print(dummy)
dummy <- dummy[-1]
print(dummy)
norm_val[i,] <- dummy
}

EOF

return R.pull "norm_val"

I dont know where to ask this question as its very particular with RinRuby. The code is working fine in R terminal.

Here it says: print('RINRUBY.EVAL.FLAG') Matrix[[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]

this matrix is suppose to be filled with values but its coming empty?? Is there a limit in integer or character sizes which we pass to R from Ruby??

complete code is here, just incase you need it:

https://github.com/kumarsaurabh20/PlotApp/blob/master/app/controllers/uploads_controller.rb

— Reply to this email directly or view it on GitHubhttps://github.com/clbustos/rinruby/issues/12 .

clbustos avatar May 02 '14 15:05 clbustos