IDEMSInternational / R-Instat

A statistics software package powered by R
http://r-instat.org/
GNU General Public License v3.0
38 stars 103 forks source link

Importing a file from a web site #6196

Open rdstern opened 3 years ago

rdstern commented 3 years ago

I am wanting to improve logistic regression in R-Instat. A useful resource is here.

It uses data from their web site and the commands there are as follows:

For our data analysis below, we are going to expand on Example 2 about getting into graduate school. 
We have generated hypothetical data, which can be obtained from our website from within R. 
Note that R requires forward slashes (/) not back slashes () when specifying a file location even if the file is on 
your hard drive.

mydata <- read.csv("https://stats.idre.ucla.edu/stat/data/binary.csv")

I would like to access this data file using our current Fil > Open from File dialogue. I suppose in the current dialogue I could use the Browse and search for the location. But it would be much simpler to copy the location from the chapter and then just paste it into the dialogue?

Is that true? If so, then could we allow pasting into that field? Would anything else need to change? Otherwise could another solution be suggested?

Aha - @dannyparsons doesn't want pasting, but thinks it should be pretty easy. He will add to this message. Contact him if you need to.

I checked this works by getting the script and pasting there. I also then changed the names of the resulting data.

# Code generated by the dialog, Import Dataset

class <- rio::import(file="https://stats.idre.ucla.edu/stat/data/binary.csv")
data_book$import_data(data_tables=list(class=class))

rm(class)

For reference I attach a copy of the data. class.xlsx

dannyparsons commented 3 years ago

Actually, I wouldn't mind if the file location textbox was editable and you could paste a web link in there instead.

However, it's not a trivial change.

This change probably shouldn't happen until after @Patowhiz has finished working on this dialog. Once that's done, this could be the next improvement to the dialog.

N-thony commented 3 years ago

Actually, I wouldn't mind if the file location textbox was editable and you could paste a web link in there instead.

However, it's not a trivial change.

  • The dialog options need to adapt based on the file type of the selected file, this need to also work for a web link. This also has implications for the file control that Patrick has created.
  • The preview currently displays automatically, and refreshes with every option change. I would suggest this shouldn't be done automatically for a weblink, only if you request a preview, to avoid continuously downloading files. So this needs a change in the dialog functionality.

This change probably shouldn't happen until after @Patowhiz has finished working on this dialog. Once that's done, this could be the next improvement to the dialog.

Okay, @dannyparsons thanks for the information about the change requested in this dialog. I will then work on it when @Patowhiz will finish working on this dialog.

rdstern commented 3 years ago

@Patowhiz now is the time to add this feature to the File > Open Data Frame dialogue. You may want to finish the refactoring first? @dannyparsons suggests any file format could also result, so the main part of the dialogue doesn't need to change. Just the location. He suggests that there may be option buttons, or a checkbox for File (what we have now) and url. Not sure of the label. So it is getting the file either from the local machine, or from somewhere else.

In either case, this dialogue is designed to read/import data. In addition - not this dialogue - we want to consider how we could do some modest "web-scraping". This is, in particular, reading an HTML (XML) file and then locating the data within the file. That will be a different dialogue. (Again, I assume html files could either be stored locally, or could be on the web.)