### 统计代写|数据可视化代写Data visualization代考|CPD146

statistics-lab™ 为您的留学生涯保驾护航 在代写数据可视化Data visualization方面已经树立了自己的口碑, 保证靠谱, 高质且原创的统计Statistics代写服务。我们的专家在代写数据可视化Data visualization代写方面经验极为丰富，各种代写数据可视化Data visualization相关的作业也就用不着说。

• Statistical Inference 统计推断
• Statistical Computing 统计计算
• Advanced Probability Theory 高等概率论
• Advanced Mathematical Statistics 高等数理统计学
• (Generalized) Linear Models 广义线性模型
• Statistical Machine Learning 统计机器学习
• Longitudinal Data Analysis 纵向数据分析
• Foundations of Data Science 数据科学基础

## 统计代写|数据可视化代写Data visualization代考|Importing Your Data

We are now ready to import our data into $R$. The data in question (sampleData.csv) involves a very short hypothetical study. It consists of two groups of students (control and target) as well as three test scores for each student (test $A$, test $B$, testC)-there are ten students in the data, so our dataset has ten rows and five columns $(10$ by 5$)$. This is a very common study design. For example, we could be examining the impact of two pedagogical approaches (target and control) on students’ learning (as measured by test scores). We will only use sampleData.csv to practice importing files into $\mathrm{R}-$ in later chapters we will examine more realistic hypothetical data.

Place the file sampleData.csv $(\$ 2.4 .1)$in the directory where your .Rproj file is, which means your directory basics will now have three files (four if you count df, created in lines 23-25 in code block 3): one .R script (rBasics.R), one .csv, and one .Rproj. Next, start a new script by clicking on File$\succ$New File$\succ R$Script (the same steps from$₫ 2.2 .2$), or press Cmd$+$Shift$+N$to achieve the same result. Save your new script as datalmport.$\mathrm{R}$, so that the file name is self-explanatory. You should now have four files in your directory. There are several options to import sampleData.csv into$R$. One option is to use the function read.csv()-you may remember that we used write.csv() in code block 3 to export our data frame.${ }^{13}$In your script (datalmport.R), write read.csv( “sampleData.csv”) and run the line to see what happens. You will notice that the entire dataset is printed in your console. But we want to assign our data to a variable, so that we can analyze it later. Let’s name our variable ch2. When you run$\operatorname{ch} 2=$read.csv( “sampleData.csv”),$\mathrm{R}$will do two things: first, import the data file; second, assign it to a variable named ch2. As a result, even though the dataset is not printed in the console, a variable has been added to your environment. This is exactly what we want. Imagine reading a dataset with 1,000 rows and having the entire dataset printed in your console (!). Being able to see an entire dataset is only useful if the dataset is small enough (and that is almost never the case). Notice that ch2 is not a file-it’s a variable inside RStudio. In other words, ch2 is a “virtual copy” of our data file; if we change it, it will not affect sampleData.csv. As a result, the actual data file will be safe unless we manually overwrite it by saving ch2 using write.csv$(\operatorname{ch} 2$, file = “sampleData.csv”$)$, for example. ## 统计代写|数据可视化代写Data visualization代考|The Tidyverse Package Before we proceed, it’s time to create another script. Even though you could do everything in a single script, it is useful to cultivate the habit of having one script for each type of task. For example, the script called datalmport. R has one main task: to import the data and check whether all is good. Now that we have imported our data, let’s create another script and save it as dataPrep. R. In this suripl, we will prepare the data for analysis. At the wp of dataPrep.$R$, type and run source( “datalmport.$R$“). When you run that line of code,$R$will run datalmport.$R$, and all the variables that are created within the script will appear in your environment (pane C). You can test it: click on the broom icon in pane$\mathrm{C}$, which will remove all variables from your environment (you could also restart RStudio). Alternatively, you can type and run$r m($list$=\operatorname{ss}()),{ }^{14}$which will also remove all variables from your environment. Now run source( “datalmport.R”) and watch ch2 reappear in your environment. You should now have a new script called dataPrep open. Next, let’s install tidyverse (Wickham 2017), likely the most important$R$package you have to know about. tidyverse consists of a set of user-friendly packages for data analysis. Even though we could accomplish all our tasks without the packages in tidyverse, doing so would be more cumbersome and would require separate packages that do not necessarily have the same syntax. As we will see throughout this book, tidyverse makes$R$code more intuitive because of its more natural syntax, and you can do almost everything in this book using this collection of packages. Don’t worry: by the end of the book, you will certainly be very familiar with tidyverse. Finally, you may recall that data tables were mentioned earlier$(\$2.3)$. If you’d like to use data tables instead of data frames (e.g., because you have too much data to process), you should definitely check the tidytable package (Fairbanks 2020 ). This package offers the speed of data tables with the convenience of tidyverse syntax, so you don’t have to learn anything new.

To install tidyverse, we will use the function install.packages(). ${ }^{15}$ During the installation, you might have to press ” $y$ ” in your console. Once the installation is done, we need to load the package using the function library(). The top of your script (dataPrep.R) should look like code block 5. Technically, these lines of code don’t need to be at the top of the document; they must, however, be placed before any other lines that require them-overall, it is best to source, install, and load packages in the preambles of files. Finally, once a package is installed, you can delete the line that installs it (or add a hashtag to comment it out) ${ }^{16}$-this will avoid rerunning the line and reinstalling the package by accident. We are now ready to use tidyverse.

When you install and load tidyverse, you will notice that this package is actually a group of packages. One of the packages inside tidyverse is dplyr (Wickham et al. 2020 ), which is used to manipulate data; another is called tidyr (Wickham and Henry 2019), which helps us create organized data; another package is called ggplot2, which is used to create figures. We will explore these packages later-you don’t need to load them individually if you load tidyverse.

## 统计代写|数据可视化代写Data visualization代考|Wide-to-Long Transformation

By now, we have created an $\mathrm{R}$ Project, an $\mathrm{R}$ script that imports sampleData. csv (which we called datalmport. R), and another script that prepares the data for analysis (dataPrep.R)-later we will import and prepare our data in a single script. When we source datalmport. $R$, we re-import our data variable, ch2. With that variable, we have used functions like summary(), str(), and head () to better understand what the structure and the contents of our data frame is. Our next step is to make our data tidy.

Throughout this book, we will rely on the concept of tidy data (Wickham et al. 2014). Simply put, a tidy dataset is a table where every variable forms a column and each observation forms a row. Visualize ch2 again by running head(ch2) – shown in Table 2.1. Note that we have three columns with test scores, which means our data is not tidy. This is not ideal because if we wanted to create a figure with “Test” on the $x$-axis and “Score” on the $\gamma^{\prime}$ axis, we would run into problems. A typical axis contains information from one variable, that is, one column, but “Test” depends on three separate columns at the moment. We need to convert our table from a wide format to a long format. Wide-to-long transformations are very common, especially because many survey tools (e.g., Google Forms) will produce outputs in a wide format.

The data frame we want has a column called test and another column called score – shown in Table 2.2. The test column will hold three possible values, test $A$, test $B$, and test $C$; the score column will be a numeric variable that holds all the scores from all three tests. Let’s do that using tidyverse, more specifically, a function called pivot_longer(). The discussion that follows will include code block 6, which you should place in dataPrep.R-see Table D.1 in Appendix D. You don’t need to skip ahead to the code block yet; we will get there shortly.

## 有限元方法代写

tatistics-lab作为专业的留学生服务机构，多年来已为美国、英国、加拿大、澳洲等留学热门地的学生提供专业的学术服务，包括但不限于Essay代写，Assignment代写，Dissertation代写，Report代写，小组作业代写，Proposal代写，Paper代写，Presentation代写，计算机作业代写，论文修改和润色，网课代做，exam代考等等。写作范围涵盖高中，本科，研究生等海外留学全阶段，辐射金融，经济学，会计学，审计学，管理学等全球99%专业科目。写作团队既有专业英语母语作者，也有海外名校硕博留学生，每位写作老师都拥有过硬的语言能力，专业的学科背景和学术写作经验。我们承诺100%原创，100%专业，100%准时，100%满意。

## MATLAB代写

MATLAB 是一种用于技术计算的高性能语言。它将计算、可视化和编程集成在一个易于使用的环境中，其中问题和解决方案以熟悉的数学符号表示。典型用途包括：数学和计算算法开发建模、仿真和原型制作数据分析、探索和可视化科学和工程图形应用程序开发，包括图形用户界面构建MATLAB 是一个交互式系统，其基本数据元素是一个不需要维度的数组。这使您可以解决许多技术计算问题，尤其是那些具有矩阵和向量公式的问题，而只需用 C 或 Fortran 等标量非交互式语言编写程序所需的时间的一小部分。MATLAB 名称代表矩阵实验室。MATLAB 最初的编写目的是提供对由 LINPACK 和 EISPACK 项目开发的矩阵软件的轻松访问，这两个项目共同代表了矩阵计算软件的最新技术。MATLAB 经过多年的发展，得到了许多用户的投入。在大学环境中，它是数学、工程和科学入门和高级课程的标准教学工具。在工业领域，MATLAB 是高效研究、开发和分析的首选工具。MATLAB 具有一系列称为工具箱的特定于应用程序的解决方案。对于大多数 MATLAB 用户来说非常重要，工具箱允许您学习应用专业技术。工具箱是 MATLAB 函数（M 文件）的综合集合，可扩展 MATLAB 环境以解决特定类别的问题。可用工具箱的领域包括信号处理、控制系统、神经网络、模糊逻辑、小波、仿真等。