[R] Help with finalfit and knitr

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Wed Aug 8 17:06:48 CEST 2018


R syntax does not allow for objects to be plopped next to each other separated by a space. There should be a newline after the t1 variable. This kind of problem plagues people copying HTML into emails on this mailing list (losing newlines), and was probably introduced into your code during a copy-paste as well.

There is no package called "kable"... that is a function in the knitr package.

My advice is to enter one line of each example at a time and study what it does before proceeding to the next line. Copying whole swathes of code and marveling at the result is exhilarating but ultimately leaves you handicapped in creating your own code.

On August 8, 2018 6:49:18 AM PDT, Bill Poling <Bill.Poling using zelis.com> wrote:
>Hi using some of my own data I am trying to reproduce examples from
>this tutorial:
>
>https://cran.r-project.org/web/packages/finalfit/vignettes/finalfit_basics.html
>
>Here are my sys info:
>R version 3.5.1 (2018-07-02)
>Platform: x86_64-w64-mingw32/x64 (64-bit)
>Running under: Windows Server >= 2012 x64 (build 9200)
>
>Here is my data structure:
>str(df6)
># 'data.frame': 78407 obs. of  6 variables:
>#   $ ProductName    : Factor w/ 2 levels "Editing","OON": 2 2 2 2 2 2
>2 2 2 2 ...
># $ RevCodeCats    : Factor w/ 20 levels "BHAccomodations",..: 10 10 12
>12 8 8 12 20 8 19 ...
># $ AgeCat         : Factor w/ 10 levels "[>80]","[0-5]",..: 9 9 5 5 7
>4 7 7 7 9 ...
># $ PatientGender  : Factor w/ 3 levels "F","M","U": 2 2 2 2 2 1 1 1 1
>1 ...
># $ AcceptedSavings: num  0 0 0 0 48.9 ...
># $ BinaryAccSav   : Factor w/ 2 levels "0","1": 1 1 1 1 2 2 2 2 2 2
>...
>
>Here is my call:
>
>explanatory = c("ProductName", "AgeCat", "PatientGender")
>dependent = "BinaryAccSav"
>#-------------------------------------------------------
>AcceptedSavings 1=Y 0=N
>df6 %>%  finalfit(dependent, explanatory, p=TRUE,
>add_dependent_label=TRUE) -> t1 knitr::kable(t1, row.names=FALSE,
>align=c("l", "l", "r", "r", "r"))
>
>Here is the error:
>#Error: unexpected symbol in " df6 %>%  finalfit(dependent,
>explanatory, p=TRUE, add_dependent_label=TRUE) -> t1 knitr"
>
>The error is identifying the knitr::kable(t1, row.names=FALSE,
>align=c("l", "l", "r", "r", "r")) as the problem
>
>I believe I have copied the procedure correctly from the tutorial and
>replaced the tutorial variables with mine.
>
>Libraries I believe are necessary:
>library("knitr", lib.loc="~/R/win-library/3.5")
>library("rmarkdown", lib.loc="~/R/win-library/3.5")
>library("htmlTable", lib.loc="~/R/win-library/3.5")
>
>And I see --Warning in install.packages :  package 'kable' is not
>available (for R version 3.5.1) which I believe is my problem?
>
>
>  1.  can my hunch be validated by someone please?
>  2.  Is there a solution for this?
>  3.  or do I contact the package authors directly?
>
>Thank you all!
>
>WHP
>
>
>Confidentiality Notice This message is sent from Zelis.
>...{{dropped:15}}
>
>______________________________________________
>R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.




More information about the R-help mailing list