Found 26504 Articles for Server Side Programming

Find the Nth Number Made Up of only Odd Digits using C++

Prateek Jangid
Updated on 23-Nov-2021 10:35:12

560 Views

C++ has a huge list of functions to solve mathematical issues. One of the mathematical functions is to find Nth odd digits using codes. This article will describe the complete approach of finding the odd Nth number and understand what odd numbers are and what numbers are made up of odd digits.Finding the Nth Number Made up of Odd Digits OnlyOdd numbers give remainder on dividing by two, so the first few odd numbers are 1, 3, 5, 7, 9, 11, 13, 15, 17, 19...To find the required number, we have two approaches here −Approach 1 − Check every natural ... Read More

Find the Nth_Non_Square_Number using C++

Prateek Jangid
Updated on 23-Nov-2021 10:35:55

243 Views

We all know about the numbers that are not square of any number like 2, 3, 5, 7, 8, etc. There are Nth numbers of non-square numbers, and it is impossible to know every number. So In this article, we will explain everything about the square-free number or non-square number and what are the ways to find Nth non-square number in C++.Nth Non-Square NumberA number is said to be a perfect square if it is a square of an integer. Some example of perfect square numbers are −1 is square of 1 4 is square of 2 9 is square ... Read More

How to find the moving standard deviation in an R matrix?

Nizamuddin Siddiqui
Updated on 23-Nov-2021 06:52:55

387 Views

To find the moving standard deviation in a matrix is done in the same way as in a data frame, we just need to use the matrix object name in place of data frame name. Hence, we can make use of rollapply function of zoo package for this purpose.For example, if we have a matrix called M and we want to find the 2 moving standard deviations then we can use the below given command −rollapply(M,width=2,FUN=sd,fill=0,align="r")Example 1Following snippet creates a matrix −M1

How to round the summary output in R?

Nizamuddin Siddiqui
Updated on 23-Nov-2021 06:49:16

4K+ Views

To round the output of summary function in R, we can use digits argument while applying the summary function.For example, if we have a data frame called df then to find the summary statistics with two digits in the output we can use the below given command −summary(df, digits=2)Example 1Following snippet creates a dataframe −head(iris, 20) The following dataframe is created − Sepal.Length Sepal.Width Petal.Length Petal.Width Species 1    5.1       3.5         1.4         0.2         setosa 2    4.9       3.0         1.4 ... Read More

How to find the row wise sum for n number of columns in R?

Nizamuddin Siddiqui
Updated on 23-Nov-2021 06:36:30

3K+ Views

To find the row wise sum of n number of columns can be found by using the rowSums function along with subsetting of the columns with single square brackets.For example, if we have a data frame called df that contains five columns and we want to find the row sums for last three columns then we can use the following command −df$Sum_3

How to extract the maximum value from named vector in R?

Nizamuddin Siddiqui
Updated on 23-Nov-2021 06:31:08

1K+ Views

To extract the maximum value from named vector in R, we can use which.max function.For example, if we have a vector called X which is a named vector then we can use the following command to find the maximum value in X.X[which.max(X)]Check out the below examples to understand how it works.Example 1Following snippet creates a vector −x1

How to reduce the space between Y-axis value and ticks using ggplot2 in R?

Nizamuddin Siddiqui
Updated on 23-Nov-2021 06:21:07

5K+ Views

To reduce the space between axis value and ticks using ggplot2, we can use theme function of ggplot2 package with margin set to 0.For example, if we have a data frame called df that contains two columns say x and y then the scatterplot between x and y with reduced space between Y-axis value and ticks can be created by using the following command −ggplot(df,aes(x,y))+geom_point()+theme(axis.text.y=element_text(margin=margin(r=0)))ExampleFollowing snippet creates a sample data frame −x

How to display fraction in a plot title using ggplot2 in R?

Nizamuddin Siddiqui
Updated on 23-Nov-2021 06:11:56

1K+ Views

To display fraction in a plot title using ggplot2 in R, we can use frac function inside ggtitle function of ggplot2 package. Generally, fraction is displayed as X/Y but frac function helps to create the fraction in over form.Check out the below example to understand how over form of fraction can be displayed in a plot title using ggplot2.ExampleFollowing snippet creates a sample data frame −x

How to find the sequence of correlation between variables in an R data frame or matrix?

Nizamuddin Siddiqui
Updated on 23-Nov-2021 05:51:00

308 Views

To find the sequence of correlation between variables in an R data frame or matrix, we can use correlate and stretch function from corrr package.For example, if we have a data frame called df then we can find the sequence of correlation between variables in df by using the below given command −df%>% correlate() %>% stretch() %>% arrange(r)Example 1Following snippet creates a sample data frame −x1% + arrange(r) Correlation method: 'pearson' Missing treated using: 'pairwise.complete.obs' # A tibble: 25 x 3OutputIf you execute all the above given snippets as a single program, it generates the following output −  ... Read More

How to create a matrix with vectors as elements in R?

Nizamuddin Siddiqui
Updated on 23-Nov-2021 05:45:59

757 Views

To create a matrix with vectors as elements in R, we can create arrays because an array contains matrices with vectors as elements.Check out the below given examples of arrays and vectors extracted by the arrays to understand how matrices stored in an array represent vectors as elements.Example 1Following snippet creates arrays consisting of matrices −Array

Advertisements