0

I am trying to download polling data into R for some regressions. How do I download it in R? I am trying to download ANES data from the CSV form. It is not working for some reason right now.

I am trying to download it from either: https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/FXGD96 or https://electionstudies.org/data-center/2016-time-series-study/ when I try to open it, and I download the CSV, I get error messages.

I have tried it before, but my data sets aren't working anymore.

Sorry for being bad at stackoverflow, I'm new to it.

Irene
  • 11
  • 2
  • 3
    What code are you using? Where are you downloading it from? When you say "it is not working" - is there an error message or a warning? Or the file download but you can't find it? Or R crashes? Something else? – Gregor Thomas Nov 20 '22 at 20:08
  • 1
    Please edit your question to include these important details, don't bury them in the comments. – Gregor Thomas Nov 20 '22 at 20:12
  • 2
    *"I get error messages"*, can you show the code you attempted and the errors you get? For help on how to make questions more _reproducible_ (and therefore much more likely to get a rapid and accurate answer), see https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info – r2evans Nov 20 '22 at 20:26
  • The right way to "get good at StackOverflow" is to read the help pages https://meta.stackoverflow.com/help like [ask] and and review the MetaStackOverflow pages that address issues you might be having. And you _should_ have [edit]-ed the body of your question to add requested detail outlined by @r2evans and GregorThomas. – IRTFM Nov 23 '22 at 01:48

1 Answers1

0

You need to include the full text of all error messages following the code you used just before you got the error.

The webpages linked from https://electionstudies.org/data-center/2020-time-series-study/ let you choose file types by clicking on an icon with a text label for the file type. When I click on the CSV icon at the page for the 2020 election, it is actually sending me to https://electionstudies.org/anes_timeseries_2020_csv_20220210/ The page has code that automagically wants me to download not a csv file but rather a zip file.

download.file( url = "https://electionstudies.org/anes_timeseries_2020_csv_20220210/" , 
     dest = "~/Downloads/2020ANES.zip")  #name of destination
#trying URL 'https://electionstudies.org/anes_timeseries_2020_csv_20220210/'
#Content type 'application/x-zip-compressed' length 7777954 bytes (7.4 MB)
#=====builds a progress bar ========================
# downloaded 7.4 MB   (completion message appears)

You then need to extract the data from the zip file with your system tools or perhaps with r functions.

IRTFM
  • 258,963
  • 21
  • 364
  • 487
  • How do you get a link? When I click the SAV it just downloads to my computer and it opens in downloads, in finder, anes_timeseries_2016_sav (7) 3 – Irene Nov 22 '22 at 20:11
  • Once I was at the data-center page and navigated to the particular year, 2020 in this case, I right-clicked on the CSV icon and picked "copy link address" from the dropdown menu .... you did say you wanted csv didn't you? Why would you be doing anything with the SAV icon? That's not for csv-formatted data downloads. – IRTFM Nov 23 '22 at 01:46