5

I feel that in this forum there is a preference for embedding data in a line of code instead of loading an external data source such as the below.

test <- read.csv("http://dl.dropbox.com/u/9641130/R/eu27.csv", sep=',')[2]

I'd like to comply with this social code, but I am puzzled whether there is an easy way to generate a line of code of the above csv-source that I can publish in this forum so that people can reproduce the problem I am posting?

Understanding how this works will help me make better posts in the future.

0

2 Answers 2

2

Using dropbox is perfectly fine and even preferred if a large dataset is needed to replicate the problem and you are willing/allowed to share your real data.

If only a small part of your data is needed, it might be too much effort to upload it somewhere. There is a FAQ explaining how to post data in a way that allows others to easily import it into their R session. It might also be convenient to use one of the datasets provided with R or one of the packages.

Often, creating mock-up data is simply the least effort and allows others to understand the structure of your data easily.

1
  • 1
    Hi Roland, the only part of this that I would change is to also include something inline. Dropbox is okay, but if the dropbox like were to break and the users couldn't replicate the problem, then that would be bad.
    – jmort253
    Nov 12, 2012 at 2:53
2

OK Roland's answer let me to the solution and that is:

test <- structure(list(Series = c(88.3, 97.1, 110.2, 93.1, 104.7, 102.6, 
94.8, 85.6, 103.8, 109.6, 111.4, 98.6, 102.5, 101.8, 113.6, 99, 
104.6, 106, 99.2, 87.5, 101.6, 111.3, 106.9, 91.6, 99.4, 100.3, 
108.3, 106.2, 104.1, 105.2, 103.9, 85.8, 107.5, 113.7, 110, 97, 
101.6, 102.4, 112, 104.1, 103.3, 104.4, 106.1, 83.9, 112.2, 117.7, 
110.2, 104.7, 101.8, 106.9, 123.3, 112.5, 108.7, 117.4, 109.3, 
92.3, 118, 117.6, 121.3, 108, 106.5, 109.6, 121, 116.3, 114, 
121.8, 109.9, 99.1, 124, 121.2, 128.2, 113.1, 117.5, 119.4, 139.9, 
119.4, 131, 131.3, 117.1, 107.1, 128.7, 133.7, 134.6, 115.3, 
126.3, 124.9, 140.5, 123.6, 129.9, 132.9, 127.6, 113.1, 130, 
141.5, 139.4, 112.8, 132.5, 133.8, 132.7, 138.7, 128.5, 133.2, 
130.8, 105.5, 134.4, 134.4, 118.3, 99.9, 102.8, 103.3, 113.8, 
104.6, 101.4, 109.9, 109.9, 90.6, 118.1, 119.8, 115.8, 104.2, 
104.3, 109.5, 128.7, 116.2, 115.2, 126.2, 116.9, 102.6, 127, 
126.6, 129, 115.3, 115.8, 118.4, 137.3, 119.4, 128.1, 125.7, 
117.1, 109.4, 130.3, 123.7, 127.9, 111.3, 117.1, 120.5, 132, 
115.5, 123.3, 122.9, 118.3)), .Names = "Series", class = "data.frame", row.names = c(NA, 
-151L))

Which is obtained by:

test <- dput(read.csv("http://dl.dropbox.com/u/9641130/R/eu27.csv", sep=',')[2])

Thanks!

2
  • 1
    Great. Let's also mention that when you use dropbox, we never know how long you or dropbox will keep your data there. That may be a problem for people reading your questions months, years from now.
    – flodel
    Nov 10, 2012 at 11:16
  • @flodel that was exactly my concern about posting with links to dropbox and that is why I asked the question to start with. Thanks.
    – Jochem
    Nov 10, 2012 at 15:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .