Server Side Programming Articles

Page 1146 of 2109

How to display positive sign for X-axis labels in R using ggplot2?

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

By default, the positive signs are not displayed in any plot in R. It is well known that if there is no sign seen with any value then it is considered positive, therefore, we do not need the sign but to distinguish between 0 and positive values it could be done. To display positive sign for X-axis labels, we can use scale_x_continuous function.Consider the below data frame −Examplex

Read More

How to deal with error "Error in shapiro.test(...) : sample size must be between 3 and 5000" in R?

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

The shapiro.test has a restriction in R that it can be applied only up to a sample of size 5000 and the least sample size must be 3. Therefore, we have an alternative hypothesis test called Anderson Darling normality test. To perform this test, we need load nortest package and use the ad.test function as shown in the below examples.Consider the below data frame −Examplex

Read More

How to display negative labels below bars in barplot using ggplot2 in R?

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

Be default, the labels on the plot are represented without sign in a barplot that is created by using ggplot2 but we might want to display the sign of the labels especially in cases where we have some negative values. This can be done with the help of geom_text function of ggplot2 package as shown in the below example.Consider the below data frame −Examplex

Read More

How to remove duplicate rows in an R data frame if exists in two columns?

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

If two values are repeated in a column that means there are many same values in that column but if those values are repeated in column as well as rows then they are called duplicated rows in two columns. To remove duplicate rows in an R data frame if exists in two columns, we can use duplicated function as shown in the below examples.Consider the below data frame −Examplex1

Read More

How to create boxplot for a list object in base R?

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

A list object can contain multiple elements of data, also the size of the data may vary. If a list object has numerical vectors then the boxplot for each of the elements can be created simply by using boxplot function. For example, if we have a list object called LIST that contains five numerical vectors then the boxplot for each of the vectors can be created by using the command boxplot(LIST)ExampleList

Read More

How to change the default type of points for scatterplot using ggplot2 in R?

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

To change the defaults for ggplot2 geoms, we need to use update_geom_defaults function. If we want to change the shape of points for scatterplot, we can use the below syntax −update_geom_defaults("point",list(shape=”point_shape_number”))The point shape number ranges from 0 to 25. We can change that according to our need.Consider the below data frame −Examplex

Read More

How to extract axes labels for the plot drawn using ggplot2 in R?

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

When we create a plot using ggplot2, the axes labels are automatically generated for both the axes. We might want to use those axes labels for report writing or some other purpose, therefore, extraction of those labels for a plot created by using ggplot2 package can be found by using the ggplot_build function as shown in the below example but we need to save the plot in an object.Consider the below data frame −Examplex

Read More

How to increase the X-axis length of histogram in base R?

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

To increase the X-axis length of histogram in base R, we can use the axis function. The most important thing to remember while using the axis function is mentioning the appropriate sequence based on the values in the vector or in the column of the data frame if a data frame is used.Examplex

Read More

How to set the plot area to assign the plots manually in base R?

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

We can split the screen to assign the plots manually in the plot area. The split.screen function can be used for this purpose. For example, if we want to create 4 plots in the plot window then we can use split.screen(c(2, 2)). Now to create the plot in first screen the command will be screen(1) then plot will be created. If we again create the plot then the original plot in screen(1) will be replaced with the new one. To create the plot in 3rd screen that is screen(3), we first need to use the command screen(3) and then create ...

Read More

Can we define an enum inside a class in Java?

Maruthi Krishna
Maruthi Krishna
Updated on 11-Mar-2026 17K+ Views

Enumerations in Java represents a group of named constants, you can create an enumeration using the following syntaxenum Days {    SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY }Yes, we can define an enumeration inside a class. You can retrieve the values in an enumeration using the values() method.Examplepublic class EnumerationExample {    enum Enum {       Mango, Banana, Orange, Grapes, Thursday, Apple    }    public static void main(String args[]) {       Enum constants[] = Enum.values();       System.out.println("Value of constants: ");         for(Enum d: constants) {          System.out.println(d); ...

Read More
Showing 11451–11460 of 21,090 articles
Advertisements