DS4PS / cpp-526-spr-2020

Course shell for CPP 526 Foundations of Data Science I for Spring 2020.
http://ds4ps.org/cpp-526-spr-2020/
3 stars 0 forks source link

Lab 02 - Question 8 #14

Open karen-liz opened 4 years ago

karen-liz commented 4 years ago

Hello everyone, I can't seem to figure out how to go about question 8. This is what I currently have with the professor's guidance but it seems I didn't fully understand. Any guidance is appreciated!

Screen Shot 2020-01-28 at 1 35 09 PM

Thanks!

jamisoncrawford commented 4 years ago

You're really close!

Ultimately, you want to pare down or subset the downtown data to only those delinquent on taxes, or downtown$amtdelinqt > 0. You've done that by putting the correct conditional statement on the left side of the comma in brackets [ , ].

However, you'll want to leave the right side of the comma empty, since the left side subsets your rows, and the right side subsets your columns. By leaving it empty, you tell R that you don't have any conditions for selecting columns, and therefore R should keep all the columns in the downtown data.

Then you can call function table() on your these.landuse object! Give it a try and hope this helps!

karen-liz commented 4 years ago

Thanks! I'm glad I was on the right track!

I continue to get this error but I'm not sure why since I'm not using a unique function.

Screen Shot 2020-01-28 at 2 12 19 PM

lecy commented 4 years ago

We also want to emphasize the usefulness of logical statements with this lab. It's the syntax we use to translate from plain English to computer code.

Your approach works, but you are subsetting the data to isolate the delinquent cases then analyzing land use within the subset.

Alternatively, we could look at a table of land use and delinquency. You did this last time looking at homes with high value and neighborhood. You just need to translate the numeric vector into a catgorical one first. So:

delinquent.yes.no <- amt > 0  # all late cases TRUE and FALSE
table( landuse , delinquent.yes.no )

Gives you a compact way to define your group quickly (delinquent) and count cases across subcategories (landuse) -> just have to translate everything into groups first.

If your question starts with, "how many..." or "what proportion of..." chances are you can answer it quickly using logical statements and your code will be cleaner because your logic is explicit in the statement itself instead of implied by subset steps.

karen-liz commented 4 years ago

Super helpful thanks!