Category: R
How to bind R data frames vertically
Here is how to bind two or more R data frames vertically using different methods and dealing with possible errors. Binding R data frames together by rows might be easy, but there might be situations where columns don’t match or there are more than two data frames.
How to calculate weighted mean in R
Calculation of weighted mean in R is done easily by dedicated function or mathematically. Here are a couple of situations and solutions to successfully do weighted mean calculations in R.
Detect combination of multiple strings in R
Here is how to detect multiple strings in R using base function grepl and alternatives, like str_detect from package stringr. There will be two main scenarios – detection of multiple strings simultaneously and any of the given strings.
dplyr error: `n()` must only be used inside dplyr verbs
If you are using R and getting dplyr error: `n()` must only be used inside dplyr verbs, then here is the most likely cause and 3 possible solutions to this problem.
Recode data in R, replace values
Here is how to recode data in R in 3 different ways. Some may call it an efficient way how to replace existing values with new values.
My top 10 favorite dplyr tips and tricks
Here is a compilation of my favorite dplyr tips and tricks that are very useful and easy to learn. When I started to work with the dplyr package, the first thing was the shortcut for the pipe operator in Windows Ctrl + Shift + M. A little thing with a significant impact. That is why…
5 ways how to format output in R console
Here is how to format output in the R console in 5 different ways to make your dataset look better if that’s necessary. In my case, I like to take a quick look at few lines of a data frame and want to add gridlines or other formatting features to make them easier to read.
Get the first and last row of the data group in R
If your data frame content is categorized and you are interested to extract the first and the last row of each group in R, this post is for you. It is a useful solution to detect the minimum and the maximum by a group in big data sets. In my experience, it works faster than…