[R] NA, where no NA should (could!) be!

Sarah Goslee sarah.goslee at gmail.com
Sat Dec 20 22:46:53 CET 2008


I think we need the reproducible example requested in
the posting guide.

Sarah

On Sat, Dec 20, 2008 at 4:42 PM, Oliver Bandel
<oliver at first.in-berlin.de> wrote:
> Hello,
>
> again I'm on my weblog-script... having problems...
>
>
>
>
> This code:
>
> ===========================
> weblog <- read_weblog("web.log")
> weblog_by_date <- split(weblog, weblog$date)
>
> #for ( i in names(weblog_by_day) ) { print(i); print(weblog_by_day$i) }
> for ( datum in names(weblog_by_date) )
> {
>  print(datum)
>  selected <- weblog_by_date[[datum]]
>
>  res_size_by_host <- tapply( selected$size, selected$host, sum)
>  mycat <- function(a,b) cat(paste(a, "==>", b, "\n"))
>  mapply( mycat, selected$size, selected$host )
>  print( res_size_by_host )
> }
> ===========================
>
>
>
> produces this result (only a part is shown!):
>
> =======================================
>  124.0.210.117   145.253.3.244   160.91.44.155   174.36.196.98
> 193.47.80.48
>             NA              NA              NA              NA
>    NA
>  200.212.63.51   200.87.53.234   208.80.194.30   208.80.194.35
> 208.80.194.46
>             NA             294              NA            5774
>    NA
>  208.80.194.49   209.17.171.58   210.207.57.39  211.171.202.85
> 211.43.212.94
> =======================================
>
> There are no "NA"-values, because the function read_weblog()
> replaces all NA by 0.
>
> So there should be no way to produce NA's!
>
> How can this happen?
>
>
> Ciao,
>   Oliver


-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list