User Tools

Site Tools


r:input_output

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
r:input_output [2018/11/16 08:26] – [Reading from CSV Files] hkimscilr:input_output [2019/09/20 10:32] (current) – [Reading from CSV Files] hkimscil
Line 69: Line 69:
 Yates     Frank     1902 1994 Yates     Frank     1902 1994
 Smith     Kirstine  1878 1939 Smith     Kirstine  1878 1939
 +
 </code> </code>
  
-<code>> records <- read.fwf("fixed-width.txt", widths=c(10,10,4,-1,4))+<code>> records <- read.fwf("http://commres.net/wiki/_export/code/r/input_output?codeblock=11", widths=c(10,10,4,-1,4))
 </code> </code>
  
Line 86: Line 87:
 Funky variable names (V1, V2, . . .). Use the below method with "col.names=c()" option. Funky variable names (V1, V2, . . .). Use the below method with "col.names=c()" option.
  
-<code>> records <- read.fwf("fixed-width.txt", widths=c(10,10,4,-1,4),+<code>> records <- read.fwf("http://commres.net/wiki/_export/code/r/input_output?codeblock=11", widths=c(10,10,4,-1,4),
 +                     col.names=c("Last","First","Born","Died")) +                     col.names=c("Last","First","Born","Died"))
 > records > records
Line 164: Line 165:
 </code> </code>
  
-<code>> tbl <- read.csv("filename")+<code>> tbl <- read.csv("filename.csv")
 > tbl</code> > tbl</code>
  
-<code>> tbl <- read.csv("filename", header=FALSE)+<code>> tbl <- read.csv("filename.csv", header=FALSE)
 > tbl</code> > tbl</code>
  
-<code>> tbl <- read.csv("filename", header=FALSE, sep="\t")+<code>> tbl <- read.csv("filename.csv", header=FALSE, sep="\t")
 > tbl</code> > tbl</code>
  
Line 229: Line 230:
 > url <- 'http://en.wikipedia.org/wiki/World_population' > url <- 'http://en.wikipedia.org/wiki/World_population'
 > tbls <- readHTMLTable(url) > tbls <- readHTMLTable(url)
 +</code>
 +
 +The above not working for me. :(
 +
 +<code>library(httr)
 +url <- 'http://en.wikipedia.org/wiki/World_population'
 +tables <- GET(url)
 +tables <- readHTMLTable(rawToChar(tables$content))
 </code> </code>
  
r/input_output.1542324383.txt.gz · Last modified: 2018/11/16 08:26 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki