G'day Henrik,
On Thu, 18 May 2023 08:35:38 -0700
Henrik Bengtsson wrote:
> ... or just put the R expression inside curly brackets, e.g.
I was wondering whether I was having a fortunes::fortune(106) moment. :-)
Cheers,
Berwin
__
R-help@r-pro
G'day Greg,
On Thu, 18 May 2023 08:57:55 -0600
Greg Snow <538...@gmail.com> wrote:
[...]
> `fun(x <- expr)` Assigns the value of `expr` to the variable `x` in
> the frame/environment that `fun` is called from.
Only if the argument 'x' is evaluated during the function call AFAIK.
If it is not, d
... or just put the R expression inside curly brackets, e.g.
tryCatch({
sexsnp[i] = fisher.test(table(data[,3], data[,i+38]))$p
}, error=function(e) print(NA))
Exercise: Compare
> list(a = 2)
$a
[1] 2
with
> list({ a = 2 })
[[1]]
[1] 2
and
> list(b = { a = 2 })
$b
[1] 2
BTW, note how the
G'day Federico,
On Wed, 17 May 2023 10:42:17 +
"Calboli Federico (LUKE)" 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] ="
G'day Federico,
On Wed, 17 May 2023 10:42:17 +
"Calboli Federico (LUKE)" wrote:
> I_d be obliged if someone can explain why tryCatch assigns items with _<-_
> and not _=_.
It is not just tryCatch but any function. In function calls the "=" is
used to assign actual arguments to formal argu
Because `<-` and `=` do different things (and I am one of the old
fossils that wish they had not been confounded).
`fun(x <- expr)` Assigns the value of `expr` to the variable `x` in
the frame/environment that `fun` is called from.
`fun(x = expr)` Assigns the value of `expr`to the variable `x` in
> The only difference is the use of ’=’ or ‘<-‘ to assign the p value of
the fisher test to the vector. I stopped using ‘<-‘ eons ago so it took a
bit to figure out.
The '=' has a context-dependent meaning - in a function call it is used to
name arguments and outside of a function call it is use
Hello,
I run a fisher.test() in a loop, with the issue that some of the data will not
be useable. To protect the loop I used tryCatch but:
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: unexpecte
8 matches
Mail list logo