Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 47 of 196

How to change the name of variables in a list in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 1K+ Views

The name of variables in a list are actually the list elements. These elements can be either named or unnamed. The naming can be done with the help of names function and renaming can be done in the same way as well. For example, if we have a list called LIST then the names of the element in LIST can be done by using the below command: names(LIST)

Read More

How to find the sum of squared deviations for an R data frame column?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 2K+ Views

The sum of squared deviations is the total of the square of difference between each value and the mean. To find this value, we need to create the formula in R platform. For example, if we have a data frame called df that contains a column x then the sum of squared deviations for x can be calculated by using sum((df$x−mean(df$x))^2).Example1y1

Read More

How to find the correlation of one variable with all the other variables in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 3K+ Views

To find the correlation of each variable with remaining variables, we can create a correlation matrix but for the correlation of only one variable with all the other variables we need to define the columns inside the cor function. The output will represent the columns and rows as passed inside the function.Example1y1

Read More

How to create a frequency table in R that includes zero frequency for value that are not available?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 2K+ Views

When we use table function in R, the output shows the frequency of values that are available in the vector or in column of the data frame. If we want to create the table with the frequency zero for values that are not part of the vector or the column then first we need to convert them to factor first and then use the table function.Example1x1

Read More

How to create a column with largest size string value in rows in an R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 215 Views

To create a column with largest size string value in rows, we can use apply function and define the size of the string for the largest value by creating a function as shown in the below examples. If the number of characters in all the columns are same or there exists some ties then the output will be the first one.Example1y1

Read More

How to multiply all values in a list by a number in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 4K+ Views

To multiply all values in a list by a number, we can use lapply function. Inside the lapply function we would need to supply multiplication sign that is * with the list name and the number by which we want to multiple all the list values. For example, if we have a list called LIST and we want to multiply each value in LIST by 2 then it can be done by using the command lapply(LIST,"*",2).Example1List1

Read More

How to find the sum of rows, columns, and total in a matrix in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 11K+ Views

To find the sum of row, columns, and total in a matrix can be simply done by using the functions rowSums, colSums, and sum respectively. The row sums, column sums, and total are mostly used comparative analysis tools such as analysis of variance, chi−square testing etc.Example1M1

Read More

How to use column index instead of column name while using group_by of dplyr in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 1K+ Views

When we use group_by function of dplyr package, we need to pass the column name(s) that are categorical in nature. If we want to use the index of the same column(s) then group_by_at function needs to be used, where we can pass the column index as the argument.Example1y1

Read More

How to perform rounding in R to next 10 instead of nearest 10?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 290 Views

In general, most commonly used rounding is rounding to nearest 10 or nearest 100 but sometimes we actually want to remove the values after a value instead of rounding. For example, removing values after 2 decimal places, this is the type of situation where we need to round to next 10 instead of nearest 10. This can be done with the help of floor function as shown in the below examples.Example1x1

Read More

How to check if a list element is greater than a certain value in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 1K+ Views

If we have a list that contains numeric elements and we want to check whether the elements are greater than a certain value then as.numeric function can be used. The output of the function will be in 0/1 format where 0 represents FALSE and 1 represents TRUE. For example, if we have a list called LIST then to check whether elements in LIST are greater than 2 can be done as as.numeric(LIST>2).Example1List15)Output[1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0Example2List22)Output[1] 1 1 1 1 0 0 1 0 1 1 1 1 1 0 0 0 1 1 1 0

Read More
Showing 461–470 of 1,958 articles
« Prev 1 45 46 47 48 49 196 Next »
Advertisements