Help with finalfit and knitr

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with finalfit and knitr

Bill Poling
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}}

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Help with finalfit and knitr

Jeff Newmiller
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 <[hidden email]> 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}}
>
>______________________________________________
>[hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Fwd: Help with finalfit and knitr

Bert Gunter-2
(From Jeff Newmiller)


"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."

Fortune nomination!

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Wed, Aug 8, 2018 at 8:06 AM, Jeff Newmiller <[hidden email]>
wrote:

> 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 <[hidden email]>
> 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}}
> >
> >______________________________________________
> >[hidden email] 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.
>
> ______________________________________________
> [hidden email] 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/posti
> ng-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Help with finalfit and knitr

Martin Maechler
>>>>> Bert Gunter
>>>>>     on Wed, 8 Aug 2018 08:21:05 -0700 writes:

    > (From Jeff Newmiller) "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."

    > Fortune nomination!

seconded!
Martin

    > Cheers, Bert

    > Bert Gunter

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Help with finalfit and knitr

Bill Poling
In reply to this post by Jeff Newmiller
Wow, thank you Jeff, that’s got it!

explanatory = c("ProductName", "AgeCat", "PatientGender","RevCodeCats")
 View(explanatory)
dependent = "BinaryAccSav" # ---------------------------------------------------- AcceptedSavings AcceptedSavings 1=Y 0=N
View(dependent)
df6 %>% summary_factorlist(dependent, explanatory, p=TRUE, add_dependent_label=TRUE) -> t1
View(t1)
knitr::kable(t1, row.names=FALSE, align=c("l", "l", "r", "r", "r"))

WHP


From: Jeff Newmiller <[hidden email]>
Sent: Wednesday, August 08, 2018 11:07 AM
To: [hidden email]; Bill Poling <[hidden email]>; r-help ([hidden email]) <[hidden email]>
Subject: Re: [R] Help with finalfit and knitr

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 <[hidden email]<mailto:[hidden email]>> 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<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}}
>
>______________________________________________
>[hidden email]<mailto:[hidden email]> mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html<http://www.R-project.org/posting-guide.html>
>and provide commented, minimal, self-contained, reproducible code.

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

Confidentiality Notice This message is sent from Zelis. This transmission may contain information which is privileged and confidential and is intended for the personal and confidential use of the named recipient only. Such information may be protected by applicable State and Federal laws from this disclosure or unauthorized use. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any disclosure, review, discussion, copying, or taking any action in reliance on the contents of this transmission is strictly prohibited. If you have received this transmission in error, please contact the sender immediately. Zelis, 2018.

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.