Server Side Programming Articles

Page 12 of 2108

PHP tan() Function

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

Definition and UsageThe tan() function returns the tangent ratio of given angle in radians. In trigonometry, tangent of an angle is defined as ratio of lengths of opposite side and adjacent side.tan(x) = opposite/adjacenttangent of an angle is also defined as ratio of its sine and cosinetan(x) = sin(x)/cos(x)If x=45 degree, tan(x) = 1 as in a right angled traingle, opposite and adjacent sides are qual.This function returns a float value.Syntaxtan ( float $arg ) : floatParametersSr.NoParameter & Description1argA floating point value that represents angle in radiansReturn ValuesPHP tan() function returns tangent ratio of given parameter.PHP VersionThis function is available in PHP versions 4.x, PHP ...

Read More

Why do we get warning 'newdata' had 1 row but variables found have X rows while predicting a linear model in R?

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

The reason we get newdata had 1 row warning is the newdata is not correctly defined. We should give the name of the explanatory variable or independent variable to the newdata so that the model can identify that we are passing the mean of the explanatory variable, otherwise it considers all the values of the explanatory hence the result of the predict function yields the predicted values for the sample size.Examplepredict(M, newdata=data.frame(1.2), interval="confidence") fit lwr upr 1 4.645695 3.690676 5.600715 2 4.459543 3.635161 5.283925 ...

Read More

How to save a plot as SVG created with ggplot2 in R?

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

   There are multiple ways to save a plot created in R. Base R provides, metafile, bitmap, and postscript options to copy and save the plots created in R but we can also save the plots created with ggplot2 as an SVG file with the help of svglite package. The ggsave function of svglite package does this job easily and we can also define the height and width of the plot inside this function.Examplehead(ToothGrowth) len supp dose 1 4.2 VC 0.5 2 11.5 VC 0.5 3 7.3 VC 0.5 4 5.8 VC 0.5 5 6.4 VC 0.5 6 10.0 VC 0.5 library(ggplot2) library(svglite) ScatterPlotImage

Read More

How to create a line chart for a subset of a data frame using ggplot2 in R?

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

Subsetting is not a difficult thing in R but if we make our code short then it is a little tedious task because we will have to introduce code between codes and that creates confusion. Therefore, we must be very careful while writing a code inside another code. To create a line with subsetting the data frame using ggplot function of ggplot2 can be done by using subset function.Exampleggplot(subset(df,x1 %in% c("Sample1","Sample2","Sample3")))+ + geom_line(aes(x2,x3,group=x1,colour=x1))Output

Read More

How to add or multiply each element of a matrix to the corresponding element of another matrix in R, if these matrices are stored as a list?

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

Basic mathematical operations such as addition, subtraction, multiplication, and division are common for matrices and we often do that but if the matrices are stored as a list in R then these basic calculations are done differently as they are not direct objects. To add or multiply the matrices in a list, we can use Reduce function with the plus (+) or multiply (*) sign and the list name.ExampleMatrices_List

Read More

How to create a new data frame for the mean of rows of some columns from an R data frame?

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

Finding row means help us to identity the average performance of a case if all the variables are of same nature and it is also an easy job. But if some of the columns have different type of data then we have to extract columns for which we want to find the row means. Therefore, we can create a new data frame with row means of the required columns using rowMeans function.Examplerow_means_3.4_cols_df

Read More

How to a split a continuous variable into multiple groups in R?

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

Splitting a continuous variable is required when we want to compare different levels of a categorical variable based on some characteristics of the continuous variable. For example, creating the salary groups from salary and then comparing those groups using analysis of variance or Kruskal-Wallis test. To split a continuous variable into multiple groups we can use cut2 function of Hmisc package −Exampledf$Salary_Group

Read More

How to find the mean of columns of an R data frame or a matrix?

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

If all the columns in an R data frame are numeric then it makes sense to find the mean for each of the columns. This calculation will help us to view how different the values of means are for each of the columns but to make sure that they are significantly different, we will need to run a hypothesis test. To find the column means of a data frame or a matrix we can use colMeans function.ExampleConsider the below data frame −set.seed(9) x1

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

Program to check whether one value is present in BST or not in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 1K+ Views

Suppose we have a binary search tree and another input called val, we have to check whether val is present in the tree or not.So, if the input is likeval = 7, then the output will be True, as 7 is present in the tree.To solve this, we will follow these steps−Define a function solve() . This will take root, valif root is null, thenreturn Falseif data of root is same as val, thenreturn Trueif data of root < val, thenreturn solve(left of root, val)return solve(right of root, val)Let us see the following implementation to get better understanding−class TreeNode:   ...

Read More
Showing 111–120 of 21,076 articles
« Prev 1 10 11 12 13 14 2108 Next »
Advertisements