• How to create a blank column in the R data frame?

    How to create a blank column in the R data frame?

    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

    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

    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…

  • How to save R plots or other results temporarily

    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…

  • Convert images to WebP in R programming

    Convert images to WebP in R programming

    It is possible to export or convert images to WebP format by using R programming. Images in WebP format mostly have much smaller sizes than in the JPEG or PNG format. If you are using images on websites, this format is worth considering.

  • Script progress bar in R that works with purrr and in batch mode

    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 suppress package loading messages in R or warnings

    How to suppress package loading messages in R or warnings

    If you want a cleaner look while running your code in interactive or batch mode, try to suppress package loading messages in R. There are also possible to disable some of the warnings. It is typically at the loading of chatty packages like dplyr or janitor. Of course, they have helpful information, and you should…

  • How to combine Excel files in R, including transformations

    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

    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

    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.