Sometimes it is necessary to create a blank column in the R data frame to ensure that it will be available at all times. Here are multiple scenarios on how to do that. It might be just one blank column or multiple blank columns. Sometimes based on which of the necessary columns are missing.
Compare data frames in R, column names, data types, and content
Before appending or joining, it might be necessary to compare data frames in R. For example, differences in column names and data types. Sometimes even necessary if you are dealing with an error caused by unmatching columns or data types. Besides that, you can also compare other content.
Add data labels to column or bar chart in R
Here are multiple examples of how to add data labels to the column or bar chart in R if you are using the ggplot2 or plotly packages. You can add them in various positions, and it is good to know typical ones. In the case of plotly, interactivity and tooltips might be enough, but you… Continue reading Add data labels to column or bar chart in R
How to save R plots or other results temporarily
If you want to save R plots or other script results temporarily, here is a simple way to do that. It might be helpful if it is necessary to save them outside the R environment, but you don’t want to clean up secondary results. For example, by converting plots to another image format. Here is… Continue reading How to save R plots or other results temporarily
Script progress bar in R that works with purrr and in batch mode
Here is how to create a progress bar in R that is versatile when working with loops, for example, by using package purrr or the function lapply. Sometimes there is also necessary to see progress when running R scripts in batch mode from the command line and remove unnecessary messages.
How to combine Excel files in R, including transformations
Here are two quick solutions to combine Excel files in R with the necessary transformations. Fundamentally it is a similar approach that I used to combine multiple RDS files in R.
Get file location in R
Here are multiple scenarios on how to get file location in R. It can be a directory or a full path, and sometimes there are specific file types that you want to detect. A typical use case is when combining data from multiple files, for example, rds files or other formats.
How to do something across columns in R using dplyr
If you know how to efficiently do calculations across columns in the R data frame it can save you a lot of time. One of the best ways to do that with data frames is by using the across function from dplyr.