Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 148 of 196

How to create a bar chart for single vector using ggplot2 in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 13-Aug-2021 731 Views

To create a bar chart for single vector using ggplot2 in R, we can follow the below steps −First of all, create a vector and melt it using melt function of reshape2 package and save the melted data.Then, create the bar chart with melted data using ggplot2.Create the vector and melt itCreating the vector and using melt function of reshape2 to melt the data in vector −x

Read More

How to divide data.table object rows by row median in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 13-Aug-2021 228 Views

To divide the row values by row median in R’s data.table object, we can follow the below steps −First of all, create a data.table object.Then, use apply function to divide the data.table object row values by row median.Create the data.table objectLet's create a data frame as shown below −> library(data.table) > x y z DT DTOn executing, the above script generates the below output(this output will vary on your system due to randomization) −    x y  z 1:  5 3  2 2:  1 3  7 3:  6 0 13 4:  6 2 10 5:  8 1  9 6:  9 ...

Read More

How to check the data frame structure without using str function in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Aug-2021 254 Views

To check the data frame structure without using str function in R, we can follow the below steps −First of all, load the data or create new data or use an in-built data set.Then, use glimpse function of tibble package.Example 1Use in-built data setConsider the mtcars data set, load the tibble package and use glimpse function to look at the structure of mtcars data −library(tibble) glimpse(mtcars)OutputRows: 32 Columns: 11 $ mpg   21.0, 21.0, 22.8, 21.4, 18.7, 18.1, 14.3, 24.4, 22.8, 19.2, 17.8, ~ $ cyl   6, 6, 4, 6, 8, 6, 8, 4, 4, 6, 6, 8, 8, ...

Read More

How to read a CSV file and store the values into an array in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 25-Mar-2021 29K+ Views

A CSV file is a comma-separated file, that is used to store data in an organized way. It usually stores data in tabular form. Most of the business organizations store their data in CSV files.In C#, StreamReader class is used to deal with the files. It opens, reads and helps in performing other functions to different types of files. We can also perform different operations on a CSV file while using this class.OpenRead() method is used to open a CSV file and ReadLine() method is used to read its contents.OpenRead() method is used to open a CSV file and ReadLine() ...

Read More

How to find the number of unique values for each column in data.table object in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 16-Mar-2021 846 Views

To find the number of unique values for each column in data.table object, we can use uniqueN function along with lapply. For example, if we have a data.table object called DT that contains five columns each containing some duplicate values then the number of unique values in each of these columns can be found by using DT[,lapply(.SD,uniqueN)].ExampleConsider the below data.table object −x1

Read More

How to multiply large numbers with all digits in the output in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 06-Mar-2021 310 Views

To multiply large numbers with all digits in the output, we can use mul.bigz function of gmp package. For example, if we have two vectors say x and y each containing numbers of large size then the multiplication of these numbers that will return all the digits of the multiplication can be done by using the command mul.bigz(x,y).Example1Loading gmp package and multiplying vectors containing large number values −library(gmp) x1

Read More

How to show values in boxplot in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 06-Mar-2021 5K+ Views

The main values in a boxplot are minimum, first quartile, median, third quartile, and the maximum, and this group of values is also called five-number summary. Therefore, if we want to show values in boxplot then we can use text function and provide the five-number summary and labels with fivenum function as shown in the below examples.Example1x

Read More

How to create a horizontal boxplot in base R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 06-Mar-2021 3K+ Views

To create a horizontal boxplot in base R, we can set the horizontal argument inside boxplot function to TRUE. For example, if we have a vector called x then the horizontal histogram of that vector can be created by using the command boxplot(x,horizontal=TRUE).Example1x

Read More

How to create normal random variables with specific correlation between them in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 06-Mar-2021 698 Views

To create normal random variables with specific correlation between them, we can use mvrnorm function of MASS package. For example, if we want to create two variables of size 10 with means equal to 2 and 4 and standard deviation of 0.5 then it can be done by using the command −mvrnorm(10,mu=c(2,4),Sigma=matrix(c(1,0.5,0.5,1),ncol=2),empirical=TRUE)Example1library(MASS) X

Read More

How to find prime factors of a number in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 06-Mar-2021 1K+ Views

A prime number is the number that is only divisible by itself and one. These prime numbers can also divide other numbers hence they become a factor of those numbers. For example, 5 is a prime number and it also divides 20. To find the prime factors of a number, we can use primeFactors function of numbers package.Exampleslibrary(numbers)primeFactors(100)[1] 2 2 5 5primeFactors(1000)[1] 2 2 2 5 5 5 primeFactors(32547)[1] 3 19 571primeFactors(12354767)[1] 17 726751 primeFactors(21457)[1] 43 499primeFactors(99)[1] 3 3 11 primeFactors(365748)[1] 2 2 3 29 1051primeFactors(214687)[1] 11 29 673 primeFactors(3587497)[1] 3587497primeFactors(35874)[1] 2 3 3 1993 primeFactors(268713)[1] 3 3 73 409primeFactors(298473)[1] ...

Read More
Showing 1471–1480 of 1,958 articles
« Prev 1 146 147 148 149 150 196 Next »
Advertisements