Code Monkey home page Code Monkey logo

loaddata's Introduction

Load external data from a .csv file into a data frame


Try by intuition

Document what you did.

# Some code goes here

Back to the lesson

To download the data into the data/ subdirectory, run the following:

WARNING: This will fail. Why? (Run and read the error message)

Hint: * Look in the Files tab. What's missing? * What are the first two arguments of download.file()? * Find out with the help of autocompletion (press TAB) or with ?

# MISTERY-FUNCTION-GOES-HERE("data")

download.file(
  "https://ndownloader.figshare.com/files/2292169",
  "data/portal_data_joined.csv"
)
#> Warning in download.file("https://ndownloader.figshare.com/files/
#> 2292169", : URL https://ndownloader.figshare.com/files/2292169: cannot open
#> destfile 'data/portal_data_joined.csv', reason 'No such file or directory'
#> Warning in download.file("https://ndownloader.figshare.com/files/
#> 2292169", : download had nonzero exit status

You are now ready to load the data:

surveys <- read.csv("data/portal_data_joined.csv")

Print the variable's value: surveys

# WARNING: In the console, this prints looooong output
surveys

Let's check the top (the first 6 lines) of this data frame using the function head():

head(surveys)
#>   record_id month day year plot_id species_id sex hindfoot_length weight
#> 1         1     7  16 1977       2         NL   M              32     NA
#> 2        72     8  19 1977       2         NL   M              31     NA
#> 3       224     9  13 1977       2         NL                  NA     NA
#> 4       266    10  16 1977       2         NL                  NA     NA
#> 5       349    11  12 1977       2         NL                  NA     NA
#> 6       363    11  12 1977       2         NL                  NA     NA
#>     genus  species   taxa plot_type
#> 1 Neotoma albigula Rodent   Control
#> 2 Neotoma albigula Rodent   Control
#> 3 Neotoma albigula Rodent   Control
#> 4 Neotoma albigula Rodent   Control
#> 5 Neotoma albigula Rodent   Control
#> 6 Neotoma albigula Rodent   Control

Thank you

loaddata's People

Contributors

maurolepore avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.