Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 108 of 196

How to determine the row that have min and max values in an R data frame column?

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

In data analysis, often we require to determine the minimum and maximum values because these values help us to understand the limits of a column or variable under consideration. This can be done by using which.max for maximum and which.min for minimum with single square brackets to extract the rows.ExampleConsider the below data frame −x1

Read More

How to save the summary statistics into a data frame in R?

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

When we find the summary statistics of a data frame then the output is returned as a table and each of the column records the minimum, first quartile, median, median, third quartile, and maximum with their names. If we want to save this summary as a data frame then it is better to calculate it with apply function and store it as data.frame.ExampleConsider the below data frame −x1

Read More

How to sort one column of an R data frame in ascending and the other in descending order?

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

Sorting of columns of an R data frame is not difficult but sometimes we want to sort them in opposite orders, for example, we might want to sort some columns in ascending order and some in descending order. This variation in sorting purpose makes it a little complicated. Therefore, we can use negation with sort function to sort the columns that we want to sort in descending order.ExampleConsider the below data frame −set.seed(111) x1

Read More

How to remove last few rows from an R data frame?

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

An R data frame can contain a very large number of rows and we might want to get rid of some rows if they’re not supposed to be helpful in our data analysis. Therefore, we can remove these rows prior to starting the analysis process. We can say that this removal of some rows is a part of data cleaning and obviously data cleaning helps us creating a smooth data set for analysis. In R, we can simply use head function to remove last few rows from an R data frame, also we can store them as a new data ...

Read More

How to find the total number of rows per group combination in an R data frame?

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

An R data frame that contains two or more factor columns then there are a greater number of combinations for the number of factors, obviously, if the number of factors is large with large number of levels then the combination of levels of the factors is also large. To find total number of rows per group combination we can use transform function.ExampleConsider the below data frame −set.seed(101) Group

Read More

How to X-axis labels to the top of the plot using ggplot2 in R?

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

Usually, a plot created in R or any of the statistical analysis software have X-axis labels on the bottom side but we might be interested in showing them at the top of the plot. It can be done for any type of two-dimensional plot whether it is a scatterplot, bar plot, etc. This is possible by using scale_x_continuous function of ggplot2 package in R.Exampleset.seed(123) x

Read More

How to change the color of bars of a bar plot using ggplot2 in R?

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

The default color of the bars created by using ggplot2 package is grey but we can change that color to any depending on our interest. This change is highly required in professions such as academic writing and analytics because everyone wants to look at attractive images. They are not meant to be useful if you just want to learn the concept but when it comes to practical, you need to do it as attractive images gets more attention, thus, they become memorable. To change the color of the bars in ggplot2, we can use fill argument of geom_bar function.ExampleConsider the ...

Read More

How to create vector in R with a sequence of numbers?

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

Creating a numeric vector is the first step towards learning R programming and there are many ways to do that but if we want to generate a sequence of number then it is a bit different thing, not totally different. We can create a vector with a sequence of numbers by using − if the sequence of numbers needs to have only the difference of 1, otherwise seq function can be used.Example> x1 x1Output[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 [26] ...

Read More

How to plot multiple time series using ggplot2 in R?

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

For a one point of time, we might have multiple time series data, this could be weather for multiple cities, price variation in multiple products, demand expectancy at different locations, or anything that changes with time and measured for multiple things or locations. If we have such type of time series data then we would be needing to plot that data in a single plot and it can be done with the help of geom_line function of ggplot2 package.ExampleConsider the below data frames −> x1 y1 df1 df1Output   x1 y1 1 1 -0.1165387 2 2 -0.9084062 3 3 0.4696637 4 ...

Read More

How to get the list of data sets available in base R or in a package in R?

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

There are many data sets available in base R and in different packages of R. The characteristics of these data sets are very different, for example, some data sets are time series data, some have only numerical columns, some have numerical as well as factor columns, some includes character columns with other type of columns. Therefore, it becomes helpful to everyone who want to learn the use of R programming. To get the list of available data sets in base R we can use data() but to get the list of data sets available in a package we first need ...

Read More
Showing 1071–1080 of 1,958 articles
« Prev 1 106 107 108 109 110 196 Next »
Advertisements