[R] Survey package/svyby source code help

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Tue Feb 11 17:07:59 CET 2020


On Tue, 11 Feb 2020 15:23:14 +0000
AndertechLLC using protonmail.com wrote:

> The attr(, "var") that I am interested in is displayed with
> str(results) after the results object is declared.  First line of the
> subject code looks like:
> 
> results <- (if (multicore) parallel::mcapply else lapply)(uniques,
> function(i){....

'if' returns whatever the taken branch returns (it is documented
in ?'if', section "Value").

The rest of the statement applies the function FUN (passed as argument
to svyby) to the data (passed as `formula` argument), so the "var"
attribute you are looking for in fact comes from the FUN invocation and
not from svyby itself. Most examples from ?svyby use FUN=svymean, so
perhaps this is where you should be going next. Make sure to check out
R-Intro [*] to avoid common pitfalls when working with methods in R.

-- 
Best regards,
Ivan

[*]
https://cran.r-project.org/doc/manuals/r-release/R-intro.html#Object-orientation



More information about the R-help mailing list