0

I am using the latest versions of R and R Studio on a 64 bit Windows 7 system and have successfully constructed the R program needed to complete my course project. However, I am required to turn in R markdown output as compiled html. My program runs to about 70% completion in R markdown and then throws an error that I cannot understand. I can't complete my project due to this R markdown problem.

Here's more detail:

My markdown document begins with:

---
title: 'Final Report: Prediction Assignment'
author: "Donald Chambless"
date: "June 23, 2016"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
..................................
..................................

and all of the code that follows executes correctly in R markdown until this statement:

trainingPred <- predict(RandomTreeModel, trainingData[ , -54])

This line fails in R markdown with the following error message:

Error in eval(expr, envir, enclos) : object 'accel_forearm_y' not found calls: ... predict.train -> model.frame -> model.frame.default -> eval -> eval

I don't understand what's going on. Can anyone help?

I'm a newcomer to Stack Overflow, but I hope I have explained my problem sufficiently.

989
  • 12,579
  • 5
  • 31
  • 53
  • 1
    Welcome to SO. You will need to provide a bit more to go on. I.e. some data, and the shortest amount of code that replicates your error. Please read [this](http://stackoverflow.com/help/mcve) and [this](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) to learn handy tips on how to construct a great question. – dww Jun 25 '16 at 01:03
  • It seems that `accel_forearm_y` is not defined. Make sure that the lines that defined it in your original script are also present in your markdown file. If you are using RStudio, you can press Ctrl+Alt+R to run the Code in all your chunks. This might make it easier to debug. If you cleaned your Envrionment before doing this, you can easily check whether the variable `accel_forearm_y` has been created. – Stibu Jun 25 '16 at 05:42
  • Hi Don, first make sure all your r object names are correct. Second, try storing your test data into another variable like: `testData <- traindata[,-54`] `trainingPred <- predict(RandomTreeModel, testData)` Before running R markdown, check if it works in R console. – Sowmya S. Manian Jun 25 '16 at 08:59
  • I can't find the green arrows I see referenced, so I'll have to just say "thanks." – Don Chambless Jun 26 '16 at 22:37

0 Answers0