├── README.md ├── analysis_start.md ├── assets ├── ISBE_example.png ├── commit.png ├── file_list.png ├── first_commit.png ├── git_changed.png ├── git_commit_message.png ├── git_commit_message2.png ├── git_diff.png ├── git_more_shell.png ├── git_origin.png ├── git_pane.png ├── git_pane_added.png ├── git_push.png ├── github_git_commands.png ├── new_repo.png ├── project_files.png ├── project_screen1.png ├── project_screen2.png ├── project_screen3.png ├── readme_commit.png └── staged_readme.png ├── commit.md ├── created_earlier.md ├── github.md ├── github_sync.md ├── installing_software.md ├── license.txt ├── making_change.md ├── next_steps.md ├── rstudio_project.md ├── updates.md └── version_control.md /README.md: -------------------------------------------------------------------------------- 1 | # Citing this work 2 | 3 | You are free to use this work in your own projects. However, we would appreciate a citation: [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.61435.svg)](https://doi.org/10.5281/zenodo.61435) 4 | 5 | 6 | # Introduction to Reproducible Research in R and R Studio. 7 | 8 | In this session, we are going to get you started with using version control from within RStudio. 9 | 10 | The material is self-paced and includes a worked-example. It is suggested that you work through the sections in order. 11 | 12 | ## Version control with git and github 13 | 14 | * [Installing the software](./installing_software.md) - Get what you need on your own machine 15 | * [Getting an account on github](./github.md) - Sign up for github 16 | * [Creating an RStudio project](./rstudio_project.md) - Creating an example, version controlled project 17 | * [Starting our analysis project](./analysis_start.md) - A simple script to get us started 18 | * [Getting our project under version control](./version_control.md) - First step into a larger world 19 | * [Making a change](./making_change.md) - Making our script more useful 20 | * [Committing our change](./commit.md) - How to commit a change 21 | * [Connecting our local repository to github](./github_sync.md) - Backup! Making our code available to the world. 22 | * [Subsequent updates](./updates.md) - Now we are set up, the workflow is easy. 23 | * [The example repo](./created_earlier.md) - My version of the repo we've created today 24 | * [Things we haven't told you](./next_steps.md) - Steps to further learning 25 | -------------------------------------------------------------------------------- /analysis_start.md: -------------------------------------------------------------------------------- 1 | # Starting our analysis project 2 | 3 | The purpose of this tutorial is to teach you version control. In order to do this, however, we'll need to make up a simple project that needs controlling! 4 | 5 | Our initial project will be extremely simple -- a very small data file and a script that loads and plots it. Later, we'll add code to fit a nonlinear curve to it. (Based on the tutorial at http://www.walkingrandomly.com/?p=5254) 6 | 7 | Download this data to your project folder: [Example data](https://raw.githubusercontent.com/mikecroucher/Code_cafe/master/First_steps_with_R/example_data.csv) (right click and use your Web browser's save as functionality. You may need to manually add the file extension ".csv"). 8 | 9 | Create a new R script in RStudio. **File** -> **New File** -> **R script** 10 | 11 | Enter the following commands into your new RScript 12 | 13 | ``` 14 | mydata = read.csv("example_data.csv") 15 | plot(mydata$xdata,mydata$ydata) 16 | ``` 17 | 18 | Save the R Script as `myscript.R`. When you run it, it should load and plot the data. 19 | 20 | Your directory should now contain 4 files: 21 | 22 | ![](./assets/file_list.png) 23 | -------------------------------------------------------------------------------- /assets/ISBE_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikecroucher/ISBE_Symposium/a15feb6f2b1fceb42359bb628f9f8be2da8b5236/assets/ISBE_example.png -------------------------------------------------------------------------------- /assets/commit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikecroucher/ISBE_Symposium/a15feb6f2b1fceb42359bb628f9f8be2da8b5236/assets/commit.png -------------------------------------------------------------------------------- /assets/file_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikecroucher/ISBE_Symposium/a15feb6f2b1fceb42359bb628f9f8be2da8b5236/assets/file_list.png -------------------------------------------------------------------------------- /assets/first_commit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikecroucher/ISBE_Symposium/a15feb6f2b1fceb42359bb628f9f8be2da8b5236/assets/first_commit.png -------------------------------------------------------------------------------- /assets/git_changed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikecroucher/ISBE_Symposium/a15feb6f2b1fceb42359bb628f9f8be2da8b5236/assets/git_changed.png -------------------------------------------------------------------------------- /assets/git_commit_message.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikecroucher/ISBE_Symposium/a15feb6f2b1fceb42359bb628f9f8be2da8b5236/assets/git_commit_message.png -------------------------------------------------------------------------------- /assets/git_commit_message2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikecroucher/ISBE_Symposium/a15feb6f2b1fceb42359bb628f9f8be2da8b5236/assets/git_commit_message2.png -------------------------------------------------------------------------------- /assets/git_diff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikecroucher/ISBE_Symposium/a15feb6f2b1fceb42359bb628f9f8be2da8b5236/assets/git_diff.png -------------------------------------------------------------------------------- /assets/git_more_shell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikecroucher/ISBE_Symposium/a15feb6f2b1fceb42359bb628f9f8be2da8b5236/assets/git_more_shell.png -------------------------------------------------------------------------------- /assets/git_origin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikecroucher/ISBE_Symposium/a15feb6f2b1fceb42359bb628f9f8be2da8b5236/assets/git_origin.png -------------------------------------------------------------------------------- /assets/git_pane.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikecroucher/ISBE_Symposium/a15feb6f2b1fceb42359bb628f9f8be2da8b5236/assets/git_pane.png -------------------------------------------------------------------------------- /assets/git_pane_added.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikecroucher/ISBE_Symposium/a15feb6f2b1fceb42359bb628f9f8be2da8b5236/assets/git_pane_added.png -------------------------------------------------------------------------------- /assets/git_push.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikecroucher/ISBE_Symposium/a15feb6f2b1fceb42359bb628f9f8be2da8b5236/assets/git_push.png -------------------------------------------------------------------------------- /assets/github_git_commands.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikecroucher/ISBE_Symposium/a15feb6f2b1fceb42359bb628f9f8be2da8b5236/assets/github_git_commands.png -------------------------------------------------------------------------------- /assets/new_repo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikecroucher/ISBE_Symposium/a15feb6f2b1fceb42359bb628f9f8be2da8b5236/assets/new_repo.png -------------------------------------------------------------------------------- /assets/project_files.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikecroucher/ISBE_Symposium/a15feb6f2b1fceb42359bb628f9f8be2da8b5236/assets/project_files.png -------------------------------------------------------------------------------- /assets/project_screen1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikecroucher/ISBE_Symposium/a15feb6f2b1fceb42359bb628f9f8be2da8b5236/assets/project_screen1.png -------------------------------------------------------------------------------- /assets/project_screen2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikecroucher/ISBE_Symposium/a15feb6f2b1fceb42359bb628f9f8be2da8b5236/assets/project_screen2.png -------------------------------------------------------------------------------- /assets/project_screen3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikecroucher/ISBE_Symposium/a15feb6f2b1fceb42359bb628f9f8be2da8b5236/assets/project_screen3.png -------------------------------------------------------------------------------- /assets/readme_commit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikecroucher/ISBE_Symposium/a15feb6f2b1fceb42359bb628f9f8be2da8b5236/assets/readme_commit.png -------------------------------------------------------------------------------- /assets/staged_readme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikecroucher/ISBE_Symposium/a15feb6f2b1fceb42359bb628f9f8be2da8b5236/assets/staged_readme.png -------------------------------------------------------------------------------- /commit.md: -------------------------------------------------------------------------------- 1 | # Committing our change 2 | 3 | Make sure you've saved the script. Now, click on the **git** tab in RStudio. You'll notice that there's only one file listed -- our script -- since that's the only file that's changed. 4 | 5 | ![](./assets/git_changed.png) 6 | 7 | Click on the staged box to stage our change. Now click on **Diff** to give a summary of what's changed. Lines that have been added are green. Lines that have been removed are red. 8 | 9 | From git's point of view, a modification to a line is actually two operations - The removal of the original line followed by the creation of the new line. 10 | 11 | ![](./assets/git_diff.png) 12 | 13 | Add a commit message and click on commit 14 | 15 | ![](./assets/git_commit_message2.png) 16 | 17 | # Viewing history 18 | 19 | In the **git** tab of RStudio, click on **diff** and then **History**. You'll see that you can look through every commit you've ever made. This can be extremely useful for finding bugs or looking back to how your model looked a few months ago. 20 | 21 | It's not possible to revert back to a previous commit using the RStudio interface. For that, you need to learn some command-line git which is beyond the scope of this session. 22 | -------------------------------------------------------------------------------- /created_earlier.md: -------------------------------------------------------------------------------- 1 | # Here's one we created earlier 2 | 3 | My version of the project we've been working through - https://github.com/mikecroucher/ISBE_example 4 | -------------------------------------------------------------------------------- /github.md: -------------------------------------------------------------------------------- 1 | # Create an account on github 2 | 3 | Although git can be used on its own, most people choose to use it in conjunction with an online repository service. The most popular of these, by far, is github. 4 | 5 | It has become so standard that some organisations will ask to see your github profile as part of job applications! 6 | 7 | * Create a free account on github. **If you have an academic email account you should use it here.** 8 | * https://github.com/join 9 | 10 | Github users can create an unlimited number of free, **public** repositories. If you want to create **private** repositories, most people need to purchase a subscription. 11 | 12 | **Academic users can get access to an unlimited number of free private repositories.** The key to these riches is your academic email address which has to be associated with your github account. 13 | 14 | * If you are an academic, request free private repositories - https://education.github.com/discount_requests/new 15 | 16 | It may take a while to receive the verification email for this step. Don't worry about this, you'll not need it for the rest of the session. 17 | -------------------------------------------------------------------------------- /github_sync.md: -------------------------------------------------------------------------------- 1 | # Connecting our local repository to github 2 | 3 | Our project is fully version controlled so we have access to a detailed history of every change we've ever made to it. This is a great first step but all of this only exists on our own computers at the moment. 4 | 5 | It's time to upload our project to github! 6 | 7 | Putting your code on github confers a number of benefits: 8 | 9 | * Everything is backed up for you. 10 | * Your project is made available to others. This is a vital part of modern scientific dissemination. 11 | * Github has a range of project management and collaboration tools that work on a per-project basis. 12 | * Your github profile can be used as part of your online-identity. 13 | 14 | **Creating a new repository on github** 15 | 16 | * Log into github and go to your profile page. On the **repositories** tab, click **New** 17 | 18 | ![](./assets/new_repo.png) 19 | 20 | At the **Create a new repository** screen, give your repo a name and click **Create Repository**. 21 | 22 | ![](./assets/ISBE_example.png) 23 | 24 | The **Quick Setup** screen gives sets of git commands that can be used in various circumstances. We are interested in **…or push an existing repository from the command line**. Copy these commands to the clipboard 25 | 26 | ![](./assets/github_git_commands.png) 27 | 28 | In RStudio, navigate to the **git** tab and click on **More -> Shell** 29 | 30 | ![](./assets/git_more_shell.png) 31 | 32 | Paste the git commands into the Shell and press Enter to execute them. 33 | 34 | ![](./assets/git_origin.png) 35 | 36 | Confirm that the project has been uploaded to your git profile. 37 | -------------------------------------------------------------------------------- /installing_software.md: -------------------------------------------------------------------------------- 1 | ## Installing R, RStudio and git 2 | 3 | Many users of R use it from within another free piece of software called **RStudio.** 4 | RStudio is a powerful and productive user interface for R. It’s free and open source, and works great on Windows, Mac, and Linux. 5 | 6 | Rstudio's version control functionality is provided by yet another software called **git** 7 | 8 | Our first task, therefore, is to install R, RStudio and git. 9 | 10 | **Install R** 11 | 12 | Install R first. Downloads are available at https://cran.rstudio.com/ 13 | * Direct link for Windows https://cran.r-project.org/bin/windows/base/ 14 | * Direct link for MacOS X https://cran.r-project.org/bin/macosx/ 15 | * Direct link for Linux https://cran.r-project.org/bin/linux/ 16 | 17 | **Install RStudio** 18 | 19 | Next, install RStudio. 20 | 21 | * Downloads are available at https://www.rstudio.com/products/rstudio/download/ 22 | 23 | **Install git** 24 | 25 | Git is one of the most popular version control systems in the world. It is free and open source. 26 | 27 | * Windows & OS X: http://git-scm.com/downloads 28 | * Debian/Ubuntu: `sudo apt-get install git-core` 29 | * Fedora/RedHat: `sudo yum install git-core` 30 | 31 | **Configure git** 32 | 33 | After installing git, you need to tell it who you are. Open a terminal window (**cmd.exe on windows**) and type the following 34 | 35 | ``` 36 | git config --global user.email "you@youremail.com" 37 | git config --global user.name "Your Name" 38 | ``` 39 | 40 | On succesful completion, you should see no output from these commands. 41 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | Attribution 3.0 Unported 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR 10 | DAMAGES RESULTING FROM ITS USE. 11 | 12 | License 13 | 14 | THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE 15 | COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY 16 | COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS 17 | AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. 18 | 19 | BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE 20 | TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY 21 | BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS 22 | CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND 23 | CONDITIONS. 24 | 25 | 1. Definitions 26 | 27 | a. "Adaptation" means a work based upon the Work, or upon the Work and 28 | other pre-existing works, such as a translation, adaptation, 29 | derivative work, arrangement of music or other alterations of a 30 | literary or artistic work, or phonogram or performance and includes 31 | cinematographic adaptations or any other form in which the Work may be 32 | recast, transformed, or adapted including in any form recognizably 33 | derived from the original, except that a work that constitutes a 34 | Collection will not be considered an Adaptation for the purpose of 35 | this License. For the avoidance of doubt, where the Work is a musical 36 | work, performance or phonogram, the synchronization of the Work in 37 | timed-relation with a moving image ("synching") will be considered an 38 | Adaptation for the purpose of this License. 39 | b. "Collection" means a collection of literary or artistic works, such as 40 | encyclopedias and anthologies, or performances, phonograms or 41 | broadcasts, or other works or subject matter other than works listed 42 | in Section 1(f) below, which, by reason of the selection and 43 | arrangement of their contents, constitute intellectual creations, in 44 | which the Work is included in its entirety in unmodified form along 45 | with one or more other contributions, each constituting separate and 46 | independent works in themselves, which together are assembled into a 47 | collective whole. A work that constitutes a Collection will not be 48 | considered an Adaptation (as defined above) for the purposes of this 49 | License. 50 | c. "Distribute" means to make available to the public the original and 51 | copies of the Work or Adaptation, as appropriate, through sale or 52 | other transfer of ownership. 53 | d. "Licensor" means the individual, individuals, entity or entities that 54 | offer(s) the Work under the terms of this License. 55 | e. "Original Author" means, in the case of a literary or artistic work, 56 | the individual, individuals, entity or entities who created the Work 57 | or if no individual or entity can be identified, the publisher; and in 58 | addition (i) in the case of a performance the actors, singers, 59 | musicians, dancers, and other persons who act, sing, deliver, declaim, 60 | play in, interpret or otherwise perform literary or artistic works or 61 | expressions of folklore; (ii) in the case of a phonogram the producer 62 | being the person or legal entity who first fixes the sounds of a 63 | performance or other sounds; and, (iii) in the case of broadcasts, the 64 | organization that transmits the broadcast. 65 | f. "Work" means the literary and/or artistic work offered under the terms 66 | of this License including without limitation any production in the 67 | literary, scientific and artistic domain, whatever may be the mode or 68 | form of its expression including digital form, such as a book, 69 | pamphlet and other writing; a lecture, address, sermon or other work 70 | of the same nature; a dramatic or dramatico-musical work; a 71 | choreographic work or entertainment in dumb show; a musical 72 | composition with or without words; a cinematographic work to which are 73 | assimilated works expressed by a process analogous to cinematography; 74 | a work of drawing, painting, architecture, sculpture, engraving or 75 | lithography; a photographic work to which are assimilated works 76 | expressed by a process analogous to photography; a work of applied 77 | art; an illustration, map, plan, sketch or three-dimensional work 78 | relative to geography, topography, architecture or science; a 79 | performance; a broadcast; a phonogram; a compilation of data to the 80 | extent it is protected as a copyrightable work; or a work performed by 81 | a variety or circus performer to the extent it is not otherwise 82 | considered a literary or artistic work. 83 | g. "You" means an individual or entity exercising rights under this 84 | License who has not previously violated the terms of this License with 85 | respect to the Work, or who has received express permission from the 86 | Licensor to exercise rights under this License despite a previous 87 | violation. 88 | h. "Publicly Perform" means to perform public recitations of the Work and 89 | to communicate to the public those public recitations, by any means or 90 | process, including by wire or wireless means or public digital 91 | performances; to make available to the public Works in such a way that 92 | members of the public may access these Works from a place and at a 93 | place individually chosen by them; to perform the Work to the public 94 | by any means or process and the communication to the public of the 95 | performances of the Work, including by public digital performance; to 96 | broadcast and rebroadcast the Work by any means including signs, 97 | sounds or images. 98 | i. "Reproduce" means to make copies of the Work by any means including 99 | without limitation by sound or visual recordings and the right of 100 | fixation and reproducing fixations of the Work, including storage of a 101 | protected performance or phonogram in digital form or other electronic 102 | medium. 103 | 104 | 2. Fair Dealing Rights. Nothing in this License is intended to reduce, 105 | limit, or restrict any uses free from copyright or rights arising from 106 | limitations or exceptions that are provided for in connection with the 107 | copyright protection under copyright law or other applicable laws. 108 | 109 | 3. License Grant. Subject to the terms and conditions of this License, 110 | Licensor hereby grants You a worldwide, royalty-free, non-exclusive, 111 | perpetual (for the duration of the applicable copyright) license to 112 | exercise the rights in the Work as stated below: 113 | 114 | a. to Reproduce the Work, to incorporate the Work into one or more 115 | Collections, and to Reproduce the Work as incorporated in the 116 | Collections; 117 | b. to create and Reproduce Adaptations provided that any such Adaptation, 118 | including any translation in any medium, takes reasonable steps to 119 | clearly label, demarcate or otherwise identify that changes were made 120 | to the original Work. For example, a translation could be marked "The 121 | original work was translated from English to Spanish," or a 122 | modification could indicate "The original work has been modified."; 123 | c. to Distribute and Publicly Perform the Work including as incorporated 124 | in Collections; and, 125 | d. to Distribute and Publicly Perform Adaptations. 126 | e. For the avoidance of doubt: 127 | 128 | i. Non-waivable Compulsory License Schemes. In those jurisdictions in 129 | which the right to collect royalties through any statutory or 130 | compulsory licensing scheme cannot be waived, the Licensor 131 | reserves the exclusive right to collect such royalties for any 132 | exercise by You of the rights granted under this License; 133 | ii. Waivable Compulsory License Schemes. In those jurisdictions in 134 | which the right to collect royalties through any statutory or 135 | compulsory licensing scheme can be waived, the Licensor waives the 136 | exclusive right to collect such royalties for any exercise by You 137 | of the rights granted under this License; and, 138 | iii. Voluntary License Schemes. The Licensor waives the right to 139 | collect royalties, whether individually or, in the event that the 140 | Licensor is a member of a collecting society that administers 141 | voluntary licensing schemes, via that society, from any exercise 142 | by You of the rights granted under this License. 143 | 144 | The above rights may be exercised in all media and formats whether now 145 | known or hereafter devised. The above rights include the right to make 146 | such modifications as are technically necessary to exercise the rights in 147 | other media and formats. Subject to Section 8(f), all rights not expressly 148 | granted by Licensor are hereby reserved. 149 | 150 | 4. Restrictions. The license granted in Section 3 above is expressly made 151 | subject to and limited by the following restrictions: 152 | 153 | a. You may Distribute or Publicly Perform the Work only under the terms 154 | of this License. You must include a copy of, or the Uniform Resource 155 | Identifier (URI) for, this License with every copy of the Work You 156 | Distribute or Publicly Perform. You may not offer or impose any terms 157 | on the Work that restrict the terms of this License or the ability of 158 | the recipient of the Work to exercise the rights granted to that 159 | recipient under the terms of the License. You may not sublicense the 160 | Work. You must keep intact all notices that refer to this License and 161 | to the disclaimer of warranties with every copy of the Work You 162 | Distribute or Publicly Perform. When You Distribute or Publicly 163 | Perform the Work, You may not impose any effective technological 164 | measures on the Work that restrict the ability of a recipient of the 165 | Work from You to exercise the rights granted to that recipient under 166 | the terms of the License. This Section 4(a) applies to the Work as 167 | incorporated in a Collection, but this does not require the Collection 168 | apart from the Work itself to be made subject to the terms of this 169 | License. If You create a Collection, upon notice from any Licensor You 170 | must, to the extent practicable, remove from the Collection any credit 171 | as required by Section 4(b), as requested. If You create an 172 | Adaptation, upon notice from any Licensor You must, to the extent 173 | practicable, remove from the Adaptation any credit as required by 174 | Section 4(b), as requested. 175 | b. If You Distribute, or Publicly Perform the Work or any Adaptations or 176 | Collections, You must, unless a request has been made pursuant to 177 | Section 4(a), keep intact all copyright notices for the Work and 178 | provide, reasonable to the medium or means You are utilizing: (i) the 179 | name of the Original Author (or pseudonym, if applicable) if supplied, 180 | and/or if the Original Author and/or Licensor designate another party 181 | or parties (e.g., a sponsor institute, publishing entity, journal) for 182 | attribution ("Attribution Parties") in Licensor's copyright notice, 183 | terms of service or by other reasonable means, the name of such party 184 | or parties; (ii) the title of the Work if supplied; (iii) to the 185 | extent reasonably practicable, the URI, if any, that Licensor 186 | specifies to be associated with the Work, unless such URI does not 187 | refer to the copyright notice or licensing information for the Work; 188 | and (iv) , consistent with Section 3(b), in the case of an Adaptation, 189 | a credit identifying the use of the Work in the Adaptation (e.g., 190 | "French translation of the Work by Original Author," or "Screenplay 191 | based on original Work by Original Author"). The credit required by 192 | this Section 4 (b) may be implemented in any reasonable manner; 193 | provided, however, that in the case of a Adaptation or Collection, at 194 | a minimum such credit will appear, if a credit for all contributing 195 | authors of the Adaptation or Collection appears, then as part of these 196 | credits and in a manner at least as prominent as the credits for the 197 | other contributing authors. For the avoidance of doubt, You may only 198 | use the credit required by this Section for the purpose of attribution 199 | in the manner set out above and, by exercising Your rights under this 200 | License, You may not implicitly or explicitly assert or imply any 201 | connection with, sponsorship or endorsement by the Original Author, 202 | Licensor and/or Attribution Parties, as appropriate, of You or Your 203 | use of the Work, without the separate, express prior written 204 | permission of the Original Author, Licensor and/or Attribution 205 | Parties. 206 | c. Except as otherwise agreed in writing by the Licensor or as may be 207 | otherwise permitted by applicable law, if You Reproduce, Distribute or 208 | Publicly Perform the Work either by itself or as part of any 209 | Adaptations or Collections, You must not distort, mutilate, modify or 210 | take other derogatory action in relation to the Work which would be 211 | prejudicial to the Original Author's honor or reputation. Licensor 212 | agrees that in those jurisdictions (e.g. Japan), in which any exercise 213 | of the right granted in Section 3(b) of this License (the right to 214 | make Adaptations) would be deemed to be a distortion, mutilation, 215 | modification or other derogatory action prejudicial to the Original 216 | Author's honor and reputation, the Licensor will waive or not assert, 217 | as appropriate, this Section, to the fullest extent permitted by the 218 | applicable national law, to enable You to reasonably exercise Your 219 | right under Section 3(b) of this License (right to make Adaptations) 220 | but not otherwise. 221 | 222 | 5. Representations, Warranties and Disclaimer 223 | 224 | UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR 225 | OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY 226 | KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, 227 | INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, 228 | FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF 229 | LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, 230 | WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION 231 | OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. 232 | 233 | 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE 234 | LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR 235 | ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES 236 | ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS 237 | BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 238 | 239 | 7. Termination 240 | 241 | a. This License and the rights granted hereunder will terminate 242 | automatically upon any breach by You of the terms of this License. 243 | Individuals or entities who have received Adaptations or Collections 244 | from You under this License, however, will not have their licenses 245 | terminated provided such individuals or entities remain in full 246 | compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will 247 | survive any termination of this License. 248 | b. Subject to the above terms and conditions, the license granted here is 249 | perpetual (for the duration of the applicable copyright in the Work). 250 | Notwithstanding the above, Licensor reserves the right to release the 251 | Work under different license terms or to stop distributing the Work at 252 | any time; provided, however that any such election will not serve to 253 | withdraw this License (or any other license that has been, or is 254 | required to be, granted under the terms of this License), and this 255 | License will continue in full force and effect unless terminated as 256 | stated above. 257 | 258 | 8. Miscellaneous 259 | 260 | a. Each time You Distribute or Publicly Perform the Work or a Collection, 261 | the Licensor offers to the recipient a license to the Work on the same 262 | terms and conditions as the license granted to You under this License. 263 | b. Each time You Distribute or Publicly Perform an Adaptation, Licensor 264 | offers to the recipient a license to the original Work on the same 265 | terms and conditions as the license granted to You under this License. 266 | c. If any provision of this License is invalid or unenforceable under 267 | applicable law, it shall not affect the validity or enforceability of 268 | the remainder of the terms of this License, and without further action 269 | by the parties to this agreement, such provision shall be reformed to 270 | the minimum extent necessary to make such provision valid and 271 | enforceable. 272 | d. No term or provision of this License shall be deemed waived and no 273 | breach consented to unless such waiver or consent shall be in writing 274 | and signed by the party to be charged with such waiver or consent. 275 | e. This License constitutes the entire agreement between the parties with 276 | respect to the Work licensed here. There are no understandings, 277 | agreements or representations with respect to the Work not specified 278 | here. Licensor shall not be bound by any additional provisions that 279 | may appear in any communication from You. This License may not be 280 | modified without the mutual written agreement of the Licensor and You. 281 | f. The rights granted under, and the subject matter referenced, in this 282 | License were drafted utilizing the terminology of the Berne Convention 283 | for the Protection of Literary and Artistic Works (as amended on 284 | September 28, 1979), the Rome Convention of 1961, the WIPO Copyright 285 | Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 286 | and the Universal Copyright Convention (as revised on July 24, 1971). 287 | These rights and subject matter take effect in the relevant 288 | jurisdiction in which the License terms are sought to be enforced 289 | according to the corresponding provisions of the implementation of 290 | those treaty provisions in the applicable national law. If the 291 | standard suite of rights granted under applicable copyright law 292 | includes additional rights not granted under this License, such 293 | additional rights are deemed to be included in the License; this 294 | License is not intended to restrict the license of any rights under 295 | applicable law. 296 | 297 | 298 | Creative Commons Notice 299 | 300 | Creative Commons is not a party to this License, and makes no warranty 301 | whatsoever in connection with the Work. Creative Commons will not be 302 | liable to You or any party on any legal theory for any damages 303 | whatsoever, including without limitation any general, special, 304 | incidental or consequential damages arising in connection to this 305 | license. Notwithstanding the foregoing two (2) sentences, if Creative 306 | Commons has expressly identified itself as the Licensor hereunder, it 307 | shall have all rights and obligations of Licensor. 308 | 309 | Except for the limited purpose of indicating to the public that the 310 | Work is licensed under the CCPL, Creative Commons does not authorize 311 | the use by either party of the trademark "Creative Commons" or any 312 | related trademark or logo of Creative Commons without the prior 313 | written consent of Creative Commons. Any permitted use will be in 314 | compliance with Creative Commons' then-current trademark usage 315 | guidelines, as may be published on its website or otherwise made 316 | available upon request from time to time. For the avoidance of doubt, 317 | this trademark restriction does not form part of this License. 318 | 319 | Creative Commons may be contacted at https://creativecommons.org/. 320 | -------------------------------------------------------------------------------- /making_change.md: -------------------------------------------------------------------------------- 1 | # Making a change 2 | 3 | The next version of our code will do a little more. From domain knowledge of the data, we know that a good model for it is the equation **p1\*cos(p2\*xdata) + p2\*sin(p1*xdata)**. 4 | 5 | We just need to find the values for the parameters **p1** and **p2**. Add the following code to the end of your R script. 6 | 7 | ``` 8 | # some guesses for the parameters. 9 | p1 = 1 10 | p2 = 0.2 11 | 12 | # do the fit 13 | fit = nls(ydata ~ p1*cos(p2*xdata) + p2*sin(p1*xdata), data = mydata, start = list(p1=p1,p2=p2)) 14 | 15 | #Plot the fitted line 16 | new = data.frame(xdata = seq(min(mydata$xdata),max(mydata$xdata),len=200)) 17 | lines(new$xdata,predict(fit,newdata=new)) 18 | 19 | ``` 20 | 21 | For this version, we are also going to change the command that plots our data. Change the lines 22 | 23 | ``` 24 | plot(mydata$xdata,mydata$ydata) 25 | ``` 26 | 27 | to 28 | 29 | ``` 30 | plot(mydata$xdata,mydata$ydata,col='red') 31 | ``` 32 | 33 | We do this so we can illustrate how git handles modifications of existing lines as well as simply adding extra lines of code. 34 | 35 | Make sure the code runs before proceeding further. 36 | -------------------------------------------------------------------------------- /next_steps.md: -------------------------------------------------------------------------------- 1 | # Things we haven't told you 2 | 3 | You've come a long way! You've installed and configured all the software you need and have learned the basics required to put your code under version control and make it openly available to the world. 4 | 5 | As you've seen, the standard git workflow is fairly straightforward and adds very little overhead to your workflow once you're set up. 6 | 7 | Git and github are extremely powerful systems and there is a lot more you can learn if you wish. Here are some pointers:- 8 | 9 | * Learn command line git by following this tutorial from Software Carpentry - http://swcarpentry.github.io/git-novice/ 10 | * Make your analysis citable and more discoverable by using Zenodo to assign it a Digital Object Identifier - https://zenodo.org/features 11 | 12 | **Testing and version control** 13 | 14 | By employing testing, you can ensure that your code behaves the way you expect. 15 | 16 | * Unit testing in R, the bare minimum - http://www.johnmyleswhite.com/notebook/2010/08/17/unit-testing-in-r-the-bare-minimum/ 17 | * Continuous Integration. Every time you push a change to github, your tests are automatically run. - https://docs.travis-ci.com/user/languages/r 18 | 19 | **Dealing with dependencies** 20 | 21 | Your code works on your machine but not on someone else's because they are using a different version of R and have different versions of packages installed. How might be fix this? 22 | 23 | * https://rstudio.github.io/packrat/ - Packrat enhances your project directory by storing your package dependencies inside it. 24 | * https://mran.microsoft.com/ - MRAN, The 'Managed CRAN' has snapshots of every package going back to 2014 25 | 26 | -------------------------------------------------------------------------------- /rstudio_project.md: -------------------------------------------------------------------------------- 1 | # Creating an RStudio project 2 | 3 | A project is a folder that contains everything concerning your analysis and may include code, data and documentation. It is a complete research object that can be used to describe and reproduce your research. 4 | 5 | Create a new project in RStudio as follows: 6 | 7 | **File** -> **New Project** -> **New Directory** 8 | 9 | ![](./assets/project_screen1.png) 10 | 11 | In the **Project Type** screen, click on **Empty Project**. 12 | 13 | ![](./assets/project_screen2.png) 14 | 15 | In the **Create New Project** screen, give your project a name and ensure that **create a git repository** is checked. Click on **Create Project**. 16 | 17 | ![](./assets/project_screen3.png) 18 | 19 | RStudio will create a new folder containing an empty project and set R's working directory to within it. 20 | 21 | ![](./assets/project_files.png) 22 | 23 | Two files are created in the otherwise empty project:- 24 | 25 | * **.gitignore** - Specifies files that should be ignored by the version control ystem. 26 | * **data_analysis.Rproj** - Configuration information for the RStudio project 27 | 28 | There is no need to worry about the contents of either of these for the purposes of this tutorial. 29 | -------------------------------------------------------------------------------- /updates.md: -------------------------------------------------------------------------------- 1 | # Subsequent updates 2 | 3 | Once a local repository has been associated with github, it's not necessary to use the command line for subsequent uploads. We'll demonstrate this now by adding a **README.md** file to our project. 4 | 5 | On github, the README.md file is special since it is rendered by github and is used by many people as an introduction to the project. 6 | 7 | In RStudio, click on **File->New File->Text File**. Add the following text to the file and save it as **Readme.md**. 8 | 9 | ``` 10 | # My Example Repo 11 | 12 | This repo is used to demonstrate github to users of R and R Studio. 13 | ``` 14 | 15 | In the **git** tab of RStudio, the **Readme.md** file should be the only file you see. Stage it as shown below and click **commit**. 16 | 17 | ![](./assets/staged_readme.png) 18 | 19 | Supply a commit message and click commit. 20 | 21 | ![](./assets/readme_commit.png) 22 | 23 | Finally, click **push** to upload to github. 24 | 25 | ![](./assets/git_push.png) 26 | 27 | You can see that the standard workflow loop is very quick and simple 28 | 29 | * Make your change 30 | * Stage your change 31 | * Commit 32 | * Push to github 33 | -------------------------------------------------------------------------------- /version_control.md: -------------------------------------------------------------------------------- 1 | # Getting our project under version control 2 | 3 | We now have the first version of our analysis so let's get it under version control. By default, the git version control pane is in the top right hand corner of RStudio. Find it and click on the **git** tab. 4 | 5 | ![](./assets/git_pane.png) 6 | 7 | If you hover the mouse pointer over the yellow ? marks in github, you'll see a tooltip telling us that the file is **untracked**. This means that git is not tracking versions of this file. 8 | 9 | Tick **staged** for each file. 10 | 11 | ![](./assets/git_pane_added.png) 12 | 13 | All of our files are now **staged**, ready for the first **commit**. Click on the **commit** button 14 | 15 | ![](./assets/commit.png) 16 | 17 | Details of the commit will appear in the next pane. You need to specifiy a **commit message** -- something descriptive about the changes you've made. Since this is our first commit, we'll follow tradition and call it **First Commit** 18 | 19 | Once you've typed a commit message, click on **Commit** and you're done. 20 | 21 | ![](./assets/first_commit.png) 22 | 23 | The following messages from git will shown. 24 | 25 | ![](./assets/git_commit_message.png) 26 | 27 | Click on **Close** and you are done. 28 | --------------------------------------------------------------------------------