Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 62 of 196

How to create a hierarchical cluster dendrogram in R?

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

A dendrogram display the hierarchical relationship between objects and it is created by using hierarchical clustering. In base R, we can use hclust function to create the clusters and the plot function can be used to create the dendrogram. For example, if we want to create the dendrogram for mtcars data then it can be done as shown below:> hc=hclust(dist(mtcars)) > plot(hc)Example1> head(mtcars)Outputmpg cyl disp hp drat wt qsec vs am gear carb Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4 Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4 ...

Read More

How to check whether a column value is less than or greater than a certain value in R?

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

To check whether a column value is less than or greater than a certain value, we can use with function and the output will be a logical vector representing values with TRUE when the condition is satisfied and FALSE when the condition is not satisfied. For example, if we have a column say x of an R data frame df and we want to check whether any of the values in x is greater than 10 or not then it can be done by using with(df, df$x>10).ExampleConsider the below data frame:> set.seed(1002) > x1 y1 z1 df1 df1Outputx1 y1 z1 ...

Read More

How to create an arrow in base R?

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

To create an arrow R, we can use plot function and arrows function. We just need to understand all the coordinate values that should be passed inside the arrows function. For example, if we have two vectors that contains values from 1 to 10 then the arrow can be created by using arrows function as arrows(1,1,10,10).Example> x y plot(x,y)OutputExample> arrows(1,1,10,10)Output

Read More

How to remove ticks in a plot created by using gglot2 in R?

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

In a plot created by using ggplot2, the axes values are generated with tick marks such as representing X-axis labels from 1 to 10 and Y-axis labels from 10 to 1 but we can get rid of this tick marks by using theme function. If we want to create a plot without ticks then we just need to add the following code to the plot code.theme(axis.ticks.x=element_blank(), axis.ticks.y=element_blank())ExampleConsider the below data frame.> set.seed(321) > x y df dfOutputx y 1 1.0426226 6.238295 2 0.9821990 4.855467 3 0.9930504 6.334253 4 0.9970088 3.552478 5 0.9969010 3.976679 6 1.0067046 5.128251 7 1.0181710 1.853243 8 ...

Read More

How to rotate text in base R plot?

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

To write the text in a base R plot, firstly we should create a blank chart by using type="n" if we want to plot only text then the text should be introduced with the help of text function. Now, if we want to rotate the text value then srt argument can be used. For example, if we want to rotate the text to 45 degree then srt = -45 can be used.Example1> plot(1:10, type="n") > text(x=5, y=5, "Text inside plot")OutputExample2> plot(1:10, type="n") > text(x=5, y=5, "Text inside plot", srt=-20)OutputExample3> plot(1:10, type="n") > text(x=5, y=5, "Text inside plot", srt=-45)Output

Read More

How to create horizontal histogram in R?

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

Generally, the histogram is a graph that is displayed in vertical form and it helps us to analyze the distribution of a variable, mainly to understand whether the distribution is normal or not. The horizontal histogram can be also created by using coord_flip function of ggplot2 package. Check out the below example to understand how it works.ExampleConsider the below data frame.> x df head(df, 20)Outputx 1 3.509446 2 5.075813 3 5.242884 4 5.236765 5 5.775746 6 5.331167 7 5.250956 8 5.925262 9 6.102322 10 4.045241 11 4.117635 12 4.137581 13 4.758140 14 5.311225 15 4.354592 16 4.021351 17 5.330966 18 ...

Read More

How to create bin frequency table in R?

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

The bin frequency table is the table that represent the frequency for a range of values in a particular variable, in R we generally store these variables in a vector or a column of an R data frame. If we want to create a bin frequency table then table function with cut and breaks function can be used.Example1> x1 x1Output[1] 3 4 3 4 3 3 2 5 2 2 4 4 5 4 5 2 5 2 3 2 4 4 3 3 5 2 2 2 2 3 2 4 3 3 3 5 4 [38] 4 3 ...

Read More

How to find the union of two vectors in R?

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

The union of vectors return all the unique values in both the vectors. For example, if we have a vector x that contains 1, 2, 3, 4, 2, 3, 4, 1, 1, 4 and another vector that contains 2, 1, 2, 4, 5, 7, 5, 1, 2, 3, 7, 6, 5, 7, 4, 2, 4, 1, 5, 8, 1, 3 then the union of these two vectors will be 1, 2, 3, 4, 5, 6, 7, 8. In R, we can do this by using union function.Example> x1 x1Output[1] 2 2 0 1 1 1 4 1 2 2Example> y1 ...

Read More

How to convert a data frame column to date that contains integer values in R?

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

If we have an integer column that actually contains date values, for example having 29th September 2020 as 20200929 then we can convert it to date by using transform function by reading the dates with as.Date function but as.character will also be needed so that as.Date function can read the date values.Example1S.NO

Read More

How to find the frequency of a particular string in a column based on another column in an R data frame using dplyr package?

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

When we have two or more categorical columns in an R data frame with strings as level of the categories or numbers as strings/integers then we can find the frequency of one based on another. This will help us to identify the cross-column frequencies and we can understand the distribution of one categorical based on another column. To do this with dplyr package, we can use filter function.ExampleClass%filter(Class=="First")%>%count(Gender) Gender n 1 Female 2 2 Male 2 df2%>%filter(Class=="Second")%>%count(Gender) Gender n 1 Female 6 2 Male 2

Read More
Showing 611–620 of 1,958 articles
« Prev 1 60 61 62 63 64 196 Next »
Advertisements