R

t-test and interpretation in R

Masumbuko Semba
A formal statistical test called a hypothesis test is used to confirm or disprove a statistical hypothesis. The following R hypothesis tests are demonstrated in this course. T-test with one sample T-Test of two samples T-test for paired samples Each type of test can be run using the R function t.test().The function comes with the following arguments; t.test(x, y = NULL, alternative = c("two-sided", "less", "greater"), mu = 0, paired = FALSE, var.

Combining plots in R

Masumbuko Semba
The ggplot2 package doesn’t provide a function to arrange multiple plots in a single figure (Wickham 2016). Still, some packages allow combining multiple plots into a single figure with custom layouts, width, and height, such as cowplot (Wilke 2018), gridExtra, and patchwork (Pedersen 2020). In this post we are going to use several packages, let’us load them in our session require(tidyverse) require(patchwork) require(cowplot) Sample datasets # tuna = tibble( # tl = runif(n = 120, min = 30, max = 120), # seasons = rep(c("Northeast", "Southeast", "Inter"), each = 40) # ) tuna = tibble( tl = c(rnorm(n = 40, mean = 80, sd = 30), rnorm(n = 40, mean = 61,10), rnorm(n = 40, mean = 96, 25)), seasons = rep(c("Northeast", "Southeast", "Inter"), each = 40) ) ridges = tuna %>% ggplot() + ggridges::geom_density_ridges(aes(x = tl, y = seasons, fill = seasons), position = "identity", alpha = .

A chord diagram in R

Masumbuko Semba
A chord diagram is a graphical representation of the data in a matrix’s interrelationships. The data is arranged in a radial pattern around a circle, with the relationships between the data points commonly depicted as arcs linking the dots (Wikipedia). Each entity is represented by a fragment on the outer part of the circular layout. Then, arcs are drawn between each entities. The size of the arc is proportional to the importance of the flow.

Data Management Plans

Masumbuko Semba
Data is the most important asset. It validates a research story and a conclusions; it provides a platform of confidence for other researchers who might continue your work; and it is a resource that can be used by researchers in other fields to undertake new work, perhaps completely unrelated to your own research interests. Well-organised data that is accessible to the research community can continue to provide extended benefit and value long after your projects have been completed.

PCA made easy in R

Masumbuko Semba
R
In the previous post I illustrated a simple way to do Principal Component Analysis in R. I simply used the output results from prcomp() function of R base. But, I constantly find hard to the untidy output that prcomp generates and wished to get a tidy result. In this post I will illustrate the approaches that I was inspired by Claus Wilke in the post PCA tidyverse style.