{"action":"created","comment":{"url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/pulls/comments/49039565","id":49039565,"diff_hunk":"@@ -1318,3 +1331,29 @@ be changed with the third argument, `drop = FALSE`).\n > gapminder_small <- gapminder[c(1:9, 19:23),]\n > ~~~\n >\n+\n+> ## Solution to challenge 7 {.challenge}\n+>\n+> How many countries in Asia had a population in either 2002 or 2007 above 20 million? \n+> Tip: Use subsetting to maintain the relevant data and then use the function `unique()` to remove duplicate countries.\n+>\n+> A. 19\n+>\n+> B. 20\n+>\n+> C. 21\n+>\n+> D. 22\n+>\n+> Answer: B\n+> \n+> The answer can be derived using the following statement\n+> ~~~{.r}\n+> length(unique(\n+>   gapminder[\n+>     gapminder$year >= 2002 & \n+>     gapminder$year <= 2007 & ","path":"06-data-subsetting.md","position":45,"original_position":45,"commit_id":"94714415558038b990aba4638f6db585cda46416","original_commit_id":"94714415558038b990aba4638f6db585cda46416","user":{"login":"naupaka","id":1428071,"avatar_url":"https://avatars.githubusercontent.com/u/1428071?v=3","gravatar_id":"","url":"https://api.github.com/users/naupaka","html_url":"https://github.com/naupaka","followers_url":"https://api.github.com/users/naupaka/followers","following_url":"https://api.github.com/users/naupaka/following{/other_user}","gists_url":"https://api.github.com/users/naupaka/gists{/gist_id}","starred_url":"https://api.github.com/users/naupaka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/naupaka/subscriptions","organizations_url":"https://api.github.com/users/naupaka/orgs","repos_url":"https://api.github.com/users/naupaka/repos","events_url":"https://api.github.com/users/naupaka/events{/privacy}","received_events_url":"https://api.github.com/users/naupaka/received_events","type":"User","site_admin":false},"body":"This may be as good a place as any to talk about the differences between `&` vs `&&` and `|` vs `||` in R. From the help docs:\r\n\r\n> & and && indicate logical AND and | and || indicate logical OR. The shorter form performs elementwise comparisons in much the same way as arithmetic operators. The longer form evaluates left to right examining only the first element of each vector. Evaluation proceeds only until the result is determined. The longer form is appropriate for programming control-flow and typically preferred in if clauses.\r\n\r\nThis is often something people (especially those coming from other languages) want to know and get tripped up on.","created_at":"2016-01-07T03:46:45Z","updated_at":"2016-01-07T03:46:45Z","html_url":"https://github.com/swcarpentry/r-novice-gapminder/pull/76#discussion_r49039565","pull_request_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/pulls/76","_links":{"self":{"href":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/pulls/comments/49039565"},"html":{"href":"https://github.com/swcarpentry/r-novice-gapminder/pull/76#discussion_r49039565"},"pull_request":{"href":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/pulls/76"}}},"pull_request":{"url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/pulls/76","id":55205694,"html_url":"https://github.com/swcarpentry/r-novice-gapminder/pull/76","diff_url":"https://github.com/swcarpentry/r-novice-gapminder/pull/76.diff","patch_url":"https://github.com/swcarpentry/r-novice-gapminder/pull/76.patch","issue_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/issues/76","number":76,"state":"open","locked":false,"title":"Exercise for instructor training.","user":{"login":"kyrcha","id":400161,"avatar_url":"https://avatars.githubusercontent.com/u/400161?v=3","gravatar_id":"","url":"https://api.github.com/users/kyrcha","html_url":"https://github.com/kyrcha","followers_url":"https://api.github.com/users/kyrcha/followers","following_url":"https://api.github.com/users/kyrcha/following{/other_user}","gists_url":"https://api.github.com/users/kyrcha/gists{/gist_id}","starred_url":"https://api.github.com/users/kyrcha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyrcha/subscriptions","organizations_url":"https://api.github.com/users/kyrcha/orgs","repos_url":"https://api.github.com/users/kyrcha/repos","events_url":"https://api.github.com/users/kyrcha/events{/privacy}","received_events_url":"https://api.github.com/users/kyrcha/received_events","type":"User","site_admin":false},"body":"Exercise for instructor training regarding subsetting using multiple logical operators and introducing the unique() function","created_at":"2016-01-06T12:02:07Z","updated_at":"2016-01-07T03:46:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"040eb0934b5589f6bad664b7ca8435bad82ef2c3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/pulls/76/commits","review_comments_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/pulls/76/comments","review_comment_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/pulls/comments{/number}","comments_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/issues/76/comments","statuses_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/statuses/94714415558038b990aba4638f6db585cda46416","head":{"label":"kyrcha:gh-pages","ref":"gh-pages","sha":"94714415558038b990aba4638f6db585cda46416","user":{"login":"kyrcha","id":400161,"avatar_url":"https://avatars.githubusercontent.com/u/400161?v=3","gravatar_id":"","url":"https://api.github.com/users/kyrcha","html_url":"https://github.com/kyrcha","followers_url":"https://api.github.com/users/kyrcha/followers","following_url":"https://api.github.com/users/kyrcha/following{/other_user}","gists_url":"https://api.github.com/users/kyrcha/gists{/gist_id}","starred_url":"https://api.github.com/users/kyrcha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyrcha/subscriptions","organizations_url":"https://api.github.com/users/kyrcha/orgs","repos_url":"https://api.github.com/users/kyrcha/repos","events_url":"https://api.github.com/users/kyrcha/events{/privacy}","received_events_url":"https://api.github.com/users/kyrcha/received_events","type":"User","site_admin":false},"repo":{"id":49128917,"name":"r-novice-gapminder","full_name":"kyrcha/r-novice-gapminder","owner":{"login":"kyrcha","id":400161,"avatar_url":"https://avatars.githubusercontent.com/u/400161?v=3","gravatar_id":"","url":"https://api.github.com/users/kyrcha","html_url":"https://github.com/kyrcha","followers_url":"https://api.github.com/users/kyrcha/followers","following_url":"https://api.github.com/users/kyrcha/following{/other_user}","gists_url":"https://api.github.com/users/kyrcha/gists{/gist_id}","starred_url":"https://api.github.com/users/kyrcha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyrcha/subscriptions","organizations_url":"https://api.github.com/users/kyrcha/orgs","repos_url":"https://api.github.com/users/kyrcha/repos","events_url":"https://api.github.com/users/kyrcha/events{/privacy}","received_events_url":"https://api.github.com/users/kyrcha/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kyrcha/r-novice-gapminder","description":"Introduction to R for non-programmers using gapminder data.","fork":true,"url":"https://api.github.com/repos/kyrcha/r-novice-gapminder","forks_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/forks","keys_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/teams","hooks_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/hooks","issue_events_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/issues/events{/number}","events_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/events","assignees_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/assignees{/user}","branches_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/branches{/branch}","tags_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/tags","blobs_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/git/refs{/sha}","trees_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/statuses/{sha}","languages_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/languages","stargazers_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/stargazers","contributors_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/contributors","subscribers_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/subscribers","subscription_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/subscription","commits_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/commits{/sha}","git_commits_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/git/commits{/sha}","comments_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/comments{/number}","issue_comment_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/issues/comments{/number}","contents_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/contents/{+path}","compare_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/merges","archive_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/downloads","issues_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/issues{/number}","pulls_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/pulls{/number}","milestones_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/milestones{/number}","notifications_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/labels{/name}","releases_url":"https://api.github.com/repos/kyrcha/r-novice-gapminder/releases{/id}","created_at":"2016-01-06T10:33:18Z","updated_at":"2016-01-06T10:33:19Z","pushed_at":"2016-01-06T11:57:19Z","git_url":"git://github.com/kyrcha/r-novice-gapminder.git","ssh_url":"git@github.com:kyrcha/r-novice-gapminder.git","clone_url":"https://github.com/kyrcha/r-novice-gapminder.git","svn_url":"https://github.com/kyrcha/r-novice-gapminder","homepage":null,"size":12058,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"gh-pages"}},"base":{"label":"swcarpentry:gh-pages","ref":"gh-pages","sha":"a92de8347b8eaac4d2bdf113d254792e3a416005","user":{"login":"swcarpentry","id":2238358,"avatar_url":"https://avatars.githubusercontent.com/u/2238358?v=3","gravatar_id":"","url":"https://api.github.com/users/swcarpentry","html_url":"https://github.com/swcarpentry","followers_url":"https://api.github.com/users/swcarpentry/followers","following_url":"https://api.github.com/users/swcarpentry/following{/other_user}","gists_url":"https://api.github.com/users/swcarpentry/gists{/gist_id}","starred_url":"https://api.github.com/users/swcarpentry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swcarpentry/subscriptions","organizations_url":"https://api.github.com/users/swcarpentry/orgs","repos_url":"https://api.github.com/users/swcarpentry/repos","events_url":"https://api.github.com/users/swcarpentry/events{/privacy}","received_events_url":"https://api.github.com/users/swcarpentry/received_events","type":"Organization","site_admin":false},"repo":{"id":34186021,"name":"r-novice-gapminder","full_name":"swcarpentry/r-novice-gapminder","owner":{"login":"swcarpentry","id":2238358,"avatar_url":"https://avatars.githubusercontent.com/u/2238358?v=3","gravatar_id":"","url":"https://api.github.com/users/swcarpentry","html_url":"https://github.com/swcarpentry","followers_url":"https://api.github.com/users/swcarpentry/followers","following_url":"https://api.github.com/users/swcarpentry/following{/other_user}","gists_url":"https://api.github.com/users/swcarpentry/gists{/gist_id}","starred_url":"https://api.github.com/users/swcarpentry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swcarpentry/subscriptions","organizations_url":"https://api.github.com/users/swcarpentry/orgs","repos_url":"https://api.github.com/users/swcarpentry/repos","events_url":"https://api.github.com/users/swcarpentry/events{/privacy}","received_events_url":"https://api.github.com/users/swcarpentry/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/swcarpentry/r-novice-gapminder","description":"Introduction to R for non-programmers using gapminder data.","fork":false,"url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder","forks_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/forks","keys_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/teams","hooks_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/hooks","issue_events_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/issues/events{/number}","events_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/events","assignees_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/assignees{/user}","branches_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/branches{/branch}","tags_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/tags","blobs_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/git/refs{/sha}","trees_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/statuses/{sha}","languages_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/languages","stargazers_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/stargazers","contributors_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/contributors","subscribers_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/subscribers","subscription_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/subscription","commits_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/commits{/sha}","git_commits_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/git/commits{/sha}","comments_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/comments{/number}","issue_comment_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/issues/comments{/number}","contents_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/contents/{+path}","compare_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/merges","archive_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/downloads","issues_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/issues{/number}","pulls_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/pulls{/number}","milestones_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/milestones{/number}","notifications_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/labels{/name}","releases_url":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/releases{/id}","created_at":"2015-04-18T22:58:07Z","updated_at":"2015-12-24T14:58:01Z","pushed_at":"2016-01-06T12:02:07Z","git_url":"git://github.com/swcarpentry/r-novice-gapminder.git","ssh_url":"git@github.com:swcarpentry/r-novice-gapminder.git","clone_url":"https://github.com/swcarpentry/r-novice-gapminder.git","svn_url":"https://github.com/swcarpentry/r-novice-gapminder","homepage":null,"size":16128,"stargazers_count":11,"watchers_count":11,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":43,"mirror_url":null,"open_issues_count":18,"forks":43,"open_issues":18,"watchers":11,"default_branch":"gh-pages"}},"_links":{"self":{"href":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/pulls/76"},"html":{"href":"https://github.com/swcarpentry/r-novice-gapminder/pull/76"},"issue":{"href":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/issues/76"},"comments":{"href":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/issues/76/comments"},"review_comments":{"href":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/pulls/76/comments"},"review_comment":{"href":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/pulls/76/commits"},"statuses":{"href":"https://api.github.com/repos/swcarpentry/r-novice-gapminder/statuses/94714415558038b990aba4638f6db585cda46416"}}}}