Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 94 of 196

How to create plot in R with different shape of points?

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

In base R, the plot with different shape of points can be created by using pch argument inside the plot function. The list of pch values with shape is as written below −pch = 0 display square pch = 1 display circle pch = 2 display triangle point up pch = 3 display plus pch = 4 display cross pch = 5 display diamond pch = 6 display triangle point down pch = 7 display square cross pch = 8 display star pch = 9 display diamond plus pch = 10 display circle plus pch = 11 display triangles up ...

Read More

How to convert columns of an R data frame into rows?

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

If the row values are incorrectly recorded into columns then we might want to convert the columns into rows. Thus, to convert columns of an R data frame into rows we can use transpose function t. For example, if we have a data frame df with five columns and five rows then we can convert the columns of the df into rows by using as.data.frame(t(df)).Exampleset.seed(4) x1

Read More

How to find the cube root of negative values in R?

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

There is no function in R to find the cube root of negative values, hence we need to create that. The code to create the function is as shown below −CubeRoot

Read More

How to combine two matrices to create a block-diagonal matrix in R?

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

A block-diagonal matrix means that a matrix added to another matrix at the end the last element. For example, if we have a matrix with nine values and the other matrix also has nine values then the second matrix will be added to the first matrix and the elements below first matrix will be zero and the elements above the second matrix will also be zero.ExampleM1

Read More

How to find the size of the plotting window in R?

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

The plotting window size can be found by using dev.size function and we can pass in for inches and cm for centimeters. For example, if we create a plot then we can use dev.size("in") to find the plot size in inches and dev.size("cm") to find the size in centimeters.ExampleConsider the below vectors and create a point chart between those vectors −x

Read More

How to create a plot with cross sign in R?

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

In base R, the plot with different shape of points can be created by using pch argument inside the plot function but if we want to use any sign that is not designed for pch argument by default then we should pass that particular sign. For example, if we want to use cross sign then we can use letter x with pch as pch = "x".ExampleConsider the below vector and create the plot by displaying cross sign using letter x −x

Read More

How to create regression model line in a scatterplot created by using ggplot2 in R?

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

To add a regression model line in a scatterplot created by using ggplot2, we need to use geom_smooth function to define the line for linear model. For example, if we have a data frame df that contains independent variable x and the dependent variable y then the regression line can be created by using the code −ggplot(df,aes(x,y))+geom_point()+geom_smooth(method="lm")ExampleConsider the below data frame −set.seed(133) x

Read More

How to convert rows in an R data frame to list?

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

Sometimes each row needs to be treated differently, therefore, we might want to convert those rows into list. This will help us to perform the operations on our row elements separately. To convert the rows into list, we can use split function by defining the number of rows in the data frame.Consider the below data frame −Exampleset.seed(101) x1

Read More

How to create a sequence of time in minutes with date in R?

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

To create a sequence of time in minutes with date we can use seq function and define the date and time with as.POSIXct. For example, if we want to generate a sequence of time between 2 pm on tenth October 2020 to 4 pm on the same date then we can use the following code −seq(from=as.POSIXct("2020-10-10 14:00"), to=as.POSIXct("2020-10-10 16:00"), by="min")Exampleseq(from=as.POSIXct("2020-01-01 00:01"), to=as.POSIXct("2020-01-01 01:00"), by="min")Output[1] "2020-01-01 00:01:00 IST" "2020-01-01 00:02:00 IST" [3] "2020-01-01 00:03:00 IST" "2020-01-01 00:04:00 IST" [5] "2020-01-01 00:05:00 IST" "2020-01-01 00:06:00 IST" [7] "2020-01-01 00:07:00 IST" "2020-01-01 00:08:00 IST" [9] "2020-01-01 00:09:00 IST" "2020-01-01 00:10:00 IST" [11] "2020-01-01 ...

Read More

How to find the difference between regression line and the points in R?

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

The difference between regression line and the points on the scatterplot are actually the residuals, thus we need to calculate the residual from the model object. This can be simply done by using residuals function. For example, if we create a linear model defined as Model between x and y then the residuals will be found as residuals(Model).Consider the below data frame −Exampleset.seed(999) x1

Read More
Showing 931–940 of 1,958 articles
« Prev 1 92 93 94 95 96 196 Next »
Advertisements