Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 55 of 196

How to randomize column values of a data.table object for all columns in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 14-Aug-2021 317 Views

To randomize column values of a data.table object for all columns in R, we can follow the below steps −First of all, create a data.table object.Then, use sample function with lapply to randomize the columns of the data.table object.Create the data frameLet's create a data frame as shown below −library(data.table) x

Read More

How to create two lines using ggplot2 based on a categorical column in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 14-Aug-2021 623 Views

To create two lines using ggplot2 based on a categorical column in R, we can follow the below steps −First of all, create a data frame.Then, create the line chart with categorical column read as factor inside aes of ggplot function.Create the data frameLet's create a data frame as shown below − Live Demox

Read More

How to create a clone of a data frame in R without data values?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 14-Aug-2021 740 Views

To create a clone of a data frame in R without data values, we can follow the below steps −First of all, create a data frame.Then, create the clone of the data frame by subsetting zero rows.Example 1Create the data frameLet's create a data frame as shown below − Live Demox1

Read More

How to filter data frame by categorical variable in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 14-Aug-2021 4K+ Views

To filter data frame by categorical variable in R, we can follow the below steps −Use inbuilt data sets or create a new data set and look at top few rows in the data set.Then, look at the bottom few rows in the data set.Check the data structure.Filter the data by categorical column using split function.Use inbuilt data setLet’s consider CO2 data set in base R − Live Demodata(CO2) head(CO2, 10)On executing, the above script generates the below output(this output will vary on your system due to randomization) −Grouped Data: uptake ~ conc | Plant   Plant Type Treatment conc uptake ...

Read More

How to find the summary by categorical variable in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 14-Aug-2021 963 Views

To find the summary by categorical variable, we can follow the below steps −Use inbuilt data sets or create a new data set.Find the summary statistics with by function.Use inbuilt data setLet’s consider mtcars data set in base R − Live Demodata(mtcars) head(mtcars, 25)On executing, the above script generates the below output(this output will vary on your system due to randomization) −                      mpg  cyl disp   hp  drat   wt   qsec vs am gear carb Mazda RX4             21.0 6   160.0 110  3.90 2.620 ...

Read More

How to add values in columns having same name and merge them in R?

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

To add values in columns having same name and merge them in R, we can follow the below steps −First of all, create a data frame.Add column values that have same name and merge them by using cbind with do.call.Create the data frameLet's create a data frame as shown below −df

Read More

How to change the color of line of a plot created for an xts object in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 14-Aug-2021 298 Views

To change the color of line of a plot created for an xts object in R, we can follow the below steps −First of all, create a data frame.Then, convert this data frame into an xts object.Create the plot for the data in xts object with default color.Then, create the plot for the data in xts object with different colorCreate the data frameLet's create a data frame as shown below −Dates

Read More

How to create facetted plot with one facet displaying all data using ggplot2 in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 14-Aug-2021 264 Views

To create facetted plot with one facet displaying all data using ggplot2 in R, we can follow the below steps −First of all, create a data frame.Then, create facetted plot using facet_grid function.After that, create the facetted plot with margins argument set to TRUE to display the plot with all data.Create the data frameLet's create a data frame as shown below − Live Demox

Read More

How to create facetted plot with facets in horizontal direction using ggplot2 in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 14-Aug-2021 597 Views

To create facetted plot with facets in horizontal direction using ggplot2 in R, we can follow the below steps −First of all, create a data frame.Then, create the facetted plot using facet_grid function of ggplot2 package.Use facet_grid function with reversed value of categorical column to create the facetted plot with facets in horizontal direction.Create the data frameLet's create a data frame as shown below − Live Demox

Read More

How to define points outside the R data frame and draw them in ggplot2 graph?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 14-Aug-2021 330 Views

To define points outside the R data frame and draw them in ggplot2 graph, we can follow the below step −First of all, create a data frameThen, create the scatterplot using geom_point function of ggplot2 package.Create the scatterplot with data outside data frame using data.frame inside geom_point.Create the data frameLet's create a data frame as shown below − Live Demox

Read More
Showing 541–550 of 1,958 articles
« Prev 1 53 54 55 56 57 196 Next »
Advertisements