Category: R
ISO week number and ISO year in R
The easiest way to do ISO week number and ISO year calculations in R is by using two simple functions from package lubridate.
Variance or other calculation across columns in R
Here is how to calculate variance across columns in the R data frame. The same technique can be useful in other situations. Like in this other example. Get a count of NA values for each of the columns in the R data frame.
Group index that restarts in R
Here is how to generate a group index in R that restarts every time there change in variables.
Running, moving, rolling average in R, dplyr
You can calculate the moving average (also called a running or rolling average) in different ways by using R packages.
Combine apply and match in R, return the name of the column
Here is how to use functions apply and match together in R and a result – return the name of the column that contains minimum or maximum.
Edit R data frame almost like in Excel
Do you want to edit R data frame like an Excel table? It is not possible the same way. But on the other hand, there is a solution that is comfortable enough to edit a few entries.
R “not in” operator, opposite of “in”
R operator %in% is handy for working with vectors, but how to use it oppositely? Something like %notin% that will exclude anything that is in a vector.
Move column to a specific position in R
The easiest way to move the data frame column to a specific position in R is by using the function relocate from package dplyr.
Find min or max for each row in R
If you want to calculate min or max for a range of columns in each row of the data frame in R, then here is how to do that easily.
dcast : Aggregation function missing: defaulting to length
If you are having this dcast warning Aggregation function missing: defaulting to length there might be a simple solution to this problem.