Skip to content
Prev 374521 / 398513 Next

Average of results coming from B=100 repetitions (looping)

On 5/8/2018 12:26 PM, varin sacha via R-help wrote:
<<<snip>>>

You need to spend some time with the Introduction to R that came with 
your R installation.  First, lst in your example is not a function, it 
is a list. And as you found, the mean() function does not work on a 
list. Second, your "minimal reproducible" example could have been 
something like this

lst <- list()
for (i in 1:10) lst[i] <- i
mean(lst)  # does not work

The documentation for mean, ?mean, says that it is looking for a numeric 
or logical vector.  To convert your list to a numeric vector you could 
unlist() it.

mean(unlist(lst))


Hope this is helpful,

Dan