DS4PS / cpp-526-fall-2019

Course material for CPP 526 Foundations of Data Science I
http://ds4ps.org/cpp-526-fall-2019
4 stars 4 forks source link

Lab 01 Question #3 #11

Closed castower closed 5 years ago

castower commented 5 years ago

Hello all,

I am currently trying to solve question number 3, "How many vacant BUILDINGS are there in Syracuse (sum over a logical vector)?". However, although the table indicates that vacantbuil is a logical statement, running class(dat$vacantbuil) is returning that it is a character type. I have reloaded the data again, but it keeps telling me that it is a character vector. Therefore, I am a little confused on how to make it load into R correctly. Any advice would be helpful!

Thanks, Courtney

lecy commented 5 years ago

If you run this chunk, what do you get?

```{r}
URL <- "https://raw.githubusercontent.com/DS4PS/Data-Science-Class/master/DATA/syr_parcels.csv"
dat <- read.csv( URL, stringsAsFactors=FALSE )
class( dat$vacantbuil )
castower commented 5 years ago

If you run this chunk, what do you get?

```{r}
URL <- "https://raw.githubusercontent.com/DS4PS/Data-Science-Class/master/DATA/syr_parcels.csv"
dat <- read.csv( URL, stringsAsFactors=FALSE )
class( dat$vacantbuil )

This chunk returns logical for me.

lecy commented 5 years ago

Were you reading the data in this way?

If so, then you must be re-casting that variable somehow. That's my best guess without seeing your script.

castower commented 5 years ago

Were you reading the data in this way?

If so, then you must be re-casting that variable somehow. That's my best guess without seeing your script.

I think I must have re-casted it somehow. However, running that chunk seems to have fixed it because now it is a logical vector again. Thank you!

lecy commented 5 years ago

Yep!