Programming Articles

Page 18 of 2546

How to align the bars of a barplot with the X-axis using ggplot2 in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 2K+ Views

The bar plot is created with geom_bar function but there always exist some space between the bars and the X-axis labels. If we want to reduce that space or completely remove it we need to use scale_y_continuous function by defining expand argument for former and scale_y_continuous(expand=c(0,0)) for latter.Exampleggplot(df,aes(x,y))+geom_bar(stat="identity")+scale_y_continuous(expand=c(0,0))Output

Read More

How to find the minimum value of an array in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 11-Mar-2026 3K+ Views

We can find the minimum value of an array using Math.min() and sort()1) Math.min() Math.min() function usually takes all the elements in an array and scrutinize each and every value to get the minimum value.It's methodology is discussed in the below example.    var numbers = [6, 39, 55, 1, 44];    document.getElementById("min").innerHTML = numbers;    function myFunction() {       numbers.sort(function(a, b){return b - a});    document.getElementById("min").innerHTML = numbers;    document.write(numbers[numbers.length-1]); } After running the program the out put will be shown as in  the following imageOutputOn clicking the click me button above ...

Read More

How to perform group-wise linear regression for a data frame in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 5K+ Views

The group−wise linear regression means creating regression model for group levels. For example, if we have a dependent variable y and the independent variable x also a grouping variable G that divides the combination of x and y into multiple groups then we can create a linear regression model for each of the group. In R, we can convert data frame to data.table object, this will help us to create the regression models easily.Exampledf2[,as.list(coef(lm(Salary~Ratings))),by=Class]OutputClass (Intercept) Ratings 1: I 31894.13 194.9152 2: III 35270.10 663.4089 3: II 40405.42 -1087.9103

Read More

PHP abs() Function

Malhar Lathkar
Malhar Lathkar
Updated on 11-Mar-2026 3K+ Views

Definition and UsageThe abs() function is an in-built function in PHP iterpreter. This function accepts any number as argument and returns a positive value, disregarding its sign. Absolute value of any number is always positive.This function always returns positive number.Syntaxabs( mixed $num)ParametersSr.NoParameter & Description1numThis parameter stores a value whose absolute value is to be obtained.Return ValuesPHP abs() function returns absolute value of num. If data type of num is float, return type is also float.For integer parameter, return type is integer.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.ExampleOutputThis will produce the following ...

Read More

PHP acosh() Function

Malhar Lathkar
Malhar Lathkar
Updated on 11-Mar-2026 306 Views

Definition and UsageThe acosh() function returns the inverse hyperbolic cosine ratio of given angle in of given parameter. In other words, the return value of asinh() is hyperbolic sine of given parameter. A hyperbolic inverse hyperbolic cosine function is defined as −.acosh(x) = log(x+sqrt(pow(x, 2)-1))This function returns a float value.Syntaxacosh ( float $arg ) : floatParametersSr.NoParameter & Description1argA floating point value whose inverse hyperbolic cosine is to be calculatedReturn ValuesPHP acosh() function returns inverse hyperbolic cosine ratio of given parameter.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.ExampleFollowing example calculates acosh(pi/2) and returns ...

Read More

Write a program to reverse digits of a number in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 659 Views

A program to reverse digits of a number will interchange the position of the digits and reverse there order.Let’s suppose be a number abcde the reverse will be edcba.Let’s take an example to understand the problem, Inputn = 786521Output125687To reverse digits of the number, we will take each digit of the number from MSB(unit digit) and add it to reverse number variable, after this divide the original number by 10 and the reverse_number is multiplied by 10. This will be done until the number becomes 0.This repetitive process can be accomplished by two methods, iteration, and recursion, we will create ...

Read More

How to print a one-month calendar of user choice using for loop in C?

Mandalika
Mandalika
Updated on 11-Mar-2026 6K+ Views

The logic to print a one-month calendar is as follows −for(i=1;i

Read More

How to find the total of frequency based on the values of a factor column in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 515 Views

Often, we have duplicate values in a factor column that means a factor column has many levels and each of these levels occur many times. In this situation, if we have a frequency column then we want to find the total of that frequency based on the values of a factor column and this can be done by using aggregate function.Example> Metal Quantity df2 head(df2, 10)   Metal    Quantity 1    Iron    43 2    Nickel  33 3    Lead    25 4    Zinc    24 5    Tin    27 6    Sodium  34 7    Silver ...

Read More

How to create a step histogram using ggplot2 in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 413 Views

To create a step histogram using ggplot2, we can use geom="step" argument inside stat_bin function. For example, if we have a data frame that contains a single column then the step histogram can be created using the command − ggplot(df,aes(x))+stat_bin(geom="step",bins=30)Examplelibrary(ggplot2) ggplot(df,aes(x))+stat_bin(geom="step",bins=30)Output

Read More

How to display star for significance in base R boxplot?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 3K+ Views

To display the star for significance in a base R boxplot, we can use text function. The text function will be helpful in defining the star sign (that is asterisk or *). If the significance is high then three stars are used and the significance is low then a single star is used. We need to use the appropriate position using x and y values.Exampletext(x=1,y=max(df$y[df$x==1]),"***",pos=3,cex=1.5)Output

Read More
Showing 171–180 of 25,451 articles
« Prev 1 16 17 18 19 20 2546 Next »
Advertisements