cssearcy / AYS-R-Coding-SPR-2020

Coding in R for Policy Analytics
https://cssearcy.github.io/AYS-R-Coding-SPR-2020/
3 stars 3 forks source link

Lab 01 - Error When Knitting Markdown #33

Open eneleven11 opened 3 years ago

eneleven11 commented 3 years ago

My understanding is that the template document should be 'knit ready'

however, when I knit the template with no changes

this error appears on R Markdown

" Quitting from lines 312-317 (Lab-01-v2_LastName.Rmd) Error in sum(dat$sqft) : invalid 'type' (character) of argument Calls: ... handle -> withCallingHandlers -> withVisible -> eval -> eval Execution halted "

It seems as if the command is trying to do something to the wrong type of element? A character instead of a number?

I'm not sure how to fix this error

lecy commented 3 years ago

Many of the templates have example placeholder code within chunks that may need to be adapted to run.

If a specific chunk is not working you can add the chunk argument eval=F to skip that chunk.

```{r, eval=F}

R recently updated the way that it load CSV files - it may have impacted the default data types. To convert from character to numeric you can re-cast the variable.

URL <- "https://raw.githubusercontent.com/DS4PS/Data-Science-Class/master/DATA/syr_parcels.csv"
dat <- read.csv( URL )
dat$sqft <- as.numeric( dat$sqft )

See: http://ds4ps.org/dp4ss-textbook/ch-050-vectors.html#data-types

jamisoncrawford commented 3 years ago

Thanks @lecy. @eneleven11 - the error message is pointing you towards Lines 312-317, where there's function sum() etc. Unless you've coded a few dozen lines for the assignment, those should be in the submission instructions (anything under "Delete This Line & All Lines Below..." message).

@lecy's solution will help run the document with the submission instructions, but you should remove those before submitting anyway. This will eliminate the problematic code chunk. Let us know if this works!

eneleven11 commented 3 years ago

@jamisoncrawford @lecy Thank you! This worked!

jamisoncrawford commented 3 years ago

@eneleven11 glad to hear it!