Help Required for R Markdown function.

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

Help Required for R Markdown function.

Kishor raut
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]]

______________________________________________
[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 Required for R Markdown function.

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


--
John Kane
Kingston ON Canada

        [[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: Help Required for R Markdown function.

Kishor raut
Thanks, I'll check it out.

On Sun, 28 Feb, 2021, 1:37 AM John Kane, <[hidden email]> wrote:

> 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 <[hidden email]> 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]]
>>
>> ______________________________________________
>> [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.
>>
>
>
> --
> John Kane
> Kingston ON Canada
>

        [[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: Help Required for R Markdown function.

R help mailing list-2
In reply to this post by John Kane-3
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 <[hidden email]> On Behalf Of John Kane
Sent: Saturday, February 27, 2021 3:07 PM
To: Kishor raut <[hidden email]>
Cc: R. Help Mailing List <[hidden email]>
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 <[hidden email]> 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]]
>
> ______________________________________________
> [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.
>


--
John Kane
Kingston ON Canada

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

______________________________________________
[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 Required for R Markdown function.

R help mailing list-2
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 <[hidden email]>
Sent: Monday, March 1, 2021 2:31 AM
To: Avi Gross <[hidden email]>
Cc: 'R. Help Mailing List' <[hidden email]>
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 <[hidden email] <mailto:[hidden email]> > 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 <[hidden email] <mailto:[hidden email]> > On Behalf Of John Kane
Sent: Saturday, February 27, 2021 3:07 PM
To: Kishor raut <[hidden email] <mailto:[hidden email]> >
Cc: R. Help Mailing List <[hidden email] <mailto:[hidden email]> >
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 <[hidden email] <mailto:[hidden email]> > 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]]
>
> ______________________________________________
> [hidden email] <mailto:[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.
>


--
John Kane
Kingston ON Canada

[[alternative HTML version deleted]]

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

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




        [[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: Help Required for R Markdown function.

Jeff Newmiller
In reply to this post by R help mailing list-2
It is standard for install.packages to download packages into a temporary directory before actually installing them. That message has been there for many many years every time you install a contributed package.

You have not provided a complete copy of the errors that were generated... I am certain something else happened that was in the output you failed to show us.

While I think RStudio is a fine tool, it does sometimes make non-trivial changes to standard outputs... I recommend that you try things in RGui or R from the command line (in this case the install.packages call) and describe them as such when asking for help here to reduce possible confusion as to where the problem is coming from. If it works in RGui but not in RStudio then you probably need to get help in their community forum.

Also, don't hijack conversation threads... start your own to ask a question, and reply to it as needed. Even changing the subject line doesn't disconnect your question from the original thread in the archive (or most email programs).

On February 28, 2021 2:04:52 PM PST, Avi Gross via R-help <[hidden email]> 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 <[hidden email]> On Behalf Of John Kane
>Sent: Saturday, February 27, 2021 3:07 PM
>To: Kishor raut <[hidden email]>
>Cc: R. Help Mailing List <[hidden email]>
>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 <[hidden email]>
>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]]
>>
>> ______________________________________________
>> [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.
>>
>
>
>--
>John Kane
>Kingston ON Canada
>
> [[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.
>
>______________________________________________
>[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.