Programming Articles - Page 853 of 3363

How to create ACF plot in R?

Nizamuddin Siddiqui
Updated on 22-Nov-2021 07:22:14

9K+ Views

The autocorrelation plot or ACF plot is a display of serial correlation in data that changes over time. The ACF plot can be easily created by using acf function.For example, if we have a vector called V then we can create its autocorrelation plot by using the command given below −acf(V)Check out the below examples to understand how it can be done.Example 1To create ACF plot in R, use the code given below −x

How to convert character column of a matrix into numeric in R?

Nizamuddin Siddiqui
Updated on 22-Nov-2021 07:19:54

3K+ Views

If we have a matrix that contains character columns and we want to convert a single column to numeric then we first need to convert the matrix into a data frame using as.data.frame function after that as.numeric function can be used to change the particular column to numeric type as shown in the below examples.Example 1Following snippet creates a matrix −M1

How to find the average of a particular column in R data frame?

Nizamuddin Siddiqui
Updated on 22-Nov-2021 07:12:53

14K+ Views

To find the average of a particular column in R data frame, we can take the help of delta ($) operator.For example, if we have a data frame called df that contains a column x then we can find the average of column x by using the command given below −mean(df$x)Example 1Following snippet creates a sample data frame −x1

How to find the mean of all matrices stored in an R list?

Nizamuddin Siddiqui
Updated on 22-Nov-2021 07:08:25

450 Views

To find the mean of all matrices stored in an R list, we can use sapply function along with mean function. For example, if we have a list called LIST that contains some matrices then the mean of each matrix can be found by using the command given below −sapply(LIST,mean)Check out the below given example to understand how it works.ExampleFollowing snippet creates a list of matrices −M1

How to update single value in an R data frame?

Nizamuddin Siddiqui
Updated on 22-Nov-2021 07:04:37

3K+ Views

To update single value in an R data frame, we can use row and column indices with single square brackets.For example, if we have a data frame called df that contains two columns and ten rows and if we want to change the fifth value in second column to 10 then we can use the command given below −df[5,2]

How to find the coordinate of a value in an R matrix?

Nizamuddin Siddiqui
Updated on 22-Nov-2021 07:00:27

2K+ Views

The coordinate of a value in an R matrix is the row and column intersection that is the row and column index for that particular value. This can be found by using which function.For example, if we have a matrix called M that contains value starting from 1 to 20 then we can find the coordinate of value 5 by using the command given below − which(M==5,arr.ind=TRUE)ExampleFollowing snippet creates a matrix −M1

How to group test cases in Pytest?

Debomita Bhattacharjee
Updated on 19-Nov-2021 12:14:41

1K+ Views

We can group test cases in Pytest. Pytest is a test framework in python. To install pytest, we need to use the command pip install pytest. After installation, we can verify if python has been installed by the command pytest – version. The version of pytest shall be known.Pytest can be used for creating and executing test cases. It can be used in a wide range of testing API, UI, database, and so on. The test file of pytest has a naming convention that it starts with test_ or ends with _test keyword and every line of code should be ... Read More

What are fixtures in Pytest?

Debomita Bhattacharjee
Updated on 19-Nov-2021 12:10:34

336 Views

The fixtures are methods that shall execute before each test method to which it is associated in pytest. Pytest is a test framework in python. To install pytest, we need to use the command pip install pytest. After installation, we can verify if python has been installed by the command pytest –version. The version of pytest shall be known.Pytest can be used for creating and executing test cases. It can be used in a wide range of testing API, UI, database, and so on. The test file of pytest has a naming convention that it starts with test_ or ends ... Read More

How to exclude a test from execution in Pytest?

Debomita Bhattacharjee
Updated on 19-Nov-2021 12:09:05

6K+ Views

We can exclude a test from execution in Pytest. Pytest is a test framework in python. To install pytest, we need to use the command pip install pytest. After installation, we can verify if python has been installed by the command pytest –version. The version of pytest shall be known.Pytest can be used for creating and executing test cases. It can be used in a wide range of testing API, UI, database, and so on. The test file of pytest has a naming convention that it starts with test_ or ends with _test keyword and every line of code should ... Read More

How to execute a selected test from a collection of tests in Pytest?

Debomita Bhattacharjee
Updated on 19-Nov-2021 12:04:57

693 Views

We can execute a selected test from a collection of tests in Pytest. Pytest is a test framework in python. To install pytest, we need to use the command pip install pytest. After installation, we can verify if python has been installed by the command pytest –version. The version of pytest shall be known.Pytest can be used for creating and executing test cases. It can be used in a wide range of testing API, UI, database, and so on. The test file of pytest has a naming convention that it starts with test_ or ends with _test keyword and every ... Read More

Advertisements