Found 26504 Articles for Server Side Programming

How to find 95% confidence interval for binomial data in R?

Nizamuddin Siddiqui
Updated on 10-Oct-2020 12:57:27

804 Views

The binomial data has two parameters, the sample size and the number of successes. To find the 95% confidence interval we just need to use prop.test function in R but we need to make sure that we put correct argument to FALSE so that the confidence interval will be calculated without continuity correction. In the below examples, we have found the 95% confidence interval for different values of sample size and number of successes.Example Live Demoprop.test(x=25, n=100, conf.level=0.95, correct=FALSE)Output1-sample proportions test without continuity correction data: 25 out of 100, null probability 0.5 X-squared = 25, df = 1, p-value = 5.733e-07 ... Read More

How to find the maximum of factor levels in numerical column and return the output including other columns in the R data frame?

Nizamuddin Siddiqui
Updated on 10-Oct-2020 12:54:58

712 Views

When we have factor column that helps to differentiate between numerical column then we might want to find the maximum value for each of the factor levels. This will help us to compare the factor levels in terms of their maximum and if we want to do this by getting all the columns in the data frame then aggregate function needs to be used with merge function.Consider the below data frame −Example Live Demoset.seed(78) Group

Program to find length of longest increasing subsequence in Python

Arnab Chakraborty
Updated on 10-Oct-2020 13:10:29

581 Views

Suppose we have a list of numbers. We have to find the length of longest increasing subsequence. So if the input is like [6, 1, 7, 2, 8, 3, 4, 5], then the output will be 5, as the longest increasing subsequence is [2, 3, 4, 5, 6].To solve this, we will follow these steps −Make an array called tails whose size is same as nums, and fill this with 0.size := 0for each element x in nums array −i := 0, j := sizewhile i is not same as j, thenmid := i + (j – i)/2if tails[mid] < ... Read More

How to take a subset of a matrix in R with finite values only if the matrix contains NA and Inf values?

Nizamuddin Siddiqui
Updated on 10-Oct-2020 12:50:52

406 Views

If we have a matrix that contains NA or Inf values and we want to take the subset of that matrix with finite values then only the rows that do not contain NA or Inf values will be the output. We can do this in R by using rowSums and is.finite function with negation operator !.Example Live Demoset.seed(999) M1

How to find the index of the last occurrence of repeated values in a vector in R?

Nizamuddin Siddiqui
Updated on 10-Oct-2020 12:41:25

551 Views

Indexing helps us to understand the location of the value in the vector. If we have a vector that contains repeated values then we might want to figure out the last occurrence of the repeated value. For example, if we have a vector x that contains 1, 1, 2, 1, 2 then the last occurrence of repeated values will be 4 and 5 because the last 1 is at 4th position and 2 is at the 5th position. We can find this by using tapply function in R.Example Live Demox1

Program to find longest even value path of a binary tree in Python

Arnab Chakraborty
Updated on 30-Jun-2025 15:49:58

246 Views

A Binary tree is one of the data structures in Python in which each element is known as a Node. Each node should have a minimum of two child nodes. These children nodes are called as left child and the right child. The top node of the binary tree is known as the Root Node, and the nodes with no children are called Leaf Nodes. Following is the representation of the Binary Tree in Python - 10 / \ 5 ... Read More

How to join points in a point chart with lines using ggplot2 in R?

Nizamuddin Siddiqui
Updated on 10-Oct-2020 12:35:08

563 Views

Usually, a point chart is created to assess the relationship or movement of two variables together but sometimes these points are scattered in a way that makes confusion. Hence, data analyst or researcher try to visualize this type of graph by joining the points with lines. In ggplot2, this joining can be done by using geom_line() function.Consider the below data frame −Example Live Demoset.seed(111) x

How to generate a normal random vector using the mean of a vector in R?

Nizamuddin Siddiqui
Updated on 10-Oct-2020 12:32:07

984 Views

To create a normal random vector, we can use rnorm function with mean and standard deviation as well as without passing these arguments. If we have a different vector derived from another distribution or simply represent some numbers then we can use the mean of that vector in the rnorm function for mean argument.Example Live Demoset.seed(101) x1

How to find prime numbers between two values or up to a value in R?

Nizamuddin Siddiqui
Updated on 10-Oct-2020 12:30:22

1K+ Views

We know that the prime numbers are the numbers that are not divisible by any number except by themselves or 1 and 1 is not considered as a prime number. In R, we can find the prime numbers up to a number or between two numbers by using Prime function of numbers package. If we want to find the total number of prime numbers between 1 and 10, then we just need to pass 10 inside the Prime function, otherwise range will be required.Loading numbers package −library("numbers")Primes(10)[1] 2 3 5 7Primes(100)[1] 2 3 5 7 11 13 17 19 23 ... Read More

Program to find longest equivalent sublist after K increments in Python

Niharikaa Aitam
Updated on 30-Jun-2025 16:52:55

219 Views

The longest equivalent sublist after K increments is known as the longest contiguous portion of a list where we can make all the elements equal by performing at most K increment operations. Suppose we have a list of numbers called nums and k. Now, consider an operation where we can increment any one element once. If we can perform operations at most k times, we have to find the longest sub-list containing equal elements. Input Output Scenario Let's consider the following scenario, as we can increment 9 once and 6 four times to get the sublist [10, 10, 10], ... Read More

Advertisements