Nizamuddin Siddiqui has Published 2307 Articles

How to save list where each element contains equal number of values to a text file in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Dec-2020 05:49:00

146 Views

If we want to save a list to a text file then first step would be converting that list to a data frame then write.table function can be used for saving. For example, if we have a list defined as LIST and it has elements each containing 50 values then ... Read More

How to set comma as decimal separator in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Dec-2020 05:45:57

5K+ Views

In European countries, a comma is used to separate the integral part of a number from the decimal part. Thus, we might want to create data or perform calculations with comma as decimal separator. In R, we can do this by just using the code options(OutDec=", "). Once we will ... Read More

How to generate a probability density distribution from a set of observations in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Dec-2020 05:44:08

3K+ Views

The probability density distribution is the synonym of probability density function. It is a function that defines the density of a continuous random variable. In R, we can use density function to create a probability density distribution from a set of observations.Example Live Demox1

How to divide row values of a numerical column based on categorical column values in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Dec-2020 05:38:51

314 Views

If we have a categorical column that has two or more categories and a numerical column then we might want to divide the one category numerical value from other category numerical value. This can be done by using divide sign / but we need to use the proper subset of ... Read More

How to find the correlation matrix of groups for a data.table object in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Dec-2020 05:36:27

281 Views

To find the correlation of groups, we can use cor function but it cannot be directly used.For this purpose, we first need to set they key for group column of data table object. For example, if we have a data.table DT with one numerical column defined as x and one ... Read More

How to replace upper triangular matrix with lower triangular matrix and vice versa in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Dec-2020 05:35:21

688 Views

The upper triangular matrix can be replaced with lower triangular matrix by transposing the whole matrix and extracting upper triangular matrix from it then storing it in the original matrix. For example, if we have a matrix M then upper triangular matrix of M can be replaced with lower triangular ... Read More

How to remove duplicate rows and sort based on a numerical column an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Dec-2020 05:21:59

563 Views

If we have duplicate rows in an R data frame then we can remove them by using unique function with data frame object name. And if we want to order the data frame with duplicate rows based on a numerical column then firstly unique rows should be found then order ... Read More

How to find the table of ordered frequencies of vector elements in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Dec-2020 05:20:21

319 Views

We can create table of frequencies of a vector element by using table function and the ordering can be done by using sort function. If we want to order the frequencies in decreasing order then decreasing argument can be used. For example, if we have a vector x then the ... Read More

How to create a classification model using svm for multiple categories in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Dec-2020 05:18:50

285 Views

SVM is a supervised machine learning algorithm which can be used for both classification or regression challenges but mostly we use it for classification. The classification using svm can be done for two or more categories as well. In R, we can use simply use svm function of e1071 package.ExampleConsider ... Read More

How to truncate a numerical vector to a specified number of decimal places in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Dec-2020 05:12:15

3K+ Views

The truncation means removing the number of decimal places but not rounding. For example, if we have a value 5.1742145 then truncating to one decimal place will be 5.1 and rounding will be 5.2. In R, we can do this by using trunc function as shown in the below examples.Example Live ... Read More

Advertisements