Start every string with a capital letter in R

If you want to start every string with a capital letter in R, you should know a reliable function that works in every situation. Same as the PROPER function in Excel. Of course, it is possible to write your R functions, but sometimes it is not worth the effort.

Extract date from datetime in R

Here are a couple of examples on how to extract date from datetime in R – with the results class of Date or POSIXct. If you have a large dataset, then here is my favorite solution at this moment with the function fastPOSIXct from the fasttime package that can extract date as POSIXct.

Remove all objects except one or few in R

Sometimes you need an almost fresh start, and, in that case, here is how to remove all objects except one or few in R.

How to get top or bottom values by each group in R

It is easy to return top or bottom values by a group with functions slice_min and slice_max from dplyr in R. If you can’t find those functions, then you have to update dplyr.

Remove scientific notation in R

Here is how to remove scientific notation in R. Sometimes, numbers as a result of calculation are not so small. It is hard to read them when they are in scientific formatting.

How to categorize numbers in R

Here is my approach on how to categorize numbers by user-defined groups with R. When you have a few predictable groups, you can use the ifelse function. But sometimes, there is a long list of numbers that are changing over time.

Exit mobile version