Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rmarkdown error #147

Open
tomassilveira opened this issue May 24, 2018 · 7 comments
Open

Rmarkdown error #147

tomassilveira opened this issue May 24, 2018 · 7 comments

Comments

@tomassilveira
Copy link

Hi everyone,

I am trying to run an rmarkdown document similar to the one we did on clustering but get the following error :

rmarkdown::render("INSEADAnalytics-master/INSEADAnalytics-master/CourseSessions/Homicides_project/Final_Project_v2TS.Rmd")
processing file: Final_Project_v2TS.Rmd
Installing package into 'C:/Users/tomas/Documents/R/win-library/3.5'
(as 'lib' is unspecified)
trying URL 'https://cran.r-project.org/src/contrib/Archive/networkD3/networkD3_0.2.13.tar.gz'
Content type 'application/x-gzip' length 107647 bytes (105 KB)
downloaded 105 KB

  • installing source package 'networkD3' ...
    ** package 'networkD3' successfully unpacked and MD5 sums checked
    ** R
    ** data
    *** moving datasets to lazyload DB
    ** inst
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
    converting help for package 'networkD3'
    finding HTML links ... done
    JS html
    finding level-2 HTML links ... done

    MisLinks html
    MisNodes html
    SchoolsJournals html
    as.radialNetwork html
    chordNetwork html
    dendroNetwork html
    diagonalNetwork html
    forceNetwork html
    igraph_to_networkD3 html
    networkD3-package html
    networkD3-shiny html
    radialNetwork html
    sankeyNetwork html
    saveNetwork html
    simpleNetwork html
    ** building package indices
    ** testing if installed package can be loaded
    *** arch - i386
    *** arch - x64

  • DONE (networkD3)
    In R CMD INSTALL
    Quitting from lines 174-175 (Final_Project_v2TS.Rmd)
    Error in quantile.default(r, 0.25) :
    missing values and NaN's not allowed if 'na.rm' is FALSE
    In addition: Warning messages:
    1: In block_exec(params) : failed to tidy R code in chunk
    reason: Error in loadNamespace(name) : there is no package called 'formatR'

2: In block_exec(params) : failed to tidy R code in chunk
reason: Error in loadNamespace(name) : there is no package called 'formatR'

Anyone had the same issue/would be willing to help?

Tomas

@tomassilveira
Copy link
Author

The error seems to be coming from this line of code :

iprint.df(round(my_summary(ProjectDataFactor), 2))

@Antoine-Engerand
Copy link

Hi Tomas. Maybe this website can help for the tidy R error: https://yihui.name/formatr/
For the first one, there may be NA or NaN values in your data. That's what the message seems to indicate. I hope it helps! ;)

@tomassilveira
Copy link
Author

Thank you Antoine! Indeed, there was a problem with some NA values. Slowly progressing :)

@cynthiadandrea
Copy link

I am also trying to do the same thing, but am getting a different style of error: "Error in quantile.default(r, 0.25) :
missing values and NaN's not allowed if 'na.rm' is FALSE "

@tomassilveira
Copy link
Author

Seems to be in the same line you are having a problem, and also due to NA values.

Have you checked the ProjectData_Initial file to see if you have any NAs?

@cynthiadandrea
Copy link

I do. I tried using the below to fix it, but it doesnt seem to work.
fixNAs<-function(data_frame){

Define reactions to NAs

integer_reac<-0
factor_reac<-"FIXED_NA"
character_reac<-"FIXED_NA"
date_reac<-as.Date("1900-01-01")

@tomassilveira
Copy link
Author

Here is how we did. Perhaps it will work with you :

rawdata$Perpetrator.Age[rawdata$Perpetrator.Age=="NA"] = 0
rawdata$Victim.Age[rawdata$Victim.Age=="NA"] = 0
rawdata$Victim.Age[rawdata$Victim.Age=="NA"] = 0

The first line for instance is basically saying : if column Perpetrator.Age in rawdata is equal to "NA", then turn it equal to 0. With just one line you solve the problem of an entire column

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants