Why Type I ANOVA is Sequential Sum of Squares (R code example)

Type 1 ANOVA is also called sequential sum of squares, because it considers the order effect of entering factors into the model. If you change the order of the factors in the model, the results will be different. The following uses an example in R to explain this. Step 1: Prepare the data The following is … Read more

How to Interpret Type 1, Type 2, and Type 3 ANOVA

1. Introduction What are the meanings of different types of ANOVA? In other words, what are Type 1 (Type I), Type 2 (Type II), and Type 3 (Type III) ANOVA? The following uses the model of factors A and B, and its interaction A*B as an example to explain the difference of Type 1 (Type … Read more

How to Conduct Two-Way ANOVA in R

This tutorial shows how you can do two-way ANOVA in R with examples. A two-way ANOVA is used to test whether the means from the two or more categorieal variables are significantly different from one another. For instance, below, there are two categorical variables, namely city (city 1 and city 2) and store (store 1 and store 2). … Read more

Categories R

R Vetors

Vectors are a basic data object in R. There are six types of vectors, namely logical, integer, double, complex, character and raw. You can use a c() function to create vectors, and the following shows the examples. 1. Logical Vector Output: [1] TRUE FALSE [1] “logical” 2. Integer Vector Output: [1] 44 56 [1] “integer” … Read more

Categories R

Combine Vetors to a Dataframe in R

How can you combine vectors into a dataframe in R. To do that, we can use the function of data.frame() to convert vetors into a dataframe in R. The following is the example. Step 1: Generating Vetors Output: [1] “City1” “City1” “City1” “City1” “City1” “City2” “City2” “City2” “City2” “City2” [1] “store1” “store2” “store1” “store2” “store1” … Read more

Categories R

rep() Function in R (4 Examples)

rep() is a built-in R function that replicates the values in the provided vector. This tutorial shows how to use rep() function in R with 4 examples. Example 1 The following code is to repeat the number 4 twice. Output: [1] 4 4 Example 2 Output: [1] 1 2 3 1 2 3 1 2 3 … Read more

Categories R

rep() Function in R (Examples)

rep() is a built-in R function that replicates the values in the provided vector. The following shows examples of using rep() in R. Example 1 The following code is to repeat the number 4 twice. Output: [1] 4 4 Example 2 Output: [1] 1 2 3 1 2 3 1 2 3 1 2 3 Example … Read more

Categories R

How to Convert Array to Column in Pandas dataframe

You can use pd.DataFrame() function to convert an array to a column in a Pandas dataframe. The following shows examples of how to convert array from Numpy to a column in Pandas. Example 1: Single Column Step 1: Using Numpy to create an array Output: [‘City1’ ‘City1’ ‘City1’ ‘City1’ ‘City1’ ‘City2’ ‘City2’ ‘City2’ ‘City2’ ‘City2’] … Read more

How to Create an Empty Matrix in NumPy

The syntax of creating an empty array is as follows. Method 1: Full of zero numpy.zeros(shape=(n,m)) Method 2: Really empty Note that, empty, unlike zeros, does not set the array values to zero, and may therefore be marginally faster. However, it requires the user to manually set all the values in the array, and thus you … Read more