rscript - Updating lists in R -


i have following list in r , want replace null in list zero. there better way of doing rather iterating through list?

$`2014-06-15` null $`2014-06-16` [1] 7 $`2014-06-17` [1] 17 $`2014-06-18` [1] 24 $`2014-06-19` [1] 8 $`2014-06-20` [1] 11 $`2014-06-21` null $`2014-06-22` [1] 1 $`2014-06-23` [1] 20 $`2014-06-24` [1] 21 

in reference solution, way easier , faster replacing for loop , if statement. here's short example.

> ( temp <- list(a = null, b = 1:5) ) # $a # null #  # $b # [1] 1 2 3 4 5  > temp[sapply(temp, is.null)] <- 0 > temp # $a # [1] 0 # # $b # [1] 1 2 3 4 5 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

django - CSRF verification failed. Request aborted. CSRF cookie not set -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -