Server Side Programming Articles

Page 1159 of 2109

How to find the row mean for columns in an R data frame by ignoring missing values?

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

To find the row mean for columns by ignoring missing values, we would need to use rowMeans function with na.rm. For example, if we have a data frame called df that contains five columns and some of the values are missing then the row means will be calculated by using the command: rowMeans(df,na.rm=TRUE).Consider the below data frame −Examplex1

Read More

How to remove rows from an R data frame that contains at least one NaN?

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

The NA values and NaN values are very different in nature, therefore, removal of rows containing NA values is different from removal of rows containing NaN values. For example, if we have a data frame that has NaN values the rows will be removed by using the is.finite function as shown in the below examples.Consider the below data frame −Examplex1

Read More

How to add a row to a frame from another data frame in R?

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

Sometimes we want to add new data to original data frame in situations such as we need more data for analysis, looking for comparison between small size and large size data, or some data is missing in the original data and hence need more to be added from other data sets. One such thing would be adding a new to an existing data frame from another data frame. It can be done with the help of rbind function as shown in the below example.Consider the below data frames df1 and df2 −Examplex

Read More

How to create boxplot for list elements using ggplot2 in R?

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

If list elements are of equal size having numerical values then the boxplot for each element can be created by using ggplot2 but before creating the boxplot we would need to convert the list to a data frame. The conversion of list elements to a data frame will be done by unlisting of elements and creating two columns, one for categories and one for response variable. Check out the below example to understand how it works.Consider the below list −ExampleList

Read More

How to create Directories using the File utility methods in Java?

Maruthi Krishna
Maruthi Krishna
Updated on 11-Mar-2026 454 Views

Since Java 7 the File.02s class was introduced this contains (static) methods that operate on files, directories, or other types of files.The createDirectory() method of the Files class accepts the path of the required directory and creates a new directory.ExampleFollowing Java example reads the path and name of the directory to be created, from the user, and creates it.import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Scanner; public class Test {    public static void main(String args[]) throws IOException {       System.out.println("Enter the path to create a directory: ");       Scanner sc = new Scanner(System.in);       ...

Read More

How to multiply only one column in an R data frame with a number?

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

To multiply only one column with a number, we can simply use the multiplication operator * but need to replace the original column with the new values. For example, if we have a data frame called df that contains three columns x1, x2, and x3, and we want to multiply the second column x2 with 2 then it can be done as df$x2

Read More

How to create a combination of pairs from a vector in R?

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

To create a combination of pairs, we can use the combn function. This function will be helpful to use the vector length and the value 2 that represents a pair to create the combinations. Although, this is enough but we can transpose the output to get a better−looking output.Example1x1

Read More

How to convert a super class variable into a sub class type in Java

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

Inheritance is a relation between two classes where one class inherits the properties of the other class. This relation can be defined using the extends keyword as −public class A extends B{}The class which inherits the properties is known as sub class or, child class and the class whose properties are inherited is super class or, parent class.In inheritance a copy of super class members is created in the sub class object. Therefore, using the sub class object you can access the members of the both classes.Converting a super class reference variable into a sub class typeYou can try to convert ...

Read More

How to add a new value to each element of list in R?

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

Suppose we have a list that contain two elements and we get a new value for both of these elements then the problem of adding those values to the original list arises. This can be done with the help of mapply function. We can append the new values in the original easily but a vector of the new values needs to be created first.Example1List1

Read More

How to create a large vector with repetitive elements of varying size in R?

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

To create a large vector of repetitive elements of varying size we can use the rep function along with the logical vector as an index. The logical vector that contains TRUE or FALSE will define the selection or omission of the values in the vector created with the help of rep function as shown in the below examples. If the vector created by using rep is larger than the logical vector then the logical vector will be recycled.Example1x1

Read More
Showing 11581–11590 of 21,090 articles
Advertisements