Knitr chunk imports a subset of records from * .csv as the same code in R

Rstudio version 0.96.331 and version knitr 0.8

I thought my problem was resolved with updating RStudio and libraries ... however:

The next run in R gives me 940 unique Table.ID values. Run in a piece of knitr. I get 228 unique values ​​and the following warning:

"invalid entry found when connecting input http://www2.census.gov/acs2010_5yr/summaryfile/Sequence_Number_and_Table_Number_Lookup.txt '

I do not understand why there is a difference between the two methods.

Sequence <- read.csv("http://www2.census.gov/acs2010_5yr/summaryfile/Sequence_Number_and_Table_Number_Lookup.txt", stringsAsFactors=FALSE) unique(Sequence$Table.ID) 

enter image description hereenter image description here

+4
source share
1 answer

Works great in Rstudio 0.96.331 and knitr 0.8

My .Rmd file:

  knitr test for length ======================================================== This should successfully return a length of 940 ```{r} Sequence <- read.csv("http://www2.census.gov/acs2010_5yr/summaryfile/Sequence_Number_and_Table_Number_Lookup.txt", fileEncoding = "iso8859-8", stringsAsFactors = FALSE) length(unique(Sequence$Table.ID)) ``` 

As a result:

enter image description here

+5
source

Source: https://habr.com/ru/post/1433006/


All Articles