Nizamuddin Siddiqui has Published 2307 Articles

How to replace missing values with linear interpolation method in an R vector?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Nov-2020 07:51:59

2K+ Views

The linear interpolation is a method of fitting a curve using linear polynomials and it helps us to create a new data points but these points lie within the range of the original values for which the linear interpolation is done. Sometimes these values may go a little far from ... Read More

How to add a new column to a matrix in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Nov-2020 07:50:01

2K+ Views

A data collection process is one of the initial and very important tasks in a data analysis project and sometimes we miss something. Therefore, we need to collect that data later and add it to the originally collected data. This mistake can be done for matrix data as well, hence ... Read More

How to add a picture to plot in base R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Nov-2020 07:44:05

4K+ Views

To add a picture to a plot in base R, we first need to read the picture in the appropriate format and then rasterImage function can be used. The most commonly used format for picture in R is PNG. A picture in PNG format can be added to a plot ... Read More

How to find the sum based on a categorical variable in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Nov-2020 07:41:20

2K+ Views

Finding group-wise mean is a common thing but if we go for step-by-step analysis then sum of values are also required when we have a categorical variable in our data set. This can be easily done with the help of group_by and summarise_each function of dplyr package.ExampleConsider the below data ... Read More

How to find the mean of list elements without unlisting them in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Nov-2020 07:38:02

205 Views

Most of the times, unlisting is used to find the mean of list elements but we can also use double-square brackets for the same purpose. The double-square brackets are basically used to access the values in the elements of the list, thus mean function works with those values directly. Look ... Read More

How to extract the names of vector values from a named vector in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Nov-2020 07:32:32

4K+ Views

How to extract the names of vector values from a named vector in R?The names of vector values are created by using name function and the names can be extracted by using the same function. For example, if we have a vector called x that contains five values(1 to 5) ... Read More

How to perform cartesian join for two data.table objects in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Nov-2020 07:27:49

985 Views

The cartesian join is the joining of two objects that creates the combination of each value in object with all the values in the other object. For example, if we have a vector x that contains 1, 2, 3 and the other object y contains a, b, c then the ... Read More

How to find the column number of minimum values in each row for a data frame in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Nov-2020 07:25:26

556 Views

To find the column number of minimum values in each row for a data frame, we can use apply function but if we want to return the output in tabular form then matrix function should be used. For example, if we have a data frame df then our problem can ... Read More

How to replace numbers with ordinal strings for a survey in an R vector?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Nov-2020 07:22:16

1K+ Views

The easiest way to replace numbers with ordinal strings is using ifelse function. The ifelse function in R works as ifelse(test_expression, x, y). Here, test_expression must be a logical vector or an object that can be coerced to logical). The return value is a vector with the same length as ... Read More

How to create a blank csv file in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Nov-2020 07:19:09

442 Views

We can create a blank csv file using a single line code in R and the function that can do this is cat. If we want to have the file blank then NULL value will be passed inside the function and the file name must be used. For example, if ... Read More

Advertisements