Found 26504 Articles for Server Side Programming

How to hide outliers in base R boxplot?

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

353 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

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

Merge Sort Tree in C++

Sunidhi Bansal
Updated on 05-Nov-2021 07:20:07

664 Views

We are given an integer array, a set of segment start and end pointers and a key value and the problem statement here is to find all the values in the given range which are smaller than or equal to the given key value.Let us understand with exampleInput − arr[] = {7, 8 , 1, 4 , 6 , 8 , 10 }Segment 1: start = 2, end = 4, k = 2Segment 2: start = 1, end = 6, k = 3Output − Count of number which are smaller than or equal to key value in the given range are 2 ... Read More

How to check if a matrix has any missing value 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

How to remove line numbers from data.table object in R?

Nizamuddin Siddiqui
Updated on 05-Nov-2021 06:31:38

2K+ Views

To remove line numbers from data.table object in R, we can set row.names to FALSE and print the data.table object.For Example, if we have a data.table object called DT then we can remove line numbers from DT by using the command given below −print(DT,row.names=FALSE)Example 1To load data.table object and create an object use the following snippet to create a data frame −library(data.table) x1

Create stacked bar plot for one categorical variable in an R dataframe.

Nizamuddin Siddiqui
Updated on 05-Nov-2021 06:20:11

1K+ Views

To create stacked bar plot for one categorical variable in an R data frame, we can use ggplot function and geom_bar function of ggplot2 and provide 1 as the X variable inside aes.For Example, if we have a data frame called df that contains a one categorical column say C and one numerical column Num then we can create the stacked bar plot by using the below command −ggplot(df,aes(1,Num,fill=C))+geom_bar(stat="identity")ExampleFollowing snippet creates a sample data frame −x

Find the value in an R data frame column that exist n times.

Nizamuddin Siddiqui
Updated on 05-Nov-2021 06:15:19

191 Views

To find the value in an R data frame column that exist n times, we first need to tabulate the column with factor then extracting the levels of the column after that reading them with as.numeric.Check out the Examples given below to understand how it can be done.Example 1Following snippet creates a sample data frame −x

Memorization (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

How to round matrix values in R?

Nizamuddin Siddiqui
Updated on 05-Nov-2021 06:06:36

4K+ Views

To round matrix values, we can use round function.For Example, if we have a matrix called M and we want to round the value in M to 2 decimal places by using the below command −M

How to display numbers with decimal in R data frame column?

Nizamuddin Siddiqui
Updated on 05-Nov-2021 05:59:31

7K+ Views

To display numbers with decimal in R data frame column, we can use format function with round function and nsmall argument.For Example, if we have a data frame called df that contains an integer column say X then we can display numbers in X with 2 decimal places by using the below command −df$X

Advertisements