Watts-College / cpp-527-fall-2021

A course shell for CPP 527 Foundations of Data Science II
https://watts-college.github.io/cpp-527-fall-2021/
2 stars 6 forks source link

Error When Knitting: Error in parse #77

Open AmyTrumpower opened 2 years ago

AmyTrumpower commented 2 years ago

I'm trying to knit my code and I'm getting the following error:

Error in parse(text = x, srcfile = src) : attempt to use zero-length variable name Calls: ... -> parse_all -> parse_all.character -> parse

I'm not sure if this is the code that is giving issue, but it's the only place that I see parse. Also, it doesn't happen when I run the chunks, only when I knit- I'm getting the first names separated when running the chunks.

#Step 2: Parse First Name

get_first_name <- function(name)
{

# extract names after comma 
first.middle <- sub( ".*, " , "", name)

# extract name before space
first.name <- sub(" .*", "", first.middle)

}

top.25 <- head( d$Full.Name,25 )
first.25 <- get_first_name( name=top.25 )

data.frame( top.25, first.25 ) %>% pander()

here is the output returned in RStudio:

---------------------------------
        top.25          first.25 
---------------------- ----------
   Tamer, A Joseph         A     

    Falvey, Aaron        Aaron   

    Downey, Aaron        Aaron   

     Boyd, Aaron         Aaron   

     Hess, Aaron         Aaron   
     Baker, Aaron        Aaron   

Any help is greatly appreciated.

lecy commented 2 years ago

Are there any chunks that are missing a tick mark?

https://stackoverflow.com/questions/46171362/rmarkdown-error-attempt-to-use-zero-length-variable-name

Are you sure you have all data and packages loaded? All of your custom functions loaded before trying to call them?

lecy commented 2 years ago

Have you tested this function with the full set of unique names?

get_first_name( name=top.25 )

AmyTrumpower commented 2 years ago

I had:

````{r}
#Step 2: Parse First Name

get_first_name <- function(name)

Of all the errors I have worked out on my own, it was the extra tick mark that stumped me. That will be one that I don't forget.

Thank you!

lecy commented 2 years ago

I should give awards for the best bug on every assignment. This one is pretty good! Subtle enough that you would be too focused on the code to catch it.

Did the chunk actually run like that?

AmyTrumpower commented 2 years ago

yes, it ran perfectly which is surprising because I have forgotten the ticks on the end a couple of times and nothing happens.

lecy commented 2 years ago

Interesting. That’s a new one for me!

lecy commented 2 years ago

@AmyTrumpower you have competition for the sneakiest bug: https://github.com/Watts-College/cpp-527-fall-2021/issues/75#issuecomment-939186978