Programming Articles

Page 2275 of 2547

How to fill the NA values from above row values in an R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 08-Oct-2020 1K+ Views

Sometimes we have missing values that can be replaced with the values on the above row values, it often happens in situations when the data is recorded manually and the person responsible for it just mention the unique values because he or she understand the data characteristics. But if this data needs to be re-used by someone else then it does not make sense and we have to connect with the concerned person. If the concerned person tells us that the first value in each row can be filled for every NA in the same column then it can be ...

Read More

How to represent the mean with vertical line in a histogram created by hist function in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 08-Oct-2020 2K+ Views

The value of mean is an important characteristic of the data to be represented by a histogram, therefore, one might want to plot it with the histogram. If the histogram is created by using hist function then we can create a vertical line on the histogram with the help of abline function by defining mean of the data for vertical argument v.Exampleset.seed(101) x

Read More

How to represent the legend in a plot created by using plot function with colored straight lines or stars in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 08-Oct-2020 272 Views

A legend helps us to differentiate between the type of values or any another division of values in a data set. These legends can be represented in many ways and two of these ways are straight lines and stars. To represent the legend in a plot created by using plot function with colored straight lines or stars, we need to correct lty and pch arguments.ExampleConsider the below vectors −set.seed(199) x

Read More

How to create a frequency polygon in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 08-Oct-2020 2K+ Views

Frequency polygons are the graphs of the values to understand the shape of the distribution of the values. They are useful in comparing different data sets and visualising cumulative frequency distribution of the data sets. In base R, we can use polygon function to create the frequency polygon but first we should create a line plot for the two variables under consideration.ExampleConsider the below vectors x and y −set.seed(999) x

Read More

How to reduce the size of the area covered by legend in R for a plot created by using plot function?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 08-Oct-2020 2K+ Views

By default, the area covered by legends for a plot created by using plot function is of full size that is 1 (the area size has a range of 0 to 1, where 1 refers to the full size and 0 refers to none). To reduce the size, we can use cex argument with the legend function as shown in the below example.ExampleConsider the below vectors and the plot created between these two vectors −x

Read More

How to create a standard normal distribution curve with 3-sigma limits in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 07-Oct-2020 480 Views

A standard normal distribution has mean equals to zero and the standard deviation equals to one. Therefore, when we plot it with three sigma limits, we have six points on the X-axis referring to the plus and minus around zero. If the limits are defined then the plotting can be shown with larger width and that will change the display of the curve. We can do this by creating a sequence for the length of the standard normal variable and its density.Consider the below vectors corresponding to the limits and density−x

Read More

Program to find N-th term of series 0, 2,1, 3, 1, 5, 2, 7, 3...in C++

Ayush Gupta
Ayush Gupta
Updated on 03-Oct-2020 241 Views

In this problem, we are given a number N. Our task is to create a Program to find N-th term of series 0, 2, 1, 3, 1, 5, 2, 7, 3...in C++.Problem Description − We are given the Series −0, 2, 1, 3, 1, 5, 2, 7, 3...N TermTo find the Nth term of this series, we will formula the general term of the series and then find the Nth term.Let’s take an example to understand the problem, Input − N = 7Output − 2Solution Approach :To solve the problem and find the general formula for the series. We need ...

Read More

Program to find N-th term of series 0, 9, 22, 39, 60, 85, 114, 147, ...in C++

Ayush Gupta
Ayush Gupta
Updated on 03-Oct-2020 224 Views

In this problem, we are given a number N. Our task is to create a Program to find N-th term of series 0, 9, 22, 39, 60, 85, 114, 147, …in C++.Problem Description − We are given the Series −0, 9, 22, 39, 60, 85, 114, 147, ....NtermsTo find the Nth term of this series, we will formula the general term of the series and then find the Nth term.Let’s take an example to understand the problem, Input − N = 6Output − 85Solution Approach:To find the general term of the series. Let’s observe the growth of the values of ...

Read More

Program to find N-th term of series 1, 3, 12, 60, 360...in C++

Ayush Gupta
Ayush Gupta
Updated on 03-Oct-2020 231 Views

In this problem, we are given a number N. Our task is to create a Program to find N-th term of series 1, 3, 12, 60, 360...in C++.Given Series1, 3, 12, 60, 360, 2520 … N TermsLet’s take an example to understand the problem, Input − N = 6Output − 2520Solution Approach:The general term formula for this one is a bit tricky. So, the increase in the series values is huge. So, there can be a few possibilities factorial or exponentials. So, we will first consider factorial, and on observing we can see the growth half as half of the ...

Read More

Program to find N-th term of series 0, 11, 28, 51, 79, 115, 156, 203, ...In C++

Ayush Gupta
Ayush Gupta
Updated on 03-Oct-2020 166 Views

In this problem, we are given a number N. Our task is to create a program to find N-th term of series 0, 11, 28, 51, 79, 115, 156, 203, … In C++.Problem Description − To find the Nth terms of the series −0, 11, 28, 51, 79, 115, 156, 203, … N-th term.Let’s take an example to understand the problem,Input − N = 5Output − 79Solution Approach:The general formula for nth term of the series is −Tn = 3*(N*N) + 2*N - 5Program to illustrate the working of our solution,#include using namespace std; int findNTerm(int N) { int nthTerm = ( (3*N*N) + 2*N - 5); return nthTerm; } int main() { int N = 9; cout

Read More
Showing 22741–22750 of 25,466 articles
Advertisements