Category: R
How to transpose data frame in R
Here are multiple scenarios of how to transpose data frame in R. Not the most frequently used transformation, but might be necessary, especially if you are getting your data from Excel.
count in R, more than 10 examples
Count in R might be one of the calculations that can give a quick and useful insight into data. Sometimes it might be all that’s necessary for a simple analysis. In this post, I collected more than 10 useful and different examples of how to count values in R.
Add or subtract days from date or datetime in R
There are multiple ways how to add or subtract days from date in R, and here are some of them. The lubridate package is essential in these tasks. It has multiple functions that help do deal with even more difficult situations. You can easily calculate the first or last days of the month or age…
Return matching patterns in R
Imagine that you are looking for multiple text patterns in a data frame column that contains the text. The question is which of the matching patterns in R are detected in text. There might be multiple different matches, or something is matching multiple times. Which of the patterns is used to filter records? Which one…
Detect strings that start or end with in R
Here is how to detect strings that start or end with certain parameters in R. You can do that by using grepl and a little bit of regex or package stringr. In this case, function grepl is a better choice than grep because it returns a logical vector that is useful to detect and filter…
How to quickly drop columns in R in data frame
Here are multiple ways how to drop one or multiple columns in the R data frame. You can use R base functionality or package like dplyr, but it is not the most time-consuming operation. By knowing how to do that in different ways, you can choose a suitable approach.
Logarithmic transformation in R, inverse logarithmic transformation in R
Logarithmic transformation in R is one of the transformations that is typically used in time series forecasting. If your forecasting results have negative values, then log transformation of the target value will prevent from going below zero. In other words, logarithmic transformation stabilizes the variance of the time series and ensures that predictions stay positive.
How to connect to the Salesforce data with R
Here is how to get necessary Salesforce data with R. Previously, there was a package RForcecom, but now you should use the salesforcer package instead. During this year, RForcecom was removed from CRAN.
How use dplyr distinct with exceptions, select unique rows in R
Here are several examples of how to use dplyr distinct to select only unique rows in the data frame. Examples starting with situations where you define columns used to get distinct rows and ending with dplyr distinct with exceptions. Similarly to distinct by using one or multiple columns to get unique rows, maybe it is more…