Latex Code for Correlation Formula

The following are the correlation formula. Below includes tutorials showing how to write it as Latex code in Markdown and WordPress. Latex Code for Correlation Formula The following is the Latex code for correlation formula. r_{xy}=\frac{\sum_{i=1}^{n}((x_i-\bar{x})(y_i-\bar{y}))}{\sqrt{\sum_{i=1}^{n}(x_i-\bar{x})^2}\sqrt{\sum_{i=1}^{n}(y_i-\bar{y})^2}} Latex Code for Correlation Formula in Markdown You can use the following Latex code to show the correlation formula … Read more

Latex Code for Density Function of Normal Distribution

The following is density function of normal distribution. Below includes tutorials showing how to write it as Latex code in Markdown and WordPress. Latex Code for Density Function of Normal Distribution The following is raw Latex code for the density function for normal distribution. f(x)=\frac{1}{\sqrt{2 \pi \sigma^2}}e^{-\frac{1}{2}(\frac{x-\mu}{\sigma})^2} Latex Code for Density Function of Normal Distribution … Read more

How to Use rnorm in R (Examples of Simulate Normal Distribution)

rnorm() in R can be used to simulate a sample of normal distribution data. This tutorial uses 3 examples showing how you can simulate normal distribution sample using rnorm(). In particular, rnorm has the following statement. rnorm(n, mean=0, sd=1) n: The number of observations, namely the sample size mean: The mean of the normal distribution sample data. The default … Read more

Categories R

How to Calculate Trimmed Means in R (Examples)

A trimmed mean is a mean trimmed by x%, where x is the percentage of observations removed from both the upper and lower bounds. For instance, 10% trimmed mean is the mean computed by excluding th 10% largest and 10% smallest observations in the data. mean() in R has the parameter of trim, which should … Read more

Categories R

How to Use Mean() In R with Examples

mean() can be used to calculate mean in R. The following is the basic statement. mean(x, trim = 0, na.rm = FALSE) x: It is an R object.  trim: It is in the range of (0 to 0.5). The number indicates the percentage of observations to be trimmed from each end of sorted x, before the mean is computed. … Read more

Categories R

How to Interpret Interaction Effects in Linear Regression (4 Steps)

This tutorial shows how to interpret interaction effects in linear regression models. In summary, there are two perspectives, (a) mean difference perspective and (b) slope difference perspective. Interpret Interaction Effect in Linear Regression (a) Mean Difference Perspective: One way to interpret interaction effects in linear regression is based on mean differences. A significant interaction means … Read more

How to Plot 2-Way ANOVA Interaction in R (with Example)

This tutorial shows how to plot the figure for the interaction in 2-way ANOVA in R. Steps of Plotting 2-Way ANOVA Interaction in R Step 1: Prepare the data The following is the data being used for the examples. It has two categorical variables (i.e., City and Brand) and one continuous variable (i.e., sales). Output: … Read more

Categories R

How to Use stringsAsFactors in R

stringsAsFactors decides the strings will be considered as factors or just strings or characters. The following uses two examples to explains the difference. Example 1: stringsAsFactors= FALSE The following sets stringsAsFactors= FALSE. We can see that the data type of the column of Names is characters. (chr represents characters.) Output: Names Ages 1 Jack 32 … Read more

Categories R

How to Calculate Means by Group in R (2 Examples)

This tutorial is about how to calculate means by group in R. There are two methods of calculating means by groups in R, either aggregate() or dplyr. Method 1: Use base R aggregate(df$col_being_aggregated, list(df$col_1_groupby,df$col_2_groupby,…), FUN=mean) Method 2: Use package of dplyr library(dplyr) df%>% group_by(col_1_groupby,col_2_groupby,…) %>% summarise_at(vars(col_being_aggregated), list(name = mean)) Example for Method 1 The following … Read more

Categories R

How to Avoid Including Dataframe Index when Saving as CSV file in Python

To avoid including the index column when saving as a CSV file, you can add index=False in df.to_csv() to avoid including the index clumn when saving a Python Pandas dataframe as a CSV file. df.to_csv(‘filename.csv’, index=False) Output: brands models 0 Tesla Model 3 1 Toyota RAV4 The following code with index=False is not to include … Read more