Book Image

R for Data Science Cookbook (n)

By : Yu-Wei, Chiu (David Chiu)
Book Image

R for Data Science Cookbook (n)

By: Yu-Wei, Chiu (David Chiu)

Overview of this book

This cookbook offers a range of data analysis samples in simple and straightforward R code, providing step-by-step resources and time-saving methods to help you solve data problems efficiently. The first section deals with how to create R functions to avoid the unnecessary duplication of code. You will learn how to prepare, process, and perform sophisticated ETL for heterogeneous data sources with R packages. An example of data manipulation is provided, illustrating how to use the “dplyr” and “data.table” packages to efficiently process larger data structures. We also focus on “ggplot2” and show you how to create advanced figures for data exploration. In addition, you will learn how to build an interactive report using the “ggvis” package. Later chapters offer insight into time series analysis on financial data, while there is detailed information on the hot topic of machine learning, including data classification, regression, clustering, association rule mining, and dimension reduction. By the end of this book, you will understand how to resolve issues and will be able to comfortably offer solutions to problems encountered while performing data analysis.
Table of Contents (19 chapters)
R for Data Science Cookbook
About the Author
About the Reviewer

Understanding the Wilcoxon Rank Sum and Signed Rank tests

The Wilcoxon Rank Sum and Signed Rank test (Mann-Whitney-Wilcoxon) is a nonparametric test of the null hypothesis that two different groups come from the same population without assuming the two groups are normally distributed. This recipe will show you how to conduct a Wilcoxon Rank Sum and Signed Rank test in R.

Getting ready

In this recipe, we will use the wilcox.test function that originated from the stat package.

How to do it…

Perform the following steps to conduct a Wilcoxon Rank Sum and Signed Rank test:

  1. First, prepare the Facebook likes of a fan page:

    > likes <- c(17,40,57,30,51,35,59,64,37,49,39,41,17,53,21,28,46,23,14,13,11,17,15,21,9,17,10,11,13,16,18,17,27,11,12,5,8,4,12,7,11,8,4,8,7,3,9,9,9,12,17,6,10)
  2. Then, plot the Facebook Likes data into a histogram:


    Figure 10: The histogram of Facebook likes of a fan page

  3. Now, perform a one-sample Wilcoxon signed rank test to determine whether the median of the input...