STAT545-UBC / Discussion

Public discussion
38 stars 20 forks source link

map(sth, "char") #400

Open sinaneza opened 8 years ago

sinaneza commented 8 years ago

Dear professor and peers

Would you mind telling me why we cant have access to the "login" part of "owner" list in "gh_repo" by the following command:

map(gh_repo,"login").

It seems that map(sth,"char") only finds things in lists located in second layer.

@jennybc

sinaneza commented 8 years ago

map(gh_repos,"login").

jennybc commented 8 years ago

First, the object name is gh_repos, with an s. But I assume that's just a typo and not your actual problem.

The main problem is that the first-level lists in gh_repos are unnamed.

names(repurrrsive::gh_repos[[1]])
#> NULL

The user's login information is there, but nested more deeply. Redundantly, in fact, because it's present for each of the user's ~30 repos.

But I suspect this problem is simpler: Are you actually thinking of the object gh_users?

names(repurrrsive::gh_users[[1]])
#>  [1] "login"               "id"                  "avatar_url"         
#>  [4] "gravatar_id"         "url"                 "html_url"           
#>  [7] "followers_url"       "following_url"       "gists_url"          
#> [10] "starred_url"         "subscriptions_url"   "organizations_url"  
#> [13] "repos_url"           "events_url"          "received_events_url"
#> [16] "type"                "site_admin"          "name"               
#> [19] "company"             "blog"                "location"           
#> [22] "email"               "hireable"            "bio"                
#> [25] "public_repos"        "public_gists"        "followers"          
#> [28] "following"           "created_at"          "updated_at"