Download excel file from an ArcGIS rest endpoint using R - r

I'm trying to download the excel file stored at https://www.arcgis.com/sharing/rest/content/items/b5e7488e117749c19881cce45db13f7e/data (website: https://www.folkhalsomyndigheten.se/smittskydd-beredskap/utbrott/aktuella-utbrott/covid-19/bekraftade-fall-i-sverige) with COVID-19 data on Sweden. The data is freely available and is stored on an ArcGIS infrastructure.
I tried with download.file() but the what is produced is not the excel but some unreadable file whose actual format is not clear to me.
I tried to investigate the ArcGis Rest API but I couldn't find a simple solution.
Do you have any guidance on how to do this with R or with a general CURL/WGET based infrastructure?

Related

Is there an R package to import VSAM files as a tbble or dataframe?

I am looking for ways to process VSAM files with R and export as a csv.
I have been searching the web and have not been able to find any methods of using R to read VSAM files.
A little more information would be of use. How are you going to get the data from the VSAM files? Are you reading directly from an IBM system? What access method will you be using? What is the structure of the file you are reading since since if you want it to be put in a data.frame, is it something like a CSV file already?. So any other particulars would be helpful.

R Leaflet loading lat/long from csv

I can make a R-Leaflet map in RStudio and export to html.
Here's the senario, a client has limited web infrastructure, basic webhosting: no database, no shiny server, no r-server etc.
They want an online map on their website which can be updated (by them), so how can I link the html so it looks up the coordinate from a file rather than being hard coded in the script (e.g. through src="lat-long.csv"). Alternatively could a shape file be accessed (using the SP library)? Or even a Geojson file.

How to store r results in tableau extract? We want to share the tableau workbook with users who do not have R or Rserver installed

There are users who do not have R installed on their machine. We want to share the tableau workbook with them. Is it possible to include the results from R script execution in the extract and use that data instead of live execution every time you open the workbook?
Tableau's R integration requires LIVE connection to R Server, therefore it cannot store any data that you calculate using R.
SOLUTION: Run R code and store the result to Rdata/CSV file that you can then directly connect to in Tableau.
Let's say you have a Tableau workbook that uses as a connection excel files (one or many). If the excel files are generated with R, or with another automatic process, I embed those files with the Tableau workbook with extension .twbx, so I can share the report.
In order to embed the excel file/s with the Tableau Workbook I do the following:
Make sure you have in the same folder a Tableau workbook and the connection files. The Tableau workbook has extension .twb, and the connection files are, for instance, 'data_a.xlsx' and 'data_b.xlsx'.
Then I just zip the Tableau workbook with the data files with extension .twbx:
workbook_name <- 'charges'
workbook_data <- c('data_a.xlsx', 'data_b.xlsx')
zip(paste0(workbook_name, '.twbx'),
files=c(workbook_data,
paste0(workbook_name, '.twb'))
)
Then you have a Tableau workbook with the data updated using R.

Reading LabVIEW TDMS files with R

As part of a transition from MATLAB to R, I am trying to figure out how to read TDMS files created with National Instruments LabVIEW using R. TDMS is a fairly complex binary file format (http://www.ni.com/white-paper/5696/en/).
Add-ons exist for excel and open-office (http://www.ni.com/white-paper/3727/en/), and I could make something in LabVIEW to make the conversion, but I am looking for a solution that would let me read the TDMS files directly into R. This would allow us to test out the use of R for certain data processing requirements without changing what we do earlier in the data acquisition process. Having a simple process would also reduce the barriers to others trying out R for this purpose.
Does anyone have any experience with reading TDMS files directly into R, that they could share?
This is far from supporting all TDMS specifications but I started a port of a python npTDMS package into R here https://github.com/msuefishlab/tdmsreader and it has been tested out in the context of a shiny app here
You don't say if you need to automate the reading of these files using R, or just convert the data manually. I'm assuming you or your colleagues don't have any access to LabVIEW yourselves otherwise you could just create a LabVIEW tool to do the conversion (and build it as a standalone application or DLL, if you have the professional development system or app builder - you could run the built app from your R code by passing parameters on a command line).
The document on your first link refers to (a) add-ins for OpenOffice Calc and for Excel, which should work for a manual conversion and which you might be able to automate using those programs' respective macro languages, and (b) a C DLL for reading TDMS - would it be possible for you to use one of those?

R dataset connection to tableau

Recently tableau gave the functionality of R connection in their release 8.1. I want to know if there is any way i can call an entire table created in R to tableau. Or an .rds object which contains the dataset into Tableau?
There is a tutorial on the Tableau website for this and a blog on r-bloggers which discuss. The tutorial has a number of comments and one of them (in early Dec I think) asks how to get an rds file in. You need to start Rserve and then execute a script on it to get your data.
Sorry I can't be more help as I only looked into it briefly and put it on the back-burner but if you get stuck they seem to come back quickly if you post a comment on the page:
http://www.tableausoftware.com/about/blog/2013/10/tableau-81-and-r-25327
Just pointing out that the Tableau Data Extract API might be useful here, even if the current version of R integration doesn't yet meet your needs. (Note, that link is to the version 8.1 docs released in late 2013 - so look for the latest version to see what functionality they've added since)
If what you want to do is to manipulate data in R and then send a table of data to Tableau for visualization, you could first try the simple step of exporting the data from R as a CSV file and then visualizing that data in Tableau. I know that's not sexy, but its always good to make sure you've got a way to get the output result you need before investing time in optimizing the process.
If that gets the effect you want, but you just want to automate more of the steps, then take a look at the Tableau Data Extract API. You could use that library to generate a Tableau Data Extract instead of a CSV file. If you have something in production that needs updates, then you could presumably create a python script or JVM program to read your RDS file periodically and generate a revised extract.
Let us assume your data.frame/ tibble etc (say dataset object) is ready in R/ RStudio and you want to connect it with Tableau
1. In RStudio (or R terminal), execute the following steps:
install.packages("Rserve")
library(Rserve)
Rserve() ##This gets the R connection service up and running
2. Now go to Tableau (I am using 10.3.2):
Help > Settings and Performances > Manage External Service Connection
Enter localhost in the Server field and click on Test Connection.
You have now established a connection between R and Tableau.
3. Come back to RStudio. Now we need a .rdatafile that will consist of our R object(s). In this case, dataset. This is the R object that we want to use in Tableau. Enter this in the R console:
save(dataset, file="objectName.rdata")
4. Switch to Tableau now.
Connect To a File > Statistical File
Go to your working directory where the newly created objectName.rdata resides. From the drop down list of file type, select R files (*.rdata, *.rda) and select your object. This will open the object you created in R in Tableau. Alternatively, you can drag and drop your object directly to Tableau's workspace.

Resources