├── .gitignore ├── LICENSE ├── R-Fundamentals.Rproj ├── README.md ├── data ├── fun_data.RData ├── gapminder-FiveYearData.csv ├── heart.csv └── sleep_VIM.csv ├── images ├── DatasetEx.png └── hfs.png ├── install.R ├── lessons ├── Part1.R ├── Part2.R ├── Part3.R └── Part4.R ├── runtime.txt └── solutions ├── Part1_solutions.R ├── Part2_solutions.R ├── Part3_solutions.R └── Part4_solutions.R /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.toptal.com/developers/gitignore/api/r,windows,macos,visualstudiocode 2 | # Edit at https://www.toptal.com/developers/gitignore?templates=r,windows,macos,visualstudiocode 3 | 4 | ### macOS ### 5 | # General 6 | .DS_Store 7 | .AppleDouble 8 | .LSOverride 9 | 10 | # Icon must end with two \r 11 | Icon 12 | 13 | 14 | # Thumbnails 15 | ._* 16 | 17 | # Files that might appear in the root of a volume 18 | .DocumentRevisions-V100 19 | .fseventsd 20 | .Spotlight-V100 21 | .TemporaryItems 22 | .Trashes 23 | .VolumeIcon.icns 24 | .com.apple.timemachine.donotpresent 25 | 26 | # Directories potentially created on remote AFP share 27 | .AppleDB 28 | .AppleDesktop 29 | Network Trash Folder 30 | Temporary Items 31 | .apdisk 32 | 33 | ### macOS Patch ### 34 | # iCloud generated files 35 | *.icloud 36 | 37 | ### R ### 38 | # History files 39 | .Rhistory 40 | .Rapp.history 41 | 42 | # Session Data files 43 | .RData 44 | .RDataTmp 45 | 46 | # User-specific files 47 | .Ruserdata 48 | 49 | # Example code in package build process 50 | *-Ex.R 51 | 52 | # Output files from R CMD build 53 | /*.tar.gz 54 | 55 | # Output files from R CMD check 56 | /*.Rcheck/ 57 | 58 | # RStudio files 59 | .Rproj.user/ 60 | 61 | # produced vignettes 62 | vignettes/*.html 63 | vignettes/*.pdf 64 | 65 | # OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 66 | .httr-oauth 67 | 68 | # knitr and R markdown default cache directories 69 | *_cache/ 70 | /cache/ 71 | 72 | # Temporary files created by R markdown 73 | *.utf8.md 74 | *.knit.md 75 | 76 | # R Environment Variables 77 | .Renviron 78 | 79 | # pkgdown site 80 | docs/ 81 | 82 | # translation temp files 83 | po/*~ 84 | 85 | # RStudio Connect folder 86 | rsconnect/ 87 | 88 | ### R.Bookdown Stack ### 89 | # R package: bookdown caching files 90 | /*_files/ 91 | 92 | ### VisualStudioCode ### 93 | .vscode/* 94 | !.vscode/settings.json 95 | !.vscode/tasks.json 96 | !.vscode/launch.json 97 | !.vscode/extensions.json 98 | !.vscode/*.code-snippets 99 | 100 | # Local History for Visual Studio Code 101 | .history/ 102 | 103 | # Built Visual Studio Code Extensions 104 | *.vsix 105 | 106 | ### VisualStudioCode Patch ### 107 | # Ignore all local history of files 108 | .history 109 | .ionide 110 | 111 | ### Windows ### 112 | # Windows thumbnail cache files 113 | Thumbs.db 114 | Thumbs.db:encryptable 115 | ehthumbs.db 116 | ehthumbs_vista.db 117 | 118 | # Dump file 119 | *.stackdump 120 | 121 | # Folder config file 122 | [Dd]esktop.ini 123 | 124 | # Recycle Bin used on file shares 125 | $RECYCLE.BIN/ 126 | 127 | # Windows Installer files 128 | *.cab 129 | *.msi 130 | *.msix 131 | *.msm 132 | *.msp 133 | 134 | # Windows shortcuts 135 | *.lnk 136 | 137 | # End of https://www.toptal.com/developers/gitignore/api/r,windows,macos,visualstudiocode 138 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Creative Commons Attribution-NonCommercial 4.0 International Public License 3 | 4 | By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. 5 | 6 | Section 1 – Definitions. 7 | 8 | Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. 9 | Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. 10 | Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. 11 | Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. 12 | Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. 13 | Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. 14 | Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. 15 | Licensor means the individual(s) or entity(ies) granting rights under this Public License. 16 | NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange. 17 | Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. 18 | Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. 19 | You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. 20 | Section 2 – Scope. 21 | 22 | License grant. 23 | Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: 24 | reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and 25 | produce, reproduce, and Share Adapted Material for NonCommercial purposes only. 26 | Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. 27 | Term. The term of this Public License is specified in Section 6(a). 28 | Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. 29 | Downstream recipients. 30 | Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. 31 | No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. 32 | No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). 33 | Other rights. 34 | 35 | Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. 36 | Patent and trademark rights are not licensed under this Public License. 37 | To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes. 38 | Section 3 – License Conditions. 39 | 40 | Your exercise of the Licensed Rights is expressly made subject to the following conditions. 41 | 42 | Attribution. 43 | 44 | If You Share the Licensed Material (including in modified form), You must: 45 | 46 | retain the following if it is supplied by the Licensor with the Licensed Material: 47 | identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); 48 | a copyright notice; 49 | a notice that refers to this Public License; 50 | a notice that refers to the disclaimer of warranties; 51 | a URI or hyperlink to the Licensed Material to the extent reasonably practicable; 52 | indicate if You modified the Licensed Material and retain an indication of any previous modifications; and 53 | indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. 54 | You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. 55 | If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. 56 | If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License. 57 | Section 4 – Sui Generis Database Rights. 58 | 59 | Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: 60 | 61 | for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only; 62 | if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and 63 | You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. 64 | For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. 65 | Section 5 – Disclaimer of Warranties and Limitation of Liability. 66 | 67 | Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You. 68 | To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You. 69 | The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. 70 | Section 6 – Term and Termination. 71 | 72 | This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. 73 | Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: 74 | 75 | automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or 76 | upon express reinstatement by the Licensor. 77 | For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. 78 | For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. 79 | Sections 1, 5, 6, 7, and 8 survive termination of this Public License. 80 | Section 7 – Other Terms and Conditions. 81 | 82 | The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. 83 | Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. 84 | Section 8 – Interpretation. 85 | 86 | For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. 87 | To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. 88 | No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. 89 | Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. 90 | -------------------------------------------------------------------------------- /R-Fundamentals.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # D-Lab R Fundamentals Workshop 2 | 3 | [![DataHub](https://img.shields.io/badge/launch-datahub-blue)](https://dlab.datahub.berkeley.edu/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fdlab-berkeley%2FR-Fundamentals&urlpath=rstudio%2F&branch=main) 4 | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/dlab-berkeley/R-Fundamentals/HEAD?urlpath=rstudio) 5 | [![License: CC BY 4.0](https://img.shields.io/badge/License-CC_BY_4.0-lightgrey.svg)](https://creativecommons.org/licenses/by/4.0/) 6 | 7 | 8 | This repository contains the materials for the D-Lab R Fundamentals workshop. No 9 | prior experience with R is required. 10 | 11 | ## Workshop Goals 12 | 13 | In this workshop, we provide a broad overview of the fundamentals of using R, a programming language geared toward statistical analysis and data science. 14 | The workshop is divided into four parts, which cover the following topics: 15 | - Part 1: Introduction to R, navigating RStudio, variable assignment, data types and coercion, and data structures. 16 | - Part 2: Working with data frames: importing, subsetting, filtering, and merging. 17 | - Part 3: Data visualization using R and ggplot2. 18 | - Part 4: Functions, for loops, and if-else statements. 19 | 20 | No prior experience with R is required. 21 | 22 | ## Installation Instructions 23 | 24 | RStudio is a software commonly used by R practitioners to develop code in R. We 25 | will use RStudio to go through the workshop materials, which requires the 26 | installation of both the R language and the RStudio software. If you would like 27 | to run R on your own computer, complete the following steps prior to the 28 | workshop: 29 | 30 | 1. [Download R](https://cloud.r-project.org/): Follow the links according to the operating system you are running. You will first need to click on a link corresponding to your operating system, and then an additional link to select a specific version of R. Download the package, and install R onto your computer. You should install the most recent version (at least version 4.1). 31 | 32 | * If you are using a Mac, click "Download R for macOS" and then select the 33 | right version of R. You will need to select the version corresponding to 34 | your specific version of macOS, as well as whether you have an Intel or 35 | Apple Silicon Mac. 36 | * If you are using Windows, click "Download R for Windows", then click 37 | "base", and click the download link. 38 | * If you are using Linux, click on the link corresponding to your Linux 39 | distribution, and then follow the instructions. 40 | 41 | 2. [Download RStudio](https://rstudio.com/products/rstudio/download/#download): 42 | Install RStudio Desktop. This should be free. Do this after you have already 43 | installed R. The D-Lab strongly recommends an RStudio edition of 44 | 2022.02.0+443 "Prairie Trillium" or higher. 45 | 46 | * Some individuals with older operating systems may run into odd issues. If 47 | you are running into issues with the installation of RStudio, you may need 48 | to install a specific version of RStudio. Please check [this 49 | link](https://www.rstudio.com/products/rstudio/older-versions/) if this 50 | applies to you. 51 | 52 | 3. Download these R Fundamentals [workshop materials](https://github.com/dlab-berkeley/R-Fundamentals): 53 | 54 | * Click the green "Code" button in the top right of the repository 55 | information. 56 | * Click "Download Zip". 57 | * Extract this file to a folder on your computer where you can easily access 58 | it (we recommend Desktop). 59 | 60 | 4. Optional: if you're familiar with `git`, you can instead clone this repository by opening a terminal and entering `git clone git@github.com:dlab-berkeley/R-Fundamentals.git`. 61 | 62 | ## Is R not working on your laptop? 63 | 64 | If you do not have R installed and the materials loaded on your workshop by the time it starts, we *strongly* recommend using the UC Berkeley DataHub to run the materials for these lessons. You can access the DataHub by clicking the following button: 65 | 66 | [![DataHub](https://img.shields.io/badge/launch-datahub-blue)](https://dlab.datahub.berkeley.edu/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fdlab-berkeley%2FR-Fundamentals&urlpath=rstudio%2F&branch=main) 67 | 68 | Some users may have to click the link twice if the materials do not load initially. 69 | 70 | The DataHub downloads this repository, along with any necessary packages, and 71 | allows you to run the materials in an RStudio instance on UC Berkeley's servers. 72 | No installation is needed from your end - you only need an internet browser and 73 | a CalNet ID to log in. By using the DataHub, you can save your work and come 74 | back to it at any time. When you want to return to your saved work, go straight 75 | to [DataHub](https://dlab.datahub.berkeley.edu), sign in, and click on the 76 | `R-Fundamentals` folder. 77 | 78 | If you don't have a Berkeley CalNet ID, you can still run these lessons in the cloud, by clicking this button: 79 | 80 | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/dlab-berkeley/R-Fundamentals/HEAD?urlpath=rstudio) 81 | 82 | If you are loading Binder with this repository for the first time, it may take a 83 | few minutes to set up. Binder operates similarly to the D-Lab DataHub, but on a 84 | different set of servers. By using Binder, however, you cannot save your work. 85 | 86 | ## Run the Code 87 | 88 | Now that you have all the required software and materials, you need to run the 89 | code. 90 | 91 | 1. Launch the RStudio software. 92 | 93 | 2. Use the file navigator to find the R-Fundamentals folder you downloaded from 94 | Github. Open `R-Fundamentals.Rproj` by double clicking on the file. 95 | 96 | 3. Open up the file corresponding to the part of the workshop you're attending 97 | (`Part1.R`, `Part2.R`, `Part3.R`, `Part4.R`) via the Files panel in RStudio. 98 | 99 | 4. Place your cursor on a given line and press `Command + Enter` (Mac) or 100 | `Control + Enter` (PC) to run an individual line of code. 101 | 102 | 5. The `solutions` folder contains the solutions to the challenge problems. 103 | 104 | # Additional Resources 105 | 106 | Check out the following online resources to learn more about R: 107 | 108 | * [Software Carpentry](https://swcarpentry.github.io/) 109 | * [Quick-R](http://statmethods.net/) 110 | * [UCLA Institute for Digital Research and Education](https://stats.idre.ucla.edu/r/) 111 | * [R-bloggers](https://www.r-bloggers.com/) 112 | * [R Markdown: The Definitive Guide](https://bookdown.org/yihui/rmarkdown/) 113 | * [The tidyverse style guide](http://style.tidyverse.org/) 114 | 115 | as well as the following books: 116 | 117 | * [Bookdown Featured Books](https://bookdown.org/) 118 | * [Introduction to Probability and Statistics in R](http://www.atmos.albany.edu/facstaff/timm/ATM315spring14/R/IPSUR.pdf) by G. Jay Kearns. 119 | * [Advanced R](http://adv-r.had.co.nz/) by Hadley Wickham. 120 | * [R for Data Science](http://r4ds.had.co.nz/) by Hadley Wickham and Garrett Grolemund. 121 | * [R for Everyone](http://www.jaredlander.com/r-for-everyone/) by Jared Lander. 122 | * [Art of R Programming](https://www.nostarch.com/artofr.htm) by Norman Matloff. 123 | 124 | # About the UC Berkeley D-Lab 125 | 126 | D-Lab works with Berkeley faculty, research staff, and students to advance 127 | data-intensive social science and humanities research. Our goal at D-Lab is to 128 | provide practical training, staff support, resources, and space to enable you to 129 | use R for your own research applications. Our services cater to all skill levels 130 | and no programming, statistical, or computer science backgrounds are necessary. 131 | We offer these services in the form of workshops, one-to-one consulting, and 132 | working groups that cover a variety of research topics, digital tools, and 133 | programming languages. 134 | 135 | Visit the [D-Lab homepage](https://dlab.berkeley.edu/) to learn more about us. 136 | You can view our [calendar](https://dlab.berkeley.edu/events/calendar) for 137 | upcoming events, learn about how to utilize our 138 | [consulting](https://dlab.berkeley.edu/consulting) and [data 139 | services](https://dlab.berkeley.edu/data), and check out upcoming 140 | [workshops](https://dlab.berkeley.edu/events/workshops). Subscribe to our 141 | [newsletter](https://dlab.berkeley.edu/news/weekly-newsletter) to stay up to 142 | date on D-Lab events, services, and opportunities. 143 | 144 | # Other D-Lab R workshops 145 | 146 | D-Lab offers a variety of R workshops, catered toward different levels of 147 | expertise. 148 | ## Introductory Workshops 149 | 150 | * [R Data Wrangling](https://github.com/dlab-berkeley/R-Data-Wrangling) 151 | * [R Data Visualization](https://github.com/dlab-berkeley/R-Data-Visualization) 152 | * [R Census Data](https://github.com/dlab-berkeley/Census-Data-in-R) 153 | 154 | ## Intermediate and Advanced Workshops 155 | * [R Geospatial Fundamentals](https://github.com/dlab-berkeley/R-Geospatial-Fundamentals) 156 | * [R Machine Learning](https://github.com/dlab-berkeley/R-Machine-Learning) 157 | * [R Deep Learning](https://github.com/dlab-berkeley/R-Deep-Learning) 158 | 159 | # Contributors 160 | * [Pratik Sachdeva](https://github.com/pssachdeva) 161 | * [Alex Stephenson](https://github.com/asteves/) 162 | * [Evan Muzzall](https://github.com/EastBayEv) 163 | * [Aniket Kesari](https://akesari12.github.io/) 164 | * [Jae Yeon Kim](https://jaeyk.github.io/) 165 | * [Sam Abdel-Ghaffar](https://github.com/samyag1) 166 | * [Avery Richards](https://github.com/Averysaurus) 167 | * Guadalupe Tuñón 168 | * Shinhye Choi 169 | * Patty Frontiera 170 | * Rochelle Terman 171 | * Dillon Niederhut 172 | -------------------------------------------------------------------------------- /data/fun_data.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dlab-berkeley/R-Fundamentals-Legacy/19d0dd0cc120f04aca448447fdf29764f9ee05f6/data/fun_data.RData -------------------------------------------------------------------------------- /data/gapminder-FiveYearData.csv: -------------------------------------------------------------------------------- 1 | country,year,pop,continent,lifeExp,gdpPercap 2 | Afghanistan,1952,8425333,Asia,28.801,779.4453145 3 | Afghanistan,1957,9240934,Asia,30.332,820.8530296 4 | Afghanistan,1962,10267083,Asia,31.997,853.10071 5 | Afghanistan,1967,11537966,Asia,34.02,836.1971382 6 | Afghanistan,1972,13079460,Asia,36.088,739.9811058 7 | Afghanistan,1977,14880372,Asia,38.438,786.11336 8 | Afghanistan,1982,12881816,Asia,39.854,978.0114388 9 | Afghanistan,1987,13867957,Asia,40.822,852.3959448 10 | Afghanistan,1992,16317921,Asia,41.674,649.3413952 11 | Afghanistan,1997,22227415,Asia,41.763,635.341351 12 | Afghanistan,2002,25268405,Asia,42.129,726.7340548 13 | Afghanistan,2007,31889923,Asia,43.828,974.5803384 14 | Albania,1952,1282697,Europe,55.23,1601.056136 15 | Albania,1957,1476505,Europe,59.28,1942.284244 16 | Albania,1962,1728137,Europe,64.82,2312.888958 17 | Albania,1967,1984060,Europe,66.22,2760.196931 18 | Albania,1972,2263554,Europe,67.69,3313.422188 19 | Albania,1977,2509048,Europe,68.93,3533.00391 20 | Albania,1982,2780097,Europe,70.42,3630.880722 21 | Albania,1987,3075321,Europe,72,3738.932735 22 | Albania,1992,3326498,Europe,71.581,2497.437901 23 | Albania,1997,3428038,Europe,72.95,3193.054604 24 | Albania,2002,3508512,Europe,75.651,4604.211737 25 | Albania,2007,3600523,Europe,76.423,5937.029526 26 | Algeria,1952,9279525,Africa,43.077,2449.008185 27 | Algeria,1957,10270856,Africa,45.685,3013.976023 28 | Algeria,1962,11000948,Africa,48.303,2550.81688 29 | Algeria,1967,12760499,Africa,51.407,3246.991771 30 | Algeria,1972,14760787,Africa,54.518,4182.663766 31 | Algeria,1977,17152804,Africa,58.014,4910.416756 32 | Algeria,1982,20033753,Africa,61.368,5745.160213 33 | Algeria,1987,23254956,Africa,65.799,5681.358539 34 | Algeria,1992,26298373,Africa,67.744,5023.216647 35 | Algeria,1997,29072015,Africa,69.152,4797.295051 36 | Algeria,2002,31287142,Africa,70.994,5288.040382 37 | Algeria,2007,33333216,Africa,72.301,6223.367465 38 | Angola,1952,4232095,Africa,30.015,3520.610273 39 | Angola,1957,4561361,Africa,31.999,3827.940465 40 | Angola,1962,4826015,Africa,34,4269.276742 41 | Angola,1967,5247469,Africa,35.985,5522.776375 42 | Angola,1972,5894858,Africa,37.928,5473.288005 43 | Angola,1977,6162675,Africa,39.483,3008.647355 44 | Angola,1982,7016384,Africa,39.942,2756.953672 45 | Angola,1987,7874230,Africa,39.906,2430.208311 46 | Angola,1992,8735988,Africa,40.647,2627.845685 47 | Angola,1997,9875024,Africa,40.963,2277.140884 48 | Angola,2002,10866106,Africa,41.003,2773.287312 49 | Angola,2007,12420476,Africa,42.731,4797.231267 50 | Argentina,1952,17876956,Americas,62.485,5911.315053 51 | Argentina,1957,19610538,Americas,64.399,6856.856212 52 | Argentina,1962,21283783,Americas,65.142,7133.166023 53 | Argentina,1967,22934225,Americas,65.634,8052.953021 54 | Argentina,1972,24779799,Americas,67.065,9443.038526 55 | Argentina,1977,26983828,Americas,68.481,10079.02674 56 | Argentina,1982,29341374,Americas,69.942,8997.897412 57 | Argentina,1987,31620918,Americas,70.774,9139.671389 58 | Argentina,1992,33958947,Americas,71.868,9308.41871 59 | Argentina,1997,36203463,Americas,73.275,10967.28195 60 | Argentina,2002,38331121,Americas,74.34,8797.640716 61 | Argentina,2007,40301927,Americas,75.32,12779.37964 62 | Australia,1952,8691212,Oceania,69.12,10039.59564 63 | Australia,1957,9712569,Oceania,70.33,10949.64959 64 | Australia,1962,10794968,Oceania,70.93,12217.22686 65 | Australia,1967,11872264,Oceania,71.1,14526.12465 66 | Australia,1972,13177000,Oceania,71.93,16788.62948 67 | Australia,1977,14074100,Oceania,73.49,18334.19751 68 | Australia,1982,15184200,Oceania,74.74,19477.00928 69 | Australia,1987,16257249,Oceania,76.32,21888.88903 70 | Australia,1992,17481977,Oceania,77.56,23424.76683 71 | Australia,1997,18565243,Oceania,78.83,26997.93657 72 | Australia,2002,19546792,Oceania,80.37,30687.75473 73 | Australia,2007,20434176,Oceania,81.235,34435.36744 74 | Austria,1952,6927772,Europe,66.8,6137.076492 75 | Austria,1957,6965860,Europe,67.48,8842.59803 76 | Austria,1962,7129864,Europe,69.54,10750.72111 77 | Austria,1967,7376998,Europe,70.14,12834.6024 78 | Austria,1972,7544201,Europe,70.63,16661.6256 79 | Austria,1977,7568430,Europe,72.17,19749.4223 80 | Austria,1982,7574613,Europe,73.18,21597.08362 81 | Austria,1987,7578903,Europe,74.94,23687.82607 82 | Austria,1992,7914969,Europe,76.04,27042.01868 83 | Austria,1997,8069876,Europe,77.51,29095.92066 84 | Austria,2002,8148312,Europe,78.98,32417.60769 85 | Austria,2007,8199783,Europe,79.829,36126.4927 86 | Bahrain,1952,120447,Asia,50.939,9867.084765 87 | Bahrain,1957,138655,Asia,53.832,11635.79945 88 | Bahrain,1962,171863,Asia,56.923,12753.27514 89 | Bahrain,1967,202182,Asia,59.923,14804.6727 90 | Bahrain,1972,230800,Asia,63.3,18268.65839 91 | Bahrain,1977,297410,Asia,65.593,19340.10196 92 | Bahrain,1982,377967,Asia,69.052,19211.14731 93 | Bahrain,1987,454612,Asia,70.75,18524.02406 94 | Bahrain,1992,529491,Asia,72.601,19035.57917 95 | Bahrain,1997,598561,Asia,73.925,20292.01679 96 | Bahrain,2002,656397,Asia,74.795,23403.55927 97 | Bahrain,2007,708573,Asia,75.635,29796.04834 98 | Bangladesh,1952,46886859,Asia,37.484,684.2441716 99 | Bangladesh,1957,51365468,Asia,39.348,661.6374577 100 | Bangladesh,1962,56839289,Asia,41.216,686.3415538 101 | Bangladesh,1967,62821884,Asia,43.453,721.1860862 102 | Bangladesh,1972,70759295,Asia,45.252,630.2336265 103 | Bangladesh,1977,80428306,Asia,46.923,659.8772322 104 | Bangladesh,1982,93074406,Asia,50.009,676.9818656 105 | Bangladesh,1987,103764241,Asia,52.819,751.9794035 106 | Bangladesh,1992,113704579,Asia,56.018,837.8101643 107 | Bangladesh,1997,123315288,Asia,59.412,972.7700352 108 | Bangladesh,2002,135656790,Asia,62.013,1136.39043 109 | Bangladesh,2007,150448339,Asia,64.062,1391.253792 110 | Belgium,1952,8730405,Europe,68,8343.105127 111 | Belgium,1957,8989111,Europe,69.24,9714.960623 112 | Belgium,1962,9218400,Europe,70.25,10991.20676 113 | Belgium,1967,9556500,Europe,70.94,13149.04119 114 | Belgium,1972,9709100,Europe,71.44,16672.14356 115 | Belgium,1977,9821800,Europe,72.8,19117.97448 116 | Belgium,1982,9856303,Europe,73.93,20979.84589 117 | Belgium,1987,9870200,Europe,75.35,22525.56308 118 | Belgium,1992,10045622,Europe,76.46,25575.57069 119 | Belgium,1997,10199787,Europe,77.53,27561.19663 120 | Belgium,2002,10311970,Europe,78.32,30485.88375 121 | Belgium,2007,10392226,Europe,79.441,33692.60508 122 | Benin,1952,1738315,Africa,38.223,1062.7522 123 | Benin,1957,1925173,Africa,40.358,959.6010805 124 | Benin,1962,2151895,Africa,42.618,949.4990641 125 | Benin,1967,2427334,Africa,44.885,1035.831411 126 | Benin,1972,2761407,Africa,47.014,1085.796879 127 | Benin,1977,3168267,Africa,49.19,1029.161251 128 | Benin,1982,3641603,Africa,50.904,1277.897616 129 | Benin,1987,4243788,Africa,52.337,1225.85601 130 | Benin,1992,4981671,Africa,53.919,1191.207681 131 | Benin,1997,6066080,Africa,54.777,1232.975292 132 | Benin,2002,7026113,Africa,54.406,1372.877931 133 | Benin,2007,8078314,Africa,56.728,1441.284873 134 | Bolivia,1952,2883315,Americas,40.414,2677.326347 135 | Bolivia,1957,3211738,Americas,41.89,2127.686326 136 | Bolivia,1962,3593918,Americas,43.428,2180.972546 137 | Bolivia,1967,4040665,Americas,45.032,2586.886053 138 | Bolivia,1972,4565872,Americas,46.714,2980.331339 139 | Bolivia,1977,5079716,Americas,50.023,3548.097832 140 | Bolivia,1982,5642224,Americas,53.859,3156.510452 141 | Bolivia,1987,6156369,Americas,57.251,2753.69149 142 | Bolivia,1992,6893451,Americas,59.957,2961.699694 143 | Bolivia,1997,7693188,Americas,62.05,3326.143191 144 | Bolivia,2002,8445134,Americas,63.883,3413.26269 145 | Bolivia,2007,9119152,Americas,65.554,3822.137084 146 | Bosnia and Herzegovina,1952,2791000,Europe,53.82,973.5331948 147 | Bosnia and Herzegovina,1957,3076000,Europe,58.45,1353.989176 148 | Bosnia and Herzegovina,1962,3349000,Europe,61.93,1709.683679 149 | Bosnia and Herzegovina,1967,3585000,Europe,64.79,2172.352423 150 | Bosnia and Herzegovina,1972,3819000,Europe,67.45,2860.16975 151 | Bosnia and Herzegovina,1977,4086000,Europe,69.86,3528.481305 152 | Bosnia and Herzegovina,1982,4172693,Europe,70.69,4126.613157 153 | Bosnia and Herzegovina,1987,4338977,Europe,71.14,4314.114757 154 | Bosnia and Herzegovina,1992,4256013,Europe,72.178,2546.781445 155 | Bosnia and Herzegovina,1997,3607000,Europe,73.244,4766.355904 156 | Bosnia and Herzegovina,2002,4165416,Europe,74.09,6018.975239 157 | Bosnia and Herzegovina,2007,4552198,Europe,74.852,7446.298803 158 | Botswana,1952,442308,Africa,47.622,851.2411407 159 | Botswana,1957,474639,Africa,49.618,918.2325349 160 | Botswana,1962,512764,Africa,51.52,983.6539764 161 | Botswana,1967,553541,Africa,53.298,1214.709294 162 | Botswana,1972,619351,Africa,56.024,2263.611114 163 | Botswana,1977,781472,Africa,59.319,3214.857818 164 | Botswana,1982,970347,Africa,61.484,4551.14215 165 | Botswana,1987,1151184,Africa,63.622,6205.88385 166 | Botswana,1992,1342614,Africa,62.745,7954.111645 167 | Botswana,1997,1536536,Africa,52.556,8647.142313 168 | Botswana,2002,1630347,Africa,46.634,11003.60508 169 | Botswana,2007,1639131,Africa,50.728,12569.85177 170 | Brazil,1952,56602560,Americas,50.917,2108.944355 171 | Brazil,1957,65551171,Americas,53.285,2487.365989 172 | Brazil,1962,76039390,Americas,55.665,3336.585802 173 | Brazil,1967,88049823,Americas,57.632,3429.864357 174 | Brazil,1972,100840058,Americas,59.504,4985.711467 175 | Brazil,1977,114313951,Americas,61.489,6660.118654 176 | Brazil,1982,128962939,Americas,63.336,7030.835878 177 | Brazil,1987,142938076,Americas,65.205,7807.095818 178 | Brazil,1992,155975974,Americas,67.057,6950.283021 179 | Brazil,1997,168546719,Americas,69.388,7957.980824 180 | Brazil,2002,179914212,Americas,71.006,8131.212843 181 | Brazil,2007,190010647,Americas,72.39,9065.800825 182 | Bulgaria,1952,7274900,Europe,59.6,2444.286648 183 | Bulgaria,1957,7651254,Europe,66.61,3008.670727 184 | Bulgaria,1962,8012946,Europe,69.51,4254.337839 185 | Bulgaria,1967,8310226,Europe,70.42,5577.0028 186 | Bulgaria,1972,8576200,Europe,70.9,6597.494398 187 | Bulgaria,1977,8797022,Europe,70.81,7612.240438 188 | Bulgaria,1982,8892098,Europe,71.08,8224.191647 189 | Bulgaria,1987,8971958,Europe,71.34,8239.854824 190 | Bulgaria,1992,8658506,Europe,71.19,6302.623438 191 | Bulgaria,1997,8066057,Europe,70.32,5970.38876 192 | Bulgaria,2002,7661799,Europe,72.14,7696.777725 193 | Bulgaria,2007,7322858,Europe,73.005,10680.79282 194 | Burkina Faso,1952,4469979,Africa,31.975,543.2552413 195 | Burkina Faso,1957,4713416,Africa,34.906,617.1834648 196 | Burkina Faso,1962,4919632,Africa,37.814,722.5120206 197 | Burkina Faso,1967,5127935,Africa,40.697,794.8265597 198 | Burkina Faso,1972,5433886,Africa,43.591,854.7359763 199 | Burkina Faso,1977,5889574,Africa,46.137,743.3870368 200 | Burkina Faso,1982,6634596,Africa,48.122,807.1985855 201 | Burkina Faso,1987,7586551,Africa,49.557,912.0631417 202 | Burkina Faso,1992,8878303,Africa,50.26,931.7527731 203 | Burkina Faso,1997,10352843,Africa,50.324,946.2949618 204 | Burkina Faso,2002,12251209,Africa,50.65,1037.645221 205 | Burkina Faso,2007,14326203,Africa,52.295,1217.032994 206 | Burundi,1952,2445618,Africa,39.031,339.2964587 207 | Burundi,1957,2667518,Africa,40.533,379.5646281 208 | Burundi,1962,2961915,Africa,42.045,355.2032273 209 | Burundi,1967,3330989,Africa,43.548,412.9775136 210 | Burundi,1972,3529983,Africa,44.057,464.0995039 211 | Burundi,1977,3834415,Africa,45.91,556.1032651 212 | Burundi,1982,4580410,Africa,47.471,559.603231 213 | Burundi,1987,5126023,Africa,48.211,621.8188189 214 | Burundi,1992,5809236,Africa,44.736,631.6998778 215 | Burundi,1997,6121610,Africa,45.326,463.1151478 216 | Burundi,2002,7021078,Africa,47.36,446.4035126 217 | Burundi,2007,8390505,Africa,49.58,430.0706916 218 | Cambodia,1952,4693836,Asia,39.417,368.4692856 219 | Cambodia,1957,5322536,Asia,41.366,434.0383364 220 | Cambodia,1962,6083619,Asia,43.415,496.9136476 221 | Cambodia,1967,6960067,Asia,45.415,523.4323142 222 | Cambodia,1972,7450606,Asia,40.317,421.6240257 223 | Cambodia,1977,6978607,Asia,31.22,524.9721832 224 | Cambodia,1982,7272485,Asia,50.957,624.4754784 225 | Cambodia,1987,8371791,Asia,53.914,683.8955732 226 | Cambodia,1992,10150094,Asia,55.803,682.3031755 227 | Cambodia,1997,11782962,Asia,56.534,734.28517 228 | Cambodia,2002,12926707,Asia,56.752,896.2260153 229 | Cambodia,2007,14131858,Asia,59.723,1713.778686 230 | Cameroon,1952,5009067,Africa,38.523,1172.667655 231 | Cameroon,1957,5359923,Africa,40.428,1313.048099 232 | Cameroon,1962,5793633,Africa,42.643,1399.607441 233 | Cameroon,1967,6335506,Africa,44.799,1508.453148 234 | Cameroon,1972,7021028,Africa,47.049,1684.146528 235 | Cameroon,1977,7959865,Africa,49.355,1783.432873 236 | Cameroon,1982,9250831,Africa,52.961,2367.983282 237 | Cameroon,1987,10780667,Africa,54.985,2602.664206 238 | Cameroon,1992,12467171,Africa,54.314,1793.163278 239 | Cameroon,1997,14195809,Africa,52.199,1694.337469 240 | Cameroon,2002,15929988,Africa,49.856,1934.011449 241 | Cameroon,2007,17696293,Africa,50.43,2042.09524 242 | Canada,1952,14785584,Americas,68.75,11367.16112 243 | Canada,1957,17010154,Americas,69.96,12489.95006 244 | Canada,1962,18985849,Americas,71.3,13462.48555 245 | Canada,1967,20819767,Americas,72.13,16076.58803 246 | Canada,1972,22284500,Americas,72.88,18970.57086 247 | Canada,1977,23796400,Americas,74.21,22090.88306 248 | Canada,1982,25201900,Americas,75.76,22898.79214 249 | Canada,1987,26549700,Americas,76.86,26626.51503 250 | Canada,1992,28523502,Americas,77.95,26342.88426 251 | Canada,1997,30305843,Americas,78.61,28954.92589 252 | Canada,2002,31902268,Americas,79.77,33328.96507 253 | Canada,2007,33390141,Americas,80.653,36319.23501 254 | Central African Republic,1952,1291695,Africa,35.463,1071.310713 255 | Central African Republic,1957,1392284,Africa,37.464,1190.844328 256 | Central African Republic,1962,1523478,Africa,39.475,1193.068753 257 | Central African Republic,1967,1733638,Africa,41.478,1136.056615 258 | Central African Republic,1972,1927260,Africa,43.457,1070.013275 259 | Central African Republic,1977,2167533,Africa,46.775,1109.374338 260 | Central African Republic,1982,2476971,Africa,48.295,956.7529907 261 | Central African Republic,1987,2840009,Africa,50.485,844.8763504 262 | Central African Republic,1992,3265124,Africa,49.396,747.9055252 263 | Central African Republic,1997,3696513,Africa,46.066,740.5063317 264 | Central African Republic,2002,4048013,Africa,43.308,738.6906068 265 | Central African Republic,2007,4369038,Africa,44.741,706.016537 266 | Chad,1952,2682462,Africa,38.092,1178.665927 267 | Chad,1957,2894855,Africa,39.881,1308.495577 268 | Chad,1962,3150417,Africa,41.716,1389.817618 269 | Chad,1967,3495967,Africa,43.601,1196.810565 270 | Chad,1972,3899068,Africa,45.569,1104.103987 271 | Chad,1977,4388260,Africa,47.383,1133.98495 272 | Chad,1982,4875118,Africa,49.517,797.9081006 273 | Chad,1987,5498955,Africa,51.051,952.386129 274 | Chad,1992,6429417,Africa,51.724,1058.0643 275 | Chad,1997,7562011,Africa,51.573,1004.961353 276 | Chad,2002,8835739,Africa,50.525,1156.18186 277 | Chad,2007,10238807,Africa,50.651,1704.063724 278 | Chile,1952,6377619,Americas,54.745,3939.978789 279 | Chile,1957,7048426,Americas,56.074,4315.622723 280 | Chile,1962,7961258,Americas,57.924,4519.094331 281 | Chile,1967,8858908,Americas,60.523,5106.654313 282 | Chile,1972,9717524,Americas,63.441,5494.024437 283 | Chile,1977,10599793,Americas,67.052,4756.763836 284 | Chile,1982,11487112,Americas,70.565,5095.665738 285 | Chile,1987,12463354,Americas,72.492,5547.063754 286 | Chile,1992,13572994,Americas,74.126,7596.125964 287 | Chile,1997,14599929,Americas,75.816,10118.05318 288 | Chile,2002,15497046,Americas,77.86,10778.78385 289 | Chile,2007,16284741,Americas,78.553,13171.63885 290 | China,1952,556263527.999989,Asia,44,400.448610699994 291 | China,1957,637408000,Asia,50.54896,575.9870009 292 | China,1962,665770000,Asia,44.50136,487.6740183 293 | China,1967,754550000,Asia,58.38112,612.7056934 294 | China,1972,862030000,Asia,63.11888,676.9000921 295 | China,1977,943455000,Asia,63.96736,741.2374699 296 | China,1982,1000281000,Asia,65.525,962.4213805 297 | China,1987,1084035000,Asia,67.274,1378.904018 298 | China,1992,1164970000,Asia,68.69,1655.784158 299 | China,1997,1230075000,Asia,70.426,2289.234136 300 | China,2002,1280400000,Asia,72.028,3119.280896 301 | China,2007,1318683096,Asia,72.961,4959.114854 302 | Colombia,1952,12350771,Americas,50.643,2144.115096 303 | Colombia,1957,14485993,Americas,55.118,2323.805581 304 | Colombia,1962,17009885,Americas,57.863,2492.351109 305 | Colombia,1967,19764027,Americas,59.963,2678.729839 306 | Colombia,1972,22542890,Americas,61.623,3264.660041 307 | Colombia,1977,25094412,Americas,63.837,3815.80787 308 | Colombia,1982,27764644,Americas,66.653,4397.575659 309 | Colombia,1987,30964245,Americas,67.768,4903.2191 310 | Colombia,1992,34202721,Americas,68.421,5444.648617 311 | Colombia,1997,37657830,Americas,70.313,6117.361746 312 | Colombia,2002,41008227,Americas,71.682,5755.259962 313 | Colombia,2007,44227550,Americas,72.889,7006.580419 314 | Comoros,1952,153936,Africa,40.715,1102.990936 315 | Comoros,1957,170928,Africa,42.46,1211.148548 316 | Comoros,1962,191689,Africa,44.467,1406.648278 317 | Comoros,1967,217378,Africa,46.472,1876.029643 318 | Comoros,1972,250027,Africa,48.944,1937.577675 319 | Comoros,1977,304739,Africa,50.939,1172.603047 320 | Comoros,1982,348643,Africa,52.933,1267.100083 321 | Comoros,1987,395114,Africa,54.926,1315.980812 322 | Comoros,1992,454429,Africa,57.939,1246.90737 323 | Comoros,1997,527982,Africa,60.66,1173.618235 324 | Comoros,2002,614382,Africa,62.974,1075.811558 325 | Comoros,2007,710960,Africa,65.152,986.1478792 326 | Congo Dem. Rep.,1952,14100005,Africa,39.143,780.5423257 327 | Congo Dem. Rep.,1957,15577932,Africa,40.652,905.8602303 328 | Congo Dem. Rep.,1962,17486434,Africa,42.122,896.3146335 329 | Congo Dem. Rep.,1967,19941073,Africa,44.056,861.5932424 330 | Congo Dem. Rep.,1972,23007669,Africa,45.989,904.8960685 331 | Congo Dem. Rep.,1977,26480870,Africa,47.804,795.757282 332 | Congo Dem. Rep.,1982,30646495,Africa,47.784,673.7478181 333 | Congo Dem. Rep.,1987,35481645,Africa,47.412,672.774812 334 | Congo Dem. Rep.,1992,41672143,Africa,45.548,457.7191807 335 | Congo Dem. Rep.,1997,47798986,Africa,42.587,312.188423 336 | Congo Dem. Rep.,2002,55379852,Africa,44.966,241.1658765 337 | Congo Dem. Rep.,2007,64606759,Africa,46.462,277.5518587 338 | Congo Rep.,1952,854885,Africa,42.111,2125.621418 339 | Congo Rep.,1957,940458,Africa,45.053,2315.056572 340 | Congo Rep.,1962,1047924,Africa,48.435,2464.783157 341 | Congo Rep.,1967,1179760,Africa,52.04,2677.939642 342 | Congo Rep.,1972,1340458,Africa,54.907,3213.152683 343 | Congo Rep.,1977,1536769,Africa,55.625,3259.178978 344 | Congo Rep.,1982,1774735,Africa,56.695,4879.507522 345 | Congo Rep.,1987,2064095,Africa,57.47,4201.194937 346 | Congo Rep.,1992,2409073,Africa,56.433,4016.239529 347 | Congo Rep.,1997,2800947,Africa,52.962,3484.164376 348 | Congo Rep.,2002,3328795,Africa,52.97,3484.06197 349 | Congo Rep.,2007,3800610,Africa,55.322,3632.557798 350 | Costa Rica,1952,926317,Americas,57.206,2627.009471 351 | Costa Rica,1957,1112300,Americas,60.026,2990.010802 352 | Costa Rica,1962,1345187,Americas,62.842,3460.937025 353 | Costa Rica,1967,1588717,Americas,65.424,4161.727834 354 | Costa Rica,1972,1834796,Americas,67.849,5118.146939 355 | Costa Rica,1977,2108457,Americas,70.75,5926.876967 356 | Costa Rica,1982,2424367,Americas,73.45,5262.734751 357 | Costa Rica,1987,2799811,Americas,74.752,5629.915318 358 | Costa Rica,1992,3173216,Americas,75.713,6160.416317 359 | Costa Rica,1997,3518107,Americas,77.26,6677.045314 360 | Costa Rica,2002,3834934,Americas,78.123,7723.447195 361 | Costa Rica,2007,4133884,Americas,78.782,9645.06142 362 | "Cote d'Ivoire",1952,2977019,Africa,40.477,1388.594732 363 | "Cote d'Ivoire",1957,3300000,Africa,42.469,1500.895925 364 | "Cote d'Ivoire",1962,3832408,Africa,44.93,1728.869428 365 | "Cote d'Ivoire",1967,4744870,Africa,47.35,2052.050473 366 | "Cote d'Ivoire",1972,6071696,Africa,49.801,2378.201111 367 | "Cote d'Ivoire",1977,7459574,Africa,52.374,2517.736547 368 | "Cote d'Ivoire",1982,9025951,Africa,53.983,2602.710169 369 | "Cote d'Ivoire",1987,10761098,Africa,54.655,2156.956069 370 | "Cote d'Ivoire",1992,12772596,Africa,52.044,1648.073791 371 | "Cote d'Ivoire",1997,14625967,Africa,47.991,1786.265407 372 | "Cote d'Ivoire",2002,16252726,Africa,46.832,1648.800823 373 | "Cote d'Ivoire",2007,18013409,Africa,48.328,1544.750112 374 | Croatia,1952,3882229,Europe,61.21,3119.23652 375 | Croatia,1957,3991242,Europe,64.77,4338.231617 376 | Croatia,1962,4076557,Europe,67.13,5477.890018 377 | Croatia,1967,4174366,Europe,68.5,6960.297861 378 | Croatia,1972,4225310,Europe,69.61,9164.090127 379 | Croatia,1977,4318673,Europe,70.64,11305.38517 380 | Croatia,1982,4413368,Europe,70.46,13221.82184 381 | Croatia,1987,4484310,Europe,71.52,13822.58394 382 | Croatia,1992,4494013,Europe,72.527,8447.794873 383 | Croatia,1997,4444595,Europe,73.68,9875.604515 384 | Croatia,2002,4481020,Europe,74.876,11628.38895 385 | Croatia,2007,4493312,Europe,75.748,14619.22272 386 | Cuba,1952,6007797,Americas,59.421,5586.53878 387 | Cuba,1957,6640752,Americas,62.325,6092.174359 388 | Cuba,1962,7254373,Americas,65.246,5180.75591 389 | Cuba,1967,8139332,Americas,68.29,5690.268015 390 | Cuba,1972,8831348,Americas,70.723,5305.445256 391 | Cuba,1977,9537988,Americas,72.649,6380.494966 392 | Cuba,1982,9789224,Americas,73.717,7316.918107 393 | Cuba,1987,10239839,Americas,74.174,7532.924763 394 | Cuba,1992,10723260,Americas,74.414,5592.843963 395 | Cuba,1997,10983007,Americas,76.151,5431.990415 396 | Cuba,2002,11226999,Americas,77.158,6340.646683 397 | Cuba,2007,11416987,Americas,78.273,8948.102923 398 | Czech Republic,1952,9125183,Europe,66.87,6876.14025 399 | Czech Republic,1957,9513758,Europe,69.03,8256.343918 400 | Czech Republic,1962,9620282,Europe,69.9,10136.86713 401 | Czech Republic,1967,9835109,Europe,70.38,11399.44489 402 | Czech Republic,1972,9862158,Europe,70.29,13108.4536 403 | Czech Republic,1977,10161915,Europe,70.71,14800.16062 404 | Czech Republic,1982,10303704,Europe,70.96,15377.22855 405 | Czech Republic,1987,10311597,Europe,71.58,16310.4434 406 | Czech Republic,1992,10315702,Europe,72.4,14297.02122 407 | Czech Republic,1997,10300707,Europe,74.01,16048.51424 408 | Czech Republic,2002,10256295,Europe,75.51,17596.21022 409 | Czech Republic,2007,10228744,Europe,76.486,22833.30851 410 | Denmark,1952,4334000,Europe,70.78,9692.385245 411 | Denmark,1957,4487831,Europe,71.81,11099.65935 412 | Denmark,1962,4646899,Europe,72.35,13583.31351 413 | Denmark,1967,4838800,Europe,72.96,15937.21123 414 | Denmark,1972,4991596,Europe,73.47,18866.20721 415 | Denmark,1977,5088419,Europe,74.69,20422.9015 416 | Denmark,1982,5117810,Europe,74.63,21688.04048 417 | Denmark,1987,5127024,Europe,74.8,25116.17581 418 | Denmark,1992,5171393,Europe,75.33,26406.73985 419 | Denmark,1997,5283663,Europe,76.11,29804.34567 420 | Denmark,2002,5374693,Europe,77.18,32166.50006 421 | Denmark,2007,5468120,Europe,78.332,35278.41874 422 | Djibouti,1952,63149,Africa,34.812,2669.529475 423 | Djibouti,1957,71851,Africa,37.328,2864.969076 424 | Djibouti,1962,89898,Africa,39.693,3020.989263 425 | Djibouti,1967,127617,Africa,42.074,3020.050513 426 | Djibouti,1972,178848,Africa,44.366,3694.212352 427 | Djibouti,1977,228694,Africa,46.519,3081.761022 428 | Djibouti,1982,305991,Africa,48.812,2879.468067 429 | Djibouti,1987,311025,Africa,50.04,2880.102568 430 | Djibouti,1992,384156,Africa,51.604,2377.156192 431 | Djibouti,1997,417908,Africa,53.157,1895.016984 432 | Djibouti,2002,447416,Africa,53.373,1908.260867 433 | Djibouti,2007,496374,Africa,54.791,2082.481567 434 | Dominican Republic,1952,2491346,Americas,45.928,1397.717137 435 | Dominican Republic,1957,2923186,Americas,49.828,1544.402995 436 | Dominican Republic,1962,3453434,Americas,53.459,1662.137359 437 | Dominican Republic,1967,4049146,Americas,56.751,1653.723003 438 | Dominican Republic,1972,4671329,Americas,59.631,2189.874499 439 | Dominican Republic,1977,5302800,Americas,61.788,2681.9889 440 | Dominican Republic,1982,5968349,Americas,63.727,2861.092386 441 | Dominican Republic,1987,6655297,Americas,66.046,2899.842175 442 | Dominican Republic,1992,7351181,Americas,68.457,3044.214214 443 | Dominican Republic,1997,7992357,Americas,69.957,3614.101285 444 | Dominican Republic,2002,8650322,Americas,70.847,4563.808154 445 | Dominican Republic,2007,9319622,Americas,72.235,6025.374752 446 | Ecuador,1952,3548753,Americas,48.357,3522.110717 447 | Ecuador,1957,4058385,Americas,51.356,3780.546651 448 | Ecuador,1962,4681707,Americas,54.64,4086.114078 449 | Ecuador,1967,5432424,Americas,56.678,4579.074215 450 | Ecuador,1972,6298651,Americas,58.796,5280.99471 451 | Ecuador,1977,7278866,Americas,61.31,6679.62326 452 | Ecuador,1982,8365850,Americas,64.342,7213.791267 453 | Ecuador,1987,9545158,Americas,67.231,6481.776993 454 | Ecuador,1992,10748394,Americas,69.613,7103.702595 455 | Ecuador,1997,11911819,Americas,72.312,7429.455877 456 | Ecuador,2002,12921234,Americas,74.173,5773.044512 457 | Ecuador,2007,13755680,Americas,74.994,6873.262326 458 | Egypt,1952,22223309,Africa,41.893,1418.822445 459 | Egypt,1957,25009741,Africa,44.444,1458.915272 460 | Egypt,1962,28173309,Africa,46.992,1693.335853 461 | Egypt,1967,31681188,Africa,49.293,1814.880728 462 | Egypt,1972,34807417,Africa,51.137,2024.008147 463 | Egypt,1977,38783863,Africa,53.319,2785.493582 464 | Egypt,1982,45681811,Africa,56.006,3503.729636 465 | Egypt,1987,52799062,Africa,59.797,3885.46071 466 | Egypt,1992,59402198,Africa,63.674,3794.755195 467 | Egypt,1997,66134291,Africa,67.217,4173.181797 468 | Egypt,2002,73312559,Africa,69.806,4754.604414 469 | Egypt,2007,80264543,Africa,71.338,5581.180998 470 | El Salvador,1952,2042865,Americas,45.262,3048.3029 471 | El Salvador,1957,2355805,Americas,48.57,3421.523218 472 | El Salvador,1962,2747687,Americas,52.307,3776.803627 473 | El Salvador,1967,3232927,Americas,55.855,4358.595393 474 | El Salvador,1972,3790903,Americas,58.207,4520.246008 475 | El Salvador,1977,4282586,Americas,56.696,5138.922374 476 | El Salvador,1982,4474873,Americas,56.604,4098.344175 477 | El Salvador,1987,4842194,Americas,63.154,4140.442097 478 | El Salvador,1992,5274649,Americas,66.798,4444.2317 479 | El Salvador,1997,5783439,Americas,69.535,5154.825496 480 | El Salvador,2002,6353681,Americas,70.734,5351.568666 481 | El Salvador,2007,6939688,Americas,71.878,5728.353514 482 | Equatorial Guinea,1952,216964,Africa,34.482,375.6431231 483 | Equatorial Guinea,1957,232922,Africa,35.983,426.0964081 484 | Equatorial Guinea,1962,249220,Africa,37.485,582.8419714 485 | Equatorial Guinea,1967,259864,Africa,38.987,915.5960025 486 | Equatorial Guinea,1972,277603,Africa,40.516,672.4122571 487 | Equatorial Guinea,1977,192675,Africa,42.024,958.5668124 488 | Equatorial Guinea,1982,285483,Africa,43.662,927.8253427 489 | Equatorial Guinea,1987,341244,Africa,45.664,966.8968149 490 | Equatorial Guinea,1992,387838,Africa,47.545,1132.055034 491 | Equatorial Guinea,1997,439971,Africa,48.245,2814.480755 492 | Equatorial Guinea,2002,495627,Africa,49.348,7703.4959 493 | Equatorial Guinea,2007,551201,Africa,51.579,12154.08975 494 | Eritrea,1952,1438760,Africa,35.928,328.9405571 495 | Eritrea,1957,1542611,Africa,38.047,344.1618859 496 | Eritrea,1962,1666618,Africa,40.158,380.9958433 497 | Eritrea,1967,1820319,Africa,42.189,468.7949699 498 | Eritrea,1972,2260187,Africa,44.142,514.3242082 499 | Eritrea,1977,2512642,Africa,44.535,505.7538077 500 | Eritrea,1982,2637297,Africa,43.89,524.8758493 501 | Eritrea,1987,2915959,Africa,46.453,521.1341333 502 | Eritrea,1992,3668440,Africa,49.991,582.8585102 503 | Eritrea,1997,4058319,Africa,53.378,913.47079 504 | Eritrea,2002,4414865,Africa,55.24,765.3500015 505 | Eritrea,2007,4906585,Africa,58.04,641.3695236 506 | Ethiopia,1952,20860941,Africa,34.078,362.1462796 507 | Ethiopia,1957,22815614,Africa,36.667,378.9041632 508 | Ethiopia,1962,25145372,Africa,40.059,419.4564161 509 | Ethiopia,1967,27860297,Africa,42.115,516.1186438 510 | Ethiopia,1972,30770372,Africa,43.515,566.2439442 511 | Ethiopia,1977,34617799,Africa,44.51,556.8083834 512 | Ethiopia,1982,38111756,Africa,44.916,577.8607471 513 | Ethiopia,1987,42999530,Africa,46.684,573.7413142 514 | Ethiopia,1992,52088559,Africa,48.091,421.3534653 515 | Ethiopia,1997,59861301,Africa,49.402,515.8894013 516 | Ethiopia,2002,67946797,Africa,50.725,530.0535319 517 | Ethiopia,2007,76511887,Africa,52.947,690.8055759 518 | Finland,1952,4090500,Europe,66.55,6424.519071 519 | Finland,1957,4324000,Europe,67.49,7545.415386 520 | Finland,1962,4491443,Europe,68.75,9371.842561 521 | Finland,1967,4605744,Europe,69.83,10921.63626 522 | Finland,1972,4639657,Europe,70.87,14358.8759 523 | Finland,1977,4738902,Europe,72.52,15605.42283 524 | Finland,1982,4826933,Europe,74.55,18533.15761 525 | Finland,1987,4931729,Europe,74.83,21141.01223 526 | Finland,1992,5041039,Europe,75.7,20647.16499 527 | Finland,1997,5134406,Europe,77.13,23723.9502 528 | Finland,2002,5193039,Europe,78.37,28204.59057 529 | Finland,2007,5238460,Europe,79.313,33207.0844 530 | France,1952,42459667,Europe,67.41,7029.809327 531 | France,1957,44310863,Europe,68.93,8662.834898 532 | France,1962,47124000,Europe,70.51,10560.48553 533 | France,1967,49569000,Europe,71.55,12999.91766 534 | France,1972,51732000,Europe,72.38,16107.19171 535 | France,1977,53165019,Europe,73.83,18292.63514 536 | France,1982,54433565,Europe,74.89,20293.89746 537 | France,1987,55630100,Europe,76.34,22066.44214 538 | France,1992,57374179,Europe,77.46,24703.79615 539 | France,1997,58623428,Europe,78.64,25889.78487 540 | France,2002,59925035,Europe,79.59,28926.03234 541 | France,2007,61083916,Europe,80.657,30470.0167 542 | Gabon,1952,420702,Africa,37.003,4293.476475 543 | Gabon,1957,434904,Africa,38.999,4976.198099 544 | Gabon,1962,455661,Africa,40.489,6631.459222 545 | Gabon,1967,489004,Africa,44.598,8358.761987 546 | Gabon,1972,537977,Africa,48.69,11401.94841 547 | Gabon,1977,706367,Africa,52.79,21745.57328 548 | Gabon,1982,753874,Africa,56.564,15113.36194 549 | Gabon,1987,880397,Africa,60.19,11864.40844 550 | Gabon,1992,985739,Africa,61.366,13522.15752 551 | Gabon,1997,1126189,Africa,60.461,14722.84188 552 | Gabon,2002,1299304,Africa,56.761,12521.71392 553 | Gabon,2007,1454867,Africa,56.735,13206.48452 554 | Gambia,1952,284320,Africa,30,485.2306591 555 | Gambia,1957,323150,Africa,32.065,520.9267111 556 | Gambia,1962,374020,Africa,33.896,599.650276 557 | Gambia,1967,439593,Africa,35.857,734.7829124 558 | Gambia,1972,517101,Africa,38.308,756.0868363 559 | Gambia,1977,608274,Africa,41.842,884.7552507 560 | Gambia,1982,715523,Africa,45.58,835.8096108 561 | Gambia,1987,848406,Africa,49.265,611.6588611 562 | Gambia,1992,1025384,Africa,52.644,665.6244126 563 | Gambia,1997,1235767,Africa,55.861,653.7301704 564 | Gambia,2002,1457766,Africa,58.041,660.5855997 565 | Gambia,2007,1688359,Africa,59.448,752.7497265 566 | Germany,1952,69145952,Europe,67.5,7144.114393 567 | Germany,1957,71019069,Europe,69.1,10187.82665 568 | Germany,1962,73739117,Europe,70.3,12902.46291 569 | Germany,1967,76368453,Europe,70.8,14745.62561 570 | Germany,1972,78717088,Europe,71,18016.18027 571 | Germany,1977,78160773,Europe,72.5,20512.92123 572 | Germany,1982,78335266,Europe,73.8,22031.53274 573 | Germany,1987,77718298,Europe,74.847,24639.18566 574 | Germany,1992,80597764,Europe,76.07,26505.30317 575 | Germany,1997,82011073,Europe,77.34,27788.88416 576 | Germany,2002,82350671,Europe,78.67,30035.80198 577 | Germany,2007,82400996,Europe,79.406,32170.37442 578 | Ghana,1952,5581001,Africa,43.149,911.2989371 579 | Ghana,1957,6391288,Africa,44.779,1043.561537 580 | Ghana,1962,7355248,Africa,46.452,1190.041118 581 | Ghana,1967,8490213,Africa,48.072,1125.69716 582 | Ghana,1972,9354120,Africa,49.875,1178.223708 583 | Ghana,1977,10538093,Africa,51.756,993.2239571 584 | Ghana,1982,11400338,Africa,53.744,876.032569 585 | Ghana,1987,14168101,Africa,55.729,847.0061135 586 | Ghana,1992,16278738,Africa,57.501,925.060154 587 | Ghana,1997,18418288,Africa,58.556,1005.245812 588 | Ghana,2002,20550751,Africa,58.453,1111.984578 589 | Ghana,2007,22873338,Africa,60.022,1327.60891 590 | Greece,1952,7733250,Europe,65.86,3530.690067 591 | Greece,1957,8096218,Europe,67.86,4916.299889 592 | Greece,1962,8448233,Europe,69.51,6017.190733 593 | Greece,1967,8716441,Europe,71,8513.097016 594 | Greece,1972,8888628,Europe,72.34,12724.82957 595 | Greece,1977,9308479,Europe,73.68,14195.52428 596 | Greece,1982,9786480,Europe,75.24,15268.42089 597 | Greece,1987,9974490,Europe,76.67,16120.52839 598 | Greece,1992,10325429,Europe,77.03,17541.49634 599 | Greece,1997,10502372,Europe,77.869,18747.69814 600 | Greece,2002,10603863,Europe,78.256,22514.2548 601 | Greece,2007,10706290,Europe,79.483,27538.41188 602 | Guatemala,1952,3146381,Americas,42.023,2428.237769 603 | Guatemala,1957,3640876,Americas,44.142,2617.155967 604 | Guatemala,1962,4208858,Americas,46.954,2750.364446 605 | Guatemala,1967,4690773,Americas,50.016,3242.531147 606 | Guatemala,1972,5149581,Americas,53.738,4031.408271 607 | Guatemala,1977,5703430,Americas,56.029,4879.992748 608 | Guatemala,1982,6395630,Americas,58.137,4820.49479 609 | Guatemala,1987,7326406,Americas,60.782,4246.485974 610 | Guatemala,1992,8486949,Americas,63.373,4439.45084 611 | Guatemala,1997,9803875,Americas,66.322,4684.313807 612 | Guatemala,2002,11178650,Americas,68.978,4858.347495 613 | Guatemala,2007,12572928,Americas,70.259,5186.050003 614 | Guinea,1952,2664249,Africa,33.609,510.1964923 615 | Guinea,1957,2876726,Africa,34.558,576.2670245 616 | Guinea,1962,3140003,Africa,35.753,686.3736739 617 | Guinea,1967,3451418,Africa,37.197,708.7595409 618 | Guinea,1972,3811387,Africa,38.842,741.6662307 619 | Guinea,1977,4227026,Africa,40.762,874.6858643 620 | Guinea,1982,4710497,Africa,42.891,857.2503577 621 | Guinea,1987,5650262,Africa,45.552,805.5724718 622 | Guinea,1992,6990574,Africa,48.576,794.3484384 623 | Guinea,1997,8048834,Africa,51.455,869.4497668 624 | Guinea,2002,8807818,Africa,53.676,945.5835837 625 | Guinea,2007,9947814,Africa,56.007,942.6542111 626 | Guinea-Bissau,1952,580653,Africa,32.5,299.850319 627 | Guinea-Bissau,1957,601095,Africa,33.489,431.7904566 628 | Guinea-Bissau,1962,627820,Africa,34.488,522.0343725 629 | Guinea-Bissau,1967,601287,Africa,35.492,715.5806402 630 | Guinea-Bissau,1972,625361,Africa,36.486,820.2245876 631 | Guinea-Bissau,1977,745228,Africa,37.465,764.7259628 632 | Guinea-Bissau,1982,825987,Africa,39.327,838.1239671 633 | Guinea-Bissau,1987,927524,Africa,41.245,736.4153921 634 | Guinea-Bissau,1992,1050938,Africa,43.266,745.5398706 635 | Guinea-Bissau,1997,1193708,Africa,44.873,796.6644681 636 | Guinea-Bissau,2002,1332459,Africa,45.504,575.7047176 637 | Guinea-Bissau,2007,1472041,Africa,46.388,579.231743 638 | Haiti,1952,3201488,Americas,37.579,1840.366939 639 | Haiti,1957,3507701,Americas,40.696,1726.887882 640 | Haiti,1962,3880130,Americas,43.59,1796.589032 641 | Haiti,1967,4318137,Americas,46.243,1452.057666 642 | Haiti,1972,4698301,Americas,48.042,1654.456946 643 | Haiti,1977,4908554,Americas,49.923,1874.298931 644 | Haiti,1982,5198399,Americas,51.461,2011.159549 645 | Haiti,1987,5756203,Americas,53.636,1823.015995 646 | Haiti,1992,6326682,Americas,55.089,1456.309517 647 | Haiti,1997,6913545,Americas,56.671,1341.726931 648 | Haiti,2002,7607651,Americas,58.137,1270.364932 649 | Haiti,2007,8502814,Americas,60.916,1201.637154 650 | Honduras,1952,1517453,Americas,41.912,2194.926204 651 | Honduras,1957,1770390,Americas,44.665,2220.487682 652 | Honduras,1962,2090162,Americas,48.041,2291.156835 653 | Honduras,1967,2500689,Americas,50.924,2538.269358 654 | Honduras,1972,2965146,Americas,53.884,2529.842345 655 | Honduras,1977,3055235,Americas,57.402,3203.208066 656 | Honduras,1982,3669448,Americas,60.909,3121.760794 657 | Honduras,1987,4372203,Americas,64.492,3023.096699 658 | Honduras,1992,5077347,Americas,66.399,3081.694603 659 | Honduras,1997,5867957,Americas,67.659,3160.454906 660 | Honduras,2002,6677328,Americas,68.565,3099.72866 661 | Honduras,2007,7483763,Americas,70.198,3548.330846 662 | Hong Kong China,1952,2125900,Asia,60.96,3054.421209 663 | Hong Kong China,1957,2736300,Asia,64.75,3629.076457 664 | Hong Kong China,1962,3305200,Asia,67.65,4692.648272 665 | Hong Kong China,1967,3722800,Asia,70,6197.962814 666 | Hong Kong China,1972,4115700,Asia,72,8315.928145 667 | Hong Kong China,1977,4583700,Asia,73.6,11186.14125 668 | Hong Kong China,1982,5264500,Asia,75.45,14560.53051 669 | Hong Kong China,1987,5584510,Asia,76.2,20038.47269 670 | Hong Kong China,1992,5829696,Asia,77.601,24757.60301 671 | Hong Kong China,1997,6495918,Asia,80,28377.63219 672 | Hong Kong China,2002,6762476,Asia,81.495,30209.01516 673 | Hong Kong China,2007,6980412,Asia,82.208,39724.97867 674 | Hungary,1952,9504000,Europe,64.03,5263.673816 675 | Hungary,1957,9839000,Europe,66.41,6040.180011 676 | Hungary,1962,10063000,Europe,67.96,7550.359877 677 | Hungary,1967,10223422,Europe,69.5,9326.64467 678 | Hungary,1972,10394091,Europe,69.76,10168.65611 679 | Hungary,1977,10637171,Europe,69.95,11674.83737 680 | Hungary,1982,10705535,Europe,69.39,12545.99066 681 | Hungary,1987,10612740,Europe,69.58,12986.47998 682 | Hungary,1992,10348684,Europe,69.17,10535.62855 683 | Hungary,1997,10244684,Europe,71.04,11712.7768 684 | Hungary,2002,10083313,Europe,72.59,14843.93556 685 | Hungary,2007,9956108,Europe,73.338,18008.94444 686 | Iceland,1952,147962,Europe,72.49,7267.688428 687 | Iceland,1957,165110,Europe,73.47,9244.001412 688 | Iceland,1962,182053,Europe,73.68,10350.15906 689 | Iceland,1967,198676,Europe,73.73,13319.89568 690 | Iceland,1972,209275,Europe,74.46,15798.06362 691 | Iceland,1977,221823,Europe,76.11,19654.96247 692 | Iceland,1982,233997,Europe,76.99,23269.6075 693 | Iceland,1987,244676,Europe,77.23,26923.20628 694 | Iceland,1992,259012,Europe,78.77,25144.39201 695 | Iceland,1997,271192,Europe,78.95,28061.09966 696 | Iceland,2002,288030,Europe,80.5,31163.20196 697 | Iceland,2007,301931,Europe,81.757,36180.78919 698 | India,1952,3.72e+08,Asia,37.373,546.5657493 699 | India,1957,4.09e+08,Asia,40.249,590.061996 700 | India,1962,4.54e+08,Asia,43.605,658.3471509 701 | India,1967,5.06e+08,Asia,47.193,700.7706107 702 | India,1972,5.67e+08,Asia,50.651,724.032527 703 | India,1977,6.34e+08,Asia,54.208,813.337323 704 | India,1982,7.08e+08,Asia,56.596,855.7235377 705 | India,1987,7.88e+08,Asia,58.553,976.5126756 706 | India,1992,8.72e+08,Asia,60.223,1164.406809 707 | India,1997,9.59e+08,Asia,61.765,1458.817442 708 | India,2002,1034172547,Asia,62.879,1746.769454 709 | India,2007,1110396331,Asia,64.698,2452.210407 710 | Indonesia,1952,82052000,Asia,37.468,749.6816546 711 | Indonesia,1957,90124000,Asia,39.918,858.9002707 712 | Indonesia,1962,99028000,Asia,42.518,849.2897701 713 | Indonesia,1967,109343000,Asia,45.964,762.4317721 714 | Indonesia,1972,121282000,Asia,49.203,1111.107907 715 | Indonesia,1977,136725000,Asia,52.702,1382.702056 716 | Indonesia,1982,153343000,Asia,56.159,1516.872988 717 | Indonesia,1987,169276000,Asia,60.137,1748.356961 718 | Indonesia,1992,184816000,Asia,62.681,2383.140898 719 | Indonesia,1997,199278000,Asia,66.041,3119.335603 720 | Indonesia,2002,211060000,Asia,68.588,2873.91287 721 | Indonesia,2007,223547000,Asia,70.65,3540.651564 722 | Iran,1952,17272000,Asia,44.869,3035.326002 723 | Iran,1957,19792000,Asia,47.181,3290.257643 724 | Iran,1962,22874000,Asia,49.325,4187.329802 725 | Iran,1967,26538000,Asia,52.469,5906.731805 726 | Iran,1972,30614000,Asia,55.234,9613.818607 727 | Iran,1977,35480679,Asia,57.702,11888.59508 728 | Iran,1982,43072751,Asia,59.62,7608.334602 729 | Iran,1987,51889696,Asia,63.04,6642.881371 730 | Iran,1992,60397973,Asia,65.742,7235.653188 731 | Iran,1997,63327987,Asia,68.042,8263.590301 732 | Iran,2002,66907826,Asia,69.451,9240.761975 733 | Iran,2007,69453570,Asia,70.964,11605.71449 734 | Iraq,1952,5441766,Asia,45.32,4129.766056 735 | Iraq,1957,6248643,Asia,48.437,6229.333562 736 | Iraq,1962,7240260,Asia,51.457,8341.737815 737 | Iraq,1967,8519282,Asia,54.459,8931.459811 738 | Iraq,1972,10061506,Asia,56.95,9576.037596 739 | Iraq,1977,11882916,Asia,60.413,14688.23507 740 | Iraq,1982,14173318,Asia,62.038,14517.90711 741 | Iraq,1987,16543189,Asia,65.044,11643.57268 742 | Iraq,1992,17861905,Asia,59.461,3745.640687 743 | Iraq,1997,20775703,Asia,58.811,3076.239795 744 | Iraq,2002,24001816,Asia,57.046,4390.717312 745 | Iraq,2007,27499638,Asia,59.545,4471.061906 746 | Ireland,1952,2952156,Europe,66.91,5210.280328 747 | Ireland,1957,2878220,Europe,68.9,5599.077872 748 | Ireland,1962,2830000,Europe,70.29,6631.597314 749 | Ireland,1967,2900100,Europe,71.08,7655.568963 750 | Ireland,1972,3024400,Europe,71.28,9530.772896 751 | Ireland,1977,3271900,Europe,72.03,11150.98113 752 | Ireland,1982,3480000,Europe,73.1,12618.32141 753 | Ireland,1987,3539900,Europe,74.36,13872.86652 754 | Ireland,1992,3557761,Europe,75.467,17558.81555 755 | Ireland,1997,3667233,Europe,76.122,24521.94713 756 | Ireland,2002,3879155,Europe,77.783,34077.04939 757 | Ireland,2007,4109086,Europe,78.885,40675.99635 758 | Israel,1952,1620914,Asia,65.39,4086.522128 759 | Israel,1957,1944401,Asia,67.84,5385.278451 760 | Israel,1962,2310904,Asia,69.39,7105.630706 761 | Israel,1967,2693585,Asia,70.75,8393.741404 762 | Israel,1972,3095893,Asia,71.63,12786.93223 763 | Israel,1977,3495918,Asia,73.06,13306.61921 764 | Israel,1982,3858421,Asia,74.45,15367.0292 765 | Israel,1987,4203148,Asia,75.6,17122.47986 766 | Israel,1992,4936550,Asia,76.93,18051.52254 767 | Israel,1997,5531387,Asia,78.269,20896.60924 768 | Israel,2002,6029529,Asia,79.696,21905.59514 769 | Israel,2007,6426679,Asia,80.745,25523.2771 770 | Italy,1952,47666000,Europe,65.94,4931.404155 771 | Italy,1957,49182000,Europe,67.81,6248.656232 772 | Italy,1962,50843200,Europe,69.24,8243.58234 773 | Italy,1967,52667100,Europe,71.06,10022.40131 774 | Italy,1972,54365564,Europe,72.19,12269.27378 775 | Italy,1977,56059245,Europe,73.48,14255.98475 776 | Italy,1982,56535636,Europe,74.98,16537.4835 777 | Italy,1987,56729703,Europe,76.42,19207.23482 778 | Italy,1992,56840847,Europe,77.44,22013.64486 779 | Italy,1997,57479469,Europe,78.82,24675.02446 780 | Italy,2002,57926999,Europe,80.24,27968.09817 781 | Italy,2007,58147733,Europe,80.546,28569.7197 782 | Jamaica,1952,1426095,Americas,58.53,2898.530881 783 | Jamaica,1957,1535090,Americas,62.61,4756.525781 784 | Jamaica,1962,1665128,Americas,65.61,5246.107524 785 | Jamaica,1967,1861096,Americas,67.51,6124.703451 786 | Jamaica,1972,1997616,Americas,69,7433.889293 787 | Jamaica,1977,2156814,Americas,70.11,6650.195573 788 | Jamaica,1982,2298309,Americas,71.21,6068.05135 789 | Jamaica,1987,2326606,Americas,71.77,6351.237495 790 | Jamaica,1992,2378618,Americas,71.766,7404.923685 791 | Jamaica,1997,2531311,Americas,72.262,7121.924704 792 | Jamaica,2002,2664659,Americas,72.047,6994.774861 793 | Jamaica,2007,2780132,Americas,72.567,7320.880262 794 | Japan,1952,86459025,Asia,63.03,3216.956347 795 | Japan,1957,91563009,Asia,65.5,4317.694365 796 | Japan,1962,95831757,Asia,68.73,6576.649461 797 | Japan,1967,100825279,Asia,71.43,9847.788607 798 | Japan,1972,107188273,Asia,73.42,14778.78636 799 | Japan,1977,113872473,Asia,75.38,16610.37701 800 | Japan,1982,118454974,Asia,77.11,19384.10571 801 | Japan,1987,122091325,Asia,78.67,22375.94189 802 | Japan,1992,124329269,Asia,79.36,26824.89511 803 | Japan,1997,125956499,Asia,80.69,28816.58499 804 | Japan,2002,127065841,Asia,82,28604.5919 805 | Japan,2007,127467972,Asia,82.603,31656.06806 806 | Jordan,1952,607914,Asia,43.158,1546.907807 807 | Jordan,1957,746559,Asia,45.669,1886.080591 808 | Jordan,1962,933559,Asia,48.126,2348.009158 809 | Jordan,1967,1255058,Asia,51.629,2741.796252 810 | Jordan,1972,1613551,Asia,56.528,2110.856309 811 | Jordan,1977,1937652,Asia,61.134,2852.351568 812 | Jordan,1982,2347031,Asia,63.739,4161.415959 813 | Jordan,1987,2820042,Asia,65.869,4448.679912 814 | Jordan,1992,3867409,Asia,68.015,3431.593647 815 | Jordan,1997,4526235,Asia,69.772,3645.379572 816 | Jordan,2002,5307470,Asia,71.263,3844.917194 817 | Jordan,2007,6053193,Asia,72.535,4519.461171 818 | Kenya,1952,6464046,Africa,42.27,853.540919 819 | Kenya,1957,7454779,Africa,44.686,944.4383152 820 | Kenya,1962,8678557,Africa,47.949,896.9663732 821 | Kenya,1967,10191512,Africa,50.654,1056.736457 822 | Kenya,1972,12044785,Africa,53.559,1222.359968 823 | Kenya,1977,14500404,Africa,56.155,1267.613204 824 | Kenya,1982,17661452,Africa,58.766,1348.225791 825 | Kenya,1987,21198082,Africa,59.339,1361.936856 826 | Kenya,1992,25020539,Africa,59.285,1341.921721 827 | Kenya,1997,28263827,Africa,54.407,1360.485021 828 | Kenya,2002,31386842,Africa,50.992,1287.514732 829 | Kenya,2007,35610177,Africa,54.11,1463.249282 830 | Korea Dem. Rep.,1952,8865488,Asia,50.056,1088.277758 831 | Korea Dem. Rep.,1957,9411381,Asia,54.081,1571.134655 832 | Korea Dem. Rep.,1962,10917494,Asia,56.656,1621.693598 833 | Korea Dem. Rep.,1967,12617009,Asia,59.942,2143.540609 834 | Korea Dem. Rep.,1972,14781241,Asia,63.983,3701.621503 835 | Korea Dem. Rep.,1977,16325320,Asia,67.159,4106.301249 836 | Korea Dem. Rep.,1982,17647518,Asia,69.1,4106.525293 837 | Korea Dem. Rep.,1987,19067554,Asia,70.647,4106.492315 838 | Korea Dem. Rep.,1992,20711375,Asia,69.978,3726.063507 839 | Korea Dem. Rep.,1997,21585105,Asia,67.727,1690.756814 840 | Korea Dem. Rep.,2002,22215365,Asia,66.662,1646.758151 841 | Korea Dem. Rep.,2007,23301725,Asia,67.297,1593.06548 842 | Korea Rep.,1952,20947571,Asia,47.453,1030.592226 843 | Korea Rep.,1957,22611552,Asia,52.681,1487.593537 844 | Korea Rep.,1962,26420307,Asia,55.292,1536.344387 845 | Korea Rep.,1967,30131000,Asia,57.716,2029.228142 846 | Korea Rep.,1972,33505000,Asia,62.612,3030.87665 847 | Korea Rep.,1977,36436000,Asia,64.766,4657.22102 848 | Korea Rep.,1982,39326000,Asia,67.123,5622.942464 849 | Korea Rep.,1987,41622000,Asia,69.81,8533.088805 850 | Korea Rep.,1992,43805450,Asia,72.244,12104.27872 851 | Korea Rep.,1997,46173816,Asia,74.647,15993.52796 852 | Korea Rep.,2002,47969150,Asia,77.045,19233.98818 853 | Korea Rep.,2007,49044790,Asia,78.623,23348.13973 854 | Kuwait,1952,160000,Asia,55.565,108382.3529 855 | Kuwait,1957,212846,Asia,58.033,113523.1329 856 | Kuwait,1962,358266,Asia,60.47,95458.11176 857 | Kuwait,1967,575003,Asia,64.624,80894.88326 858 | Kuwait,1972,841934,Asia,67.712,109347.867 859 | Kuwait,1977,1140357,Asia,69.343,59265.47714 860 | Kuwait,1982,1497494,Asia,71.309,31354.03573 861 | Kuwait,1987,1891487,Asia,74.174,28118.42998 862 | Kuwait,1992,1418095,Asia,75.19,34932.91959 863 | Kuwait,1997,1765345,Asia,76.156,40300.61996 864 | Kuwait,2002,2111561,Asia,76.904,35110.10566 865 | Kuwait,2007,2505559,Asia,77.588,47306.98978 866 | Lebanon,1952,1439529,Asia,55.928,4834.804067 867 | Lebanon,1957,1647412,Asia,59.489,6089.786934 868 | Lebanon,1962,1886848,Asia,62.094,5714.560611 869 | Lebanon,1967,2186894,Asia,63.87,6006.983042 870 | Lebanon,1972,2680018,Asia,65.421,7486.384341 871 | Lebanon,1977,3115787,Asia,66.099,8659.696836 872 | Lebanon,1982,3086876,Asia,66.983,7640.519521 873 | Lebanon,1987,3089353,Asia,67.926,5377.091329 874 | Lebanon,1992,3219994,Asia,69.292,6890.806854 875 | Lebanon,1997,3430388,Asia,70.265,8754.96385 876 | Lebanon,2002,3677780,Asia,71.028,9313.93883 877 | Lebanon,2007,3921278,Asia,71.993,10461.05868 878 | Lesotho,1952,748747,Africa,42.138,298.8462121 879 | Lesotho,1957,813338,Africa,45.047,335.9971151 880 | Lesotho,1962,893143,Africa,47.747,411.8006266 881 | Lesotho,1967,996380,Africa,48.492,498.6390265 882 | Lesotho,1972,1116779,Africa,49.767,496.5815922 883 | Lesotho,1977,1251524,Africa,52.208,745.3695408 884 | Lesotho,1982,1411807,Africa,55.078,797.2631074 885 | Lesotho,1987,1599200,Africa,57.18,773.9932141 886 | Lesotho,1992,1803195,Africa,59.685,977.4862725 887 | Lesotho,1997,1982823,Africa,55.558,1186.147994 888 | Lesotho,2002,2046772,Africa,44.593,1275.184575 889 | Lesotho,2007,2012649,Africa,42.592,1569.331442 890 | Liberia,1952,863308,Africa,38.48,575.5729961 891 | Liberia,1957,975950,Africa,39.486,620.9699901 892 | Liberia,1962,1112796,Africa,40.502,634.1951625 893 | Liberia,1967,1279406,Africa,41.536,713.6036483 894 | Liberia,1972,1482628,Africa,42.614,803.0054535 895 | Liberia,1977,1703617,Africa,43.764,640.3224383 896 | Liberia,1982,1956875,Africa,44.852,572.1995694 897 | Liberia,1987,2269414,Africa,46.027,506.1138573 898 | Liberia,1992,1912974,Africa,40.802,636.6229191 899 | Liberia,1997,2200725,Africa,42.221,609.1739508 900 | Liberia,2002,2814651,Africa,43.753,531.4823679 901 | Liberia,2007,3193942,Africa,45.678,414.5073415 902 | Libya,1952,1019729,Africa,42.723,2387.54806 903 | Libya,1957,1201578,Africa,45.289,3448.284395 904 | Libya,1962,1441863,Africa,47.808,6757.030816 905 | Libya,1967,1759224,Africa,50.227,18772.75169 906 | Libya,1972,2183877,Africa,52.773,21011.49721 907 | Libya,1977,2721783,Africa,57.442,21951.21176 908 | Libya,1982,3344074,Africa,62.155,17364.27538 909 | Libya,1987,3799845,Africa,66.234,11770.5898 910 | Libya,1992,4364501,Africa,68.755,9640.138501 911 | Libya,1997,4759670,Africa,71.555,9467.446056 912 | Libya,2002,5368585,Africa,72.737,9534.677467 913 | Libya,2007,6036914,Africa,73.952,12057.49928 914 | Madagascar,1952,4762912,Africa,36.681,1443.011715 915 | Madagascar,1957,5181679,Africa,38.865,1589.20275 916 | Madagascar,1962,5703324,Africa,40.848,1643.38711 917 | Madagascar,1967,6334556,Africa,42.881,1634.047282 918 | Madagascar,1972,7082430,Africa,44.851,1748.562982 919 | Madagascar,1977,8007166,Africa,46.881,1544.228586 920 | Madagascar,1982,9171477,Africa,48.969,1302.878658 921 | Madagascar,1987,10568642,Africa,49.35,1155.441948 922 | Madagascar,1992,12210395,Africa,52.214,1040.67619 923 | Madagascar,1997,14165114,Africa,54.978,986.2958956 924 | Madagascar,2002,16473477,Africa,57.286,894.6370822 925 | Madagascar,2007,19167654,Africa,59.443,1044.770126 926 | Malawi,1952,2917802,Africa,36.256,369.1650802 927 | Malawi,1957,3221238,Africa,37.207,416.3698064 928 | Malawi,1962,3628608,Africa,38.41,427.9010856 929 | Malawi,1967,4147252,Africa,39.487,495.5147806 930 | Malawi,1972,4730997,Africa,41.766,584.6219709 931 | Malawi,1977,5637246,Africa,43.767,663.2236766 932 | Malawi,1982,6502825,Africa,45.642,632.8039209 933 | Malawi,1987,7824747,Africa,47.457,635.5173634 934 | Malawi,1992,10014249,Africa,49.42,563.2000145 935 | Malawi,1997,10419991,Africa,47.495,692.2758103 936 | Malawi,2002,11824495,Africa,45.009,665.4231186 937 | Malawi,2007,13327079,Africa,48.303,759.3499101 938 | Malaysia,1952,6748378,Asia,48.463,1831.132894 939 | Malaysia,1957,7739235,Asia,52.102,1810.066992 940 | Malaysia,1962,8906385,Asia,55.737,2036.884944 941 | Malaysia,1967,10154878,Asia,59.371,2277.742396 942 | Malaysia,1972,11441462,Asia,63.01,2849.09478 943 | Malaysia,1977,12845381,Asia,65.256,3827.921571 944 | Malaysia,1982,14441916,Asia,68,4920.355951 945 | Malaysia,1987,16331785,Asia,69.5,5249.802653 946 | Malaysia,1992,18319502,Asia,70.693,7277.912802 947 | Malaysia,1997,20476091,Asia,71.938,10132.90964 948 | Malaysia,2002,22662365,Asia,73.044,10206.97794 949 | Malaysia,2007,24821286,Asia,74.241,12451.6558 950 | Mali,1952,3838168,Africa,33.685,452.3369807 951 | Mali,1957,4241884,Africa,35.307,490.3821867 952 | Mali,1962,4690372,Africa,36.936,496.1743428 953 | Mali,1967,5212416,Africa,38.487,545.0098873 954 | Mali,1972,5828158,Africa,39.977,581.3688761 955 | Mali,1977,6491649,Africa,41.714,686.3952693 956 | Mali,1982,6998256,Africa,43.916,618.0140641 957 | Mali,1987,7634008,Africa,46.364,684.1715576 958 | Mali,1992,8416215,Africa,48.388,739.014375 959 | Mali,1997,9384984,Africa,49.903,790.2579846 960 | Mali,2002,10580176,Africa,51.818,951.4097518 961 | Mali,2007,12031795,Africa,54.467,1042.581557 962 | Mauritania,1952,1022556,Africa,40.543,743.1159097 963 | Mauritania,1957,1076852,Africa,42.338,846.1202613 964 | Mauritania,1962,1146757,Africa,44.248,1055.896036 965 | Mauritania,1967,1230542,Africa,46.289,1421.145193 966 | Mauritania,1972,1332786,Africa,48.437,1586.851781 967 | Mauritania,1977,1456688,Africa,50.852,1497.492223 968 | Mauritania,1982,1622136,Africa,53.599,1481.150189 969 | Mauritania,1987,1841240,Africa,56.145,1421.603576 970 | Mauritania,1992,2119465,Africa,58.333,1361.369784 971 | Mauritania,1997,2444741,Africa,60.43,1483.136136 972 | Mauritania,2002,2828858,Africa,62.247,1579.019543 973 | Mauritania,2007,3270065,Africa,64.164,1803.151496 974 | Mauritius,1952,516556,Africa,50.986,1967.955707 975 | Mauritius,1957,609816,Africa,58.089,2034.037981 976 | Mauritius,1962,701016,Africa,60.246,2529.067487 977 | Mauritius,1967,789309,Africa,61.557,2475.387562 978 | Mauritius,1972,851334,Africa,62.944,2575.484158 979 | Mauritius,1977,913025,Africa,64.93,3710.982963 980 | Mauritius,1982,992040,Africa,66.711,3688.037739 981 | Mauritius,1987,1042663,Africa,68.74,4783.586903 982 | Mauritius,1992,1096202,Africa,69.745,6058.253846 983 | Mauritius,1997,1149818,Africa,70.736,7425.705295 984 | Mauritius,2002,1200206,Africa,71.954,9021.815894 985 | Mauritius,2007,1250882,Africa,72.801,10956.99112 986 | Mexico,1952,30144317,Americas,50.789,3478.125529 987 | Mexico,1957,35015548,Americas,55.19,4131.546641 988 | Mexico,1962,41121485,Americas,58.299,4581.609385 989 | Mexico,1967,47995559,Americas,60.11,5754.733883 990 | Mexico,1972,55984294,Americas,62.361,6809.40669 991 | Mexico,1977,63759976,Americas,65.032,7674.929108 992 | Mexico,1982,71640904,Americas,67.405,9611.147541 993 | Mexico,1987,80122492,Americas,69.498,8688.156003 994 | Mexico,1992,88111030,Americas,71.455,9472.384295 995 | Mexico,1997,95895146,Americas,73.67,9767.29753 996 | Mexico,2002,102479927,Americas,74.902,10742.44053 997 | Mexico,2007,108700891,Americas,76.195,11977.57496 998 | Mongolia,1952,800663,Asia,42.244,786.5668575 999 | Mongolia,1957,882134,Asia,45.248,912.6626085 1000 | Mongolia,1962,1010280,Asia,48.251,1056.353958 1001 | Mongolia,1967,1149500,Asia,51.253,1226.04113 1002 | Mongolia,1972,1320500,Asia,53.754,1421.741975 1003 | Mongolia,1977,1528000,Asia,55.491,1647.511665 1004 | Mongolia,1982,1756032,Asia,57.489,2000.603139 1005 | Mongolia,1987,2015133,Asia,60.222,2338.008304 1006 | Mongolia,1992,2312802,Asia,61.271,1785.402016 1007 | Mongolia,1997,2494803,Asia,63.625,1902.2521 1008 | Mongolia,2002,2674234,Asia,65.033,2140.739323 1009 | Mongolia,2007,2874127,Asia,66.803,3095.772271 1010 | Montenegro,1952,413834,Europe,59.164,2647.585601 1011 | Montenegro,1957,442829,Europe,61.448,3682.259903 1012 | Montenegro,1962,474528,Europe,63.728,4649.593785 1013 | Montenegro,1967,501035,Europe,67.178,5907.850937 1014 | Montenegro,1972,527678,Europe,70.636,7778.414017 1015 | Montenegro,1977,560073,Europe,73.066,9595.929905 1016 | Montenegro,1982,562548,Europe,74.101,11222.58762 1017 | Montenegro,1987,569473,Europe,74.865,11732.51017 1018 | Montenegro,1992,621621,Europe,75.435,7003.339037 1019 | Montenegro,1997,692651,Europe,75.445,6465.613349 1020 | Montenegro,2002,720230,Europe,73.981,6557.194282 1021 | Montenegro,2007,684736,Europe,74.543,9253.896111 1022 | Morocco,1952,9939217,Africa,42.873,1688.20357 1023 | Morocco,1957,11406350,Africa,45.423,1642.002314 1024 | Morocco,1962,13056604,Africa,47.924,1566.353493 1025 | Morocco,1967,14770296,Africa,50.335,1711.04477 1026 | Morocco,1972,16660670,Africa,52.862,1930.194975 1027 | Morocco,1977,18396941,Africa,55.73,2370.619976 1028 | Morocco,1982,20198730,Africa,59.65,2702.620356 1029 | Morocco,1987,22987397,Africa,62.677,2755.046991 1030 | Morocco,1992,25798239,Africa,65.393,2948.047252 1031 | Morocco,1997,28529501,Africa,67.66,2982.101858 1032 | Morocco,2002,31167783,Africa,69.615,3258.495584 1033 | Morocco,2007,33757175,Africa,71.164,3820.17523 1034 | Mozambique,1952,6446316,Africa,31.286,468.5260381 1035 | Mozambique,1957,7038035,Africa,33.779,495.5868333 1036 | Mozambique,1962,7788944,Africa,36.161,556.6863539 1037 | Mozambique,1967,8680909,Africa,38.113,566.6691539 1038 | Mozambique,1972,9809596,Africa,40.328,724.9178037 1039 | Mozambique,1977,11127868,Africa,42.495,502.3197334 1040 | Mozambique,1982,12587223,Africa,42.795,462.2114149 1041 | Mozambique,1987,12891952,Africa,42.861,389.8761846 1042 | Mozambique,1992,13160731,Africa,44.284,410.8968239 1043 | Mozambique,1997,16603334,Africa,46.344,472.3460771 1044 | Mozambique,2002,18473780,Africa,44.026,633.6179466 1045 | Mozambique,2007,19951656,Africa,42.082,823.6856205 1046 | Myanmar,1952,20092996,Asia,36.319,331 1047 | Myanmar,1957,21731844,Asia,41.905,350 1048 | Myanmar,1962,23634436,Asia,45.108,388 1049 | Myanmar,1967,25870271,Asia,49.379,349 1050 | Myanmar,1972,28466390,Asia,53.07,357 1051 | Myanmar,1977,31528087,Asia,56.059,371 1052 | Myanmar,1982,34680442,Asia,58.056,424 1053 | Myanmar,1987,38028578,Asia,58.339,385 1054 | Myanmar,1992,40546538,Asia,59.32,347 1055 | Myanmar,1997,43247867,Asia,60.328,415 1056 | Myanmar,2002,45598081,Asia,59.908,611 1057 | Myanmar,2007,47761980,Asia,62.069,944 1058 | Namibia,1952,485831,Africa,41.725,2423.780443 1059 | Namibia,1957,548080,Africa,45.226,2621.448058 1060 | Namibia,1962,621392,Africa,48.386,3173.215595 1061 | Namibia,1967,706640,Africa,51.159,3793.694753 1062 | Namibia,1972,821782,Africa,53.867,3746.080948 1063 | Namibia,1977,977026,Africa,56.437,3876.485958 1064 | Namibia,1982,1099010,Africa,58.968,4191.100511 1065 | Namibia,1987,1278184,Africa,60.835,3693.731337 1066 | Namibia,1992,1554253,Africa,61.999,3804.537999 1067 | Namibia,1997,1774766,Africa,58.909,3899.52426 1068 | Namibia,2002,1972153,Africa,51.479,4072.324751 1069 | Namibia,2007,2055080,Africa,52.906,4811.060429 1070 | Nepal,1952,9182536,Asia,36.157,545.8657229 1071 | Nepal,1957,9682338,Asia,37.686,597.9363558 1072 | Nepal,1962,10332057,Asia,39.393,652.3968593 1073 | Nepal,1967,11261690,Asia,41.472,676.4422254 1074 | Nepal,1972,12412593,Asia,43.971,674.7881296 1075 | Nepal,1977,13933198,Asia,46.748,694.1124398 1076 | Nepal,1982,15796314,Asia,49.594,718.3730947 1077 | Nepal,1987,17917180,Asia,52.537,775.6324501 1078 | Nepal,1992,20326209,Asia,55.727,897.7403604 1079 | Nepal,1997,23001113,Asia,59.426,1010.892138 1080 | Nepal,2002,25873917,Asia,61.34,1057.206311 1081 | Nepal,2007,28901790,Asia,63.785,1091.359778 1082 | Netherlands,1952,10381988,Europe,72.13,8941.571858 1083 | Netherlands,1957,11026383,Europe,72.99,11276.19344 1084 | Netherlands,1962,11805689,Europe,73.23,12790.84956 1085 | Netherlands,1967,12596822,Europe,73.82,15363.25136 1086 | Netherlands,1972,13329874,Europe,73.75,18794.74567 1087 | Netherlands,1977,13852989,Europe,75.24,21209.0592 1088 | Netherlands,1982,14310401,Europe,76.05,21399.46046 1089 | Netherlands,1987,14665278,Europe,76.83,23651.32361 1090 | Netherlands,1992,15174244,Europe,77.42,26790.94961 1091 | Netherlands,1997,15604464,Europe,78.03,30246.13063 1092 | Netherlands,2002,16122830,Europe,78.53,33724.75778 1093 | Netherlands,2007,16570613,Europe,79.762,36797.93332 1094 | New Zealand,1952,1994794,Oceania,69.39,10556.57566 1095 | New Zealand,1957,2229407,Oceania,70.26,12247.39532 1096 | New Zealand,1962,2488550,Oceania,71.24,13175.678 1097 | New Zealand,1967,2728150,Oceania,71.52,14463.91893 1098 | New Zealand,1972,2929100,Oceania,71.89,16046.03728 1099 | New Zealand,1977,3164900,Oceania,72.22,16233.7177 1100 | New Zealand,1982,3210650,Oceania,73.84,17632.4104 1101 | New Zealand,1987,3317166,Oceania,74.32,19007.19129 1102 | New Zealand,1992,3437674,Oceania,76.33,18363.32494 1103 | New Zealand,1997,3676187,Oceania,77.55,21050.41377 1104 | New Zealand,2002,3908037,Oceania,79.11,23189.80135 1105 | New Zealand,2007,4115771,Oceania,80.204,25185.00911 1106 | Nicaragua,1952,1165790,Americas,42.314,3112.363948 1107 | Nicaragua,1957,1358828,Americas,45.432,3457.415947 1108 | Nicaragua,1962,1590597,Americas,48.632,3634.364406 1109 | Nicaragua,1967,1865490,Americas,51.884,4643.393534 1110 | Nicaragua,1972,2182908,Americas,55.151,4688.593267 1111 | Nicaragua,1977,2554598,Americas,57.47,5486.371089 1112 | Nicaragua,1982,2979423,Americas,59.298,3470.338156 1113 | Nicaragua,1987,3344353,Americas,62.008,2955.984375 1114 | Nicaragua,1992,4017939,Americas,65.843,2170.151724 1115 | Nicaragua,1997,4609572,Americas,68.426,2253.023004 1116 | Nicaragua,2002,5146848,Americas,70.836,2474.548819 1117 | Nicaragua,2007,5675356,Americas,72.899,2749.320965 1118 | Niger,1952,3379468,Africa,37.444,761.879376 1119 | Niger,1957,3692184,Africa,38.598,835.5234025 1120 | Niger,1962,4076008,Africa,39.487,997.7661127 1121 | Niger,1967,4534062,Africa,40.118,1054.384891 1122 | Niger,1972,5060262,Africa,40.546,954.2092363 1123 | Niger,1977,5682086,Africa,41.291,808.8970728 1124 | Niger,1982,6437188,Africa,42.598,909.7221354 1125 | Niger,1987,7332638,Africa,44.555,668.3000228 1126 | Niger,1992,8392818,Africa,47.391,581.182725 1127 | Niger,1997,9666252,Africa,51.313,580.3052092 1128 | Niger,2002,11140655,Africa,54.496,601.0745012 1129 | Niger,2007,12894865,Africa,56.867,619.6768924 1130 | Nigeria,1952,33119096,Africa,36.324,1077.281856 1131 | Nigeria,1957,37173340,Africa,37.802,1100.592563 1132 | Nigeria,1962,41871351,Africa,39.36,1150.927478 1133 | Nigeria,1967,47287752,Africa,41.04,1014.514104 1134 | Nigeria,1972,53740085,Africa,42.821,1698.388838 1135 | Nigeria,1977,62209173,Africa,44.514,1981.951806 1136 | Nigeria,1982,73039376,Africa,45.826,1576.97375 1137 | Nigeria,1987,81551520,Africa,46.886,1385.029563 1138 | Nigeria,1992,93364244,Africa,47.472,1619.848217 1139 | Nigeria,1997,106207839,Africa,47.464,1624.941275 1140 | Nigeria,2002,119901274,Africa,46.608,1615.286395 1141 | Nigeria,2007,135031164,Africa,46.859,2013.977305 1142 | Norway,1952,3327728,Europe,72.67,10095.42172 1143 | Norway,1957,3491938,Europe,73.44,11653.97304 1144 | Norway,1962,3638919,Europe,73.47,13450.40151 1145 | Norway,1967,3786019,Europe,74.08,16361.87647 1146 | Norway,1972,3933004,Europe,74.34,18965.05551 1147 | Norway,1977,4043205,Europe,75.37,23311.34939 1148 | Norway,1982,4114787,Europe,75.97,26298.63531 1149 | Norway,1987,4186147,Europe,75.89,31540.9748 1150 | Norway,1992,4286357,Europe,77.32,33965.66115 1151 | Norway,1997,4405672,Europe,78.32,41283.16433 1152 | Norway,2002,4535591,Europe,79.05,44683.97525 1153 | Norway,2007,4627926,Europe,80.196,49357.19017 1154 | Oman,1952,507833,Asia,37.578,1828.230307 1155 | Oman,1957,561977,Asia,40.08,2242.746551 1156 | Oman,1962,628164,Asia,43.165,2924.638113 1157 | Oman,1967,714775,Asia,46.988,4720.942687 1158 | Oman,1972,829050,Asia,52.143,10618.03855 1159 | Oman,1977,1004533,Asia,57.367,11848.34392 1160 | Oman,1982,1301048,Asia,62.728,12954.79101 1161 | Oman,1987,1593882,Asia,67.734,18115.22313 1162 | Oman,1992,1915208,Asia,71.197,18616.70691 1163 | Oman,1997,2283635,Asia,72.499,19702.05581 1164 | Oman,2002,2713462,Asia,74.193,19774.83687 1165 | Oman,2007,3204897,Asia,75.64,22316.19287 1166 | Pakistan,1952,41346560,Asia,43.436,684.5971438 1167 | Pakistan,1957,46679944,Asia,45.557,747.0835292 1168 | Pakistan,1962,53100671,Asia,47.67,803.3427418 1169 | Pakistan,1967,60641899,Asia,49.8,942.4082588 1170 | Pakistan,1972,69325921,Asia,51.929,1049.938981 1171 | Pakistan,1977,78152686,Asia,54.043,1175.921193 1172 | Pakistan,1982,91462088,Asia,56.158,1443.429832 1173 | Pakistan,1987,105186881,Asia,58.245,1704.686583 1174 | Pakistan,1992,120065004,Asia,60.838,1971.829464 1175 | Pakistan,1997,135564834,Asia,61.818,2049.350521 1176 | Pakistan,2002,153403524,Asia,63.61,2092.712441 1177 | Pakistan,2007,169270617,Asia,65.483,2605.94758 1178 | Panama,1952,940080,Americas,55.191,2480.380334 1179 | Panama,1957,1063506,Americas,59.201,2961.800905 1180 | Panama,1962,1215725,Americas,61.817,3536.540301 1181 | Panama,1967,1405486,Americas,64.071,4421.009084 1182 | Panama,1972,1616384,Americas,66.216,5364.249663 1183 | Panama,1977,1839782,Americas,68.681,5351.912144 1184 | Panama,1982,2036305,Americas,70.472,7009.601598 1185 | Panama,1987,2253639,Americas,71.523,7034.779161 1186 | Panama,1992,2484997,Americas,72.462,6618.74305 1187 | Panama,1997,2734531,Americas,73.738,7113.692252 1188 | Panama,2002,2990875,Americas,74.712,7356.031934 1189 | Panama,2007,3242173,Americas,75.537,9809.185636 1190 | Paraguay,1952,1555876,Americas,62.649,1952.308701 1191 | Paraguay,1957,1770902,Americas,63.196,2046.154706 1192 | Paraguay,1962,2009813,Americas,64.361,2148.027146 1193 | Paraguay,1967,2287985,Americas,64.951,2299.376311 1194 | Paraguay,1972,2614104,Americas,65.815,2523.337977 1195 | Paraguay,1977,2984494,Americas,66.353,3248.373311 1196 | Paraguay,1982,3366439,Americas,66.874,4258.503604 1197 | Paraguay,1987,3886512,Americas,67.378,3998.875695 1198 | Paraguay,1992,4483945,Americas,68.225,4196.411078 1199 | Paraguay,1997,5154123,Americas,69.4,4247.400261 1200 | Paraguay,2002,5884491,Americas,70.755,3783.674243 1201 | Paraguay,2007,6667147,Americas,71.752,4172.838464 1202 | Peru,1952,8025700,Americas,43.902,3758.523437 1203 | Peru,1957,9146100,Americas,46.263,4245.256698 1204 | Peru,1962,10516500,Americas,49.096,4957.037982 1205 | Peru,1967,12132200,Americas,51.445,5788.09333 1206 | Peru,1972,13954700,Americas,55.448,5937.827283 1207 | Peru,1977,15990099,Americas,58.447,6281.290855 1208 | Peru,1982,18125129,Americas,61.406,6434.501797 1209 | Peru,1987,20195924,Americas,64.134,6360.943444 1210 | Peru,1992,22430449,Americas,66.458,4446.380924 1211 | Peru,1997,24748122,Americas,68.386,5838.347657 1212 | Peru,2002,26769436,Americas,69.906,5909.020073 1213 | Peru,2007,28674757,Americas,71.421,7408.905561 1214 | Philippines,1952,22438691,Asia,47.752,1272.880995 1215 | Philippines,1957,26072194,Asia,51.334,1547.944844 1216 | Philippines,1962,30325264,Asia,54.757,1649.552153 1217 | Philippines,1967,35356600,Asia,56.393,1814.12743 1218 | Philippines,1972,40850141,Asia,58.065,1989.37407 1219 | Philippines,1977,46850962,Asia,60.06,2373.204287 1220 | Philippines,1982,53456774,Asia,62.082,2603.273765 1221 | Philippines,1987,60017788,Asia,64.151,2189.634995 1222 | Philippines,1992,67185766,Asia,66.458,2279.324017 1223 | Philippines,1997,75012988,Asia,68.564,2536.534925 1224 | Philippines,2002,82995088,Asia,70.303,2650.921068 1225 | Philippines,2007,91077287,Asia,71.688,3190.481016 1226 | Poland,1952,25730551,Europe,61.31,4029.329699 1227 | Poland,1957,28235346,Europe,65.77,4734.253019 1228 | Poland,1962,30329617,Europe,67.64,5338.752143 1229 | Poland,1967,31785378,Europe,69.61,6557.152776 1230 | Poland,1972,33039545,Europe,70.85,8006.506993 1231 | Poland,1977,34621254,Europe,70.67,9508.141454 1232 | Poland,1982,36227381,Europe,71.32,8451.531004 1233 | Poland,1987,37740710,Europe,70.98,9082.351172 1234 | Poland,1992,38370697,Europe,70.99,7738.881247 1235 | Poland,1997,38654957,Europe,72.75,10159.58368 1236 | Poland,2002,38625976,Europe,74.67,12002.23908 1237 | Poland,2007,38518241,Europe,75.563,15389.92468 1238 | Portugal,1952,8526050,Europe,59.82,3068.319867 1239 | Portugal,1957,8817650,Europe,61.51,3774.571743 1240 | Portugal,1962,9019800,Europe,64.39,4727.954889 1241 | Portugal,1967,9103000,Europe,66.6,6361.517993 1242 | Portugal,1972,8970450,Europe,69.26,9022.247417 1243 | Portugal,1977,9662600,Europe,70.41,10172.48572 1244 | Portugal,1982,9859650,Europe,72.77,11753.84291 1245 | Portugal,1987,9915289,Europe,74.06,13039.30876 1246 | Portugal,1992,9927680,Europe,74.86,16207.26663 1247 | Portugal,1997,10156415,Europe,75.97,17641.03156 1248 | Portugal,2002,10433867,Europe,77.29,19970.90787 1249 | Portugal,2007,10642836,Europe,78.098,20509.64777 1250 | Puerto Rico,1952,2227000,Americas,64.28,3081.959785 1251 | Puerto Rico,1957,2260000,Americas,68.54,3907.156189 1252 | Puerto Rico,1962,2448046,Americas,69.62,5108.34463 1253 | Puerto Rico,1967,2648961,Americas,71.1,6929.277714 1254 | Puerto Rico,1972,2847132,Americas,72.16,9123.041742 1255 | Puerto Rico,1977,3080828,Americas,73.44,9770.524921 1256 | Puerto Rico,1982,3279001,Americas,73.75,10330.98915 1257 | Puerto Rico,1987,3444468,Americas,74.63,12281.34191 1258 | Puerto Rico,1992,3585176,Americas,73.911,14641.58711 1259 | Puerto Rico,1997,3759430,Americas,74.917,16999.4333 1260 | Puerto Rico,2002,3859606,Americas,77.778,18855.60618 1261 | Puerto Rico,2007,3942491,Americas,78.746,19328.70901 1262 | Reunion,1952,257700,Africa,52.724,2718.885295 1263 | Reunion,1957,308700,Africa,55.09,2769.451844 1264 | Reunion,1962,358900,Africa,57.666,3173.72334 1265 | Reunion,1967,414024,Africa,60.542,4021.175739 1266 | Reunion,1972,461633,Africa,64.274,5047.658563 1267 | Reunion,1977,492095,Africa,67.064,4319.804067 1268 | Reunion,1982,517810,Africa,69.885,5267.219353 1269 | Reunion,1987,562035,Africa,71.913,5303.377488 1270 | Reunion,1992,622191,Africa,73.615,6101.255823 1271 | Reunion,1997,684810,Africa,74.772,6071.941411 1272 | Reunion,2002,743981,Africa,75.744,6316.1652 1273 | Reunion,2007,798094,Africa,76.442,7670.122558 1274 | Romania,1952,16630000,Europe,61.05,3144.613186 1275 | Romania,1957,17829327,Europe,64.1,3943.370225 1276 | Romania,1962,18680721,Europe,66.8,4734.997586 1277 | Romania,1967,19284814,Europe,66.8,6470.866545 1278 | Romania,1972,20662648,Europe,69.21,8011.414402 1279 | Romania,1977,21658597,Europe,69.46,9356.39724 1280 | Romania,1982,22356726,Europe,69.66,9605.314053 1281 | Romania,1987,22686371,Europe,69.53,9696.273295 1282 | Romania,1992,22797027,Europe,69.36,6598.409903 1283 | Romania,1997,22562458,Europe,69.72,7346.547557 1284 | Romania,2002,22404337,Europe,71.322,7885.360081 1285 | Romania,2007,22276056,Europe,72.476,10808.47561 1286 | Rwanda,1952,2534927,Africa,40,493.3238752 1287 | Rwanda,1957,2822082,Africa,41.5,540.2893983 1288 | Rwanda,1962,3051242,Africa,43,597.4730727 1289 | Rwanda,1967,3451079,Africa,44.1,510.9637142 1290 | Rwanda,1972,3992121,Africa,44.6,590.5806638 1291 | Rwanda,1977,4657072,Africa,45,670.0806011 1292 | Rwanda,1982,5507565,Africa,46.218,881.5706467 1293 | Rwanda,1987,6349365,Africa,44.02,847.991217 1294 | Rwanda,1992,7290203,Africa,23.599,737.0685949 1295 | Rwanda,1997,7212583,Africa,36.087,589.9445051 1296 | Rwanda,2002,7852401,Africa,43.413,785.6537648 1297 | Rwanda,2007,8860588,Africa,46.242,863.0884639 1298 | Sao Tome and Principe,1952,60011,Africa,46.471,879.5835855 1299 | Sao Tome and Principe,1957,61325,Africa,48.945,860.7369026 1300 | Sao Tome and Principe,1962,65345,Africa,51.893,1071.551119 1301 | Sao Tome and Principe,1967,70787,Africa,54.425,1384.840593 1302 | Sao Tome and Principe,1972,76595,Africa,56.48,1532.985254 1303 | Sao Tome and Principe,1977,86796,Africa,58.55,1737.561657 1304 | Sao Tome and Principe,1982,98593,Africa,60.351,1890.218117 1305 | Sao Tome and Principe,1987,110812,Africa,61.728,1516.525457 1306 | Sao Tome and Principe,1992,125911,Africa,62.742,1428.777814 1307 | Sao Tome and Principe,1997,145608,Africa,63.306,1339.076036 1308 | Sao Tome and Principe,2002,170372,Africa,64.337,1353.09239 1309 | Sao Tome and Principe,2007,199579,Africa,65.528,1598.435089 1310 | Saudi Arabia,1952,4005677,Asia,39.875,6459.554823 1311 | Saudi Arabia,1957,4419650,Asia,42.868,8157.591248 1312 | Saudi Arabia,1962,4943029,Asia,45.914,11626.41975 1313 | Saudi Arabia,1967,5618198,Asia,49.901,16903.04886 1314 | Saudi Arabia,1972,6472756,Asia,53.886,24837.42865 1315 | Saudi Arabia,1977,8128505,Asia,58.69,34167.7626 1316 | Saudi Arabia,1982,11254672,Asia,63.012,33693.17525 1317 | Saudi Arabia,1987,14619745,Asia,66.295,21198.26136 1318 | Saudi Arabia,1992,16945857,Asia,68.768,24841.61777 1319 | Saudi Arabia,1997,21229759,Asia,70.533,20586.69019 1320 | Saudi Arabia,2002,24501530,Asia,71.626,19014.54118 1321 | Saudi Arabia,2007,27601038,Asia,72.777,21654.83194 1322 | Senegal,1952,2755589,Africa,37.278,1450.356983 1323 | Senegal,1957,3054547,Africa,39.329,1567.653006 1324 | Senegal,1962,3430243,Africa,41.454,1654.988723 1325 | Senegal,1967,3965841,Africa,43.563,1612.404632 1326 | Senegal,1972,4588696,Africa,45.815,1597.712056 1327 | Senegal,1977,5260855,Africa,48.879,1561.769116 1328 | Senegal,1982,6147783,Africa,52.379,1518.479984 1329 | Senegal,1987,7171347,Africa,55.769,1441.72072 1330 | Senegal,1992,8307920,Africa,58.196,1367.899369 1331 | Senegal,1997,9535314,Africa,60.187,1392.368347 1332 | Senegal,2002,10870037,Africa,61.6,1519.635262 1333 | Senegal,2007,12267493,Africa,63.062,1712.472136 1334 | Serbia,1952,6860147,Europe,57.996,3581.459448 1335 | Serbia,1957,7271135,Europe,61.685,4981.090891 1336 | Serbia,1962,7616060,Europe,64.531,6289.629157 1337 | Serbia,1967,7971222,Europe,66.914,7991.707066 1338 | Serbia,1972,8313288,Europe,68.7,10522.06749 1339 | Serbia,1977,8686367,Europe,70.3,12980.66956 1340 | Serbia,1982,9032824,Europe,70.162,15181.0927 1341 | Serbia,1987,9230783,Europe,71.218,15870.87851 1342 | Serbia,1992,9826397,Europe,71.659,9325.068238 1343 | Serbia,1997,10336594,Europe,72.232,7914.320304 1344 | Serbia,2002,10111559,Europe,73.213,7236.075251 1345 | Serbia,2007,10150265,Europe,74.002,9786.534714 1346 | Sierra Leone,1952,2143249,Africa,30.331,879.7877358 1347 | Sierra Leone,1957,2295678,Africa,31.57,1004.484437 1348 | Sierra Leone,1962,2467895,Africa,32.767,1116.639877 1349 | Sierra Leone,1967,2662190,Africa,34.113,1206.043465 1350 | Sierra Leone,1972,2879013,Africa,35.4,1353.759762 1351 | Sierra Leone,1977,3140897,Africa,36.788,1348.285159 1352 | Sierra Leone,1982,3464522,Africa,38.445,1465.010784 1353 | Sierra Leone,1987,3868905,Africa,40.006,1294.447788 1354 | Sierra Leone,1992,4260884,Africa,38.333,1068.696278 1355 | Sierra Leone,1997,4578212,Africa,39.897,574.6481576 1356 | Sierra Leone,2002,5359092,Africa,41.012,699.489713 1357 | Sierra Leone,2007,6144562,Africa,42.568,862.5407561 1358 | Singapore,1952,1127000,Asia,60.396,2315.138227 1359 | Singapore,1957,1445929,Asia,63.179,2843.104409 1360 | Singapore,1962,1750200,Asia,65.798,3674.735572 1361 | Singapore,1967,1977600,Asia,67.946,4977.41854 1362 | Singapore,1972,2152400,Asia,69.521,8597.756202 1363 | Singapore,1977,2325300,Asia,70.795,11210.08948 1364 | Singapore,1982,2651869,Asia,71.76,15169.16112 1365 | Singapore,1987,2794552,Asia,73.56,18861.53081 1366 | Singapore,1992,3235865,Asia,75.788,24769.8912 1367 | Singapore,1997,3802309,Asia,77.158,33519.4766 1368 | Singapore,2002,4197776,Asia,78.77,36023.1054 1369 | Singapore,2007,4553009,Asia,79.972,47143.17964 1370 | Slovak Republic,1952,3558137,Europe,64.36,5074.659104 1371 | Slovak Republic,1957,3844277,Europe,67.45,6093.26298 1372 | Slovak Republic,1962,4237384,Europe,70.33,7481.107598 1373 | Slovak Republic,1967,4442238,Europe,70.98,8412.902397 1374 | Slovak Republic,1972,4593433,Europe,70.35,9674.167626 1375 | Slovak Republic,1977,4827803,Europe,70.45,10922.66404 1376 | Slovak Republic,1982,5048043,Europe,70.8,11348.54585 1377 | Slovak Republic,1987,5199318,Europe,71.08,12037.26758 1378 | Slovak Republic,1992,5302888,Europe,71.38,9498.467723 1379 | Slovak Republic,1997,5383010,Europe,72.71,12126.23065 1380 | Slovak Republic,2002,5410052,Europe,73.8,13638.77837 1381 | Slovak Republic,2007,5447502,Europe,74.663,18678.31435 1382 | Slovenia,1952,1489518,Europe,65.57,4215.041741 1383 | Slovenia,1957,1533070,Europe,67.85,5862.276629 1384 | Slovenia,1962,1582962,Europe,69.15,7402.303395 1385 | Slovenia,1967,1646912,Europe,69.18,9405.489397 1386 | Slovenia,1972,1694510,Europe,69.82,12383.4862 1387 | Slovenia,1977,1746919,Europe,70.97,15277.03017 1388 | Slovenia,1982,1861252,Europe,71.063,17866.72175 1389 | Slovenia,1987,1945870,Europe,72.25,18678.53492 1390 | Slovenia,1992,1999210,Europe,73.64,14214.71681 1391 | Slovenia,1997,2011612,Europe,75.13,17161.10735 1392 | Slovenia,2002,2011497,Europe,76.66,20660.01936 1393 | Slovenia,2007,2009245,Europe,77.926,25768.25759 1394 | Somalia,1952,2526994,Africa,32.978,1135.749842 1395 | Somalia,1957,2780415,Africa,34.977,1258.147413 1396 | Somalia,1962,3080153,Africa,36.981,1369.488336 1397 | Somalia,1967,3428839,Africa,38.977,1284.73318 1398 | Somalia,1972,3840161,Africa,40.973,1254.576127 1399 | Somalia,1977,4353666,Africa,41.974,1450.992513 1400 | Somalia,1982,5828892,Africa,42.955,1176.807031 1401 | Somalia,1987,6921858,Africa,44.501,1093.244963 1402 | Somalia,1992,6099799,Africa,39.658,926.9602964 1403 | Somalia,1997,6633514,Africa,43.795,930.5964284 1404 | Somalia,2002,7753310,Africa,45.936,882.0818218 1405 | Somalia,2007,9118773,Africa,48.159,926.1410683 1406 | South Africa,1952,14264935,Africa,45.009,4725.295531 1407 | South Africa,1957,16151549,Africa,47.985,5487.104219 1408 | South Africa,1962,18356657,Africa,49.951,5768.729717 1409 | South Africa,1967,20997321,Africa,51.927,7114.477971 1410 | South Africa,1972,23935810,Africa,53.696,7765.962636 1411 | South Africa,1977,27129932,Africa,55.527,8028.651439 1412 | South Africa,1982,31140029,Africa,58.161,8568.266228 1413 | South Africa,1987,35933379,Africa,60.834,7825.823398 1414 | South Africa,1992,39964159,Africa,61.888,7225.069258 1415 | South Africa,1997,42835005,Africa,60.236,7479.188244 1416 | South Africa,2002,44433622,Africa,53.365,7710.946444 1417 | South Africa,2007,43997828,Africa,49.339,9269.657808 1418 | Spain,1952,28549870,Europe,64.94,3834.034742 1419 | Spain,1957,29841614,Europe,66.66,4564.80241 1420 | Spain,1962,31158061,Europe,69.69,5693.843879 1421 | Spain,1967,32850275,Europe,71.44,7993.512294 1422 | Spain,1972,34513161,Europe,73.06,10638.75131 1423 | Spain,1977,36439000,Europe,74.39,13236.92117 1424 | Spain,1982,37983310,Europe,76.3,13926.16997 1425 | Spain,1987,38880702,Europe,76.9,15764.98313 1426 | Spain,1992,39549438,Europe,77.57,18603.06452 1427 | Spain,1997,39855442,Europe,78.77,20445.29896 1428 | Spain,2002,40152517,Europe,79.78,24835.47166 1429 | Spain,2007,40448191,Europe,80.941,28821.0637 1430 | Sri Lanka,1952,7982342,Asia,57.593,1083.53203 1431 | Sri Lanka,1957,9128546,Asia,61.456,1072.546602 1432 | Sri Lanka,1962,10421936,Asia,62.192,1074.47196 1433 | Sri Lanka,1967,11737396,Asia,64.266,1135.514326 1434 | Sri Lanka,1972,13016733,Asia,65.042,1213.39553 1435 | Sri Lanka,1977,14116836,Asia,65.949,1348.775651 1436 | Sri Lanka,1982,15410151,Asia,68.757,1648.079789 1437 | Sri Lanka,1987,16495304,Asia,69.011,1876.766827 1438 | Sri Lanka,1992,17587060,Asia,70.379,2153.739222 1439 | Sri Lanka,1997,18698655,Asia,70.457,2664.477257 1440 | Sri Lanka,2002,19576783,Asia,70.815,3015.378833 1441 | Sri Lanka,2007,20378239,Asia,72.396,3970.095407 1442 | Sudan,1952,8504667,Africa,38.635,1615.991129 1443 | Sudan,1957,9753392,Africa,39.624,1770.337074 1444 | Sudan,1962,11183227,Africa,40.87,1959.593767 1445 | Sudan,1967,12716129,Africa,42.858,1687.997641 1446 | Sudan,1972,14597019,Africa,45.083,1659.652775 1447 | Sudan,1977,17104986,Africa,47.8,2202.988423 1448 | Sudan,1982,20367053,Africa,50.338,1895.544073 1449 | Sudan,1987,24725960,Africa,51.744,1507.819159 1450 | Sudan,1992,28227588,Africa,53.556,1492.197043 1451 | Sudan,1997,32160729,Africa,55.373,1632.210764 1452 | Sudan,2002,37090298,Africa,56.369,1993.398314 1453 | Sudan,2007,42292929,Africa,58.556,2602.394995 1454 | Swaziland,1952,290243,Africa,41.407,1148.376626 1455 | Swaziland,1957,326741,Africa,43.424,1244.708364 1456 | Swaziland,1962,370006,Africa,44.992,1856.182125 1457 | Swaziland,1967,420690,Africa,46.633,2613.101665 1458 | Swaziland,1972,480105,Africa,49.552,3364.836625 1459 | Swaziland,1977,551425,Africa,52.537,3781.410618 1460 | Swaziland,1982,649901,Africa,55.561,3895.384018 1461 | Swaziland,1987,779348,Africa,57.678,3984.839812 1462 | Swaziland,1992,962344,Africa,58.474,3553.0224 1463 | Swaziland,1997,1054486,Africa,54.289,3876.76846 1464 | Swaziland,2002,1130269,Africa,43.869,4128.116943 1465 | Swaziland,2007,1133066,Africa,39.613,4513.480643 1466 | Sweden,1952,7124673,Europe,71.86,8527.844662 1467 | Sweden,1957,7363802,Europe,72.49,9911.878226 1468 | Sweden,1962,7561588,Europe,73.37,12329.44192 1469 | Sweden,1967,7867931,Europe,74.16,15258.29697 1470 | Sweden,1972,8122293,Europe,74.72,17832.02464 1471 | Sweden,1977,8251648,Europe,75.44,18855.72521 1472 | Sweden,1982,8325260,Europe,76.42,20667.38125 1473 | Sweden,1987,8421403,Europe,77.19,23586.92927 1474 | Sweden,1992,8718867,Europe,78.16,23880.01683 1475 | Sweden,1997,8897619,Europe,79.39,25266.59499 1476 | Sweden,2002,8954175,Europe,80.04,29341.63093 1477 | Sweden,2007,9031088,Europe,80.884,33859.74835 1478 | Switzerland,1952,4815000,Europe,69.62,14734.23275 1479 | Switzerland,1957,5126000,Europe,70.56,17909.48973 1480 | Switzerland,1962,5666000,Europe,71.32,20431.0927 1481 | Switzerland,1967,6063000,Europe,72.77,22966.14432 1482 | Switzerland,1972,6401400,Europe,73.78,27195.11304 1483 | Switzerland,1977,6316424,Europe,75.39,26982.29052 1484 | Switzerland,1982,6468126,Europe,76.21,28397.71512 1485 | Switzerland,1987,6649942,Europe,77.41,30281.70459 1486 | Switzerland,1992,6995447,Europe,78.03,31871.5303 1487 | Switzerland,1997,7193761,Europe,79.37,32135.32301 1488 | Switzerland,2002,7361757,Europe,80.62,34480.95771 1489 | Switzerland,2007,7554661,Europe,81.701,37506.41907 1490 | Syria,1952,3661549,Asia,45.883,1643.485354 1491 | Syria,1957,4149908,Asia,48.284,2117.234893 1492 | Syria,1962,4834621,Asia,50.305,2193.037133 1493 | Syria,1967,5680812,Asia,53.655,1881.923632 1494 | Syria,1972,6701172,Asia,57.296,2571.423014 1495 | Syria,1977,7932503,Asia,61.195,3195.484582 1496 | Syria,1982,9410494,Asia,64.59,3761.837715 1497 | Syria,1987,11242847,Asia,66.974,3116.774285 1498 | Syria,1992,13219062,Asia,69.249,3340.542768 1499 | Syria,1997,15081016,Asia,71.527,4014.238972 1500 | Syria,2002,17155814,Asia,73.053,4090.925331 1501 | Syria,2007,19314747,Asia,74.143,4184.548089 1502 | Taiwan,1952,8550362,Asia,58.5,1206.947913 1503 | Taiwan,1957,10164215,Asia,62.4,1507.86129 1504 | Taiwan,1962,11918938,Asia,65.2,1822.879028 1505 | Taiwan,1967,13648692,Asia,67.5,2643.858681 1506 | Taiwan,1972,15226039,Asia,69.39,4062.523897 1507 | Taiwan,1977,16785196,Asia,70.59,5596.519826 1508 | Taiwan,1982,18501390,Asia,72.16,7426.354774 1509 | Taiwan,1987,19757799,Asia,73.4,11054.56175 1510 | Taiwan,1992,20686918,Asia,74.26,15215.6579 1511 | Taiwan,1997,21628605,Asia,75.25,20206.82098 1512 | Taiwan,2002,22454239,Asia,76.99,23235.42329 1513 | Taiwan,2007,23174294,Asia,78.4,28718.27684 1514 | Tanzania,1952,8322925,Africa,41.215,716.6500721 1515 | Tanzania,1957,9452826,Africa,42.974,698.5356073 1516 | Tanzania,1962,10863958,Africa,44.246,722.0038073 1517 | Tanzania,1967,12607312,Africa,45.757,848.2186575 1518 | Tanzania,1972,14706593,Africa,47.62,915.9850592 1519 | Tanzania,1977,17129565,Africa,49.919,962.4922932 1520 | Tanzania,1982,19844382,Africa,50.608,874.2426069 1521 | Tanzania,1987,23040630,Africa,51.535,831.8220794 1522 | Tanzania,1992,26605473,Africa,50.44,825.682454 1523 | Tanzania,1997,30686889,Africa,48.466,789.1862231 1524 | Tanzania,2002,34593779,Africa,49.651,899.0742111 1525 | Tanzania,2007,38139640,Africa,52.517,1107.482182 1526 | Thailand,1952,21289402,Asia,50.848,757.7974177 1527 | Thailand,1957,25041917,Asia,53.63,793.5774148 1528 | Thailand,1962,29263397,Asia,56.061,1002.199172 1529 | Thailand,1967,34024249,Asia,58.285,1295.46066 1530 | Thailand,1972,39276153,Asia,60.405,1524.358936 1531 | Thailand,1977,44148285,Asia,62.494,1961.224635 1532 | Thailand,1982,48827160,Asia,64.597,2393.219781 1533 | Thailand,1987,52910342,Asia,66.084,2982.653773 1534 | Thailand,1992,56667095,Asia,67.298,4616.896545 1535 | Thailand,1997,60216677,Asia,67.521,5852.625497 1536 | Thailand,2002,62806748,Asia,68.564,5913.187529 1537 | Thailand,2007,65068149,Asia,70.616,7458.396327 1538 | Togo,1952,1219113,Africa,38.596,859.8086567 1539 | Togo,1957,1357445,Africa,41.208,925.9083202 1540 | Togo,1962,1528098,Africa,43.922,1067.53481 1541 | Togo,1967,1735550,Africa,46.769,1477.59676 1542 | Togo,1972,2056351,Africa,49.759,1649.660188 1543 | Togo,1977,2308582,Africa,52.887,1532.776998 1544 | Togo,1982,2644765,Africa,55.471,1344.577953 1545 | Togo,1987,3154264,Africa,56.941,1202.201361 1546 | Togo,1992,3747553,Africa,58.061,1034.298904 1547 | Togo,1997,4320890,Africa,58.39,982.2869243 1548 | Togo,2002,4977378,Africa,57.561,886.2205765 1549 | Togo,2007,5701579,Africa,58.42,882.9699438 1550 | Trinidad and Tobago,1952,662850,Americas,59.1,3023.271928 1551 | Trinidad and Tobago,1957,764900,Americas,61.8,4100.3934 1552 | Trinidad and Tobago,1962,887498,Americas,64.9,4997.523971 1553 | Trinidad and Tobago,1967,960155,Americas,65.4,5621.368472 1554 | Trinidad and Tobago,1972,975199,Americas,65.9,6619.551419 1555 | Trinidad and Tobago,1977,1039009,Americas,68.3,7899.554209 1556 | Trinidad and Tobago,1982,1116479,Americas,68.832,9119.528607 1557 | Trinidad and Tobago,1987,1191336,Americas,69.582,7388.597823 1558 | Trinidad and Tobago,1992,1183669,Americas,69.862,7370.990932 1559 | Trinidad and Tobago,1997,1138101,Americas,69.465,8792.573126 1560 | Trinidad and Tobago,2002,1101832,Americas,68.976,11460.60023 1561 | Trinidad and Tobago,2007,1056608,Americas,69.819,18008.50924 1562 | Tunisia,1952,3647735,Africa,44.6,1468.475631 1563 | Tunisia,1957,3950849,Africa,47.1,1395.232468 1564 | Tunisia,1962,4286552,Africa,49.579,1660.30321 1565 | Tunisia,1967,4786986,Africa,52.053,1932.360167 1566 | Tunisia,1972,5303507,Africa,55.602,2753.285994 1567 | Tunisia,1977,6005061,Africa,59.837,3120.876811 1568 | Tunisia,1982,6734098,Africa,64.048,3560.233174 1569 | Tunisia,1987,7724976,Africa,66.894,3810.419296 1570 | Tunisia,1992,8523077,Africa,70.001,4332.720164 1571 | Tunisia,1997,9231669,Africa,71.973,4876.798614 1572 | Tunisia,2002,9770575,Africa,73.042,5722.895655 1573 | Tunisia,2007,10276158,Africa,73.923,7092.923025 1574 | Turkey,1952,22235677,Europe,43.585,1969.10098 1575 | Turkey,1957,25670939,Europe,48.079,2218.754257 1576 | Turkey,1962,29788695,Europe,52.098,2322.869908 1577 | Turkey,1967,33411317,Europe,54.336,2826.356387 1578 | Turkey,1972,37492953,Europe,57.005,3450.69638 1579 | Turkey,1977,42404033,Europe,59.507,4269.122326 1580 | Turkey,1982,47328791,Europe,61.036,4241.356344 1581 | Turkey,1987,52881328,Europe,63.108,5089.043686 1582 | Turkey,1992,58179144,Europe,66.146,5678.348271 1583 | Turkey,1997,63047647,Europe,68.835,6601.429915 1584 | Turkey,2002,67308928,Europe,70.845,6508.085718 1585 | Turkey,2007,71158647,Europe,71.777,8458.276384 1586 | Uganda,1952,5824797,Africa,39.978,734.753484 1587 | Uganda,1957,6675501,Africa,42.571,774.3710692 1588 | Uganda,1962,7688797,Africa,45.344,767.2717398 1589 | Uganda,1967,8900294,Africa,48.051,908.9185217 1590 | Uganda,1972,10190285,Africa,51.016,950.735869 1591 | Uganda,1977,11457758,Africa,50.35,843.7331372 1592 | Uganda,1982,12939400,Africa,49.849,682.2662268 1593 | Uganda,1987,15283050,Africa,51.509,617.7244065 1594 | Uganda,1992,18252190,Africa,48.825,644.1707969 1595 | Uganda,1997,21210254,Africa,44.578,816.559081 1596 | Uganda,2002,24739869,Africa,47.813,927.7210018 1597 | Uganda,2007,29170398,Africa,51.542,1056.380121 1598 | United Kingdom,1952,50430000,Europe,69.18,9979.508487 1599 | United Kingdom,1957,51430000,Europe,70.42,11283.17795 1600 | United Kingdom,1962,53292000,Europe,70.76,12477.17707 1601 | United Kingdom,1967,54959000,Europe,71.36,14142.85089 1602 | United Kingdom,1972,56079000,Europe,72.01,15895.11641 1603 | United Kingdom,1977,56179000,Europe,72.76,17428.74846 1604 | United Kingdom,1982,56339704,Europe,74.04,18232.42452 1605 | United Kingdom,1987,56981620,Europe,75.007,21664.78767 1606 | United Kingdom,1992,57866349,Europe,76.42,22705.09254 1607 | United Kingdom,1997,58808266,Europe,77.218,26074.53136 1608 | United Kingdom,2002,59912431,Europe,78.471,29478.99919 1609 | United Kingdom,2007,60776238,Europe,79.425,33203.26128 1610 | United States,1952,157553000,Americas,68.44,13990.48208 1611 | United States,1957,171984000,Americas,69.49,14847.12712 1612 | United States,1962,186538000,Americas,70.21,16173.14586 1613 | United States,1967,198712000,Americas,70.76,19530.36557 1614 | United States,1972,209896000,Americas,71.34,21806.03594 1615 | United States,1977,220239000,Americas,73.38,24072.63213 1616 | United States,1982,232187835,Americas,74.65,25009.55914 1617 | United States,1987,242803533,Americas,75.02,29884.35041 1618 | United States,1992,256894189,Americas,76.09,32003.93224 1619 | United States,1997,272911760,Americas,76.81,35767.43303 1620 | United States,2002,287675526,Americas,77.31,39097.09955 1621 | United States,2007,301139947,Americas,78.242,42951.65309 1622 | Uruguay,1952,2252965,Americas,66.071,5716.766744 1623 | Uruguay,1957,2424959,Americas,67.044,6150.772969 1624 | Uruguay,1962,2598466,Americas,68.253,5603.357717 1625 | Uruguay,1967,2748579,Americas,68.468,5444.61962 1626 | Uruguay,1972,2829526,Americas,68.673,5703.408898 1627 | Uruguay,1977,2873520,Americas,69.481,6504.339663 1628 | Uruguay,1982,2953997,Americas,70.805,6920.223051 1629 | Uruguay,1987,3045153,Americas,71.918,7452.398969 1630 | Uruguay,1992,3149262,Americas,72.752,8137.004775 1631 | Uruguay,1997,3262838,Americas,74.223,9230.240708 1632 | Uruguay,2002,3363085,Americas,75.307,7727.002004 1633 | Uruguay,2007,3447496,Americas,76.384,10611.46299 1634 | Venezuela,1952,5439568,Americas,55.088,7689.799761 1635 | Venezuela,1957,6702668,Americas,57.907,9802.466526 1636 | Venezuela,1962,8143375,Americas,60.77,8422.974165 1637 | Venezuela,1967,9709552,Americas,63.479,9541.474188 1638 | Venezuela,1972,11515649,Americas,65.712,10505.25966 1639 | Venezuela,1977,13503563,Americas,67.456,13143.95095 1640 | Venezuela,1982,15620766,Americas,68.557,11152.41011 1641 | Venezuela,1987,17910182,Americas,70.19,9883.584648 1642 | Venezuela,1992,20265563,Americas,71.15,10733.92631 1643 | Venezuela,1997,22374398,Americas,72.146,10165.49518 1644 | Venezuela,2002,24287670,Americas,72.766,8605.047831 1645 | Venezuela,2007,26084662,Americas,73.747,11415.80569 1646 | Vietnam,1952,26246839,Asia,40.412,605.0664917 1647 | Vietnam,1957,28998543,Asia,42.887,676.2854478 1648 | Vietnam,1962,33796140,Asia,45.363,772.0491602 1649 | Vietnam,1967,39463910,Asia,47.838,637.1232887 1650 | Vietnam,1972,44655014,Asia,50.254,699.5016441 1651 | Vietnam,1977,50533506,Asia,55.764,713.5371196 1652 | Vietnam,1982,56142181,Asia,58.816,707.2357863 1653 | Vietnam,1987,62826491,Asia,62.82,820.7994449 1654 | Vietnam,1992,69940728,Asia,67.662,989.0231487 1655 | Vietnam,1997,76048996,Asia,70.672,1385.896769 1656 | Vietnam,2002,80908147,Asia,73.017,1764.456677 1657 | Vietnam,2007,85262356,Asia,74.249,2441.576404 1658 | West Bank and Gaza,1952,1030585,Asia,43.16,1515.592329 1659 | West Bank and Gaza,1957,1070439,Asia,45.671,1827.067742 1660 | West Bank and Gaza,1962,1133134,Asia,48.127,2198.956312 1661 | West Bank and Gaza,1967,1142636,Asia,51.631,2649.715007 1662 | West Bank and Gaza,1972,1089572,Asia,56.532,3133.409277 1663 | West Bank and Gaza,1977,1261091,Asia,60.765,3682.831494 1664 | West Bank and Gaza,1982,1425876,Asia,64.406,4336.032082 1665 | West Bank and Gaza,1987,1691210,Asia,67.046,5107.197384 1666 | West Bank and Gaza,1992,2104779,Asia,69.718,6017.654756 1667 | West Bank and Gaza,1997,2826046,Asia,71.096,7110.667619 1668 | West Bank and Gaza,2002,3389578,Asia,72.37,4515.487575 1669 | West Bank and Gaza,2007,4018332,Asia,73.422,3025.349798 1670 | Yemen Rep.,1952,4963829,Asia,32.548,781.7175761 1671 | Yemen Rep.,1957,5498090,Asia,33.97,804.8304547 1672 | Yemen Rep.,1962,6120081,Asia,35.18,825.6232006 1673 | Yemen Rep.,1967,6740785,Asia,36.984,862.4421463 1674 | Yemen Rep.,1972,7407075,Asia,39.848,1265.047031 1675 | Yemen Rep.,1977,8403990,Asia,44.175,1829.765177 1676 | Yemen Rep.,1982,9657618,Asia,49.113,1977.55701 1677 | Yemen Rep.,1987,11219340,Asia,52.922,1971.741538 1678 | Yemen Rep.,1992,13367997,Asia,55.599,1879.496673 1679 | Yemen Rep.,1997,15826497,Asia,58.02,2117.484526 1680 | Yemen Rep.,2002,18701257,Asia,60.308,2234.820827 1681 | Yemen Rep.,2007,22211743,Asia,62.698,2280.769906 1682 | Zambia,1952,2672000,Africa,42.038,1147.388831 1683 | Zambia,1957,3016000,Africa,44.077,1311.956766 1684 | Zambia,1962,3421000,Africa,46.023,1452.725766 1685 | Zambia,1967,3900000,Africa,47.768,1777.077318 1686 | Zambia,1972,4506497,Africa,50.107,1773.498265 1687 | Zambia,1977,5216550,Africa,51.386,1588.688299 1688 | Zambia,1982,6100407,Africa,51.821,1408.678565 1689 | Zambia,1987,7272406,Africa,50.821,1213.315116 1690 | Zambia,1992,8381163,Africa,46.1,1210.884633 1691 | Zambia,1997,9417789,Africa,40.238,1071.353818 1692 | Zambia,2002,10595811,Africa,39.193,1071.613938 1693 | Zambia,2007,11746035,Africa,42.384,1271.211593 1694 | Zimbabwe,1952,3080907,Africa,48.451,406.8841148 1695 | Zimbabwe,1957,3646340,Africa,50.469,518.7642681 1696 | Zimbabwe,1962,4277736,Africa,52.358,527.2721818 1697 | Zimbabwe,1967,4995432,Africa,53.995,569.7950712 1698 | Zimbabwe,1972,5861135,Africa,55.635,799.3621758 1699 | Zimbabwe,1977,6642107,Africa,57.674,685.5876821 1700 | Zimbabwe,1982,7636524,Africa,60.363,788.8550411 1701 | Zimbabwe,1987,9216418,Africa,62.351,706.1573059 1702 | Zimbabwe,1992,10704340,Africa,60.377,693.4207856 1703 | Zimbabwe,1997,11404948,Africa,46.809,792.4499603 1704 | Zimbabwe,2002,11926563,Africa,39.989,672.0386227 1705 | Zimbabwe,2007,12311143,Africa,43.487,469.7092981 1706 | -------------------------------------------------------------------------------- /data/heart.csv: -------------------------------------------------------------------------------- 1 | age,sex,cp,trestbps,chol,fbs,restecg,thalach,exang,oldpeak,slope,ca,thal,target 2 | 63,1,3,145,233,1,0,150,0,2.3,0,0,1,1 3 | 37,1,2,130,250,0,1,187,0,3.5,0,0,2,1 4 | 41,0,1,130,204,0,0,172,0,1.4,2,0,2,1 5 | 56,1,1,120,236,0,1,178,0,0.8,2,0,2,1 6 | 57,0,0,120,354,0,1,163,1,0.6,2,0,2,1 7 | 57,1,0,140,192,0,1,148,0,0.4,1,0,1,1 8 | 56,0,1,140,294,0,0,153,0,1.3,1,0,2,1 9 | 44,1,1,120,263,0,1,173,0,0,2,0,3,1 10 | 52,1,2,172,199,1,1,162,0,0.5,2,0,3,1 11 | 57,1,2,150,168,0,1,174,0,1.6,2,0,2,1 12 | 54,1,0,140,239,0,1,160,0,1.2,2,0,2,1 13 | 48,0,2,130,275,0,1,139,0,0.2,2,0,2,1 14 | 49,1,1,130,266,0,1,171,0,0.6,2,0,2,1 15 | 64,1,3,110,211,0,0,144,1,1.8,1,0,2,1 16 | 58,0,3,150,283,1,0,162,0,1,2,0,2,1 17 | 50,0,2,120,219,0,1,158,0,1.6,1,0,2,1 18 | 58,0,2,120,340,0,1,172,0,0,2,0,2,1 19 | 66,0,3,150,226,0,1,114,0,2.6,0,0,2,1 20 | 43,1,0,150,247,0,1,171,0,1.5,2,0,2,1 21 | 69,0,3,140,239,0,1,151,0,1.8,2,2,2,1 22 | 59,1,0,135,234,0,1,161,0,0.5,1,0,3,1 23 | 44,1,2,130,233,0,1,179,1,0.4,2,0,2,1 24 | 42,1,0,140,226,0,1,178,0,0,2,0,2,1 25 | 61,1,2,150,243,1,1,137,1,1,1,0,2,1 26 | 40,1,3,140,199,0,1,178,1,1.4,2,0,3,1 27 | 71,0,1,160,302,0,1,162,0,0.4,2,2,2,1 28 | 59,1,2,150,212,1,1,157,0,1.6,2,0,2,1 29 | 51,1,2,110,175,0,1,123,0,0.6,2,0,2,1 30 | 65,0,2,140,417,1,0,157,0,0.8,2,1,2,1 31 | 53,1,2,130,197,1,0,152,0,1.2,0,0,2,1 32 | 41,0,1,105,198,0,1,168,0,0,2,1,2,1 33 | 65,1,0,120,177,0,1,140,0,0.4,2,0,3,1 34 | 44,1,1,130,219,0,0,188,0,0,2,0,2,1 35 | 54,1,2,125,273,0,0,152,0,0.5,0,1,2,1 36 | 51,1,3,125,213,0,0,125,1,1.4,2,1,2,1 37 | 46,0,2,142,177,0,0,160,1,1.4,0,0,2,1 38 | 54,0,2,135,304,1,1,170,0,0,2,0,2,1 39 | 54,1,2,150,232,0,0,165,0,1.6,2,0,3,1 40 | 65,0,2,155,269,0,1,148,0,0.8,2,0,2,1 41 | 65,0,2,160,360,0,0,151,0,0.8,2,0,2,1 42 | 51,0,2,140,308,0,0,142,0,1.5,2,1,2,1 43 | 48,1,1,130,245,0,0,180,0,0.2,1,0,2,1 44 | 45,1,0,104,208,0,0,148,1,3,1,0,2,1 45 | 53,0,0,130,264,0,0,143,0,0.4,1,0,2,1 46 | 39,1,2,140,321,0,0,182,0,0,2,0,2,1 47 | 52,1,1,120,325,0,1,172,0,0.2,2,0,2,1 48 | 44,1,2,140,235,0,0,180,0,0,2,0,2,1 49 | 47,1,2,138,257,0,0,156,0,0,2,0,2,1 50 | 53,0,2,128,216,0,0,115,0,0,2,0,0,1 51 | 53,0,0,138,234,0,0,160,0,0,2,0,2,1 52 | 51,0,2,130,256,0,0,149,0,0.5,2,0,2,1 53 | 66,1,0,120,302,0,0,151,0,0.4,1,0,2,1 54 | 62,1,2,130,231,0,1,146,0,1.8,1,3,3,1 55 | 44,0,2,108,141,0,1,175,0,0.6,1,0,2,1 56 | 63,0,2,135,252,0,0,172,0,0,2,0,2,1 57 | 52,1,1,134,201,0,1,158,0,0.8,2,1,2,1 58 | 48,1,0,122,222,0,0,186,0,0,2,0,2,1 59 | 45,1,0,115,260,0,0,185,0,0,2,0,2,1 60 | 34,1,3,118,182,0,0,174,0,0,2,0,2,1 61 | 57,0,0,128,303,0,0,159,0,0,2,1,2,1 62 | 71,0,2,110,265,1,0,130,0,0,2,1,2,1 63 | 54,1,1,108,309,0,1,156,0,0,2,0,3,1 64 | 52,1,3,118,186,0,0,190,0,0,1,0,1,1 65 | 41,1,1,135,203,0,1,132,0,0,1,0,1,1 66 | 58,1,2,140,211,1,0,165,0,0,2,0,2,1 67 | 35,0,0,138,183,0,1,182,0,1.4,2,0,2,1 68 | 51,1,2,100,222,0,1,143,1,1.2,1,0,2,1 69 | 45,0,1,130,234,0,0,175,0,0.6,1,0,2,1 70 | 44,1,1,120,220,0,1,170,0,0,2,0,2,1 71 | 62,0,0,124,209,0,1,163,0,0,2,0,2,1 72 | 54,1,2,120,258,0,0,147,0,0.4,1,0,3,1 73 | 51,1,2,94,227,0,1,154,1,0,2,1,3,1 74 | 29,1,1,130,204,0,0,202,0,0,2,0,2,1 75 | 51,1,0,140,261,0,0,186,1,0,2,0,2,1 76 | 43,0,2,122,213,0,1,165,0,0.2,1,0,2,1 77 | 55,0,1,135,250,0,0,161,0,1.4,1,0,2,1 78 | 51,1,2,125,245,1,0,166,0,2.4,1,0,2,1 79 | 59,1,1,140,221,0,1,164,1,0,2,0,2,1 80 | 52,1,1,128,205,1,1,184,0,0,2,0,2,1 81 | 58,1,2,105,240,0,0,154,1,0.6,1,0,3,1 82 | 41,1,2,112,250,0,1,179,0,0,2,0,2,1 83 | 45,1,1,128,308,0,0,170,0,0,2,0,2,1 84 | 60,0,2,102,318,0,1,160,0,0,2,1,2,1 85 | 52,1,3,152,298,1,1,178,0,1.2,1,0,3,1 86 | 42,0,0,102,265,0,0,122,0,0.6,1,0,2,1 87 | 67,0,2,115,564,0,0,160,0,1.6,1,0,3,1 88 | 68,1,2,118,277,0,1,151,0,1,2,1,3,1 89 | 46,1,1,101,197,1,1,156,0,0,2,0,3,1 90 | 54,0,2,110,214,0,1,158,0,1.6,1,0,2,1 91 | 58,0,0,100,248,0,0,122,0,1,1,0,2,1 92 | 48,1,2,124,255,1,1,175,0,0,2,2,2,1 93 | 57,1,0,132,207,0,1,168,1,0,2,0,3,1 94 | 52,1,2,138,223,0,1,169,0,0,2,4,2,1 95 | 54,0,1,132,288,1,0,159,1,0,2,1,2,1 96 | 45,0,1,112,160,0,1,138,0,0,1,0,2,1 97 | 53,1,0,142,226,0,0,111,1,0,2,0,3,1 98 | 62,0,0,140,394,0,0,157,0,1.2,1,0,2,1 99 | 52,1,0,108,233,1,1,147,0,0.1,2,3,3,1 100 | 43,1,2,130,315,0,1,162,0,1.9,2,1,2,1 101 | 53,1,2,130,246,1,0,173,0,0,2,3,2,1 102 | 42,1,3,148,244,0,0,178,0,0.8,2,2,2,1 103 | 59,1,3,178,270,0,0,145,0,4.2,0,0,3,1 104 | 63,0,1,140,195,0,1,179,0,0,2,2,2,1 105 | 42,1,2,120,240,1,1,194,0,0.8,0,0,3,1 106 | 50,1,2,129,196,0,1,163,0,0,2,0,2,1 107 | 68,0,2,120,211,0,0,115,0,1.5,1,0,2,1 108 | 69,1,3,160,234,1,0,131,0,0.1,1,1,2,1 109 | 45,0,0,138,236,0,0,152,1,0.2,1,0,2,1 110 | 50,0,1,120,244,0,1,162,0,1.1,2,0,2,1 111 | 50,0,0,110,254,0,0,159,0,0,2,0,2,1 112 | 64,0,0,180,325,0,1,154,1,0,2,0,2,1 113 | 57,1,2,150,126,1,1,173,0,0.2,2,1,3,1 114 | 64,0,2,140,313,0,1,133,0,0.2,2,0,3,1 115 | 43,1,0,110,211,0,1,161,0,0,2,0,3,1 116 | 55,1,1,130,262,0,1,155,0,0,2,0,2,1 117 | 37,0,2,120,215,0,1,170,0,0,2,0,2,1 118 | 41,1,2,130,214,0,0,168,0,2,1,0,2,1 119 | 56,1,3,120,193,0,0,162,0,1.9,1,0,3,1 120 | 46,0,1,105,204,0,1,172,0,0,2,0,2,1 121 | 46,0,0,138,243,0,0,152,1,0,1,0,2,1 122 | 64,0,0,130,303,0,1,122,0,2,1,2,2,1 123 | 59,1,0,138,271,0,0,182,0,0,2,0,2,1 124 | 41,0,2,112,268,0,0,172,1,0,2,0,2,1 125 | 54,0,2,108,267,0,0,167,0,0,2,0,2,1 126 | 39,0,2,94,199,0,1,179,0,0,2,0,2,1 127 | 34,0,1,118,210,0,1,192,0,0.7,2,0,2,1 128 | 47,1,0,112,204,0,1,143,0,0.1,2,0,2,1 129 | 67,0,2,152,277,0,1,172,0,0,2,1,2,1 130 | 52,0,2,136,196,0,0,169,0,0.1,1,0,2,1 131 | 74,0,1,120,269,0,0,121,1,0.2,2,1,2,1 132 | 54,0,2,160,201,0,1,163,0,0,2,1,2,1 133 | 49,0,1,134,271,0,1,162,0,0,1,0,2,1 134 | 42,1,1,120,295,0,1,162,0,0,2,0,2,1 135 | 41,1,1,110,235,0,1,153,0,0,2,0,2,1 136 | 41,0,1,126,306,0,1,163,0,0,2,0,2,1 137 | 49,0,0,130,269,0,1,163,0,0,2,0,2,1 138 | 60,0,2,120,178,1,1,96,0,0,2,0,2,1 139 | 62,1,1,128,208,1,0,140,0,0,2,0,2,1 140 | 57,1,0,110,201,0,1,126,1,1.5,1,0,1,1 141 | 64,1,0,128,263,0,1,105,1,0.2,1,1,3,1 142 | 51,0,2,120,295,0,0,157,0,0.6,2,0,2,1 143 | 43,1,0,115,303,0,1,181,0,1.2,1,0,2,1 144 | 42,0,2,120,209,0,1,173,0,0,1,0,2,1 145 | 67,0,0,106,223,0,1,142,0,0.3,2,2,2,1 146 | 76,0,2,140,197,0,2,116,0,1.1,1,0,2,1 147 | 70,1,1,156,245,0,0,143,0,0,2,0,2,1 148 | 44,0,2,118,242,0,1,149,0,0.3,1,1,2,1 149 | 60,0,3,150,240,0,1,171,0,0.9,2,0,2,1 150 | 44,1,2,120,226,0,1,169,0,0,2,0,2,1 151 | 42,1,2,130,180,0,1,150,0,0,2,0,2,1 152 | 66,1,0,160,228,0,0,138,0,2.3,2,0,1,1 153 | 71,0,0,112,149,0,1,125,0,1.6,1,0,2,1 154 | 64,1,3,170,227,0,0,155,0,0.6,1,0,3,1 155 | 66,0,2,146,278,0,0,152,0,0,1,1,2,1 156 | 39,0,2,138,220,0,1,152,0,0,1,0,2,1 157 | 58,0,0,130,197,0,1,131,0,0.6,1,0,2,1 158 | 47,1,2,130,253,0,1,179,0,0,2,0,2,1 159 | 35,1,1,122,192,0,1,174,0,0,2,0,2,1 160 | 58,1,1,125,220,0,1,144,0,0.4,1,4,3,1 161 | 56,1,1,130,221,0,0,163,0,0,2,0,3,1 162 | 56,1,1,120,240,0,1,169,0,0,0,0,2,1 163 | 55,0,1,132,342,0,1,166,0,1.2,2,0,2,1 164 | 41,1,1,120,157,0,1,182,0,0,2,0,2,1 165 | 38,1,2,138,175,0,1,173,0,0,2,4,2,1 166 | 38,1,2,138,175,0,1,173,0,0,2,4,2,1 167 | 67,1,0,160,286,0,0,108,1,1.5,1,3,2,0 168 | 67,1,0,120,229,0,0,129,1,2.6,1,2,3,0 169 | 62,0,0,140,268,0,0,160,0,3.6,0,2,2,0 170 | 63,1,0,130,254,0,0,147,0,1.4,1,1,3,0 171 | 53,1,0,140,203,1,0,155,1,3.1,0,0,3,0 172 | 56,1,2,130,256,1,0,142,1,0.6,1,1,1,0 173 | 48,1,1,110,229,0,1,168,0,1,0,0,3,0 174 | 58,1,1,120,284,0,0,160,0,1.8,1,0,2,0 175 | 58,1,2,132,224,0,0,173,0,3.2,2,2,3,0 176 | 60,1,0,130,206,0,0,132,1,2.4,1,2,3,0 177 | 40,1,0,110,167,0,0,114,1,2,1,0,3,0 178 | 60,1,0,117,230,1,1,160,1,1.4,2,2,3,0 179 | 64,1,2,140,335,0,1,158,0,0,2,0,2,0 180 | 43,1,0,120,177,0,0,120,1,2.5,1,0,3,0 181 | 57,1,0,150,276,0,0,112,1,0.6,1,1,1,0 182 | 55,1,0,132,353,0,1,132,1,1.2,1,1,3,0 183 | 65,0,0,150,225,0,0,114,0,1,1,3,3,0 184 | 61,0,0,130,330,0,0,169,0,0,2,0,2,0 185 | 58,1,2,112,230,0,0,165,0,2.5,1,1,3,0 186 | 50,1,0,150,243,0,0,128,0,2.6,1,0,3,0 187 | 44,1,0,112,290,0,0,153,0,0,2,1,2,0 188 | 60,1,0,130,253,0,1,144,1,1.4,2,1,3,0 189 | 54,1,0,124,266,0,0,109,1,2.2,1,1,3,0 190 | 50,1,2,140,233,0,1,163,0,0.6,1,1,3,0 191 | 41,1,0,110,172,0,0,158,0,0,2,0,3,0 192 | 51,0,0,130,305,0,1,142,1,1.2,1,0,3,0 193 | 58,1,0,128,216,0,0,131,1,2.2,1,3,3,0 194 | 54,1,0,120,188,0,1,113,0,1.4,1,1,3,0 195 | 60,1,0,145,282,0,0,142,1,2.8,1,2,3,0 196 | 60,1,2,140,185,0,0,155,0,3,1,0,2,0 197 | 59,1,0,170,326,0,0,140,1,3.4,0,0,3,0 198 | 46,1,2,150,231,0,1,147,0,3.6,1,0,2,0 199 | 67,1,0,125,254,1,1,163,0,0.2,1,2,3,0 200 | 62,1,0,120,267,0,1,99,1,1.8,1,2,3,0 201 | 65,1,0,110,248,0,0,158,0,0.6,2,2,1,0 202 | 44,1,0,110,197,0,0,177,0,0,2,1,2,0 203 | 60,1,0,125,258,0,0,141,1,2.8,1,1,3,0 204 | 58,1,0,150,270,0,0,111,1,0.8,2,0,3,0 205 | 68,1,2,180,274,1,0,150,1,1.6,1,0,3,0 206 | 62,0,0,160,164,0,0,145,0,6.2,0,3,3,0 207 | 52,1,0,128,255,0,1,161,1,0,2,1,3,0 208 | 59,1,0,110,239,0,0,142,1,1.2,1,1,3,0 209 | 60,0,0,150,258,0,0,157,0,2.6,1,2,3,0 210 | 49,1,2,120,188,0,1,139,0,2,1,3,3,0 211 | 59,1,0,140,177,0,1,162,1,0,2,1,3,0 212 | 57,1,2,128,229,0,0,150,0,0.4,1,1,3,0 213 | 61,1,0,120,260,0,1,140,1,3.6,1,1,3,0 214 | 39,1,0,118,219,0,1,140,0,1.2,1,0,3,0 215 | 61,0,0,145,307,0,0,146,1,1,1,0,3,0 216 | 56,1,0,125,249,1,0,144,1,1.2,1,1,2,0 217 | 43,0,0,132,341,1,0,136,1,3,1,0,3,0 218 | 62,0,2,130,263,0,1,97,0,1.2,1,1,3,0 219 | 63,1,0,130,330,1,0,132,1,1.8,2,3,3,0 220 | 65,1,0,135,254,0,0,127,0,2.8,1,1,3,0 221 | 48,1,0,130,256,1,0,150,1,0,2,2,3,0 222 | 63,0,0,150,407,0,0,154,0,4,1,3,3,0 223 | 55,1,0,140,217,0,1,111,1,5.6,0,0,3,0 224 | 65,1,3,138,282,1,0,174,0,1.4,1,1,2,0 225 | 56,0,0,200,288,1,0,133,1,4,0,2,3,0 226 | 54,1,0,110,239,0,1,126,1,2.8,1,1,3,0 227 | 70,1,0,145,174,0,1,125,1,2.6,0,0,3,0 228 | 62,1,1,120,281,0,0,103,0,1.4,1,1,3,0 229 | 35,1,0,120,198,0,1,130,1,1.6,1,0,3,0 230 | 59,1,3,170,288,0,0,159,0,0.2,1,0,3,0 231 | 64,1,2,125,309,0,1,131,1,1.8,1,0,3,0 232 | 47,1,2,108,243,0,1,152,0,0,2,0,2,0 233 | 57,1,0,165,289,1,0,124,0,1,1,3,3,0 234 | 55,1,0,160,289,0,0,145,1,0.8,1,1,3,0 235 | 64,1,0,120,246,0,0,96,1,2.2,0,1,2,0 236 | 70,1,0,130,322,0,0,109,0,2.4,1,3,2,0 237 | 51,1,0,140,299,0,1,173,1,1.6,2,0,3,0 238 | 58,1,0,125,300,0,0,171,0,0,2,2,3,0 239 | 60,1,0,140,293,0,0,170,0,1.2,1,2,3,0 240 | 77,1,0,125,304,0,0,162,1,0,2,3,2,0 241 | 35,1,0,126,282,0,0,156,1,0,2,0,3,0 242 | 70,1,2,160,269,0,1,112,1,2.9,1,1,3,0 243 | 59,0,0,174,249,0,1,143,1,0,1,0,2,0 244 | 64,1,0,145,212,0,0,132,0,2,1,2,1,0 245 | 57,1,0,152,274,0,1,88,1,1.2,1,1,3,0 246 | 56,1,0,132,184,0,0,105,1,2.1,1,1,1,0 247 | 48,1,0,124,274,0,0,166,0,0.5,1,0,3,0 248 | 56,0,0,134,409,0,0,150,1,1.9,1,2,3,0 249 | 66,1,1,160,246,0,1,120,1,0,1,3,1,0 250 | 54,1,1,192,283,0,0,195,0,0,2,1,3,0 251 | 69,1,2,140,254,0,0,146,0,2,1,3,3,0 252 | 51,1,0,140,298,0,1,122,1,4.2,1,3,3,0 253 | 43,1,0,132,247,1,0,143,1,0.1,1,4,3,0 254 | 62,0,0,138,294,1,1,106,0,1.9,1,3,2,0 255 | 67,1,0,100,299,0,0,125,1,0.9,1,2,2,0 256 | 59,1,3,160,273,0,0,125,0,0,2,0,2,0 257 | 45,1,0,142,309,0,0,147,1,0,1,3,3,0 258 | 58,1,0,128,259,0,0,130,1,3,1,2,3,0 259 | 50,1,0,144,200,0,0,126,1,0.9,1,0,3,0 260 | 62,0,0,150,244,0,1,154,1,1.4,1,0,2,0 261 | 38,1,3,120,231,0,1,182,1,3.8,1,0,3,0 262 | 66,0,0,178,228,1,1,165,1,1,1,2,3,0 263 | 52,1,0,112,230,0,1,160,0,0,2,1,2,0 264 | 53,1,0,123,282,0,1,95,1,2,1,2,3,0 265 | 63,0,0,108,269,0,1,169,1,1.8,1,2,2,0 266 | 54,1,0,110,206,0,0,108,1,0,1,1,2,0 267 | 66,1,0,112,212,0,0,132,1,0.1,2,1,2,0 268 | 55,0,0,180,327,0,2,117,1,3.4,1,0,2,0 269 | 49,1,2,118,149,0,0,126,0,0.8,2,3,2,0 270 | 54,1,0,122,286,0,0,116,1,3.2,1,2,2,0 271 | 56,1,0,130,283,1,0,103,1,1.6,0,0,3,0 272 | 46,1,0,120,249,0,0,144,0,0.8,2,0,3,0 273 | 61,1,3,134,234,0,1,145,0,2.6,1,2,2,0 274 | 67,1,0,120,237,0,1,71,0,1,1,0,2,0 275 | 58,1,0,100,234,0,1,156,0,0.1,2,1,3,0 276 | 47,1,0,110,275,0,0,118,1,1,1,1,2,0 277 | 52,1,0,125,212,0,1,168,0,1,2,2,3,0 278 | 58,1,0,146,218,0,1,105,0,2,1,1,3,0 279 | 57,1,1,124,261,0,1,141,0,0.3,2,0,3,0 280 | 58,0,1,136,319,1,0,152,0,0,2,2,2,0 281 | 61,1,0,138,166,0,0,125,1,3.6,1,1,2,0 282 | 42,1,0,136,315,0,1,125,1,1.8,1,0,1,0 283 | 52,1,0,128,204,1,1,156,1,1,1,0,0,0 284 | 59,1,2,126,218,1,1,134,0,2.2,1,1,1,0 285 | 40,1,0,152,223,0,1,181,0,0,2,0,3,0 286 | 61,1,0,140,207,0,0,138,1,1.9,2,1,3,0 287 | 46,1,0,140,311,0,1,120,1,1.8,1,2,3,0 288 | 59,1,3,134,204,0,1,162,0,0.8,2,2,2,0 289 | 57,1,1,154,232,0,0,164,0,0,2,1,2,0 290 | 57,1,0,110,335,0,1,143,1,3,1,1,3,0 291 | 55,0,0,128,205,0,2,130,1,2,1,1,3,0 292 | 61,1,0,148,203,0,1,161,0,0,2,1,3,0 293 | 58,1,0,114,318,0,2,140,0,4.4,0,3,1,0 294 | 58,0,0,170,225,1,0,146,1,2.8,1,2,1,0 295 | 67,1,2,152,212,0,0,150,0,0.8,1,0,3,0 296 | 44,1,0,120,169,0,1,144,1,2.8,0,0,1,0 297 | 63,1,0,140,187,0,0,144,1,4,2,2,3,0 298 | 63,0,0,124,197,0,1,136,1,0,1,0,2,0 299 | 59,1,0,164,176,1,0,90,0,1,1,2,1,0 300 | 57,0,0,140,241,0,1,123,1,0.2,1,0,3,0 301 | 45,1,3,110,264,0,1,132,0,1.2,1,0,3,0 302 | 68,1,0,144,193,1,1,141,0,3.4,1,2,3,0 303 | 57,1,0,130,131,0,1,115,1,1.2,1,1,3,0 304 | 57,0,1,130,236,0,0,174,0,0,1,1,2,0 305 | -------------------------------------------------------------------------------- /data/sleep_VIM.csv: -------------------------------------------------------------------------------- 1 | "BodyWgt","BrainWgt","NonD","Dream","Sleep","Span","Gest","Pred","Exp","Danger" 2 | 6654,5712,NA,NA,3.3,38.6,645,3,5,3 3 | 1,6.6,6.3,2,8.3,4.5,42,3,1,3 4 | 3.385,44.5,NA,NA,12.5,14,60,1,1,1 5 | 0.92,5.7,NA,NA,16.5,NA,25,5,2,3 6 | 2547,4603,2.1,1.8,3.9,69,624,3,5,4 7 | 10.55,179.5,9.1,0.7,9.8,27,180,4,4,4 8 | 0.023,0.3,15.8,3.9,19.7,19,35,1,1,1 9 | 160,169,5.2,1,6.2,30.4,392,4,5,4 10 | 3.3,25.6,10.9,3.6,14.5,28,63,1,2,1 11 | 52.16,440,8.3,1.4,9.7,50,230,1,1,1 12 | 0.425,6.4,11,1.5,12.5,7,112,5,4,4 13 | 465,423,3.2,0.7,3.9,30,281,5,5,5 14 | 0.55,2.4,7.6,2.7,10.3,NA,NA,2,1,2 15 | 187.1,419,NA,NA,3.1,40,365,5,5,5 16 | 0.075,1.2,6.3,2.1,8.4,3.5,42,1,1,1 17 | 3,25,8.6,0,8.6,50,28,2,2,2 18 | 0.785,3.5,6.6,4.1,10.7,6,42,2,2,2 19 | 0.2,5,9.5,1.2,10.7,10.4,120,2,2,2 20 | 1.41,17.5,4.8,1.3,6.1,34,NA,1,2,1 21 | 60,81,12,6.1,18.1,7,NA,1,1,1 22 | 529,680,NA,0.3,NA,28,400,5,5,5 23 | 27.66,115,3.3,0.5,3.8,20,148,5,5,5 24 | 0.12,1,11,3.4,14.4,3.9,16,3,1,2 25 | 207,406,NA,NA,12,39.3,252,1,4,1 26 | 85,325,4.7,1.5,6.2,41,310,1,3,1 27 | 36.33,119.5,NA,NA,13,16.2,63,1,1,1 28 | 0.101,4,10.4,3.4,13.8,9,28,5,1,3 29 | 1.04,5.5,7.4,0.8,8.2,7.6,68,5,3,4 30 | 521,655,2.1,0.8,2.9,46,336,5,5,5 31 | 100,157,NA,NA,10.8,22.4,100,1,1,1 32 | 35,56,NA,NA,NA,16.3,33,3,5,4 33 | 0.005,0.14,7.7,1.4,9.1,2.6,21.5,5,2,4 34 | 0.01,0.25,17.9,2,19.9,24,50,1,1,1 35 | 62,1320,6.1,1.9,8,100,267,1,1,1 36 | 0.122,3,8.2,2.4,10.6,NA,30,2,1,1 37 | 1.35,8.1,8.4,2.8,11.2,NA,45,3,1,3 38 | 0.023,0.4,11.9,1.3,13.2,3.2,19,4,1,3 39 | 0.048,0.33,10.8,2,12.8,2,30,4,1,3 40 | 1.7,6.3,13.8,5.6,19.4,5,12,2,1,1 41 | 3.5,10.8,14.3,3.1,17.4,6.5,120,2,1,1 42 | 250,490,NA,1,NA,23.6,440,5,5,5 43 | 0.48,15.5,15.2,1.8,17,12,140,2,2,2 44 | 10,115,10,0.9,10.9,20.2,170,4,4,4 45 | 1.62,11.4,11.9,1.8,13.7,13,17,2,1,2 46 | 192,180,6.5,1.9,8.4,27,115,4,4,4 47 | 2.5,12.1,7.5,0.9,8.4,18,31,5,5,5 48 | 4.288,39.2,NA,NA,12.5,13.7,63,2,2,2 49 | 0.28,1.9,10.6,2.6,13.2,4.7,21,3,1,3 50 | 4.235,50.4,7.4,2.4,9.8,9.8,52,1,1,1 51 | 6.8,179,8.4,1.2,9.6,29,164,2,3,2 52 | 0.75,12.3,5.7,0.9,6.6,7,225,2,2,2 53 | 3.6,21,4.9,0.5,5.4,6,225,3,2,3 54 | 14.83,98.2,NA,NA,2.6,17,150,5,5,5 55 | 55.5,175,3.2,0.6,3.8,20,151,5,5,5 56 | 1.4,12.5,NA,NA,11,12.7,90,2,2,2 57 | 0.06,1,8.1,2.2,10.3,3.5,NA,3,1,2 58 | 0.9,2.6,11,2.3,13.3,4.5,60,2,1,2 59 | 2,12.3,4.9,0.5,5.4,7.5,200,3,1,3 60 | 0.104,2.5,13.2,2.6,15.8,2.3,46,3,2,2 61 | 4.19,58,9.7,0.6,10.3,24,210,4,3,4 62 | 3.5,3.9,12.8,6.6,19.4,3,14,2,1,1 63 | 4.05,17,NA,NA,NA,13,38,3,1,1 64 | -------------------------------------------------------------------------------- /images/DatasetEx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dlab-berkeley/R-Fundamentals-Legacy/19d0dd0cc120f04aca448447fdf29764f9ee05f6/images/DatasetEx.png -------------------------------------------------------------------------------- /images/hfs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dlab-berkeley/R-Fundamentals-Legacy/19d0dd0cc120f04aca448447fdf29764f9ee05f6/images/hfs.png -------------------------------------------------------------------------------- /install.R: -------------------------------------------------------------------------------- 1 | install.packages("tidyverse") 2 | install.packages("rmarkdown") 3 | install.packages('leaflet') 4 | -------------------------------------------------------------------------------- /lessons/Part1.R: -------------------------------------------------------------------------------- 1 | # R Fundamentals: Part 1 of 4 2 | 3 | # Section 1: Navigating RStudio 4 | 5 | ## By default, this script will open in the upper left pane of RStudio. You can open a new script by clicking File --> New File --> R Script. 6 | 7 | ## Most of the time, RStudio will be organized in the following four panes: 8 | 9 | ## 1. Script (upper left): This is where you view and edit most files, such as scripts, RMarkdown notebooks, etc. 10 | ## 2. Console (lower left): You can use this to enter R commands on the fly. Furthermore, most R output will appear here. 11 | ## 3. Global Environment (upper right): Saved variables, functions, and other R objects will appear here. 12 | ## 4. Misc (lower right): A variety of other tabs which allow you to navigate your file system, view plots, install packages, view help, etc. 13 | 14 | ## RStudio also has a lot of helpful customizations to improve your experience: 15 | 16 | ## Click Tools --> Global Options --> Appearance to change your color and font settings. 17 | ## Click Tools --> Global Options --> Code and check the box that says "Soft-wrap R source files" to wrap the text in your script to the width of the script pane. 18 | ## Click Tools --> Global Options --> Code --> Display and check the boxes that say "Highlight selected line" and "Highlight R function calls". These will provide helpful highlighting as you edit your files. 19 | 20 | # Section 2: Variable Assignment 21 | 22 | ## Try assigning the value "5" to the variable 'number' and then run 'number'. 23 | ## To run a line of code, place your cursor on a line of runnable code and click the "Run" button or click Ctrl + Enter (PC) or command + Enter (Mac). 24 | number <- 5 25 | number 26 | 27 | ## You can also use the '=' operator to do variable assignment. 28 | number = 5 29 | 30 | 31 | ## There are subtle differences between '<-' and '=', which won't matter in most cases. However, using '<-' is considered good code style. You want your code to adhere to good stylistic practices, since that makes it easier to read and use by other users. 32 | 33 | ## You can perform basic arithmetic in R: 34 | number + 1 35 | number - 2 36 | number * 3 37 | number / 4 38 | 39 | ## Use a hashtag to comment your code (e.g., write notes to your future self and your collaborators) to help keep your script organized. 40 | 41 | ## Press Ctrl + l (as in lemon) on both Mac and PC to clear your console. This does not erase any data. It simply moves the console prompt (the greater-than symbol: >) up to the top to improve readability. 42 | 43 | # Section 3: Functions and Arguments 44 | 45 | ## Functions perform actions on inputs. They are followed by trailing round parentheses. 46 | ## Arguments are the inputs - values, expressions, text, entire datasets, etc. You tell a function what arguments it needs inside the parentheses. Sometimes, these arguments are "named". This is helpful when you need to enter multiple arguments: the names tell R which arguments correspond to what variables you're passing into the function. 47 | 48 | ## Use the ls() function to see all of the variables you have defined. 49 | ## Notice that ls() does not take any arguments! 50 | ls() 51 | 52 | ## You can use the "TAB" key to autocomplete a variable. 53 | ## Place your cursor after the 'b' in 'numb' below and press TAB. 54 | ## This works for variables and functions alike. 55 | numb 56 | 57 | ## Place your cursor after the 'e' in 'me' below and press TAB 58 | ## Notice how you can get the mean() function 59 | me 60 | 61 | ## Variables will be overwritten if you redefine them. 62 | ## What happens to "UC Berkeley" when you run this code? 63 | welcome <- "UC Berkeley" 64 | welcome 65 | 66 | welcome <- "Social Sciences Building" 67 | welcome 68 | 69 | ## Try saving new values as new variables: 70 | welcome2 <- "UC Davis" 71 | welcome2 72 | 73 | # The class() function tells the data class/type of the variable and requires one argument 74 | class(welcome2) 75 | ls() 76 | 77 | ## Removing Variables. rm() will remove a variable 78 | rm(welcome) 79 | ls() 80 | welcome # Error 81 | 82 | ## Remove all variables with rm(list = ls()). 83 | ## Notice that this is the first function we're using with a named argument! 84 | ## Or, click the broom icon at top of 'Environment' pane. 85 | rm(list = ls()) 86 | ls() 87 | 88 | ## If we look at the documentation for rm(), we see a '...' for the first argument. This means we simply provide it all the variables we'd like to remove. 89 | ?rm 90 | ## Let's see this in action: 91 | var1 <- 1 92 | var2 <- 2 93 | var3 <- 3 94 | ls() 95 | rm(var1, var2) 96 | ## What variables are left? 97 | ls() 98 | ## Finish removing all variables: 99 | rm(list = ls()) 100 | 101 | ### Challenge 1: Variable Assignment 102 | ### Define three variables and then write a mathematical expression using only those variables. 103 | 104 | # Section 4: Data Classes and Coercion 105 | 106 | ## There are five main classes of data we will work with in this workshop: 107 | ## 1. numeric: decimals (the default for ALL numbers in R). 108 | ## 2. integer: whole numbers (positive and negative, including zero). 109 | ## 3. character: text strings (always wrapped in quotations). 110 | ## 4. logical: TRUE or FALSE (1 or 0). 111 | ## 5. factor: nominal or ordinal categorical type. 112 | 113 | # Section 4.1: Numerics 114 | ## Assign 5 to 'number' and check its class. 115 | number <- 5 116 | number 117 | class(number) 118 | 119 | # Section 4.2: Integers 120 | ## Coerce 'number' to integer type with the as.integer() function: 121 | number_int <- as.integer(number) 122 | class(number_int) 123 | 124 | ## Section 4.3: Characters 125 | ## Define welcome <- "Welcome to the D-Lab" and check its class: 126 | welcome <- "Welcome to the D-Lab" 127 | class(welcome) 128 | ls() 129 | 130 | ## Single and double quotes work similarly: 131 | contraction <- 'I am hungry.' 132 | contraction 133 | 134 | contraction <- "I am hungry." 135 | contraction 136 | 137 | ## You can nest single quotes inside of double quotes: 138 | contraction <- "I'm hungry" 139 | contraction 140 | 141 | ## Or, you can use all single quotes along with escape characters: 142 | contraction <- 'I\'m hungry' 143 | contraction 144 | 145 | ## However, you cannot nest single quotes inside of single quotes. 146 | 147 | ## Section: 4.4 Logicals 148 | ## Logical data will check to see if a condition is TRUE (1) or FALSE (0). 149 | class(TRUE) 150 | class(FALSE) 151 | 152 | ## Since TRUE and FALSE are stored as 1 and 0, they take on mathematical properties: 153 | TRUE + 2 154 | FALSE - 4 155 | 156 | ## Boolean data types evaluate whether a statement is TRUE. 157 | ## First let's define some variables 158 | berkeley <- 50 159 | stanford <- 30 160 | 161 | ## Check the following: 162 | stanford < berkeley # less than 163 | berkeley >= stanford # greater than or equal to 164 | berkeley == berkeley # equivalent to (equal to) 165 | "Mac" == "mac" # R is case sensitive 166 | berkeley != berkeley # not equivalent to (not equal to) 167 | "PC" != "Windows" 168 | 169 | ## Boolean 'and' (all conditions must be satisfied): 170 | cal <- TRUE 171 | ucla <- FALSE 172 | 173 | cal & cal 174 | cal & ucla 175 | 176 | ## Boolean "or" (just one condition must be satisfied): 177 | cal | cal 178 | cal | ucla 179 | 180 | # Section 4.5: Factors 181 | 182 | ## A factor variable is a set of categorical or ordinal values. To create a factor variable, we first need a vector. We'll return to factors in the next section after we've learned about vectors. 183 | 184 | ### Challenge 2: Data type coercion 185 | ### Like as.integer, other "as dot" functions exist as well, such as as.numeric, as.character, as.logical, and as.factor. 186 | ### 1. Define three variables: one numeric, one character, and one logical 187 | 188 | ### 2a. Can you convert numeric to integer type? 189 | 190 | ### 2b. Convert numeric to logical? 191 | 192 | ### 2c. Convert numeric to character? 193 | 194 | ### 2d. Convert logical to character? 195 | 196 | ### 2e. Convert character to numeric? 197 | 198 | # Section 5: Data Structures 199 | 200 | ## There are four main functions you can use to form more complex data structures: 201 | ## 1. c(): ordered groupings of the SAME type of data (called "vectors"). 202 | ## 2. data.frame(): and ordered group of equal-length vectors; also like a list. 203 | ## 3. list(): store heterogeneous data. 204 | ## 4. matrix(): like a vector, but can be ordered into rows and columns. 205 | 206 | ## Helpful tip: Type a question mark before a function name to view the help pages. Read the "Description" section for a definition. The "Usage" section shows what arguments can be passed into the function and the "Arguments" section provides definitions of the individual parameters/arguments. Also see the "Details", "References", and "Examples" sections for more information. 207 | 208 | # Section 5.1: Vectors 209 | ## A vector is an ordered group of the *same* type of data. We can we can create vectors by concatenating data together with the c() function: 210 | vec <- c(2, 5, 8, 11, 14) 211 | vec 212 | 213 | ## We can take the average using the mean function 214 | mean(vec) 215 | 216 | ## We can also store missing values in a vector using the NA keyword: 217 | vec <- c(2, 5, 8, NA, NA) 218 | vec 219 | 220 | # View the help page for the arithmetic mean function: 221 | ?mean 222 | 223 | mean(vec, na.rm = FALSE) # Does not work due to missing data. 224 | 225 | mean(vec, na.rm = TRUE) # Works properly. 226 | 227 | (2 + 5 + 8) / 3 # Do it manually! (Confidence check for our work) 228 | 229 | ## It does not matter what type the data is contained within the vector, as long as it is all the same: 230 | numeric_vector <- c(234, 31343, 78, 0.23, 0.0000002) 231 | numeric_vector 232 | class(numeric_vector) 233 | length(numeric_vector) # There are five elements in this vector. 234 | 235 | ## Indexing a vector 236 | ## To index a vector means to extract an element based on its position. 237 | ## For example, if we want to return just the third thing from "numeric_vector", we would use square brackets and type: 238 | numeric_vector[3] 239 | 240 | ## We can also add items to a vector using another c() function: 241 | numeric_vector2 <- c(numeric_vector, c(0.1, 0.2, 0.3)) 242 | numeric_vector2 243 | 244 | ## We can use the seq() function to create a vector according to a sequence: 245 | ?seq 246 | sequence <- seq(from = 0, to = 8, by = 1) 247 | sequence 248 | 249 | decimals <- seq(from = 0, to = 2, by = 0.25) 250 | decimals 251 | 252 | ## Extract just the 4th element: 253 | decimals[4] 254 | 255 | ## When we want a numeric vector with entries separated by 1, we can also use the colon operator: 256 | 0:8 257 | 258 | colon_vector <- c(28:36) 259 | colon_vector 260 | 261 | 0:length(colon_vector) 262 | 263 | # Vectors can contain other types, too. Consider the following examples: 264 | character_vector <- c("Canada", "United States", "Mexico") 265 | character_vector 266 | 267 | logical_vector <- c(TRUE, FALSE, TRUE, FALSE, TRUE) 268 | logical_vector 269 | 270 | ## R also provides the operator %in% to test if a value belongs to a vector. 271 | TRUE %in% logical_vector 272 | "Canada" %in% character_vector 273 | 26 %in% colon_vector 274 | 275 | ## The %in% operator can be very useful if you have multiple elements that you want to check. 276 | c(29, 31) %in% colon_vector 277 | c("Canada", "Ethiopia") %in% character_vector 278 | 279 | ### Challenge 3: Concatenating vectors 280 | ### 1. Create a vector starting from 10, and ending with 30, with each entry separated by 2. 281 | 282 | ### 2. Index the 3rd through 7th elements of this vector. 283 | 284 | ### 3. Index the 3rd through 7th elements and the 10th element. 285 | 286 | # Section 5.2: Factors (interlude) 287 | 288 | ## Remember above when we talked about factors are how R refers to categorical data? 289 | ## Categorical data can be important when you are performing calculations or making visualizations by group. This way, R knows that the numeric or character data should have grouping properties. 290 | ## "Levels" are the groups contained within the factor variable itself. 291 | 292 | ## Let's create a vector of countries. We'll assume that our dataset will only refer to these three countries, i.e., they're categorical values: 293 | countries <- c("Canada", "Mexico", "United States", "Mexico", "Canada") 294 | 295 | ## We can create a factor using the factor() function: 296 | countries_factor <- factor(countries) 297 | countries_factor 298 | 299 | ## Note that factors are *ordered* groupings. Here, R chose the ordering to be alphabetical, by default. We could have specified something else using the "levels" argument: 300 | countries_factor <- factor(countries, levels = c("United States", "Mexico", "Canada")) 301 | countries_factor 302 | 303 | ## Factors can also be created using numeric values: 304 | numeric_factor <- factor(c(1, 2, 1, 2, 3, 1)) 305 | numeric_factor 306 | 307 | # Section 5.3: Lists 308 | ## A list can be used to store heterogeneous data. 309 | ## Let's include three different data types: logical, character, and integer. 310 | list1 <- list(TRUE, "one", 1) 311 | list1 312 | 313 | ## Normal arithmetic operates won't work with lists, though: 314 | list1 * list(FALSE, "zero", 0) # Error 315 | 316 | 317 | ## This concludes Part 1 of R Fundamentals! In Part 2, we will take a closer look at data frames, which are the main type of data structure we'll work with to perform data analysis. -------------------------------------------------------------------------------- /lessons/Part2.R: -------------------------------------------------------------------------------- 1 | # R Fundamentals: Part 2 of 4 2 | 3 | # Section 1: Matrices 4 | 5 | ## We are now going to introduce two types of data structures for handling data that comes in multiple dimensions. In Part 1, every data structure we looked at was in just one dimension. 6 | ## A matrix is like a vector in that it can only contain data of the same type, but it can be organized into rows and columns. 7 | ## The rows and columns do not have to be the same. A matrix can have more rows than columns or more columns than rows. 8 | matrix1 <- matrix(data = 1:12, nrow = 4, ncol = 3) 9 | matrix1 10 | class(matrix1) 11 | 12 | ## You can also coerce vector to matrix. First, let's create a normal vector: 13 | vec1 <- 1:20 14 | vec1 15 | class(vec1) 16 | 17 | ## We can coerce this vector to a matrix with 10 rows and 2 columns: 18 | matrix2 <- matrix(vec1, ncol = 2) 19 | matrix2 20 | class(matrix2) 21 | 22 | ## We will see the benefits of matrices in Part 4. 23 | 24 | # Section 2: Data frames 25 | 26 | ## Why do we care about multiple dimensions? Think about datasets that you have seen before. For example, suppose we collected data on the characteristics of D-Lab Workshop learners. We might want to know the age, degree program, previous familiarity with programming, research interests, and likely many other attributes (variables). 27 | 28 | ## This kind of dataset is multidimensional. We have one row for each participant and a number of columns for each attribute we collect data on. If we had forty participants and collected 10 attributes for each participant, then we would have a 40 by 10 dataset. 29 | 30 | ## The data structure in R that is most suited for this kind of problem is the data frame. 31 | 32 | ## A data frame is a type of list with some restrictions, chiefly the components of a data frame must be of equal length. They are the most common type of data structure used for data analyses. Most of the time when we load real data into R (which we will see in the next section!), we are loading that data into a data frame. 33 | ## Since they are vectors, each column can only contain the same data type, but columns of different types can be lined up next to each other. 34 | ## Meanwhile, rows can contain heterogeneous data. 35 | 36 | ## Let's create a data frame capturing some information about countries: 37 | countries <- c("Canada", "Mexico", "United States") 38 | populations <- c(10, 20, 30) 39 | areas <- c(30, 10, 20) 40 | 41 | ## We can create the data frame with the data.frame() function. 42 | ## The equal-length vectors are the arguments. 43 | ## Notice that the name of each variable becomes the name of the column. 44 | df <- data.frame(countries, populations, areas) 45 | df 46 | 47 | ## If we wanted to change the column names, we can specify that with the function argument: 48 | df <- data.frame(country = countries, population = populations, area = areas) 49 | df 50 | 51 | ## Check the compact structure of the data frame: 52 | str(df) 53 | 54 | ## View the dimensions (nrow x ncol) of the data frame: 55 | dim(df) 56 | 57 | ## View column names: 58 | colnames(df) 59 | 60 | ## View row names (we did not change these and they default to character type): 61 | rownames(df) 62 | class(rownames(df)) 63 | 64 | ## Rename columns 65 | ## You can rename columns by assigning a vector of equal length to the colnames function on the left side of the equation: 66 | colnames(df) <- c("Country", "Population", "Area") 67 | df 68 | 69 | ## You can extract a single column with the $ operator: 70 | df$Country 71 | 72 | ## Because data frames are lists, we can also use list subsetting operations. While we do not cover list subsetting in detail, in your R journey the list subsetting can be useful when writing functions (Part 4!) that involve data frames. 73 | df[["Country"]] 74 | 75 | ## The $ operator can also be used to create new columns: 76 | df$Density <- df$Population / df$Area 77 | df 78 | 79 | 80 | ### Challenge 1: Make your own data frame. 81 | ### 1. Create a data frame that contains four different food items and three attributes for each: name, price, and quantity. 82 | ### 2. Add a fourth column that calculates the total cost for each food item. 83 | ### 3. What function could you use to calculate the total cost of all the foods combined? 84 | 85 | # Section 3: Importing Data from Files 86 | 87 | ## Data 88 | ## First, we need to set the working directory. This is the folder that RStudio considers "home base". There are a couple ways to do this. 89 | 90 | ## Option 1: Click Session -> Set Working Directory -> Choose Directory. Then, select the R-Fundamentals folder you downloaded or cloned. 91 | 92 | ## Option 2: Using the setwd() function. You need to know the exact path to where the R-Fundamentals is located. Save this in the working_directory variable: 93 | working_directory <- "" 94 | 95 | ## For example, if it's on your desktop, this path might be: 96 | ## "~/Desktop/R-Fundamentals" (Mac) 97 | ## If you downloaded the zip file of the workshop it 98 | ## might be: 99 | ## "~/Desktop/R-Fundamentals-main" 100 | 101 | ## On a PC this path might be 102 | ## "C:/Users/YourUserName/Desktop/R-Fundamentals/" or 103 | ## If you downloaded the zip file of the workshop it 104 | ## might be: 105 | ## "C:/Users/YourUserName/Desktop/R-Fundamentals-main/" 106 | 107 | ## Then, run the setwd() function: 108 | setwd(working_directory) 109 | 110 | ## You can double-check that this worked by using the getwd() function. What does this do? 111 | getwd() 112 | 113 | ## Now, let's read in the data. The dataset we'll look at is the gapminder dataset, which contains information about the GDPs and life expectancies of countries over time. This data is located in a "comma separated value" (csv) file. We'll use the read.csv() function to read in the data. 114 | 115 | ## Why doesn't this work? 116 | gap <- read.csv("gapminder-FiveYearData.csv") 117 | 118 | ## There is no such file in this directory! 119 | ## View the contents of your working directory with dir: 120 | dir() 121 | 122 | ## We need to go one level deeper into our file system (into the "data" folder). 123 | ## Therefore, we need to select the "data" folder when specifying the file path: 124 | gap <- read.csv("data/gapminder-FiveYearData.csv") 125 | gap 126 | 127 | ## This file path is "relative" to the working directory. We could have also specified an "absolute" file path. The difference between the two is that an absolute path begins with a forward slash. 128 | 129 | ## We can also add optional arguments to the read.csv() function: 130 | gap <- read.csv(file = "data/gapminder-FiveYearData.csv", 131 | # Place column names in header row outside of the data 132 | header = TRUE, 133 | # Tell R to code anything defined here as NA 134 | na.strings = c("", " ", "?", "NONE", "none")) 135 | 136 | ## The gapminder dataset is automatically loaded as a dataframe. We can preview a dataframe with the head() function. 137 | ## The first six rows are displayed by default. 138 | head(gap) 139 | 140 | ## We can see its structure: 141 | str(gap) 142 | 143 | ## Or we can view the dataset in a separate tab as well: 144 | View(gap) 145 | 146 | ## Notice that RStudio comes with a "Filter" button in the View panel. 147 | 148 | ### Challenge 2: Import data from a file. 149 | ### 1. Load the heart.csv file. Save it in a variable named heart. See more about the heart dataset here: 150 | 151 | ### https://archive.ics.uci.edu/ml/datasets/heart+Disease 152 | 153 | ### 2. Load the sleep_VIM.csv file. Save it in a variable named sleep_VIM. See more about the sleep VIM dataset here: 154 | 155 | ### https://rdrr.io/cran/VIM/man/sleep.html 156 | 157 | ### 3. What functions can you use to learn more about the heart or sleep_VIM datasets? 158 | 159 | 160 | # Section 4: Subsetting Columns in a Data Frame 161 | 162 | ## Subsetting a data frame consists of extracting "slices" of it that are meaningful. This could be getting certain rows, or columns, or both. 163 | ## The dollar sign symbol, $, allows us to subset single columns. Let's take a look at its documentation. Note that you need to wrap symbols in quotation marks to view their help pages: 164 | ?"$" 165 | 166 | ## Check out one column by typing the name of the data frame, the dollar sign, then the column name. 167 | sleep_VIM$Dream 168 | 169 | ## You can also tab complete to see a list of columns. Helpful! 170 | sleep_VIM # Place a dollar sign and press TAB to select from the available columns. 171 | 172 | 173 | # Section 5: Subsetting a Data Frame in Two Dimensions 174 | 175 | ## There are many ways to efficiently subset rows and columns in R. The simplest is "bracket notation". 176 | ## Remember how we indexed a vector by typing a number in square brackets? We will do the same here, but will use a comma in the square brackets to designate rows from columns: 177 | ## dataframe[rows, cols] 178 | 179 | ## The area BEFORE the comma is left blank and tells R we want ALL the rows returned (because we didn't specify a row subset). 180 | ## Only the BodyWgt and BrainWgt columns are returned 181 | sleep_subset_names <- sleep_VIM[, c("BodyWgt", "BrainWgt")] 182 | dim(sleep_subset_names) 183 | head(sleep_subset_names) 184 | 185 | ## We can also pass in integers to to denote column number. Let's take a look at the columns: 186 | names(sleep_VIM) 187 | 188 | ## Suppose we just want the NonD (3rd), Sleep (5th), and Exp (9th) columns: 189 | sleep_subset_ints <- sleep_VIM[, c(3, 5, 9)] 190 | dim(sleep_subset_ints) 191 | head(sleep_subset_ints) 192 | 193 | ## We can also pass in negative integers to EXCLUDE specific columns. 194 | ## Suppose we want to exclude BodyWgt and BrainWgt: 195 | names(sleep_VIM) 196 | sleep_subset_neg <- sleep_VIM[, -c(1, 2)] 197 | dim(sleep_subset_neg) 198 | head(sleep_subset_neg) 199 | 200 | ### Challenge 3: Subsetting data frames in one and two dimensions 201 | 202 | ### 1. Create a subset of heart that returns only the sex, trestbps, and target columns. 203 | 204 | ### 2. Create a subset of heart that returns rows 3-7 and row 12 along with columns 2, 4, and 14. 205 | 206 | # Section 6: Subsetting with Logical Operators 207 | 208 | ## Remember your logical symbols from Part 1? 209 | ?"==" 210 | 211 | ## We can subset rows based on a logical condition in one column. 212 | ## Let's get the rows where the experiment number is equal to 4, and only choose specific columns: 213 | sleep_logical <- sleep_VIM[sleep_VIM$Exp == 4, 8:10] 214 | dim(sleep_logical) 215 | head(sleep_logical) 216 | 217 | ## We can also subset based on multiple conditions. We'll need the AND and OR operators for this: 218 | ?"&" 219 | ?"|" 220 | 221 | ## & (and) means that all conditions must be TRUE. 222 | ## Let's subset rows where Exp is 1 AND Danger is 2: 223 | sleep_logical_and <- sleep_VIM[(sleep_VIM$Exp == 1) & (sleep_VIM$Danger == 2), ] 224 | dim(sleep_logical_and) 225 | head(sleep_logical_and) 226 | 227 | ## | (or) means that just one of the conditions must be TRUE. 228 | ## Let's subset rows where Exp is 1 OR Danger is 2. 229 | ## Do you think we will get more or less rows returned? Why or why not? 230 | sleep_logical_or <- sleep_VIM[(sleep_VIM$Exp == 1) | (sleep_VIM$Danger == 2), ] 231 | dim(sleep_logical_or) 232 | head(sleep_logical_or) 233 | 234 | 235 | ## Section 8: Using dplyr to Subset Data Frames 236 | 237 | ## A modern approach to interacting with data frames is called dplyr. This package is part of the tidyverse, a suite of packages that helps facilitate data science in R. 238 | ## We need to first install this package. We can do so by running the install.packages() function: 239 | install.packages("dplyr") 240 | 241 | ## It's good practice to pass the names of packages as a vector of names, and a requirement if you want to install more than one package at a time. The reason for this is that the second argument in install.packages() is the place on your computer where you want to install packages. R is smart enough to know what you mean by default if you just pass a single argument, but install.packages("dplyr", "anotherPackage") will lead to a cryptic warning that "lib = "anotherPackage" is not writable. Wrapping our packages in c() avoids this problem. 242 | install.packages(c("dplyr")) 243 | 244 | ## Now that it's installed, we need to import it to our current R session: 245 | library(dplyr) 246 | 247 | ## In dplyr, we can use the "select" function to select columns: 248 | sleep_select <- select(sleep_VIM, BodyWgt, BrainWgt) 249 | dim(sleep_select) 250 | head(sleep_select) 251 | 252 | ## Notice how we don't need to use quotation marks. dplyr is smart enough to figure out when we're talking about columns. 253 | ## We can also use the filter() function to subset rows according to logical condition: 254 | sleep_filter <- filter(sleep_VIM, Exp == 1 & Danger == 2) 255 | dim(sleep_filter) 256 | head(sleep_filter) 257 | 258 | ## dplyr comes with a "piping" operator that allows us to perform multiple computations on the same data frame in a single command. If you have loaded dplyr then you can access this with the %>% 259 | ## If you have R 4.1 or higher, there is now a native pipe operator |>. For both you can think of the function as taking the output of the left hand side, and passing it into the function on the right hand side. Let's see it in action: 260 | sleep_pipe <- sleep_VIM %>% 261 | filter(Exp == 1 & Danger == 2) %>% 262 | select(BodyWgt, BrainWgt) 263 | dim(sleep_pipe) 264 | head(sleep_pipe) 265 | 266 | ## Notice that we didn't need to pass sleep_VIM as the first argument of each function. The piping operator takes care of this for us. 267 | 268 | ## If you'd like to learn more about how to use dplyr to perform analysis, check out the Data Wrangling in R workshop! 269 | 270 | # Section 9: Missing Data 271 | 272 | ## Let's review missing data: 273 | ?NA 274 | ?mean # Scroll down to "na.rm". 275 | 276 | ## Let's see how this works on our sleep_VIM data: 277 | mean(sleep_VIM$NonD) 278 | 279 | ## This returns NA because R is unsure how to deal with NA cells for the mean computation. 280 | 281 | ## What happens if we use the na.rm = TRUE argument? It now computes the mean! 282 | mean(sleep_VIM$NonD, na.rm = TRUE) 283 | 284 | ## We can check to see if a cell is missing with is.na: 285 | ?is.na 286 | is.na(sleep_VIM) 287 | 288 | ## We can count the number of total missing cells. Why does this work? 289 | sum(is.na(sleep_VIM)) 290 | 291 | ## Perhaps we'd like to extract rows where NonD is *not* missing. We can do this using the ! operator and dplyr: 292 | sleep_NonD <- sleep_VIM %>% 293 | filter(!is.na(NonD)) 294 | head(sleep_NonD) 295 | 296 | ## How can we check whether the new data frame does in fact have no missing values for NonD? 297 | 298 | ## Maybe we'd like to extract the *rows* that have no missing values (rather than a specific column). Another package in the tidyverse - tidyr - provides us a useful function to do this: 299 | install.packages(c("tidyr")) 300 | library(tidyr) 301 | 302 | ## tidyr typically contains functions which allow you to transform your data frames from longer to wider (this is called pivoting). It also contains the drop_na() function, which is useful in this case: 303 | sleep_non_missing <- sleep_VIM %>% 304 | drop_na() 305 | dim(sleep_non_missing) 306 | sum(is.na(sleep_non_missing)) 307 | 308 | ## (OPTIONAL) Appendix-Merging Data Frames 309 | 310 | ## We can merge two data frames by a column that is shared by both using the merge() function: 311 | ?merge 312 | 313 | ## Let's make a toy dataframe: 314 | df1 <- data.frame(Name = c("Joe", "Susan", "Jack", "Kelly"), 315 | City = c("Berkeley", "Berkeley", "Oakland", "Oakland"), 316 | Math = c(42, 48, 50, 46), 317 | Reading = c(8, 10, 10, 10)) 318 | df1 319 | 320 | ## And a second toy dataframe: 321 | df2 <- data.frame(Name = c("Joe", "Susan", "Jack", "Kelly"), 322 | Science = c(99, 100, 99, 100), 323 | Music = c(19, 18, 20, 20), 324 | Art = c(20, 20, 19, 18)) 325 | df2 326 | 327 | ## Merge the dataframes 328 | df_merge <- merge(df1, df2, by = "Name") 329 | df_merge 330 | 331 | ## In dplyr, there are several "join" functions used to perform merges. These include inner_join(), left_join(), right_join(), and full_join(). 332 | ## The variations consist of how to treat cases when there might not be a one-to-one mapping between two rows of a data frame. 333 | ## Let's try the full_join() on the above example: 334 | df_join <- full_join(df1, df2, by = "Name") 335 | df_join 336 | 337 | ## Looks basically the same! 338 | 339 | ### Challenge 4 340 | ### Consider the following data frame: 341 | challenge_df <- data.frame(Name = c("Joe", "Susan", "Juan", "Preeti"), 342 | City = c("Berkeley", "Berkeley", "San Mateo", "San Jose"), 343 | Physics = c(20, 21, 22, 23), 344 | Chemistry = c(23, 22, 21, 20)) 345 | 346 | ### 1. Use the merge() function to merge df_merge and challenge_df by Name. What do you notice about the columns? How many rows are there? 347 | 348 | ### 2. Use the inner_join() function from dplyr to merge df_merge and challenge_df by Name. What happens if you merge by Name and City? 349 | 350 | ### 3. Use the left_join() function to merge df_merge and challenge_df by Name and City. Use the right_join() function to merge df_merge and challenge_df by Name and City. 351 | 352 | ### 4. Use the full_join() function to merge df_merge and challenge_df by Name and City. 353 | 354 | ### What do you notice about the differences among 2, 3, and 4? 355 | 356 | 357 | ### Take Home Challenge (OPTIONAL) 358 | 359 | ## This take home challenge introduces the here package, a method of organizing filepaths. 360 | 361 | ## Navigating directory structures can be confusing. We have to remember a lot of aspects of of where our files are located. This can be fragile and dependent on the way we order files on our computers, which are often different than the way our friends and colleagues do it. 362 | 363 | ## One way to make this easier is to take advantage of the "here" R package. A package is a set of R code, data, documentation, and tests that are easy to share with others. The set of code usually revolves around some kind of task. We will see several packages through this fundamentals series. 364 | 365 | 366 | ## The "here" package enables easy file referencing by using the top level directory of our project to build the file paths. For more information, check out the "here" package documentation [https://here.r-lib.org/articles/here.html] 367 | 368 | ## To use here we need to first install the package. We can do so by running the install.packages() function: 369 | install.packages("here") 370 | 371 | ## Now that it's installed, we need to import it to our current R session: 372 | library(here) 373 | 374 | ## Run the following 375 | here() 376 | 377 | ## Note that it returns a file path, which tells us what our working directory is now. 378 | ## Using here, we can read in our files like this 379 | gap <- read.csv(here("data/gapminder-FiveYearData.csv")) 380 | 381 | ## This doesn't look like much of a difference, which is a good thing! This workshop is built around an R Project, so the file structure looks the same on your machine. As you continue your R journey, we strongly recommend putting your data analyses in a similar structure. 382 | 383 | ## We can also add optional arguments to the read.csv() function with calls to "here": 384 | gap <- read.csv(file = here("data/gapminder-FiveYearData.csv"), 385 | # Place column names in header row outside of the data 386 | header = TRUE, 387 | # Tell R to code anything defined here as NA 388 | na.strings = c("", " ", "?", "NONE", "none")) 389 | 390 | ## If you take more D-Lab workshops in the future (and we hope you will!) you will notice this pattern to read in files often. -------------------------------------------------------------------------------- /lessons/Part3.R: -------------------------------------------------------------------------------- 1 | # R Fundamentals: Part 3 of 4 2 | 3 | ## In the previous lesson, we worked closely with data frames, a data structure available in R. We learned how to manipulate them in a variety of ways. In this lesson, we're going to learn how to create visualizations in R, allowing us to better analyze these data frames. 4 | 5 | ### Challenge 1: Loading Data From Files 6 | 7 | ### Let's warm up by importing the data we're going to use. 8 | 9 | ### 1. Load the gapminder-FiveYearData.csv file and save it in a variable named gap. 10 | 11 | ### 2. Load the sleep_VIM.csv file and save it in a variable named sv. 12 | 13 | ### 3. Load the heart.csv file and save it in a variable named heart. 14 | 15 | # Section 1: Saving and Loading RData Files 16 | 17 | ## Often, when we're performing data analysis, we'd like to have access to the dataset at an intermediate point (or end point) in the pipeline. While we could save it to a CSV file, this requires performing some conversions that might be a bit of a hassle. 18 | ## It'd be nice if we could just save the data frame exactly as it is in R, and load it the same way. This is the basis for an RData file. These types of files allow us to save objects in R exactly as they are. When we load them, they'll be exactly the same. 19 | ## We can use the save() and load() functions to create and load RData files. 20 | save(gap, sv, heart, file = "data/fun_data.RData") 21 | 22 | ### Challenge 2: Loading RData Files 23 | 24 | ### 1. Wipe your global environment clean. 25 | 26 | ### 2. Restart your R session by clicking "Session" --> "Restart R" 27 | 28 | ### 3. Load "fun_data.RData". If you don't know how to do this, how do you find out? 29 | 30 | # Section 2: Data Summarization 31 | 32 | ## Before diving into visualizations, computing basic summary statistics is a good first step after you familiarize yourself with data. These summaries will inform what kinds of visualizations you'll want to create. 33 | 34 | ## The summary() function will return frequencies for factor variables and six number summaries for continuous variables (minimum, 1st quartile, median, 3rd quartile, maximum, and mean): 35 | summary(gap) 36 | 37 | ## We can also use this function on a single vector: 38 | summary(gap$lifeExp) 39 | 40 | ## Note that newer versions of R will convert strings to characters automatically (and not to factors). In this case, summary will produce different results: 41 | summary(gap$continent) 42 | 43 | ## This is happening because R is summarizing a character string 44 | ## Consider the following code. While we can plainly see that there are three "one" entries and two "four" entries, the summary function evaluates the vector as a character vector with five elements: 45 | summary(c("one", "one", "four", "one", "four")) 46 | 47 | ## We can get summaries that are more reasonable by converting a character vector to a factor vector : 48 | summary(as.factor(gap$continent)) 49 | 50 | ## We can also return return observation frequencies for the different continents as contingency tables. 51 | ## Note that for contingency tables, we do not need to convert our character vector into a factor vector. 52 | table(gap$continent) 53 | prop.table(table(gap$continent)) 54 | 55 | ## We can Tabulate number of observations for continent by year: 56 | table(gap$continent, gap$year) 57 | table(gap$year, gap$continent) 58 | 59 | # Section 3: Creating Visualizations in R 60 | 61 | ## Creating visualizations is a fundamental skill in data analysis. Visualizations allow us to convey to the viewer a salient point about the data. Creating good visualizations is important, and takes a bit of practice. Luckily, R provides great resources to create clear and clean visualization. 62 | 63 | ## There are two major sets of tools for creating plots in R: 64 | 65 | ## 1. base graphics, which come with all R installations 66 | ## 2. `ggplot2`, a stand-alone package. 67 | 68 | ## We will introduce base R graphics briefly, and then discuss ggplot2, as it's the most commonly used package for creating visualizations in R. 69 | 70 | ## In presenting R visualization basics, we'll discuss three of the most common data visualizations: 71 | ## 1. Histograms: visualize the distribution of one continuous (i.e. numeric or integer) variable. 72 | ## 2. Boxplots: visualize the distribution of one continuous variable, divided amongst a categorical (factor) variable. 73 | ## 3. Scatter plots: visualize the distribution of two continuous variables against each other (one on each axis). 74 | 75 | ## Let's create these plots using the gapminder dataset using base R. 76 | 77 | ## Let's look at histograms. We can create a histogram of life expectancy in the gapminder dataset: 78 | hist(gap$lifeExp, # data to plot 79 | col = "gray90") # bar color 80 | 81 | ## We chose a specific color here, but there are many others available! 82 | colors() 83 | 84 | ## We can fully customize the histogram to make it more transparent to the viewer: 85 | histogram <- hist(gap$lifeExp, 86 | col = "honeydew1", 87 | # Add title 88 | main = "Histogram of life expectancy", 89 | # Change x-axis label 90 | xlab = "Life expectancy (years)", 91 | # Change y-axis label 92 | ylab = "Frequency", 93 | # Change x-axis limits 94 | xlim = c(20, 90), 95 | # Change y-axis limits 96 | ylim = c(0, 350), 97 | # Change tickmark value orientation 98 | # Try values of 0, 1, 2, 3. What happens? 99 | las = 1) 100 | 101 | ## Boxplots compare several distributions as a function of a categorical variable. 102 | ## In base R, we use a formula to create a boxplot, along with the boxplot function. The formula uses a tilde - this of it as meaning "by". 103 | ## For example, we can plot life expectancy BY continent: 104 | boxplot(gap$lifeExp ~ gap$continent, 105 | col = "goldenrod") 106 | 107 | ## Now, let's add some options: 108 | boxplot(gap$lifeExp ~ gap$continent, 109 | # Different colors for each of the five boxes 110 | col = c("pink2", "aquamarine", "goldenrod", "salmon", "gray80"), 111 | main = "Life expectancy boxplots", 112 | xlab = "Continent", 113 | ylab = "Life expectancy (years)", 114 | ylim = c(20, 90), 115 | las = 1) 116 | 117 | ## Notice here that we've added color as an option. We did it to demonstrate the point, but it's actually not good practice to use color when we can get that information from elsewhere (in this case, the labels). This is called a "redundant encoding". 118 | 119 | ## Scatter plots can be created with the plot() function. Let's create a scatter plot of GDP per capita vs. life expectancy. 120 | plot(x = gap$lifeExp, y = gap$gdpPercap, 121 | main = "Life expectancy versus gdpPercap", 122 | xlab = "Life expectancy (years)", 123 | ylab = "gdpPercap (USD)", 124 | # Change point colors to correspond to continents 125 | col = as.factor(gap$continent), 126 | # Change point symbols to correspond to continents 127 | pch = as.integer(as.factor(as.character(gap$continent))), 128 | # Change point size 129 | cex = 1, 130 | las = 1) 131 | 132 | # This is a lot of code! How do we know which color and shape corresponds to each continent? We do not even have a legend yet! We can add one using the legend() function: 133 | legend("topleft", 134 | inset = 0, 135 | title = "Continent", 136 | cex = 1, 137 | c("Africa", "Americas", "Asia", "Europe", "Oceania"), 138 | col = c(1,2,3,4,5), 139 | pch = c(1,2,3,4,5), 140 | horiz = FALSE) 141 | 142 | ## Base R is nice, but there's a better way to create visualizations: with ggplot2. 143 | 144 | # Section 4: Creating Visualizations with ggplot2 145 | 146 | ## We're now going to create visualizations with the package ggplot2, which is the main way R practitioners create plots. ggplot2 exists as its own package, which we need to download and install. 147 | 148 | ## In the previous lesson, we learned how to install new packages. Now, we'll do the same with ggplot2. First, we install the package: 149 | install.packages(c("ggplot2")) 150 | 151 | ## Second, we load the installed package in the current session. Remember, you need to do this each time you open a new RStudio session. 152 | library(ggplot2) 153 | 154 | ## See if you were successful! If so, you should see the help files appear. Read the "Description" section and scroll down to the "Useful links". 155 | ?ggplot2 156 | 157 | ## A ggplot is comprised of three fundamental building blocks: 158 | 159 | ## 1. Data: typically as a dataframe. 160 | ## 2. "aes"thetics: to define your x and y axes, map colors to factor levels, etc. 161 | ## 3. "geom_"s: the visual marks to represent your data - points, bars, lines, ribbons, polygons, etc. 162 | 163 | ## One thing to remember is that `ggplot2` works in layers, similar to photoimaging software such as Photoshop, Illustrator, Inkscape, GIMP, ImageJ, etc. We create a base layer, and then stack layers on top of that base layer. New layers are added to a plot using the addition (+) symbol. Lastly, plots can be further customized using a host of "theme_" functions. 164 | 165 | ## Note that ggplot2 is the name of the package, but ggplot is the main function call. 166 | 167 | ## First, let's create the base layer. Here, we have the gray background and coordinate system (lifeExp on the x-axis). The aesthetic links a column to an axis. 168 | ## As in dplyr, ggplot assumes text that you enter is going to be a column in a dataframe. So, we don't need to use quotations. 169 | ggplot(data = gap, aes(x = lifeExp)) 170 | 171 | ## Histograms, ggplot style 172 | ## Let's create a histogram. We add a layer on top of the base layer with a plus sign, and add geom_histogram() to overlay the histogram. 173 | ggplot(data = gap, aes(x = lifeExp)) + 174 | geom_histogram() 175 | 176 | ## This looks good, but we need to add some customizations. Let's make our plot have some labels with the corresponding ggplot functions. Then, we'll save the plot in its own variable: 177 | gg_hist <- ggplot(data = gap, aes(x = lifeExp)) + 178 | # Customize bar color and number 179 | geom_histogram(fill = "blue", color = "black", bins = 10) + 180 | # Add title 181 | ggtitle("Life expectancy for the gap dataset") + 182 | # Change x-axis label 183 | xlab("Life expectancy (years)") + 184 | # y-axis label 185 | ylab("Frequency") + 186 | # Change background theme 187 | theme_classic() 188 | print(gg_hist) 189 | 190 | ## Now, let's try boxplots, ggplot style: 191 | gg_box <- ggplot(data = gap, 192 | aes(x = continent, 193 | y = lifeExp, 194 | fill = continent)) + 195 | geom_boxplot() + 196 | ggtitle("Boxplots for lifeExp by continent") + 197 | xlab("Continent") + 198 | ylab("Life expectancy (years)") + 199 | theme_minimal() 200 | print(gg_box) 201 | 202 | ## Let's try and hide the legend, since it provides redundant information. The legend appears automatically since we used the "fill" parameter. To get rid of it, we add an additional layer via the guides() function: 203 | gg_box <- gg_box + guides(fill = "none") 204 | print(gg_box) 205 | 206 | ## Scatter plots - ggplot style! 207 | ## Here, we use the theme to further customize the fonts in our plot. Themes allow us to modify almost everything about our ggplot. 208 | gg_scatter <- ggplot(data = gap, aes(x = lifeExp, y = gdpPercap, 209 | color = continent, 210 | shape = continent)) + 211 | # Change point size and transparency 212 | geom_point(size = 5, alpha = 0.25) + 213 | theme_classic() + 214 | ggtitle("Scatterplot of life expectancy by gdpPercap") + 215 | xlab("Life expectancy (years)") + 216 | ylab("gdpPercap (USD)") + 217 | # Change legend position and customize it 218 | theme(legend.position = "top", 219 | plot.title = element_text(hjust = 0.5, size = 12), 220 | legend.title = element_text(size = 10), 221 | legend.text = element_text(size = 5), 222 | # Rotate x-axis text 45 degrees 223 | axis.text.x = element_text(angle = 45, hjust = 1)) 224 | print(gg_scatter) 225 | 226 | ## Looks pretty good, but this data probably needs to be scaled on the y-axis, because the GDP per capita spans many more orders of magnitude than the life expectancy. We can apply a log-transform rather easily: 227 | gg_scatter <- gg_scatter + scale_y_log10() 228 | print(gg_scatter) 229 | 230 | ## Looks much better! 231 | 232 | ## We can also split up each of the continents by using facets 233 | gg_scatter <- gg_scatter + 234 | facet_wrap(~continent) 235 | print(gg_scatter) 236 | ## We can also add a linear model on top of plots rather easily. This connects our visualizations to models that we can build using our data, to better understand the relationships amongst the features. We can do this using the geom_smooth() function: 237 | gg_line <- ggplot(gap, aes(x = gdpPercap, y = lifeExp)) + 238 | geom_point() + 239 | geom_smooth(method = "lm", lwd = 1, col = "red") + 240 | ggtitle("gdpPercap and lifeExp") + 241 | xlab("GDP per capita income (USD)") + 242 | ylab("Life expectancy (years)") + 243 | theme_bw() + 244 | theme(plot.title = element_text(hjust = 0.5, size = 40)) + 245 | scale_x_log10() 246 | print(gg_line) 247 | 248 | ### Challenge 3: Create your own ggplot 249 | ### Create a fourth ggplot figure of your choosing. Save it as a variable named gg_fourth. What relationships have we not explored yet? How about the relationship between population and other features? 250 | gg_fourth <- ggplot() 251 | 252 | # Section 5: Creating Compound Figures 253 | 254 | ## Publication quality figures often incorporate several subplots, which together tell a narrative about the problem being studied. We saw above that `ggplot2` can create something like a subplot using facets, but it can be quite limited. A package called `cowplot` makes it easy to stitch together individual plots into a bigger figure: 255 | 256 | ### Challenge 4: Installing and loading cowplot. 257 | ### 1. Install and load the cowplot package via the library function. 258 | 259 | ### 2. How do you know if it installed and libraried correctly? 260 | 261 | ## We can then use plot_grid to align our figures: 262 | ?plot_grid 263 | compound_figure <- plot_grid(gg_hist, 264 | gg_box, 265 | gg_scatter, 266 | gg_fourth, 267 | labels = c("A)", "B)", "C)", "D)"), 268 | rel_widths = 0.5, 269 | rel_heights = 0.5, 270 | ncol = 2) 271 | print(compound_figure) 272 | 273 | ### Challenge 5 274 | ### Complete the following tasks using the heart dataset: 275 | 276 | ### 1. Plot the distribution of the cholesterol variable, chol. 277 | 278 | ### 2. Visualize the differences in chol between females and males. 279 | 280 | ### View this link to learn more about the columns in this dataset: 281 | 282 | ### https://archive.ics.uci.edu/ml/datasets/heart+disease 283 | -------------------------------------------------------------------------------- /lessons/Part4.R: -------------------------------------------------------------------------------- 1 | # R Fundamentals: Part 4 of 4 2 | 3 | ## In this lesson, we're going to discuss the building blocks of making more complicated R scripts and packages. These include functions, for-loops, and if-else statements. 4 | 5 | ## These building blocks rely on two fundamental concepts which underlie much of programming in general: 6 | 7 | ## 1. Modularizing repeatable code blocks. 8 | ## 2. Controlling the flow of a program. 9 | 10 | ## By using these two principles, we're going to find that we can make our code much more clean, powerful, and useful. 11 | 12 | ## To begin, let's do a warm-up challenge. 13 | 14 | ### Challenge 1: Importing data from files. 15 | ### 1. Wipe your global environment clean. 16 | 17 | ### 2. Restart your R session by clicking "Session" --> "Restart R". 18 | 19 | ### 3. Load the gap dataset. 20 | 21 | ### 4. Load the heart dataset. 22 | 23 | # Section 1: How Do Functions Work in R? 24 | 25 | ## In R, a function is a self-contained block of code that accepts inputs and returns outputs. The strength of writing functions is their modularization: you can repeatedly use the same block of code without have to rewrite it. 26 | ## For example, if you want to run the same data analysis pipeline on several datasets, you could write a function that performs the analysis for a general dataset. Then, you could just apply the function to each dataset, without have to rewrite the code. 27 | 28 | ## We've already used functions in R - they're pre-defined terms that (sometimes) accept inputs, and then (sometimes) generate outputs. 29 | 30 | ## For example, we can use the nrow() function to get the numbers of rows in gap. Specifically, nrow() accepts a dataframe as its input, and returns an integer as the output. 31 | nrow(gap) 32 | 33 | ## The nrow() function is not some magical entity that can figure out the number of rows. It's simply a block of code (specifically, one line) that performs a computation. We've simply abstracted it to the name "nrow", which is meaningful to us as the user. 34 | 35 | ## We can actually look at the code for nrow() by typing the function name without parentheses: 36 | nrow 37 | 38 | ## We can manually use the code dim(x)[1L] to get the dimensions of gap and then extract the first element: 39 | dim(gap) 40 | dim(gap)[1L] 41 | 42 | ## Is the function output equivalent to the manual method? We can use a Boolean operator to check this: 43 | dim(gap)[1L] == nrow(gap) 44 | 45 | ## There are many built-in functions in R, as well as functions that come with packages that we may import. However, we can also write our own functions. 46 | 47 | ## Functions are structured as follows: 48 | 49 | ## function_name <- function(x) { 50 | ## body of function 51 | ## } 52 | 53 | ## They are composed of four main parts: 54 | ## 1. The function name: Functions are referred to by their name. Just like variables, assignment is done using the left arrow <-. In the above, the function is named `function_name`. 55 | ## 2. The function keyword: The `function` keyword lets R know you are writing a function. It comes on the right hand side of the assignment operator. 56 | ## 3. Inputs: The parentheses contain the inputs (also called arguments) to the function. For example, `(x)` states that there is one input named x. You don't always need an input to a function. 57 | ## 4. Function body: The meat of the function lies in its body, which is surrounded by curly braces { }. Every time you call your function, the code in the body is what runs. 58 | ## 5. Optional: a `return` statement. By default, R will return whatever the last line of the function is. You may want to make this explicit. You can use a `return` statement to indicate what exactly is returned by the function. 59 | 60 | ## Let's write our own function to calculate the number of rows of a dataframe: 61 | custom_function <- function(x){ 62 | dim(x)[1L] 63 | } 64 | 65 | ## Is our custom_function() output the same as the nrow() output? 66 | custom_function(gap) == nrow(gap) 67 | 68 | ## Does this work for other datasets? 69 | custom_function(heart) == nrow(heart) 70 | 71 | ## Let's write a new function. This one will calculate the square of an input: 72 | squares <- function(input) { 73 | input^2 74 | } 75 | 76 | ## We can apply some built-in functions to other functions: 77 | class(squares) # Returns the class of `squares` 78 | formals(squares) # Shows the defined arguments 79 | body(squares) # Displays the statement(s) to be evaluated 80 | squares # Shows your function as you have written it 81 | 82 | ## Let's test it out! 83 | squares(3) 84 | 85 | ## This function will also work on vectors! 86 | squares(1:10) # is this the same as c(1:10) ^ 2? 87 | 88 | ## We can also use a return statement to make it explicit what the function is returning: 89 | squares2 <- function(input) { 90 | return(input ^ 2) 91 | } 92 | squares2(3) 93 | 94 | # Section 2: Default Arguments 95 | 96 | ## Every argument to a function comes with its own name. In addition to the name, we can also provide default values. 97 | ## These default values are what the function uses if the user does not provide an input. Let's consider an example. 98 | 99 | ## Define the function `f` that accepts inputs x and y, and performs the simple computation (x + y) / y: 100 | f <- function(x, y){ 101 | return((x + y) / y) 102 | } 103 | 104 | ## We can run this function with two inputs: 105 | f(1, 2) 106 | ## We can also run this function while naming the input arguments: 107 | f(x = 1, y = 2) # same output 108 | ## We can try every approach of inputting arguments: 109 | f(x = 1, y = 2) # both named 110 | f(x = 1, 2) # first named 111 | f(1, y = 2) # second named 112 | f(1, 2) # neither named 113 | ## But if we omit the second argument, what happens? 114 | f(x = 1) 115 | 116 | ## So, let's define a new function which has a default argument: 117 | f2 <- function(x, y = 2){ 118 | (x + y) / y 119 | } 120 | 121 | ## This time, we only need to pass in an input for the first argument, x: 122 | f2(x = 1) 123 | f2(1) # We don't need to name x to get the same output 124 | f(x = 1, y = 2) == f2(x = 1) # Confirm we get the same output 125 | 126 | ## Of course, we're free to overwrite the default argument. We just have to be sure to include it: 127 | f2(x = 1, y = 3) # both named 128 | f2(x = 1, 3) # first named 129 | f2(1, y = 3) # second named 130 | f2(1, 3) # neither named 131 | 132 | ### Challenge 2: Write your own functions. 133 | ### 1. Write a function that calculates the area of a circle with radius r. The formula for the area of a circle is A = pi * r^2. 134 | 135 | ### 2. Write a function that calculates the sample standard deviation given a vector of numeric values. Check that this function returns the same output as the base function sd(). 136 | 137 | # Section 3: For-loops for Repeating Computation 138 | 139 | ## One strength of computers is that they are fast. To take advantage of this, we often have them perform repeated computation. One way to facilitate this is with a for-loop. 140 | ## For-loops are built on the idea of "iteration". We iterate through a procedure, with some counter keeping track of how far along the overall procedure we are. 141 | ## The structure of a for-loop is as follows: 142 | 143 | ## for(variable in sequence) { 144 | ## statement 145 | ## } 146 | 147 | ## For-loops in R have four main components: 148 | ## 1. The `for` keyword: This keyword tells R that you want to iterate over a loop. 149 | ## 2. The iterator: The parentheses denote what we are iterating over. In the example, it is `(variable in sequence)`. The `variable` is the iterator: it moves through the `sequence` for each step of the for-loop. Often, the `variable` is called `i`, but we could name it anything (`x`, `donut`, etc.). 150 | ## 3. The `sequence`: This tells R what values the iterator proceeds through. Often, it is a vector of numbers (e.g., 1:5), but it can be more general through that. 151 | ## 4. Loop body: As in functions, curly braces define the body of the loop. For each pass through the for-loop, the body is run. Thus, the body is repeatedly run `n` number of times, where `n` is the length of the sequence. 152 | 153 | ## What does this for-loop do? 154 | for (x in 1:5) { 155 | print(x) 156 | } 157 | 158 | ## How about this loop? 159 | for (iterator in c(2, 4, 6, 7)) { 160 | cube <- iterator^3 161 | print(cube + 2) 162 | } 163 | 164 | ## We don't have to just loop over integers - we can also loop over characters! 165 | animal_names <- c("Cat", "Dog", "Pig", "Elephant", "Giraffe") 166 | 167 | ## We'll use a for-loop to calculate the length of each name, and store it in a new vector. 168 | for (name in animal_names) { 169 | print(nchar(name)) 170 | } 171 | 172 | # Section 4: If-else Statements 173 | 174 | ## Decision making is an important process in programming. We'll often proceed in different ways depending on the conditions of the scenario. 175 | ## Intermediate commands called "control structures" help us control what happens in the program based on certain conditions of the data. 176 | ## If-else statements are a fundamental control structure. 177 | 178 | ## If statements are used to specify code to be evaluated when some condition is held. Here, we define a variable, and use a couple if statements to control the flow of the program: 179 | x <- 2 180 | if (x < 3) { 181 | print("x is less than 3.") 182 | } 183 | 184 | ## Notice how the structure of an if-statement is very similar to a for-loop. The main difference is that the parentheses contain a conditional, rather than an iteration. If the conditional evaluates to TRUE, the body of the if-statement runs. If not, it is skipped. Here's another example using a for-loop from before: 185 | for (x in 1:5) { 186 | if (x < 3) { 187 | print(paste0("x = ", x, ", is less than 3.")) 188 | } 189 | } 190 | 191 | ## An else-statement is used to specify what should occur when the if-statement is not satisfied. 192 | x <- 1 193 | if (x > 3) { 194 | print(x) 195 | } else { # Place else-statements right after the closing brace 196 | print("Error: number not big enough to print.") 197 | } 198 | 199 | ## Since the if condition was not met, we got an error because that is what we designated as the "else" output. 200 | 201 | ## Let's redo the above, with a different value of x: 202 | x <- 8 203 | if (x > 3) { 204 | print("x is greater than 3.") 205 | } else { 206 | print("Error: number not big enough to print.") 207 | } 208 | 209 | ## Lastly, if we want to check for multiple conditions in a row, we can use else-if statements: 210 | x <- 2 211 | if (x > 3) { 212 | print("x is greater than 3.") 213 | } else if (x > 0) { 214 | print("x is greater than 0.") 215 | } else if (x == 0){ 216 | print("x is equal to 0") 217 | } else { 218 | print("x is negative.") 219 | } 220 | 221 | ## Let's go ahead and put this if-else statement inside its own function, and run it inside a for-loop: 222 | if_checker <- function(x) { 223 | if (x > 3) { 224 | print(paste0("x = ", x, ", is greater than 3.")) 225 | } else if (x > 0) { 226 | print(paste0("x = ", x, ", is greater than 0.")) 227 | } else if (x == 0) { 228 | print(paste0("x = ", x, ", is equal to 0.")) 229 | }else { 230 | print(paste0("x = ", x, ", is negative.")) 231 | } 232 | } 233 | 234 | ## Now we can put this in a for-loop to evaluate it repeatedly: 235 | values <- -5:5 236 | for (x in values) { 237 | if_checker(x) 238 | } 239 | 240 | # Section 5: Environments and Scope 241 | 242 | ## How do we tell apart variables that are defined inside vs. outside functions? This is a question of "scope". Specifically, local vs. global scope. 243 | 244 | ## If a variable is defined within a function, it does not live in the global environment and can only be referred to by that function. Let's take a look at an example. 245 | 246 | ## In function `f`, the variable `z` is defined: 247 | f <- function(x, y = 2) { 248 | z <- 5 249 | return((x + y) / z) 250 | } 251 | 252 | ## Does it appear in your global environment? (It should not.) 253 | ls() 254 | 255 | ## OK, maybe it's because we haven't yet called the function. What about when we run the function once - does `z` enter the global environment? 256 | f(x = 4) 257 | ls() 258 | 259 | ## So, right now `z` only lives in the local environment of the function. If we define `z` in the script, it should enter the global environment: 260 | z <- 5 261 | 262 | ## Does z live in the global environment? Yes! 263 | ls() 264 | 265 | ## The function should be able to pull this value of `z` from the global environment: 266 | f <- function(x, y = 2){ 267 | return((x + y) / z) 268 | } 269 | f(4) 270 | 271 | # Section 6: Rolling Dice with Functions 272 | 273 | ## With these fundamental building blocks, we're ready to start performing some interesting experiments. We're going to start making full use of for-loops, if-else statements, and functions through Monte Carlo experiments. 274 | 275 | ## We're going to run some experiments in R that mimic the rolling of a die. To do so, we need random number generation. The sample() function is one way to randomly draw numbers from a set of values: 276 | ?sample 277 | # Let's sample one die roll: 278 | sample(1:6, 1) 279 | 280 | ## Or, we could use the sample function to simulate 100 rolls of a single die: 281 | sample(1:6, 100, replace = TRUE) 282 | 283 | ## We can think of this as one "experiment". In Monte Carlo sampling, we want to run many experiments to see how things behave in the aggregate. Let's run 10 experiments, each of which has 100 die rolls. 284 | n_experiments <- 10 285 | n_rolls <- 100 286 | 287 | ## We're interested in the average die roll. So, we'll write a for loop to iterate over the experiments, each time calculating the average die roll: 288 | for (i in 1:n_experiments) { 289 | rolls <- sample(1:6, n_rolls, replace = TRUE) 290 | print(mean(rolls)) 291 | } 292 | 293 | ## We're going to be doing this experiment a lot, so let's turn it into a function. 294 | die_roll_mean <- function(n_rolls) { 295 | rolls <- sample(1:6, n_rolls, replace = TRUE) 296 | return(mean(rolls)) 297 | } 298 | 299 | ## Now we can define the number of rolls as we choose! 300 | ## Before we run this experiment, we're going to set a random seed. This seed is a way to start the random number generator in a specific way to ensure that we all obtain the exact same results. So, everyone who sets the seed to 1 will obtain the exact same die rolls across the experiment - this helps with reproducibility! 301 | set.seed(1) 302 | die_roll_mean(n_rolls = 10000) 303 | 304 | ## This is one experiment. How can we do many experiments? The replicate function can help us out with this: 305 | ?replicate 306 | n_experiments <- 200 307 | n_rolls_high <- 100 308 | reps_high <- replicate(n_experiments, die_roll_mean(n_rolls = n_rolls_high)) 309 | reps_high 310 | 311 | ## Let's lower the number of rolls. 312 | n_rolls_low <- 5 313 | reps_low <- replicate(n_experiments, die_roll_mean(n_rolls = n_rolls_low)) 314 | reps_low 315 | 316 | ## Plotting the distribution is an easy way to tell these two apart! 317 | hist(reps_high) 318 | hist(reps_low) 319 | 320 | ## Let's customize this a bit, using what we learned from the last lesson: 321 | hist(reps_low, col = "grey") 322 | abline(v = mean(reps_high), col = "red", lwd = 2) 323 | 324 | ## Let's turn this plotting code block into a function! 325 | ## The function will take an argument called `means`, and an argument called `n_rolls`: 326 | hist_plotter <- function(means, n_rolls) { 327 | hist(means, 328 | col = "grey", 329 | xlab = "Average die roll", 330 | xlim = c(1, 6), 331 | main = paste0("Average die rolls for n = ", n_rolls, " rolls")) 332 | abline(v = mean(means), col = "red", lwd = 2) 333 | } 334 | 335 | ## Now we can easily plot the two experiments above: 336 | hist_plotter(means = reps_high, n_rolls = n_rolls_high) 337 | hist_plotter(means = reps_low, n_rolls = n_rolls_low) 338 | 339 | ## Notice how much nicer it is not having to copy the code block over and over! 340 | 341 | ## Very neat! But what if we want to loop over multiple sampling distributions? 342 | ## Imagine we have a different number of die rolls, and we want to plot the distribution of each - 10, 25, 50, 100, 200, and 500: 343 | n_die_rolls <- c(10, 25, 50, 100, 200, 500) 344 | 345 | ## Let's perform 1000 experiments for the first element in our vector, 10 rolls: 346 | n_experiments <- 1000 347 | reps <- replicate(n_experiments, die_roll_mean(n_rolls = n_die_rolls[1])) 348 | ## Then, plug it into our histogram plotting function: 349 | hist_plotter(means = reps, n_rolls = n_die_rolls[1]) 350 | 351 | ## We can then automate all six sampling distributions. 352 | 353 | ## First, change our plotting area to a 2 row by 3 column surface: 354 | par(mfrow = c(2,3)) 355 | 356 | ## Second, we define our for-loop. 357 | ## We need to iterate over different numbers of die rolls. For each die rolls, we're running 1000 experiments. So, implicitly, there's two levels of iteration going on here. For each set of experiments, we output a histogram, so we can compare across numbers of die rolls. 358 | for (i in 1:length(n_die_rolls)) { 359 | means <- replicate(n_experiments, die_roll_mean(n_rolls = n_die_rolls[i])) 360 | hist_plotter(means = means, n = n_die_rolls[i]) 361 | } 362 | 363 | # Section 7: The Birthday Problem 364 | 365 | ## If somebody asked you in a room full of 25 people, "What is the probability that two people have matching birthdays?", what would you say? 366 | 367 | ## The answer is higher than you might expect! Let's use for-loops and functions to figure it out. 368 | 369 | ## We will use this seed because it is a Berkeley zip code that gives one matching birthday: 370 | set.seed(94704) 371 | 372 | ## Now, we generate 25 samples from 365 days of the year: 373 | birthdays <- sample(1:365, 25, replace = TRUE) 374 | birthdays 375 | 376 | ## Let's check if any birthdays are duplicated: 377 | duplicated(birthdays) 378 | sum(duplicated(birthdays)) > 0 379 | 380 | ## We'll write a function to perform an experiment where we sample a group of random birthdays, and determine if anybody repeats. 381 | birthday_function <- function(n_people = 25) { 382 | # Populate the room 383 | birthdays <- sample(1:365, n_people, replace = TRUE) 384 | # Count the number of duplicated entries 385 | n_duplicated <- sum(duplicated(birthdays)) 386 | # Return a 1 if at least one birthday is repeated 387 | return(as.numeric(n_duplicated > 0)) 388 | } 389 | 390 | ## We reset the seed, and find that our mini-experiment does return a 1, as we might expect: 391 | set.seed(94704) 392 | birthday_function(n_people = 25) 393 | 394 | ## Let's run this at scale! We'll replicate the experiment 5000 times: 395 | n_reps <- 5000 396 | many_sims <- replicate(n_reps, birthday_function(n_people = 25)) 397 | many_sims 398 | 399 | ## Calculate the probability of a matching birthday 400 | mean(many_sims) 401 | 402 | ## It's over a 50% chance! How does this probability change as we vary the number of people in the room? 403 | room_sizes <- 2:100 404 | n_experiments <- length(room_sizes) 405 | 406 | ## To store the experiment results, we'll create a blank matrix. The first column will store the room size and the second column will store the probability of a matching birthday. 407 | results <- matrix(NA, nrow = n_experiments, ncol = 2) 408 | head(results) 409 | 410 | ## Let's run the entire experiment in a for-loop: 411 | for (index in 1:n_experiments) { 412 | # Get the number of people in the room 413 | n_people <- room_sizes[index] 414 | # Run the experiment many times 415 | many_sims <- replicate(n_reps, birthday_function(n_people = n_people)) 416 | # Calculate the probability 417 | probability <- mean(many_sims) 418 | # Store the results 419 | results[index, ] <- c(n_people, probability) 420 | } 421 | 422 | ## We can view the populated matrix: 423 | head(results) 424 | 425 | ## Now, let's plot the probability. We first change our plotting area back to a 1 x 1 surface: 426 | par(mfrow = c(1,1)) 427 | 428 | ## Our final plot! Let's plot the probability of matching a birthday (y-axis) against the number of people (x-axis): 429 | plot(x = results[, 1], 430 | y = results[, 2], 431 | pch = 16, 432 | col = "blue", 433 | xlab = "Number of People", 434 | ylab = "Probability of at Least\nOne Matching Birthday") 435 | 436 | ### Challenge 3: Automating tasks with functions and for-loops. 437 | ### 1. Create a function that takes a number and returns whether it is prime or not. Use a for-loop and if-statement on the inside of the function. You will need to use the modulus operator, %%. The operation a %% b returns the remainder when a is divided by b. 438 | 439 | ### 2. Monte Carlo sampling can be used to approximate the value of pi. We can do this by sampling random points in a 1x1 square. The fraction of sampled points that lie within the circle should approximate the area of the circle divided by the area of the square. A circle of radius r = 0.5 can lie within this square. The area of this circle is A = pi * (0.5)^2 = pi / 4. Since the area of the square is 1^2 = 1, this fraction is equal to pi / 4. So, Monte Carlo sampling can be used to approximate pi. 440 | 441 | ### Create a function the approximates pi. It should accept as an argument the number of points to sample. 442 | 443 | ### As an extra challenge, you can create a plotting function that plot the sampled points. Color the points that lie within the circle differently from those that lie outside the circle. 444 | 445 | ### 3. Think about a research or class project. Is there anything you can automate in those contexts to make your life easier? 446 | 447 | -------------------------------------------------------------------------------- /runtime.txt: -------------------------------------------------------------------------------- 1 | r-4.1-2022-01-10 2 | -------------------------------------------------------------------------------- /solutions/Part1_solutions.R: -------------------------------------------------------------------------------- 1 | # R Fundamentals Part 1: Challenge Problem Solutions 2 | 3 | ### Challenge 1: Variable Assignment 4 | ### Define three variables and then write a mathematical expression using only those variables. 5 | x <- 4 6 | y <- 7 7 | z <- 9 8 | 9 | (x * y) / z 10 | 11 | 12 | ### Challenge 2: Data type coercion 13 | ### Like as.integer, other "as dot" functions exist as well, such as as.numeric, as.character, as.logical, and as.factor. 14 | ### 1. Define three variables: one numeric, one character, and one logical 15 | num <- 5 16 | char <- "Oski" 17 | lgcl <- TRUE 18 | 19 | ### 2a. Can you convert numeric to integer type? 20 | num_to_int <- as.integer(num) 21 | num_to_int 22 | class(num_to_int) 23 | ## Yes! 24 | 25 | ### 2b. Convert numeric to logical? 26 | num_to_lgcl <- as.logical(num) 27 | num_to_lgcl 28 | class(num_to_lgcl) 29 | # Yes! 30 | 31 | ### 2c. Convert numeric to character? 32 | num_to_char <- as.character(num) 33 | num_to_char 34 | class(num_to_char) 35 | # Yes! 36 | 37 | ### 2d. Convert logical to character? 38 | lgcl_to_char <- as.character(lgcl) 39 | lgcl_to_char 40 | class(lgcl_to_char) 41 | # Yes! 42 | 43 | ### 2e. Convert character to numeric? 44 | char_to_num <- as.numeric(char) 45 | char_to_num 46 | class(char_to_num) 47 | # No! Technically, yes, but this will lead to some very strange behavior... 48 | 49 | 50 | ### Challenge 3: Concatenating vectors 51 | ### 1. Create a vector starting from 10, and ending with 30, with each entry separated by 2. 52 | vec <- seq(10, 30, 2) 53 | 54 | ### 2. Index the 3rd through 7th elements of this vector. 55 | vec[3:7] 56 | 57 | ### 3. Index the 3rd through 7th elements and the 10th element. 58 | vec[c(3:7, 10)] 59 | 60 | 61 | ### Challenge 4: Make your own data frame. 62 | ### 1. Create a data frame that contains four different food items and three attributes for each: name, price, and quantity. 63 | name <- c("Mango", "Pear", "Pineapple", "Kiwi") 64 | price <- c(1.29, 0.79, 2.99, 1.49) 65 | quantity <- c(4, 6, 3, 10) 66 | 67 | fruits <- data.frame(name, price, quantity) 68 | fruits 69 | 70 | ### 2. Add a fourth column that calculates the total cost for each food item. 71 | fruits$total_cost <- fruits$price * fruits$quantity 72 | fruits 73 | 74 | ### 3. What function could you use to calculate the total cost of all the fruits combined? 75 | sum(fruits$total_cost) 76 | -------------------------------------------------------------------------------- /solutions/Part2_solutions.R: -------------------------------------------------------------------------------- 1 | # R Fundamentals Part 2: Challenge Problem Solutions 2 | library(here) 3 | 4 | ## Challenge 1: Make your own data frame. 5 | 6 | ## Create a data frame that contains four different food items and three attributes for each: name, price, and quantity. 7 | foods <- data.frame(food = c("Apple", "Banana", "Tomato", "Watermelon"), 8 | itemPrice = c(1.25, .5, 1.4, 4.20), 9 | itemQuantity = c(4,6,2,1)) 10 | foods 11 | colnames(foods) <- c("food", "price", "quantity") 12 | 13 | ## Add a fourth column that calculates the total cost for each food item. 14 | foods$totalCost <- foods$price * foods$quantity 15 | 16 | 17 | ## What function could you use to calculate the total cost of all the foods combined? 18 | sum(foods$totalCost) 19 | example <- c(foods$totalCost, NA) 20 | example 21 | sum(example, na.rm = TRUE) 22 | 23 | 24 | ### Challenge 2: Import data from a file. 25 | ### 1. Load the heart.csv file. Save it in a variable named heart. 26 | heart <- read.csv("data/heart.csv") 27 | heart 28 | 29 | ## Alternatively with the here package 30 | heart <- read.csv(here("data/heart.csv")) 31 | 32 | ### 2. Load the sleep_VIM.csv file. Save it in a variable named sleep_VIM. 33 | sleep_VIM <- read.csv("data/sleep_VIM.csv") 34 | sleep_VIM 35 | 36 | ## Alternatively with the here package 37 | sleep_VIM <- read.csv("data/sleep_VIM.csv") 38 | 39 | ### 3. What functions can you use to learn more about the heart or sleep_VIM datasets? 40 | # Show compact structure 41 | str(sleep_VIM) 42 | # Show the first "n" rows (default is 6) 43 | head(sleep_VIM, n = 2) 44 | # Show the last "n" rows (default is 6) 45 | tail(sleep_VIM, n = 3) 46 | # Dimensions of dataframe 47 | dim(sleep_VIM) 48 | # Number of rows 49 | nrow(sleep_VIM) 50 | # Number of cols 51 | ncol(sleep_VIM) 52 | # Show column names (two different ways) 53 | colnames(sleep_VIM) 54 | names(sleep_VIM) 55 | # Show row names (unnamed: default to character type for row number) 56 | rownames(sleep_VIM) 57 | # Show rows with unique data 58 | unique(sleep_VIM) 59 | 60 | ### Challenge 3: Subsetting data frames in one and two dimensions 61 | 62 | ### 1. Create a subset of heart that returns only the sex, trestbps, and target columns. 63 | heart_sub1 <- heart[, c("sex", "trestbps", "target")] 64 | head(heart_sub1) 65 | 66 | ### 2. Create a subset of heart that returns rows 3-7 and row 12 along with columns 2, 4, and 14. 67 | heart_sub2 <- heart[c(3:7, 12), c(2, 4, 14)] 68 | heart_sub2 69 | 70 | 71 | ### Challenge 4 72 | ### Consider the following data frame: 73 | challenge_df <- data.frame(Name = c("Joe", "Susan", "Juan", "Preeti"), 74 | City = c("Berkeley", "Berkeley", "San Mateo", "San Jose"), 75 | Physics = c(20, 21, 22, 23), 76 | Chemistry = c(23, 22, 21, 20)) 77 | 78 | ## Data for df_merge 79 | df1 <- data.frame(Name = c("Joe", "Susan", "Jack", "Kelly"), 80 | City = c("Berkeley", "Berkeley", "Oakland", "Oakland"), 81 | Math = c(42, 48, 50, 46), 82 | Reading = c(8, 10, 10, 10)) 83 | 84 | df2 <- data.frame(Name = c("Joe", "Susan", "Jack", "Kelly"), 85 | Science = c(99, 100, 99, 100), 86 | Music = c(19, 18, 20, 20), 87 | Art = c(20, 20, 19, 18)) 88 | 89 | ## Merge the dataframes 90 | df_merge <- merge(df1, df2, by = "Name") 91 | 92 | ### 1. Use the merge() function to merge df_merge and challenge_df by Name. What do you notice about the columns? How many rows are there? 93 | merge(df_merge, challenge_df, by = "Name") 94 | # There are 2 rows and 10 columns. Without doing any additional merging by columns, we end up seeing duplicates. 95 | # Here, we get duplicates on "City". That would go away if we instead merge by additional categories: 96 | merge(df_merge, challenge_df, by = c("Name", "City")) 97 | 98 | ### 2. Use the inner_join() function from dplyr to merge df_merge and challenge_df by Name. What happens if you merge by Name and City? 99 | inner_join(df_merge, challenge_df, by = c("Name")) 100 | # Note that this gives us the same data frame as our first merge. Similarly, doing: 101 | inner_join(df_merge, challenge_df, by = c("Name", "City")) 102 | # gives us back the same data frame without two city columns 103 | ### 3. Use the left_join() function to merge df_merge and challenge_df by Name and City. Use the right_join() function to merge df_merge and challenge_df by Name and City. 104 | 105 | # The reason we want to merge by multiple columns is to avoid the city.x and city.y issue. 106 | # Here's an example with left join: 107 | left_join(df_merge, challenge_df, by = c("Name")) 108 | left_join(df_merge, challenge_df, by =c("Name", "City")) 109 | right_join(df_merge, challenge_df, by = c("Name", "City")) 110 | 111 | ### 4. Use the full_join() function to merge df_merge and challenge_df by Name and City. 112 | full_join(df_merge, challenge_df, by = c("Name", "City")) 113 | ### What do you notice about the differences among 2, 3, and 4? 114 | # There are multiple answers to this, but a basic one is what city variable has NA values. This will change depending on the type of merge. Another difference will be which names are returned. 115 | -------------------------------------------------------------------------------- /solutions/Part3_solutions.R: -------------------------------------------------------------------------------- 1 | # R Fundamentals Part 3: Challenge Problem Solutions 2 | 3 | ### Challenge 1: Loading Data From Files 4 | 5 | ### 1. Load the gapminder-FiveYearData.csv file and save it in a variable named gap. 6 | gap <- read.csv(here("data/gapminder-FiveYearData.csv")) 7 | str(gap) 8 | head(gap) 9 | 10 | ### 2. Load the sleep_VIM.csv file and save it in a variable named sv. 11 | sv <- read.csv(here("data/sleep_VIM.csv")) 12 | str(sv) 13 | head(sv) 14 | 15 | ### 3. Load the heart.csv file and save it in a variable named heart. 16 | heart <- read.csv(here("data/heart.csv")) 17 | str(heart) 18 | head(heart) 19 | 20 | ### Challenge 2: Loading RData Files 21 | 22 | ### 1. Wipe your global environment clean. 23 | rm(list = ls()) # Or, click the broom icon. 24 | 25 | ### 2. Restart your R session by clicking "Session" --> "Restart R" 26 | 27 | ### 3. Load "fun_data.RData". If you don't know how to do this, how do you find out? 28 | load("data/fun_data.RData") 29 | ?load 30 | 31 | ### Challenge 3: Create your own ggplot 32 | ### Create a fourth ggplot figure of your choosing. Save it as a variable named gg_fourth. What relationships have we not explored yet? How about the relationship between population and other features? 33 | ## Here is an example of plotting GDP per capita vs. population: 34 | library(ggplot2) 35 | gg_fourth <- ggplot(data = gap, aes(x = pop, y = gdpPercap)) + 36 | # Change point size and transparency 37 | geom_point(size = 2, alpha = 0.25) + 38 | theme_classic() + 39 | ggtitle("Scatterplot of GDP Per Capita by Population") + 40 | xlab("Population") + 41 | ylab("GDP Per Capita") + 42 | # Change legend position and customize it 43 | theme(legend.position = "top", 44 | plot.title = element_text(hjust = 0.5, size = 12), 45 | legend.title = element_text(size = 10), 46 | legend.text = element_text(size = 5), 47 | axis.text.x = element_text(angle = 45, hjust = 1)) + 48 | scale_x_log10() + 49 | scale_y_log10() 50 | print(gg_fourth) 51 | # Not much of a relationship! 52 | 53 | ## Here's another example with some data wrangling: 54 | library(dplyr) 55 | gap_lifeExp_mean <- gap |> 56 | dplyr::group_by(year, continent) |> 57 | dplyr::mutate(mean_lifeExp = mean(lifeExp)) 58 | head(gap_lifeExp_mean) 59 | 60 | gg_fourth <- ggplot(gap_lifeExp_mean, 61 | aes(x = year, y = mean_lifeExp, 62 | color = continent, 63 | linetype = continent)) + 64 | geom_line(lwd = 2) + 65 | theme_bw() + 66 | xlab("Mean lifeExp") + 67 | theme(legend.position = "top") 68 | print(gg_fourth) 69 | 70 | ### Challenge 5 71 | ### Complete the following tasks using the heart dataset: 72 | 73 | ### 1. Plot the distribution of the cholesterol variable, chol. 74 | hist(heart$chol) 75 | 76 | ### 2. Visualize the differences in chol between females and males. 77 | heart_diffs <- ggplot(heart, aes(y = chol, 78 | x = as.factor(sex), 79 | fill = as.factor(sex))) + 80 | geom_boxplot() + 81 | # Relabel x-axis tickmarks 82 | scale_x_discrete(breaks = c(0, 1), 83 | labels = c("Female", "Male")) + 84 | # Change colors 85 | scale_fill_manual(values=c("purple", "green")) + 86 | # Hide legend 87 | guides(fill = "none") + 88 | theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 89 | xlab("Sex") + 90 | ylab("Cholesterol (mg/dl)") + 91 | theme_bw() 92 | print(heart_diffs) 93 | -------------------------------------------------------------------------------- /solutions/Part4_solutions.R: -------------------------------------------------------------------------------- 1 | # R Fundamentals Part 4: Challenge Problem Solutions 2 | 3 | ### Challenge 1: Importing data from files. 4 | ### 1. Wipe your global environment clean. 5 | rm(list = ls()) 6 | 7 | ### 2. Restart your R session by clicking "Session" --> "Restart R". 8 | 9 | ### 3. Load the gap dataset. 10 | gap <- read.csv(here("data/gapminder-FiveYearData.csv")) 11 | 12 | ### 4. Load the heart dataset. 13 | heart <- read.csv(here("data/heart.csv")) 14 | 15 | ### Challenge 2: Write your own functions. 16 | ### 1. Write a function that calculates the area of a circle with radius r. The formula for the area of a circle is A = pi * r^2. 17 | area <- function(r) { 18 | return(pi * r^2) 19 | } 20 | area(2) 21 | 4 * pi 22 | 23 | ### 2. Write a function that calculates the sample standard deviation given a vector of numeric values. Check that this function returns the same output as the base function sd(). 24 | my_sd <- function(vec) { 25 | n_samples <- length(vec) 26 | avg <- mean(vec) 27 | var <- sum((vec - avg)^2) / (n_samples - 1) 28 | return(sqrt(var)) 29 | } 30 | vec <- c(2, 5, 10, 20) 31 | sd(vec) 32 | my_sd(vec) 33 | 34 | ### Challenge 3: Automating tasks with functions and for-loops. 35 | ### 1. Create a function that takes a number and returns whether it is prime or not. Use a for-loop and if-statement on the inside of the function. You will need to use the modulus operator, %%. The operation a %% b returns the remainder when a is divided by b. 36 | prime_checker <- function(n) { 37 | # The number 2 is an edge case! 38 | if (n == 2) { 39 | return(TRUE) 40 | } 41 | for (i in 2:(n-1)) { 42 | if (n %% i == 0) { 43 | return(FALSE) 44 | } 45 | } 46 | return(TRUE) 47 | } 48 | prime_checker(2) 49 | 50 | ### 2. Monte Carlo sampling can be used to approximate the value of pi. We can do this by sampling random points in a 1x1 square. The fraction of sampled points that lie within the circle should approximate the area of the circle divided by the area of the square. A circle of radius r = 0.5 can lie within this square. The area of this circle is A = pi * (0.5)^2 = pi / 4. Since the area of the square is 1^2 = 1, this fraction is equal to pi / 4. So, Monte Carlo sampling can be used to approximate pi. 51 | 52 | ### Create a function the approximates pi. It should accept as an argument the number of points to sample. 53 | simulation <- function(n_points) { 54 | # Sample points 55 | x <- runif(n_points, min = -1, max = 1) 56 | y <- runif(n_points, min = -1, max = 1) 57 | # Determine if they lie in the circle 58 | distance <- x^2 + y^2 59 | within_circle <- distance < 1 60 | # Calculate fraction of points 61 | frac_points <- mean(within_circle) 62 | # Estimate pi 63 | pi_estimate <- frac_points * 4 64 | return(pi_estimate) 65 | } 66 | simulation(1e7) 67 | 68 | ## Now, with plotting: 69 | simulation_plotter <- function(n_points) { 70 | # Sample points 71 | x <- runif(n_points, min = -1, max = 1) 72 | y <- runif(n_points, min = -1, max = 1) 73 | # Determine if they lie in the circle 74 | distance <- x^2 + y^2 75 | within_circle <- distance < 1 76 | # Calculate fraction of points 77 | frac_points <- mean(within_circle) 78 | # Estimate pi 79 | pi_estimate <- frac_points * 4 80 | # Calculate fraction of points 81 | plot(x, y, col = within_circle + 1, pch = 20, 82 | main = paste0("Pi estimate = ", pi_estimate)) 83 | 84 | } 85 | simulation_plotter(10000) 86 | --------------------------------------------------------------------------------