Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 63 of 196

How to create an ID column for the combination of values in multiple columns in R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 13-Aug-2021 1K+ Views

To create an ID column for the combination of values in multiple columns in R data frame, we can follow the below steps −First of all, create a data frame.Then, create an ID column using as.numeric, as.factor and with function for the combination of values in columns of the data frame.Create the data frameLet's create a data frame as shown below − Live Demo> x1 x2 df dfOn executing, the above script generates the below output(this output will vary on your system due to randomization) −  x1 x2 1  0  1 2  0  1 3  0  1 4  2  2 5 ...

Read More

How to add a regression line to a plot in base R if intercept and slope are given?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 13-Aug-2021 2K+ Views

To add a regression line to a plot in base R if intercept and slope are given, we can follow the below steps −First of all, create two vectors and the scatterplot between them.Then, use abline function to create the regression line with intercept and slope given by a and b respectively.Create the vectors and scatterplotUse plot functions to create scatterplot between two random vectors x and y − Live Demo> x y plot(x, y)OutputAdd regression line with given intercept and slopeExampleUsing abline function to add the regression line to the scatterplot with given intercept a = 0.51 and slope = ...

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 remove scientific notation form base R plot?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 13-Aug-2021 7K+ Views

To remove scientific notation form base R plot, we can follow the below steps −First of all, create a vector and its plot using plot function.Then, use options(scipen=999) to remove scientific notation from the plot.Create the vector and plotUsing sample function to create a vector and plot the vector with plot function − Live Demo> x plot(x)OutputRemove the scientific notation from the plotUse options(scipen=999) function and again create the same plot − Live Demo> x options(scipen=999) > plot(x)Output

Read More

How to merge two data frames of different length having same values in all columns but at different positions?

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

To merge two data frames of different length having same values in all columns but at different positions, we can follow the below steps −First of all, create two data frames.Then, merge them using merge function with all argument set to FALSE.Create the data frameLet's create a data frame as shown below − Live Demo> x y z df1 df1On executing, the above script generates the below output(this output will vary on your system due to randomization) −Output   x y z 1  2 3 5 2  3 3 2 3  5 3 1 4  1 2 3 5  1 3 2 ...

Read More

How to display ID column values in a scatterplot created with ggplot2 in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 13-Aug-2021 1K+ Views

To display ID column values in a scatterplot created with ggplot2 in R, we can follow the below steps −First of all, create a data frame.Then, create the scatterplot using ggplot2.After that, create the same plot with label argument inside aes and add the geom_text function.Create the data frameLet's create a data frame as shown below − Live Demo> ID x y df dfOn executing, the above script generates the below output(this output will vary on your system due to randomization) −  ID     x         y 1 1   -0.6980655  0.4815529 2 2    1.0943027  0.2476090 ...

Read More

How to combine multiple R data frames that contains one common column?

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

To combine multiple R data frames that contains one common column, we can follow the below steps −First of all, create a number of data frames.Then, use join_all function from plyr package to combine the data frames.Create the data frameLet's create a data frame as shown below − Live Demo> x y1 df1 df1On executing, the above script generates the below output(this output will vary on your system due to randomization) −   x y1 1  A  6 2  B 10 3  A  4 4  C  5 5  C  3 6  C  6   7  B  2 8  B 10 9  D ...

Read More

How to remove row that contains maximum for each column in R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 13-Aug-2021 1K+ Views

To remove row that contains maximum for each column in R data frame, we can follow the below steps −First of all, create a data frame.Then, remove the rows having maximum for each column using lapply and which.max function.Create the data frameLet's create a data frame as shown below − Live Demo> x1 x2 df dfOn executing, the above script generates the below output(this output will vary on your system due to randomization) −   x1 x2 1  9  10 2  1  9 3  8  9 4  7  6 5  4 10 6  4  7 7  8  8 8  5 13 9 ...

Read More

How to set the position of legend of a ggplot2 graph to left-top side in R?

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

To set the position of legend of a ggplot2 graph to left-top side in R, we can follow the below steps −First of all, create a data frame.Then, create a plot using ggplot2 with legend.After that, add theme function to the ggplot2 graph to change the position of legend.Create the data frameLet's create a data frame as shown below − Live Demo> x y Grp df dfOn executing, the above script generates the below output(this output will vary on your system due to randomization) −          x          y     Grp 1   1.534536456 ...

Read More

How to find the critical value of F for regression anova in R?

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

To find the critical value of F for regression anova in R, we can follow the below steps −First of all, create a data frame.Then, create the regression model.After that, find the critical value of F statistic using qf function.Create the data frameLet's create a data frame as shown below − Live Demo> x y df dfOn executing, the above script generates the below output(this output will vary on your system due to randomization) −   x y 1  5 5 2  0 9 3  1 3 4  3 5 5  2 5 6  2 4 7  3 6 8  4 6 ...

Read More
Showing 621–630 of 1,958 articles
« Prev 1 61 62 63 64 65 196 Next »
Advertisements