[R] Help Required for R Markdown function.
Avi Gross
@v|gro@@ @end|ng |rom ver|zon@net
Tue Mar 2 01:04:46 CET 2021
Calum,
Thanks for your thoughts. As mentioned, I fixed the problem. I actually was using require() and also tried library() but the problem was elsewhere as my R installation and startup seemed to no longer have variables set properly to find packages remotely or locally.
And yes, I made a new empty markdown but as it asks for nothing, it has no problems 😉
From: CALUM POLWART <cpolwart using chemo.org.uk>
Sent: Monday, March 1, 2021 2:31 AM
To: Avi Gross <avigross using verizon.net>
Cc: 'R. Help Mailing List' <r-help using r-project.org>
Subject: Re: [R] Help Required for R Markdown function.
Sounds like you have an install.packages("tidyverse") line in your Rmd rather than library (tidyverse)
Does this happen on a Rmd example created by doing File/New/R Markdown
With no changes?
On 28 Feb 2021 22:04, Avi Gross via R-help <r-help using r-project.org <mailto:r-help using r-project.org> > wrote:
I am sure you can get more done with a caret than a stick. I need a stick for another problem, though.
A serious question. I somehow upset my R/RSTUDIO setup while trying to see why a markdown only allowed me to save an HTML version, not PDF and DOC as it used to. It now fails on any such document with a code that indicates it is not set to find a CRAN mirror:
It seems to be upset by a simple call to get the tidyverse loaded and may succeed in one sense but not continue:
" Installing package into �C:/Users/avid2016/Documents/R/win-library/4.0�
(as �lib� is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/tidyverse_1.3.0.zip'
Content type 'application/zip' length 439972 bytes (429 KB)
downloaded 429 KB
package ‘tidyverse’ successfully unpacked and MD5 sums checked
..."
The R Markdown lower console window says:
"Error in contrib.url(repos, "source") : trying to use CRAN without setting a mirror calls <Anonymous> ...
withVisible -> eval -> eval install.packages -> contrib.url Exection halted"
I have done some work that failed. I am running on windows with the latest versions of both R and RSTUDIO after removing all old versions and re-installing both. I have seen hints I need to set some definitions in a .Rprofile or so and tried but it continues to fail. So I now can knit nothing!
Anyone have a pointer on problems like this? My next attempt would be to reinstall the programs on another hard disk entirely in case the problem is in my folder structure of ~/R and below but I dod not want to toss years of work because of one errant configuration file or the lack thereof.
Thanks in advance for any advice. It may be something trivial such as kit not knowing where to place a library so it puts it into a temp area?
Avi
-----Original Message-----
From: R-help <r-help-bounces using r-project.org <mailto:r-help-bounces using r-project.org> > On Behalf Of John Kane
Sent: Saturday, February 27, 2021 3:07 PM
To: Kishor raut <rautkishor01 using gmail.com <mailto:rautkishor01 using gmail.com> >
Cc: R. Help Mailing List <r-help using r-project.org <mailto:r-help using r-project.org> >
Subject: Re: [R] Help Required for R Markdown function.
The "confusionMatrix" function appears to be from the 'caret' package.
Have you loaded 'caret' with the library(caret) command?
On Sat, 27 Feb 2021 at 14:20, Kishor raut <rautkishor01 using gmail.com <mailto:rautkishor01 using gmail.com> > wrote:
> Respected Sir,
>
> I Mr Kishor Tried to get help online but wont found the solution so
> writting an email.
>
> Step1: While writting in rmarkdown all codes get executted very well
> till the fuction Confusionmatrix were written on it.
>
> Step2: As confusionmatrix command inserted following error is on
> screen board
>
>
> processing file: RMarkdown.Rmd
> |..... |
> 7%
> ordinary text without R code
>
> |......... |
> 13%
> label: unnamed-chunk-1
> |.............. |
> 20%
> ordinary text without R code
>
> |................... |
> 27%
> label: unnamed-chunk-2
> |....................... |
> 33%
> ordinary text without R code
>
> |............................ |
> 40%
> label: unnamed-chunk-3
> |................................. |
> 47%
> ordinary text without R code
>
> |..................................... |
> 53%
> label: unnamed-chunk-4
> |.......................................... |
> 60%
> ordinary text without R code
>
> |............................................... |
> 67%
> label: unnamed-chunk-5
> |................................................... |
> 73%
> ordinary text without R code
>
> |........................................................ |
> 80%
> label: unnamed-chunk-6
> |............................................................. |
> 87%
> ordinary text without R code
>
> |................................................................. |
> 93%
> label: unnamed-chunk-7
> Quitting from lines 98-104 (RMarkdown.Rmd) Error in
> confusionMatrix(p1, train$CTestresult) :
> could not find function "confusionMatrix"
> Calls: <Anonymous> ... handle -> withCallingHandlers -> withVisible ->
> eval
> -> eval
>
> Execution halted
>
> Step4: As codes were written these
>
>
> Using function “sample” the data takes into sample of the specified
> size from the stored data ```{r}
> set.seed(1234)
> ind<-sample(2,nrow(FEVER1),replace=TRUE, pro = c(0.7,0.3))
> train<-FEVER1[ind==1,] test<-FEVER1[ind==2,] ```
>
> Application of Random Forest
>
> ```{r}
> library(randomForest)
> set.seed(123)
> rfmodel<-randomForest(CTestresult~.,data = train,prox=TRUE) # Random
> Forest Model
> plot(rfmodel,main="RandomForest Model")
> print(rfmodel,train) # Printing Outcome of 'model for
> Training Data
>
> ```
>
> Prediction using Randome Forest Model
> ```{r}
> # Prediction of RandomForest Intial Model for Test and Train Data
>
> ptrain1<-predict(rfmodel,train) # Predicting model Prediction
> On Training Data
> # First Six Outcomes with prediction
> head(ptrain1) # Printing First Six Prediction
> using Random Forest Model
> head(train$CTestresult) # Printing First Six (6)
> Actual outcomes
>
> ```
>
>
> Tuning Model:
> Tuning of Machine learning model is important step for building good
> model for best outcome of research.
>
> ```{r}
> # Tunning RandomForest Model using Algorithm
>
> t<-tuneRF(train[,-11],train$CTestresult, mtryStart = 2,ntreeTry = 100,
> stepFactor =2,improve = 0.051,trace = TRUE, plot = TRUE, doBest=TRUE)
>
>
> ```
>
> Building New Model:
>
> New model was build on the basis of tunned model parameters and controls.
>
> ```{r}
> # New Model After Tuning Random Forest Model
>
> rf1<-randomForest(CTestresult~.,data = train,ntree = 100, mtry = 8,
> importance = TRUE,proximity = TRUE)
>
> print(rf1)
> ```
>
> Prediction and Confusion MAtrix:
>
> outcome of model will mesuare with the help of predictive outcomes
> with the help of confusion matrix.
>
> ```{r}
> # Prediction using Random Forest and Confusion Matrix for Train Data
> p1<-predict(rf1,train)
> cmatrix<-confusionMatrix(p1,train$CTestresult)
> cmatrix
>
>
> ```
>
>
> I will great thank full if you will help me for to remove the error.
>
>
>
>
> --
> *Kind Regards*
>
> Kishor Raut
> *Cell No.-07387706552*
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org <mailto: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.
>
--
John Kane
Kingston ON Canada
[[alternative HTML version deleted]]
______________________________________________
R-help using r-project.org <mailto: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.
______________________________________________
R-help using r-project.org <mailto: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.
[[alternative HTML version deleted]]
More information about the R-help
mailing list