Doing one massive export - r

I have 23 data frames listed as followed sorted into 3 seperate lists link to project https://posit.cloud/content/4971864
final_dfs_2015= list(July_2015F,August_2015F, Sept_2015F,Oct_2015F,Dec_2015f)
final_dfs_2016= list(Jan_2016f, Feb_2016F, March_2016f,April_2016f,May_2016f,June_2016f,July_2016f,Aug_2016f, Sept_2016f, Oct_2016f, Nov_2016f, Dec_2016f)
final_dfs_2017= list(Jan_2017f, Feb_2017f,March_2017f,Apri_2017f,May_2017f,June_2017f)
id also like to add the file name as the name of each graph if possible
I am using
barplot(height=Sept_2015F$Frequency,
names=Sept_2015F$arrival_date_day_of_month, col="#69b3a2")
to create plots however something i want to learn is how would i combine the lists if possible with the barplot and some form of exporting to mass export plots all at once
all dataframes have the same 2 columns "arrival_date_day_of_month, frequency"
Im not sure what kind of export to use and how to combine all the things i want to do at once with the data if anyone has any sources on that overall idea id love to read on them.

Related

Extract table from a PDF with multiple headers (R)

I am trying to get some epidemiological data stored in a pdf that is publicly available
link.
I am just looking at the data in page 9 (right table).
What I would like to achieve is to pass the data into a table, but since I have many headers, it's quite dificult to achieve this. Example: The column SIDA is divided in two further columns (SEM and ACUM). Would it be possible to split the SIDA cell?
So far I have tried to extract the data using pdftools and tabulizer.

Export dataframe to multiple excel workbooks in R with conditional formatting intact

I have a dataset that I'd like to export to multiple Excel workbooks with conditional formatting. I can't post the actual data, but a sample is below. Essentially, I've got a dataset showing whether or an individual qualifies for a survey, what department and team within the department they are in:
Survey Status
Department
Team
1
Budget Off
Acts
0
Budget Off
Acts
1
Sales
Local
1
Public Rel
Social
I want to do the following:
Conditionally format the data so that rows with a survey status of 1 are in bold, black text and rows with a survey status of 0 are in non-bold, red text for easier reading.
Maintain this formatting when exporting to Excel.
Creating an individual workbook for each Department/Team grouping.
I can format the data how I'd like within R, and I can create an individual workbook for each Department/Team grouping without a problem.
The issue is that the formatting gets lost. I've tried a few different packages, including xlsx, openxlsx, formattable, and condformat, but can't seem to bridge the gap so that the formatting is applied within the Excel files.
I was previously able to do this is SAS with no problems. We're transitioning to R, which is why I'm recreating these documents. However, I'm wondering if R is the best choice for this procedure. Perhaps Python would be better?
Thanks in advance for all your help. The SO community is my lifeline in learning to code, and has been an invaluable resource.
Finally discovered the problem with the help of YouTuber CradleToGraveR. User error! It was in the formula for the "rule" within conditionalFormatting()
I had been using the formatting examples in the documentation for openxlsx (e.g., rule = "$colname=1", but applying it to a string (e.g., rule = "$colname=YES"), which is why Excel didn't recognize it.
When conditionally formatting strings, use single quotes around the rule with double quotes around the value (e.g., rule = '$colname="YES"').
CradleToGraveR shows how to format for text values in this video, https://www.youtube.com/watch?v=ACdCQuQJxhU

Paste name of column to other columns in R?

I have recently received an output from the online survey (ESRI Survey123), storing the each recored attribte as a new column of teh table. The survey reports characteristics of single trees located on study site: e.g. beech1, beech2, etc. For each beech, several attributes are recorded such as height, shape, etc.
This is how the output table looks like in Excel. ID simply represent the site number:
Now I wonder, how can I read those data into R to make sure that columns 1:3 belong to beech1, columns 4:6 represent beech2, etc.? I am looking for something that would paste the beech1 into names of the following columns: beech1.height, beech1.shape. But I am not sure how to do it?

how do I join and center attributes of the same name in a DataFrame in R?

I'm working with some data in R, and I have a dataframe with data from areas and mining projects, so some areas have more than one type of project. In this case, I would like to gather data from areas that have the same name, differentiating only the types of projects that each area has, as in the example below:
Example of how my table looks
How would I like to organize them:
Do you want to restructure your data, or present a table in use for data visualization?
If you want to restructure your data, you can either use dplyr::chop() or dplyr::nest().
In your case, dplyr::chop() is most likely what you want. The links provided show some great examples. If your frame is called df, this is how you might use it:
nested_df <- chop(df, c(mining, project_number))

How to import reactive datasets in Rshiny?

i m creating a risk dashboard , the problem is that i need the data set to be reactive , i have a simple dataset composed of countries (8) , sectors and values , what i want is that my app will be able to deal with different data sets for example if we change the colnames (country becomes pays) and we change the position of the col ,the app will recognize the column as country (in reality the data set is composed of an undefined number of variables with unkown names)
for example for the country column , i thought of creating a list that contains all country names and and when the first row of a column matches with a country from that list ,the column become names country
like that the problem is solved for one variable and what about the other ones
I think that's unnecesary complexity.
I suggest you to build an script to clean your data first with those specifications and then use it as a source.
You can use pattern recognition to match columns but be sure there aren't similar columns, for example, if you have two numerical variables there's a big problem.
Via Shiny I suggest you:
fileInput to import your database
Visualizate your database using DT
Create as many textInput boxes as columns you have
Manually change colnames using dplyr::rename and the boxes
Use the transformed database in your dashboard
Other options can be made using base::grep and dplyr.

Resources