Programming Articles

Page 10 of 2545

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

PHP sqrt() Function

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

Definition and UsageThe sqrt() function returns square root of a positive float number. Since square root for negative number is not defined, it returns NAN. This is one of the most commonly used functions.This function always returns a floating point number.Syntaxsqrt ( float $arg ) : floatParametersSr.NoParameter & Description1arga number whose square root is to be obtainedReturn ValuesPHP sqrt() function returns square root of the given arg number. For negative number, the function returns NAN.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.ExampleOutputThis will produce following result −sqrt(-1) = NAN

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 971 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

PHP srand() Function

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

Definition and UsageThe srand() function is used to seed the random number generaror. Seeding initializes the random number generator. Most random number generators need initial seeding. In PHP, use of srand() function is optional as it is done automatically.This function doen't have any return value.Syntaxsrand ([ int $seed ] ) : voidParametersSr.NoParameter & Description1seedan integer to be used as seed. If not given, a random number is givenReturn ValuesThis function doesn't return any value.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.ExampleOutputThis may produce following result−rand()=548287992

Read More

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

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 883 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

Matching Nonprintable Characters using Java regex

Maruthi Krishna
Maruthi Krishna
Updated on 11-Mar-2026 1K+ Views

There are 7 common non printable characters used in general and each character has its own hexadecimal representation.NamecharactersHexa-decimal representationbell\a0x07Escape\e0x1BForm feed\f0x0CLine feed0x0ACarriage return\r0X0DHorizontal tab\t0X09Vertical tab\v0X0BExample 1import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample1 {    public static void main(String[] args) {       Scanner sc = new Scanner(System.in);       System.out.println("Enter input text: ");       String input = sc.nextLine();       String regex = "\x09";       //Creating a pattern object       Pattern pattern = Pattern.compile(regex);       //Matching the compiled pattern in the String       Matcher matcher = ...

Read More

How to deal with the error “Error in int_abline---plot.new has not been called yet” in R?

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

The above error means plot is not being created yet hence abline function cannot be used to draw anything on the plot. Therefore, a plot needs to be created first to use abline function for creating a line or any other thing. Mostly, abline is used to create regression line on the plot, thus we need to create a scatterplot first before using abline.Exampleabline(lm(y~x))Output

Read More

How to create correlation matrix plot in R?

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

To create a correlation matrix plot, we can use ggpairs function of GGally package. For example, if we have a data frame called df that contains five columns then the correlation matrix plot can be created as ggpairs(df). A correlation matrix plot using ggpairs display correlation value as well as scatterplot and the distribution of variable on diagonal.Examplelibrary(GGally) ggpairs(df)Output

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 91–100 of 25,445 articles
« Prev 1 8 9 10 11 12 2545 Next »
Advertisements