Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 906 of 3366
754 Views
To create a histogram with horizontal boxplot on top in base R, we first need to define the layout of the plotting area with layout function and par function margin (mar) then the boxplot will be created and after that the histogram will be created. While creating the boxplot and histogram we need to make sure that the ylim for boxplot and xlim for histogram are same.Check out the below Example to understand how it can be done.ExampleTo create a histogram with horizontal boxplot on top in base R, use the following snippet −x
3K+ Views
To divide all columns of data frame in R by one column and keeping the original data, we can use mutate_at function of dplyr package along with list function.For example, if we have a data frame called df that contains five columns say x, y, z, a, and b then we can divide all columns by b and keep the original data by using the below given command −df%>%mutate_at(vars(x:b),list(All_by_b=~./b))Example 1Following snippet creates a sample data frame −x1
538 Views
The histogram like plot in base R is the plots of vertical lines instead of points in a vector or column of a data frame. If we increase the width of these lines then the plot becomes more like a histogram as the increment in widths make the vertical lines look like bars.To increase the width of lines for histogram like plots in base R, we can use lwd argument.Check out the below example to understand the difference between point chart and histogram like plot in base R.ExampleUse the code given below to increase the width of lines for histogram ... Read More
241 Views
We can create a circle in R by using draw.circle function of plotrix package and default border will be like straight lines. If we want to change the border style of a circle then we can use lty argument and set it to different values as shown in the below Examples.ExampleTo change the border style of a circle in R use the following snippet −plot(1:10, type="n")OutputIf you execute the above given snippet, it generates the following Output −To change the border style of a circle in R add the following code to the above snippet −plot(1:10, type="n") library(plotrix) draw.circle(5, 5, ... Read More
33K+ Views
To increase the X-axis labels font size using ggplot2, we can use axis.text.x argument of theme function where we can define the text size for axis element. This might be required when we want viewers to critically examine the X-axis labels and especially in situations when we change the scale for X-axis.Check out the below given example to understand how it can be done.ExampleFollowing snippet creates a sample data frame −x
989 Views
Suppose we have a data frame called df that contains two columns say X and Y then we can create a group column based on X and Y by converting df into a data.table object and creating list of values in X and Y with list function.Check out the below Examples to understand how it can be done.Example 1Following snippet creates a sample data frame −x1
850 Views
If we want to multiply two matrices if they contain missing values then we first need to convert the missing values to zeros and then the multiplication can be easily done. If we do not do so then the Output of the multiplication will have NAs at all positions.Check out the Examples given below to understand the correct of multiplication if NAs are present in the matrices.Example 1Following snippet creates a sample matrix −M1
4K+ Views
We are given an unsorted integer array. The task is to sort the array using merge sort technique implemented via Multi-threadingMerge SortMerge sort is a sorting technique which is based on divide and conquer technique where we divide the array into equal halves and then combine them in a sorted manner.Algorithm to implement merge sort ischeck if there is one element in the list then return the element.Else, Divide the data recursively into two halves until it can’t be divided further.Finally, merge the smaller lists into new lists in sorted order.Multi-ThreadingIn the operating system, Threads are the lightweight process which ... Read More
356 Views
To hide outliers in base R boxplot, we can use range argument inside boxplot function but we will have to play with range argument. The range argument can take many values therefore, we would need to find the correct one that removes all the outliers. To understand how it works check out the Example given below −ExampleTo hide outliners in base R boxplot, use the following snippet −x
1K+ Views
To create darker gridlines in theme_bw for a ggplot2 graph, we can use theme function, where we can use major and minor gridlines element line to black color with the help of panel.grid.major and panel.grid.minor argument as shown in the below Example.We can use any other color but black is the most preferred one as it matches with the border color.ExampleFollowing snippet creates a sample data frame −x