Search code examples
rknitrdevtools

How to troubleshoot error with "sew" when knitting my rmarkdown file


Can't find generic `sew` in package knitr to register S3 method.
i This message is only shown to developers using devtools.
i Do you need to update knitr to the latest version? 

I keep receiving the above error when I try to knit my rmarkdown file to html. All I am doing is cleaning up my dataset with dplyr (select, mutate,etc.) And generating cross tabs with the expss package

I am not using devtools. In fact, I didn't even have the package installed when the error appeared.

My code was knitting to html just fine. All I did was copy my code and change one variable (Race to Ethnicity), and then knit to HTML stopped working. It was working minutes before.

To fix this, I have tried:

  • knit to PDF (same error)

  • updating knitr and rmarkdown and expss

  • installing devtools and running library(devtools)

  • Closing out R and restarting my session

  • Clearing out my global environment and re-running everything

  • deleting the new code and running the original code that was working minutes before

None of these things worked! Any idea what could have happened with R markdown?

All I do is read in my excel sheet into "FullData" And then I run this code

```{r, include = FALSE}
Racedata <- FullData %>%
  select(Coder, Link, Chamber, SenateCommittee, SenateSubcommittee, HouseCommittee, HouseSubcommittee, Name, BillType, BillNumber, Race1, Race2) %>%

#Fix issues with Race columns
      mutate(Race2 = na_if(Race2, "Other")) %>%
    mutate(Race2 = na_if(Race2, "White"))

#Combine 2 Race columns into 1
Racedata$Race2 <- gsub("Unknown", "Audio Only", Racedata$Race2)
Newrace <- data.frame(Race = with(Racedata, replace(Race2, is.na(Race2), Race1[is.na(Race2)])))
Racedata$Race <- Newrace$Race

Racedata <- Racedata %>%
  select(-c(Race1, Race2))

```

The code works just fine when I run it, but the error occurs when I try to knit to html.

This is the table that I want to produce with Knit to HTML:

```{r RACE CHARTS, echo = FALSE}

cross_cpct(Racedata, Race, list(total(), Chamber, HouseCommittee, SenateCommittee))

```

Solution

  • I figured it out! Stupid mistake Two of my code blocks had the same name (facepalm)