1

A quick question: how can I import data that someone posts as a sample on their SO question into R?

For example, people often put something like this up as their sample data in a question on here:

    name order_no
1    Amy       12
2   Jack       14
3   Jack       16
4   Dave       11
5    Amy       12
6   Jack       16
7    Tom       19
8  Larry       22
9    Tom       19
10  Dave       11
11  Jack       17
12   Tom       20
13   Amy       23
14  Jack       16

How can I quickly store that as a data.frame in R to try and work on the question?

moman822
  • 1,904
  • 3
  • 19
  • 33
  • Without pointing the asker here? http://stackoverflow.com/a/5963610/2773500 – MikeRSpencer Oct 03 '16 at 17:05
  • @MikeR I guess the OP is asking about reading more than writing. – Frank Oct 03 '16 at 17:05
  • 2
    Using what Zheyuan said, I usually (1) copy, (2) type `read.table(text = "`, (3) paste, (4) write `")`... or I do that except using `fread` from data.table. – Frank Oct 03 '16 at 17:07
  • 1
    @Frank - exactly. Often what happens is someone points the asker to that answer and gets them to re-write the question. – MikeRSpencer Oct 03 '16 at 17:09
  • related question: http://stackoverflow.com/questions/23372627/speed-up-reading-data-in-console-using-read-tabletext-rstudio – C8H10N4O2 Oct 03 '16 at 17:10
  • Oh, good point, now I see what you meant @MikeRSpencer – Frank Oct 03 '16 at 17:10
  • 1
    Exactly - if a user doesn't make it easy for me to help them then I just don't help them until they do make it easy. – Dason Oct 03 '16 at 17:14

0 Answers0