r - Coercion To Scalar In data.table Function Argument Accepting Scalar or Vector -


i expect code:

datab <- data.table(events = c(79,68,54), duration = c(61,44,72)) datab[, .(poisson.high=poisson.test(events, t = duration)$conf.int[2])] 

to produce:

   nrow poisson.high 1:    1    1.6140585 2:    2    1.9592319 3:    3    0.9785873 

instead produces:

error in poisson.test(events, t = duration) :    case k > 2 unimplemented 

as understand it, because poisson.test's first argument can accept vector scalar. in vector case must 2 elements , no more. there 3 rows in table evaluation of first row fails sees vector 3 elements first argument poisson.test.

how can reference events in such way provides scalar value associated row? (i've tried events[1] uses first row in datab obvious reasons.)


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -