[R] suprising behaviour of tryCatch()
Berwin A Turlach
berw|n@tur|@ch @end|ng |rom gm@||@com
Thu May 18 17:22:28 CEST 2023
G'day Federico,
On Wed, 17 May 2023 10:42:17 +0000
"Calboli Federico (LUKE)" <federico.calboli using luke.fi> wrote:
> sexsnp = rep(NA, 1750)
> for(i in 1:1750){tryCatch(sexsnp[i] = fisher.test(table(data[,3],
> data[,i + 38]))$p, error = function(e) print(NA))} Error: unexpected
> '=' in "for(i in 1:1750){tryCatch(sexsnp[i] ="
Try:
R> for(i in 1:1750){tryCatch(eval(expression("sexsnp[i] = fisher.test(table(data[,3], data[,i+38]))$p")), error=function(e)print(NA))}
or
R> for(i in 1:1750){tryCatch(bquote("sexsnp[i] = fisher.test(table(data[,3], data[,i+38]))$p"), error=function(e) print(NA))}
or
R> for(i in 1:1750){tryCatch(.("sexsnp[i] = fisher.test(table(data[,3], data[,i+38]))$p"), error=function(e) print(NA))}
If you want to use the '='.
Cheers,
Berwin
More information about the R-help
mailing list