-2

There is a zip archive stored on the internet. I want to download it to my computer and read it into R with the single code.

someURL<-"http://www.stat.ucla.edu/~vlew/datasets/spssSTUFF.zip"
download.file(someURL,"ucpay.zip")
unzip("ucpay.zip", exdir = "ucpaydata")
list.files("ucpaydata")

I have downloaded the files, now i have a problem, how could I read them all into R using at most one line of code (no semi-colons allowed but nesting and piping are OK).

Bilal Para
  • 65
  • 1
  • 8
  • 4
    *"at most one line of code (no semi-colons allowed but nesting and piping are OK)"* Sounds like homework. [What have you tried so far?](https://meta.stackoverflow.com/questions/334822/how-do-i-ask-and-answer-homework-questions) – Maurits Evers Jul 28 '19 at 13:00
  • Just modify the code (nesting, piping) in answers to this question to meet your constraints. Possible duplicate of [How to import multiple .csv files at once?](https://stackoverflow.com/questions/11433432/how-to-import-multiple-csv-files-at-once) – Shree Jul 28 '19 at 13:07
  • seems like you've done 99% of the work already... well done! all that's left is to wrap what you've done into a function :) – MichaelChirico Jul 28 '19 at 13:08
  • Do you have other rules? Any time restriction? I felt like I am in a competition. – maydin Jul 28 '19 at 13:09

1 Answers1

0

Here is one way to do it.

files = list.files("ucpaydata")
Df = do.call(rbind(lapply(files, function(x) {read.csv(x, header = T)})))
Not_Dave
  • 491
  • 2
  • 8