Extracting and importing untidy Excel tables into R to wrangle for Tableau export - r

I want to read in to R an EXCEL tab that has the following content configuration into a more Tidy data format. The next picture shows how I want the content to look like once all of the code has run. The table below just represents file that will come in daily. Each day, the numbers and the date will change, but the format will be exactly the same. So I need to learn how to automate the extraction of the pieces of this format into R from EXCEL. The end goal is to stack the daily data into a format that can be exported to Tableau.
The image above (figure 2) represents the final format I want to arrive at. I know there are several packages to read in EXCEL data into R, however I cannot figure out how I can possibly automate this tasks with readr or readxl etc... I am at least hoping some one has faced this type of problem before and can give me general directions.

Related

R How to create image files from Excel range

I am trying to find a way to take a snapshot of a given cell range within an Excel workbook, that has been created by openxlsx in R, and generate a picture file with that snapshot. I have seen many posts about how to insert pictures into Excel, and one post about how to create a snapshot/chart combo however no luck with a simple picture export. Is there an openxlsx code, or other R package, that can assist with this?

extracting data from matlab file in R

It's the first time I deal with Matlab files in R.
The rationale for saving the information in a .mat file type was the length. (the dataset contains 226518 rows). We were worried to excel (and then a csv) would not take them.
I can upload the original file if necessary
So I have my Matlab file and when I open it in Matlab all good.
There are various arrays and the one I want is called "allPoints"
I can open it and then see that it contains values around 0.something.
Screenshot:
What I want to do is to extract the same data in R.
library(R.matlab)
df <- readMat("170314_Col_HD_R20_339-381um_DNNhalf_PPP1-EN_CellWallThickness.mat")
str(df)
And here I get stuck. How do I pull out "allPoints" from it. $ does not seem to work.
I will have multiple files that need to be put together in one single dataframe in R so the plan is to mutate each extracted df generating a new column for sample and then I will rbind together.
Could anybody help?

How to load a xls or csv data file to work with the rugarch and rmgarch packages in R

I am new to R and have just started to use it. I am currently experimenting with the quantmod, rugarch and rmgarch packages.
In particular, I'm implementing the last package to make a multivariate portfolio analysis for the case of the european markets. In this sense, I need to download the 3-month german treasury bills, in order to use them as risk free rate. However, as far as I known, I canĀ“t download the the mentioned data serie from Yahoo, Google or FDRA databases, so I have already downloaded them from investing.com and I want to load them in R.
The fact here is, my data is different from the ones downloaded by the getsymbols () function of yahoo, because in this case I only have 2 columns, the date column and the closing price column. To sump up, the question arises here is, is there any way to load this type of data in R for rmgarch purposes??
thanks in advance
Not sure if this is the issue, but this is how you might go about getting the data from a csv file.
data <- read.csv(file="file/path/data.csv")
head(data) # Take a look at your data
# Do this if you want the data only replacing ColumnName with the proper name
data_only <- data$ColumnName
It looks like the input data for rugarch needs to be an xts vector. So, you might want to take a look at this. You might also want to take a look at ?read.csv.

Extract data from tableau server to r data frame

We currently have a database that can only be accessed via a Tableau front end.
Is it possible with R (or any other means) to be able to extract the underlying data table into csv or txt? I don't really care what it ends up as so long as it is structured and can read into a data frame.
I can see from some looking around that I can use R scripting within Tableau but I cannot see a method to go the other way and pull data out of the Tableau Worksheet.
Any help appreciated!

R monthly plot with GGPlot2 in RMarkdown

I have a CSV file with the following data:
RegistrationDate;User_Id;Items
RegistrationDate has format like '22.05.2014 14:25'
Is there any easy way to connect CSV data to R markdown script? All of examples I've seen use random generated data, that looks too bad for reproducible research.
I need to create 2 plots with ggplot2:
a plot of users count per month.
a plot of items collected per month
I've checked a lot of graphs looks close to this one, but didn't find any right version. Looks like I don't understand something about R plotting :(.
What do you mean when you say "connect" CSV data to R markdown sript?
You mean reading them?
data <- read.csv("directory/name.csv", sep=";")
Or you mean adding somewhere a specific relation, telling that this data is related to this analysis? If the second, you can check the archivist package, stored on GitHub, that possess a set of tools for datasets and figures archivisation. There is a information how to install that package.
In question 2, you will need an extra column that specifies the month.

Resources