Reading data    into                REVISED  2012-10-05@HSPH Kazuki Yoshida, M.D.  MPH-CLE student                        ...
Previously in this groupn   Introduction to Rn   Reading Data into R (1)                  Group Website: http://rpubs.co...
Menun   Configuring RStudion   Installing/Loading packagesn   Reading text files inn   Reading excel files inn   (Readin...
Ingredients        Statistics          Programmingn   None            n   Install/Load packages                     n  ...
http://mediacrushllc.com/2012/internet-statistics-2012/                            is the study of thecollection, organiza...
Supportedn   .RData (native): load()n   .csv & text files: read.csv(), etcn   .xls/.xlsx: library(gdata) or library(xlsx...
Create a folder for this study group  This will be your working directory.
Firstconfigure   Studio
OpenR Studio
WorkspaceConsole            Plot
Tools-Options
Restart RStudioafter cofiguration
Working directory? Folder your are   working in
CRANmirror
Comprehensive      R                             You get                                  additional      Archive         ...
Createa script
Source    WorkspaceConsole     Plot
Installadditionalpackages
Install packages!   foreign sas7bdat XML                      gdata                       xlsx
programmingway to load it   Click to loadlibrary(gdata)                  packages
Use text filesuch as csv if possible
Download comma-separated and Excel Put them in folderBONEDEN.DAT.txtBONEDEN.DAT.xls        http://www.cengage.com/cgi-wads...
For comma-, tab-, orspace-separated text,  GUI is available
Text
name of a dataset here                               file name herebone <- read.csv(“BONEDEN.DAT.txt”)  function to read .c...
Excel next
Use gdata package             library(gdata)bone <- read.xls(“BONEDEN.DAT.xls”)
Use xlsx package                     library(xlsx)bone <- read.xlsx(“BONEDEN.DAT.xls”, sheetIndex = 1)
Never type all      Always hit TAB                   http://www.clickykeyboards.com/index.cfm/fa/                 items.ma...
Never type all    F1 for help                  Always hit TAB                             http://www.clickykeyboards.com/i...
Follow on-site instructions
library(foreign)  bone <- read.xport(“BONEDEN.DAT.xpt”)                     or                 library(sas7bdat)bone <- re...
library(foreign)bone <- read.dta(“BONEDEN.DAT.dta”)
HTML table!             http://         www.drugs.com/        top200_2003.html
library(XML)drug2003 <- readHTMLTable("http://www.drugs.com/    top200_2003.html", which = 2, skip.rows = 1)
Menun   Configuring RStudion   Installing/Loading packagesn   Reading text files inn   Reading excel files inn   (Readin...
Ingredients        Statistics          Programmingn   None            n   Install/Load packages                     n  ...
Reading Data into R REVISED
Reading Data into R REVISED
Upcoming SlideShare
Loading in...5
×

Reading Data into R REVISED

33,258

Published on

Published in: Education
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
33,258
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
49
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Reading Data into R REVISED

    1. 1. Reading data into REVISED 2012-10-05@HSPH Kazuki Yoshida, M.D. MPH-CLE student FREEDOM TO  KNOW
    2. 2. Previously in this groupn Introduction to Rn Reading Data into R (1) Group Website: http://rpubs.com/kaz_yos/useR_at_HSPH
    3. 3. Menun Configuring RStudion Installing/Loading packagesn Reading text files inn Reading excel files inn (Reading other files in)
    4. 4. Ingredients Statistics Programmingn None n Install/Load packages n read.____() functions n <- (assignment)
    5. 5. http://mediacrushllc.com/2012/internet-statistics-2012/ is the study of thecollection, organization, analysis, interpretation, and presentation of data http://en.wikipedia.org/wiki/Statistics
    6. 6. Supportedn .RData (native): load()n .csv & text files: read.csv(), etcn .xls/.xlsx: library(gdata) or library(xlsx)n .sas7bdat: read.sas7bdat() via library(sas7bdat)n .dta: read.dta via library(foreign)n and more... http://cran.r-project.org/doc/manuals/R-data.html
    7. 7. Create a folder for this study group This will be your working directory.
    8. 8. Firstconfigure Studio
    9. 9. OpenR Studio
    10. 10. WorkspaceConsole Plot
    11. 11. Tools-Options
    12. 12. Restart RStudioafter cofiguration
    13. 13. Working directory? Folder your are working in
    14. 14. CRANmirror
    15. 15. Comprehensive R You get additional Archive functionalities from here! Networkhttp://cran.r-project.org/web/packages/ available_packages_by_date.html
    16. 16. Createa script
    17. 17. Source WorkspaceConsole Plot
    18. 18. Installadditionalpackages
    19. 19. Install packages! foreign sas7bdat XML gdata xlsx
    20. 20. programmingway to load it Click to loadlibrary(gdata) packages
    21. 21. Use text filesuch as csv if possible
    22. 22. Download comma-separated and Excel Put them in folderBONEDEN.DAT.txtBONEDEN.DAT.xls http://www.cengage.com/cgi-wadsworth/course_products_wp.pl? fid=M20bI&product_isbn_issn=9780538733496
    23. 23. For comma-, tab-, orspace-separated text, GUI is available
    24. 24. Text
    25. 25. name of a dataset here file name herebone <- read.csv(“BONEDEN.DAT.txt”) function to read .csv files
    26. 26. Excel next
    27. 27. Use gdata package library(gdata)bone <- read.xls(“BONEDEN.DAT.xls”)
    28. 28. Use xlsx package library(xlsx)bone <- read.xlsx(“BONEDEN.DAT.xls”, sheetIndex = 1)
    29. 29. Never type all Always hit TAB http://www.clickykeyboards.com/index.cfm/fa/ items.main/parentcat/10191/subcatid/0/id/179764
    30. 30. Never type all F1 for help Always hit TAB http://www.clickykeyboards.com/index.cfm/fa/ items.main/parentcat/10191/subcatid/0/id/179764
    31. 31. Follow on-site instructions
    32. 32. library(foreign) bone <- read.xport(“BONEDEN.DAT.xpt”) or library(sas7bdat)bone <- read.sas7bdat(“BONEDEN.DAT.sas7bdat”)
    33. 33. library(foreign)bone <- read.dta(“BONEDEN.DAT.dta”)
    34. 34. HTML table! http:// www.drugs.com/ top200_2003.html
    35. 35. library(XML)drug2003 <- readHTMLTable("http://www.drugs.com/ top200_2003.html", which = 2, skip.rows = 1)
    36. 36. Menun Configuring RStudion Installing/Loading packagesn Reading text files inn Reading excel files inn (Reading other files in)
    37. 37. Ingredients Statistics Programmingn None n Install/Load packages n read.____() functions n <- (assignment)
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×