How to Remove Rows in R

To understand a detailed analysis of the dataset, sometimes, we want to remove specific rows and clear the data to analyze more efficiently. This is where subsetting is essential and, in other words deleting specific rows. How to remove rows in R To remove the rows in R, use the subsetting in R. There is … Read more

Categories R

summary in R: How to Use summary() Function

To get a better idea of the distribution of your variables in the dataset, use the summary() function. If you need a quick survey of your dataset, you can, of course, always use the R str() function and look at the structure. summary in R The summary is a built-in R function used to produce result summaries of various … Read more

Categories R

sprintf in R: How to Print Formatted String in R

R provides the sprintf() function that provides string formatting as the same C language. Specifically, the sprintf() method is a wrapper for the C library method of the same name. sprintf in R The sprintf() is a built-in R function that returns a character vector containing the formatted combination of text and variable values. It … Read more

Categories R

seq_along() Function in R: Complete Guide

The seq() function acts like the seq_along() method except when passed a vector of length 1, in which case it works like the seq_len() method. If the input number to seq() function is length 1 then the outputs between seq() and seq_along() will be different. Let’s deep dive into seq_along() function. seq_along() function in R … Read more

Categories R

seq_len in R: How to Create a Sequence from 1 to N

In the past, we used the “colon sequence” notation to create sequences. for (k in 1:5) { print(paste(k)) } Output [1] “1” [1] “2” [1] “3” [1] “4” [1] “5” But there is a problem using this notation. The colon sequence notation can be dangerous as it does not correctly handle the empty sequence case. … Read more

Categories R

as factor in R: How to Use as.factor() Function

To create a factor variable in R, use the factor function. Let’s talk about as.factor() function in R Language. as.factor in R The as.factor() is a built-in R function that converts a column from numeric to factor. The as.factor() method takes column or data frame x as an argument and returns the requested column specified as … Read more

Categories R

cumsum in R: Calculate Cumulative Sum of a Numeric Object

In data processing, the cumulative sum of the specific data objects is an exciting part. You need to calculate the sum of all values up to a particular position of data. In this example, you will see how to calculate the cumulative sum of a numerical object. cumsum in R The cumsum() is a built-in R … Read more

Categories R

Setdiff in R: How to Calculate Set difference of Subsets

R setdiff() function can be used to find differences between two sets. Let’s deep dive into the setdiff() method. setdiff in r The setdiff is a built-in R function that calculates the set difference of subsets of a probability space. The setdiff() method shows which elements of a vector or data frame x do not exist in a … Read more

Categories R

round in R: How to Round Numbers in R

Rounding implies making a number milder but keeping its value nearer to what it was. The result after rounding is less accurate but easier to use. When rounding a number, the first question in your mind should be: what are you rounding it to? The numbers can be rounded to the closest ten, nearest hundred, or thousand, … Read more

Categories R

How to Replace NA in R

The dplyr package is the next iteration of plyr, focus on tools for working with data frames. The key object in dplyr is a tbl, a representation of a tabular data structure. Replace NA in R To replace NA with specified values in R, use the replace_na() function. The replace_na() function replaces NAs with specified values. … Read more

Categories R