Assignment 4 Section "e"

Assignment 4 Section "e"

par Edgardo Torres Carmona,
Nombre de réponses : 11

Anyone willing to help/hint the answer to section "e" of assignment 4?

Using the table() function complicates the assignment a lot. Any workarounds?

I have managed to make a table with the frequencies within it, I simply can't extracting the information from the table because its not a data.frame.

Would greatly appreciate any help.

En réponse à Edgardo Torres Carmona

Re: Assignment 4 Section "e"

par Liane Phung,
I managed to get the table into a data frame by storing the table() function itself within the data.frame
ie. Sep.wards <- data.frame(table(n.Sep$spreadsheet.Ward))
(I had my slicing for Sep date in n.Sep)

However, when I sort by Freq from the table for the ward with most 311 calls, I am getting "Beaches-East York (32)" as the most instead of "Trinity-Spadina (20)". Wondering if anyone else is getting this answer?
En réponse à Liane Phung

Re: Assignment 4 Section "e"

par Erik Spence,
If you sort the table then things should be quite easy. You don't need to recast the table into a data frame.
En réponse à Liane Phung

Re: Assignment 4 Section "e"

par Edgardo Torres Carmona,
Im getting Etobicoke-Lakeshore, this is my sorted table:

Etobicoke-Lakeshore       Beaches-East York        Toronto-Danforth 

                  15835                   15232                   14282 

      Eglinton-Lawrence         Trinity-Spadina      Parkdale-High Park 

                  14262                   14174                   13521 

             Willowdale              St. Paul's               Davenport 

                  12630                   12413                   12309 

  Scarborough Southwest        Scarborough East        Etobicoke Centre 

                  12260                   12213                   11537 

        Don Valley West      Scarborough Centre       York South-Weston 

                  11053                   11024                   10782 

Toronto Centre-Rosedale Scarborough-Rouge River             York Centre 

                  10684                   10355                    8643 

        Etobicoke North   Scarborough-Agincourt         Don Valley East 

                   8240                    7996                    7688 

              York West 

                   7085 



En réponse à Liane Phung

Re: Assignment 4 Section "e"

par Madison Argo,
Hi Liane!
I am getting Beaches-East York (32) as the most too. I started part e) by converting the date to a string and then isolating the month using the substr() command. Then I spliced the division and the month. Then used sort and table to calculate the total number of service calls and ended up with the Beaches-East York (32) result. I am certain I probably did something wrong but not exactly sure where
En réponse à Madison Argo

Re: Assignment 4 Section "e"

par Liane Phung,
Hi Madison,
I realized in my code I didn't actually splice for "311" as a unique Division itself which is why I got Beaches-East York. As Erik suggested, check the numbers - when I spliced for both "311" and September the numbers dropped to less than 100 per division in order to get Trinity-Spadina.
En réponse à Edgardo Torres Carmona

Re: Assignment 4 Section "e"

par Leanna Lui,
I have the same question! After sorting the table of frequencies, I'm having trouble extracting the name of the ward. Any tips would be greatly appreciated!
En réponse à Leanna Lui

Re: Assignment 4 Section "e"

par Leanna Lui,
En réponse à Leanna Lui

Re: Assignment 4 Section "e"

par Nicholas Ainsworth,
Hi Leanna,

I'm having the same issue!

Do you have any pointers for this? I've tried using "tail" on the sorted table but it extracts the column header and frequency data, not just the name of the ward.
En réponse à Nicholas Ainsworth

Re: Assignment 4 Section "e"

par Nicholas Ainsworth,
Never mind, figured it out as well.

In case anyone else is having trouble, I found the `name()` function helpful for this step.