Increase Width of Lines for Histogram-Like Plots in Base R

Nizamuddin Siddiqui
Updated on 05-Nov-2021 07:17:39

557 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

Change Border Style of a Circle in R

Nizamuddin Siddiqui
Updated on 05-Nov-2021 07:17:23

254 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

Increase X-Axis Labels Font Size Using ggplot2 in R

Nizamuddin Siddiqui
Updated on 05-Nov-2021 07:15:31

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

Create a Group Column in an R Data Frame

Nizamuddin Siddiqui
Updated on 05-Nov-2021 07:13:42

1K+ 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

Multiply Two Matrices in R with Missing Values

Nizamuddin Siddiqui
Updated on 05-Nov-2021 07:04:41

872 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

Merge Sort Using Multithreading in C++

Sunidhi Bansal
Updated on 05-Nov-2021 07:04:34

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

Hide Outliers in Base R Boxplot

Nizamuddin Siddiqui
Updated on 05-Nov-2021 06:54:45

376 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

Memorization in 1D, 2D, and 3D Dynamic Programming in Java

Sunidhi Bansal
Updated on 05-Nov-2021 06:53:56

2K+ Views

Memorization is a technique based on dynamic programming which is used to improve the performance of a recursive algorithm by ensuring that the method does not run for the same set of inputs more than once by keeping a record of the results for the provided inputs(stored in an array).Memorization can be achieved by implementing top down approach of the recursive method.Let us understand this scenario with the help of basic Fibonacci example1-D MemorizationWe will be considering a recursive algorithm with only one non constant parameter (only one parameter changes its value) hence this method is called 1-D memorization. The ... Read More

Create Darker Gridlines in theme_bw for a ggplot2 Graph in R

Nizamuddin Siddiqui
Updated on 05-Nov-2021 06:47:02

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

Check for Missing Values in a Matrix in R

Nizamuddin Siddiqui
Updated on 05-Nov-2021 06:41:26

2K+ Views

To check if a matrix has any missing value in R, we can use any function along with is.na function.For Example, if we have a matrix called M then we can use the below command to check whether M contains any missing value or not −any(is.na(M))Example 1Following snippet creates a sample matrix −M1

Advertisements