Repository navigation
Expand file tree
/
Copy pathScript.Rmd
More file actions
579 lines (383 loc) · 24.3 KB
/
Copy pathScript.Rmd
File metadata and controls
579 lines (383 loc) · 24.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
---
title: "R Tutorial For Business Analytics"
author: "Derek Lukacsko & Jonathan Bourne"
date: "September 8, 2016"
output: html_document
---
```{r Chunk opts, echo=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
```{r Set up hidden, message=FALSE}
# Load packages
packages <- c("tidyverse", "openxlsx", "gridExtra", "caret","randomForest", "knitr")
#This piece of code will check to see if the packages you want to load are installed if they aren't it will install them
new.packages <- packages[!(packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
invisible(sapply(packages, library, character.only = TRUE))
#save the starting directory as a variable
basewd <-getwd()
```
#Introduction
This introduction is to help students on the BUSICS msc at UCL gain a basic understanding of programming in [R](https://cran.r-project.org/). The course is designed to be taught in the loosest sense of the word. Students will read the text and perform the exercises whilst someone barely more competant than themselves walks around and tries to help them. At the end of the course, they will be given the answer sheet, which will probably be worse than the work they have done.
The course focuses on a suite of packages created by [Hadley Wickham](http://hadley.nz/) called the "[tidyverse](https://cran.r-project.org/web/packages/tidyverse/tidyverse.pdf)", These packages are very widly used across the R community and have greatly helped reduced the difficulty of learning about R.
##Sources of help
1. Typing `?` followed by the function name e.g `?help` or `?sum`
1. [Google](www.google.co.uk)
2. [stackoverflow](http://www.stackoverflow.com)
3000. [Rstudio's cheatsheets](https://www.rstudio.com/resources/cheatsheets/) (for this you'll neeed the wrangling and ggplot ones)
4. [ggplot2 help website](http://docs.ggplot2.org/current/)
#Setup
Setting up the environment can be very helpful to do in one place this first code chunk can store all the packages you need in your analysis, load any custom functions that you have made through out the analysis and store the locations of any folders that you use for easy folder switching.
**TIP\:** When using Rstudio
* Short cuts can be very helpful especially inserting a new chunk using `ctrl+alt+i`
* To run code highlight it and press `ctrl+Enter`
* To view a dataframe double click on it's name in the "Environment" tab
```{r Setting Up Environment, eval=FALSE, echo=TRUE}
# Load packages
packages <- c("tidyverse", "openxlsx", "caret", "randomForest")
#This piece of code will check to see if the packages you want to load are installed if they aren't it will install them
new.packages <- packages[!(packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
invisible(sapply(packages, library, character.only = TRUE))
#save the starting directory as a variable
basewd <-getwd()
```
#First Steps
R contains many different data sets and additional data sets are usually installed with new packages. You can see what packages are installed on your machineby typing `data()` in the command line. packages can be loaded using the following methods
```{r, echo=TRUE}
data("airquality") #creates a promise
airquality %>% head #anything that calls the promises causes it to be evaluated
rm(airquality) #delete the dataframe
testdf <- airquality #loading can also be done like this
rm(testdf) #we don't need this variable cluttering up the workspace
```
Load the `mtcars` data frame and assign it to the variable `df`
```{r}
# Working dataframe
df <- mtcars
```
1. With the data frame you have just loaded, use the functions,`class`, `dim`, `head`, `colnames`, `names`, `View`.
1. Load the datasets `VADeaths` and `discoveries` and use the same functions, what happens? why do you think it happens?
```{r}
# Inspect the data
class(df)
dim(df)
colnames(df)
View(head(df))
head(df)
```
#Classes
In R all the objects you work with have different classes these can be data frames, matrices, models, vectors etc. Different objects have different properties, meaning they react differently to the functions you try on them.
Given that data frames can hold multiple data types it is worth checking what class each column in a data frame is. This can be boring to check one at a time so using a `for` loop could be an option. However R also has a group of functions called the `apply` family, `sapply`, and `lapply` being the most commonly used. These functions move across every element of a dataframe/matrix/list and perform a function on it returning the result.
##Check the class of each variable
1. Use sapply to sum up each column of the dataframe `df`
1. Use `sapply` to find out the classes of each varible in `df` compare this to the classes found in the `iris` data set.
3. Do you think the results of the summming function is surprising?
```{r using sapply, results='hide'}
#hiding results mean that the code is run , but not displayed in the knitr output. This can be useful in certain cases... this isn't one of them
sapply(df, sum)
#sapply(iris, sum)
sapply(df, class)
#sapply(iris, class)
```
##Change class
As was seen in the previous exercise some of the variables of df could do with changing class. Class can be changed by calling `as.` before the class you want to convert to e.g `as.data.frame` if possible R will then coerce the object into the new class, or return an error if it is not possible.
A matrix can only hold a single class of information for example, integers **or** characters but not both. A data frame can hold multiple data types as long as they are vectors, this makes data frames much more flexible they are the building block of working in R. A list can hold whatever you like including other lists.
1. Change the cyl, vs, and am variables to factors (Use `lapply` or `mutate_at` if you can work out how)
2. Change hp to an integer
3. Using sapply check the changes have taken place
**Tip\:** For changes to variables in a dataframe or matrix use mutate (look at the wrangling cheatsheet).
```{r, results='hide'}
#Old school solution using lapply
df2 <-df
df2[,c(2,8,9)] <- lapply(c(2,8,9), function(n) as.factor(df2[,n]))
df2$hp <- as.integer(df2$hp)
```
```{r}
#Modern style using chaining and dplyr
df %<>% mutate_at(c(2,8,9), as.factor) %>% mutate(hp= as.integer(hp))
sapply(df2, class)
sapply(df, class)
```
```{r, eval= FALSE}
#Are they equal?
all.equal(sapply(df2, class), sapply(df, class))
#win
```
```{r}
#this variable is not needed, but because the previous code chunk is not evaluated it needs to be deleted here
rm(df2)
```
#Exploring Data
Getting an idea of what is going on in your data frame is an important first step in working with data, we have already learn a bit about how the data works, now we are going to go a bit deeper.
1. Use rownames() and mutate() to make a new variable called "model" that has the names of the cars
2. Use the summary function to get a an overview of the dataset
2. Return the data frame with only th first 5 car models
3. Return the data frame with the top 5 most fuel efficient cars
4. Return a dataframe with the 5 least fuel efficient cars
5. Find the most fuel efficient car for each cylinder group
```{r, results='hide'}
#In this chunk hiding the results is useful as needs to be modified, but I don't wan tot take up a lot of space in the final document with the summary command. I could put summary in a separate chunk which doesn't get evaluated, this would be a good idea for a computationally intense action, but in this case it doesn't matter
#1
df <- df %>% mutate(model = rownames(.))
#2
summary(df)
```
```{r, results='asis'}
df %>% arrange(desc(mpg)) %>% group_by(cyl) %>% summarise_all(first) %>%
kable( ., format="markdown", caption="Top 5 unordered")
```
```{r Exercise 1: Data Cleaning, eval=FALSE}
#3
df %>% top_n(5, mpg)#top 5 unordered
#4
df %>% arrange(desc(mpg)) %>% top_n(5, mpg) #top 5 ordered
#5
df %>% arrange(mpg) %>% head(5)#
#6
df %>% arrange(desc(mpg)) %>% group_by(cyl) %>% summarise_all(first)
```
#Outside the R environment
Obviously installing packages requires exiting the R environment and accessing the packages online at CRAN, however other times it is usefull to access things outside your R environment. In this section we will look at the basics of creating new folders, changing the working directory and saving files.
##Creating sub directories
In order to make our project manageable and easy to navigate we will create a new folder for the data.
1. Set the working directory to `basewd` which was defined at the begnining, you will need the function `setwd`.
2. Use the function `dir.create` to make a new folder called "R_tutorial",check that it exists.
3. Change the working directory to be inside the "R_tutorial" folder, you might want to use the `file.path` function.
4. Create a folder called `Data` and set the working directory inside it.
5. Save the file path to the Data directory as a variable call it "DataFolder"
```{r, warning=FALSE, results='hide'}
#The reuslts are hidden as I don't want to diplay the results of the logical test `dir.create`
#1
setwd(basewd)
#2
dir.create("R_tutorial")
dir.exists("R_tutorial")
#3
setwd(file.path(basewd, "R_tutorial"))
#4
dir.create("Data")
setwd("./Data") #When you are shifting down a directory you can use the "./name" method this can be shorter
#5
DataFolder <- getwd()
```
##Saving data
We have made some changes to our dataframe and so it is a good idea to save it somewhere. Getting data in and out of R that is not a preloaded dataset can be difficult when starting out so we will go through a few methods. The most common methods for saving data is `save`, `saveRDS`, `write.csv` which is a special case of `write.table`, and `write.xlsx` from the `opsenxlsx` package.
**Tip\:** Remember to use the correct file extension at the end of the file name when saving, it makes it easier to identify files and for them to be opened by others.
1. Save a version of df using `write.csv` (dfcsv), `saveRDS` (dfRDS), and `write.xlsx` (dfxlsx)
2. Load the files using `read.csv`, `readRDS` and `read.xlsx`
3. Using the `all.equal` function compare the loaded files to the orignial df frame, what do you notice? you can also include `sapply` to compare each of the columns of the two dataframes.
4. delete all the dfxxx dataframes from the workspace.
**Note\:** You may get an error message reffering to "Rtools" when you try to use `read.xlsx`, If you do just skip the xlsx bit and install Rtools later
**TIP\:** You may wish to experiment including `row.names=1` when loading the csv.
```{r saving, results='hide'}
#1
write.csv(df, "dfcsv.csv")
saveRDS(df, "dfRDS.rds")
#write.xlsx(df, "dfxlsx.xlsx")
#2
dfcsv <- read.csv("dfcsv.csv", row.names=1)
dfRDS <- readRDS("dfRDS.rds")
#dfxlsx <-read.xlsx("dfxlsx.xlsx")
#4
all.equal(df, dfcsv)
all.equal(df, dfRDS)
#all.equal(df, dfxlsx)
all.equal(sapply(df, class), sapply(dfcsv, class))
all.equal(sapply(df, class), sapply(dfRDS, class))
#all.equal(sapply(df, class), sapply(dfxlsx, class))
#4
rm(list = c(ls()[grep("df", ls())]))
```
The way you save files and the methods you can use to load data into your machine, affect what happens to it later. Generally saving data in RDS format is a good idea, it get compressed, and all class information is maintained, it can also be used to store other objects that are not tabular datasets, such as lists, models, etc. However you will seldom be lucky enough to recieve data in RDS format so knowing what to expect when that happens is important. Lookup the `readr` package and familiarise yourself with `stringsAsFactors` in `read.csv` that can ruin your day.
#Creating Plots
In this section we willl explore using ggplot2 R's most popular plotting package to visualise data sets. We will begin using a simple scatter plot, and then build on it's complexity by adding "layers". After the scatter plot we will create a box plot which is very useful for representing catagorical/factoral data.
**Tip\:** The ggplot cheat sheet will be pretty useful
##Scatterplot
1. Load the "iris" data set
1. Plot the relationship between variables Sepal.Length and Sepal.Width
4. add a linear regression
2. Color the points by Species
5. Bring fire
```{r Exercise 2: Scatter plotting}
#1
df<-iris
#2
p1 <-ggplot(df, aes(x=Sepal.Length,y=Sepal.Width)) +
geom_point() +
labs(title = "Relationship Between Sepal.Length\n and Sepal.Width")
# 3 add linear regression
p2<-ggplot(df, aes(x=Sepal.Length,y=Sepal.Width)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE) +
labs(title = "Relationship Between Sepal.Length\n and Sepal.Width")
#4 Add in colours
p3<-ggplot(df, aes(x=Sepal.Length,y=Sepal.Width,color = Species)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE) +
labs(title = "Relationship Between Sepal.Length\n and Sepal.Width by Species")
#Using grid.arrange allows you to place unrelated plots next to each other, this can be really helpful for certain presentations
grid.arrange(p1,p2, ncol=2)
p3
#5 plots facetted with grey dots added in the background to indicate where the other species are
ggplot(df, aes(Sepal.Length,Sepal.Width, color = Species)) +
geom_point(data = transform(df, Species = NULL), colour = "grey85") +
geom_point() +
geom_smooth(method = "lm", se =FALSE) +
facet_wrap(~Species, nrow= 2) +
labs(title = "Relationship Between Sepal.Length and Sepal.Width \n Faceted by Species")
```
#Boxplots
Boxplots are a compact way of representing key statistics in categorical/factoral data. Often barplots are used to represent factoral data however they contain less information than barplots and so should generally be avoided.
1. Load "dfRDS.rds" and assign it to variable `df`
1. Make a barplot of mean mpg per cylinder, you will need to use `group_by` and `summarise`, also barplots need `stat="identity" in the geom.
1. Make a box plot of mpg per cylinder
4. Make a new folder called "Figures" in "R_tutorial" use `ggsave` and create a pdf and a png of the boxplot
5. make a denisty plot using this data, how can this be useful?
```{r, eval=FALSE}
#This can cause problems when knitting the document due to root drive issues. FOr simplicity we moved it to it's own code chunk.
setwd(DataFolder) #Set the working directory just in case we changed it for some reason
```
```{r BoxPlots}
df <-readRDS("dfRDS.rds")
#Doing you processing for plots in a chain is convenient if you don't need the processed data frame again.
p1 <-df %>% group_by(cyl) %>% summarise(mpg=mean(mpg)) %>%
ggplot(., aes(x= cyl, y=mpg, fill =cyl)) +
geom_bar(stat="identity") +ggtitle("Barplot mean mpg vs cylinder type")+
theme(legend.position="none")
p2 <-ggplot(df, aes(x= cyl, y=mpg, fill =cyl)) +
geom_boxplot()+
labs(title = "Boxplot of mpg vs cylinders")+
theme(legend.position="none")
grid.arrange(p1,p2, ncol=2)
```
```{r, eval=FALSE}
#Create new folder
#Generally it's better to create the folder structure beforehand, this allows you to create path objects making life easier. However for the purposes of this tutorial we are doing it like this.
setwd(file.path(basewd,"R_tutorial"))
dir.create("Figures")
setwd("./Figures")
#ggsave, will save the last ggplot produced
p2
ggsave("Boxplot.pdf")
```
When you are making plots, barplots should only be used if you are using raw counts across categorical values, if you are using mean or any other statistic you are better off using a boxplot. Boxplots contain much more information about data than barplots. If you want to know how to put error bars on a bar plot you're doing it wrong, use a box plot.
If you are planning on making a 3D pie chart, do a different degree.
#Tidying Data
The tidyverse uses a concept called [tidy data](http://vita.had.co.nz/papers/tidy-data.pdf). Ggplot uses data in the long form of a tidy data set. in order to get data into this form the `gather` function is needed. Gather can be a bit tricky to work out so it's worth spending a bit of time understanding it.
1. Assign the "WorldPhones" dataset to the "df" variable
2. Convert df from a matrix to a dataframe (Packages in the tidyverse only work with dataframes) and turn the row names in to a variable called year
3. Gather the data so that it comes into long form
3. Create a line plot coloured by continent
5. Add a title and rename the x and y axis to something more descriptive
**Tip\:** Remember to exclude the Year variable from the gather command.
```{r}
df <-WorldPhones %>% as.data.frame() %>% mutate(Year = rownames(.)) %>%
gather(key=Continent, value="Phones", -Year)
df %>%
ggplot(., aes(x= Year, y= Phones, group= Continent,colour=Continent)) +
geom_line() +
labs(x="Year of Survey", y= "Number of Phones ('000s)", title="Phone Lines per Continent")
```
#Modelling
The bit that everyone body wants to get to in statistical programming is modelling. This part of the tutorial isn't supposed to teach you about various machine learning techniques but how to apply them in R. Having said that we will cover the two main branches of machine learning Supervised and Unsupervised
#Supervised learning
Supervised learning is broadly speaking machine learning when you know the outcome you are trying to predict. This could be the results of sports events, age of death, rate of growth, anythign with a measurable (directly or indirectly) result.
##Regression
Regression predicts a continuous variable for amount earned by a company next quarter. The simplest form of regression that is generally considered is multi-linear regression $(X'X)^{-1}X'y = \beta$, the big sister of the "plot x against y and draw a line through the dots" everyone learnt about in school.
1. Load the "iris" dataset
2. Set the random seed to make sure the script is reproducible
3. Use `CreateDataPartition` to create a training set, where the input vector is "Species" and "list=FALSE""
4. Create a linear model predicting "Sepal.Length"
5. Use `predict` and `postResample` to find the accuracy of the model on the test set.
6. Repeat the above with "method=rf" what do you notice?
```{r}
df <- iris
set.seed(1995)
training <- createDataPartition(df$Species, times = 1, p=0.8, list=FALSE)
reg1 <- train(x=select(df,-Sepal.Length)[training,], y=df$Sepal.Length[training], method="lm" )
preds <- predict(reg1, select(df,-Sepal.Length)[-training,])
postResample(preds, df$Sepal.Length[-training])
reg2 <- train(x=select(df,-Sepal.Length)[training,], y=df$Sepal.Length[training], method="rf" )
preds <- predict(reg2, select(df,-Sepal.Length)[-training,])
postResample(preds, df$Sepal.Length[-training])
```
## Classification
When the dependent variable is in distinct categories, classification is used. Classic examples of this include SPAM vs HAM and Cat vs Dog. The previous examples are binary outcomes, however there can also be multiclass classification which is more fiddly mathmatically but makes very little difference when implementing in R.
1. Use the random forest technique to predict species from the iris data set using all other variables
2. Using the predictions look at the results of `PostResample`
3. Compare the results with `confusionMatrix` what does it mean?
4. Extract just the confusion matrix from the `confusionMatrix`
```{r}
set.seed(1982)
class1 <- train(x=select(df,-Species)[training,], y=df$Species[training], method="rf" )
preds <- predict(class1, select(df,-Species)[-training,])
postResample(preds, df$Species[-training])
confusionMatrix(preds, df$Species[-training])
```
1. Load the "warpbreaks" dataset and create a new partition using the variable "warp"
2. Repeat the activities of the previous question to get a confusion matrix
3. Repeat again using "method='glm'" remember to set family to "binomial"
```{r}
warp <- warpbreaks
set.seed(1995)
trainingwarp <- createDataPartition(warp$wool, times = 1, p=0.8, list=FALSE)
class2 <- train(x=select(warp,-wool)[trainingwarp,], y=warp$wool[trainingwarp], method="rf" )
predswarp <- predict(class2, select(warp,-wool)[-trainingwarp,])
postResample(predswarp, warp$wool[-trainingwarp])
confusionMatrix(predswarp, warp$wool[-trainingwarp])
class3 <- train(x=select(warp,-wool)[trainingwarp,], y=warp$wool[trainingwarp], method="glm", family=binomial )
predswarp <- predict(class3, select(warp,-wool)[-trainingwarp,])
postResample(predswarp, warp$wool[-trainingwarp])
confusionMatrix(predswarp, warp$wool[-trainingwarp])
```
#Unsupervised
Unsupervised learning doesn't predict an outcome it often looks for patterns in the data which imply a structure. Clustering algorithms such as Hierarchichal and k-means are good examples of unsupervised learning.
1. Use the `kmeans` function to cluster the iris datast on all the variables except the "Species" variable, set number of clusters to 3, and nstarts to 30
2. make a bivariate table (enter two vectors) comparing the clusters to the species of the iris data set. How do they compare?
3. **Challenge** make a confusion matrix, interpret.
**TIP\:** Use the `names` function to find the vector of clusters in the cluster object.
```{r}
set.seed(1666)
dfCluster <- kmeans(select(df, 1:4), 3, nstart = 30)
table(dfCluster$cluster, df$Species)
#confusionMatrix(dfCluster$cluster, as.integer(df$Species))
```
You can find more information on using random forest with the iris training set [here](http://rischanlab.github.io/RandomForest.html)
#Amazon AWS
Sooner or later you are going to run out of processing power. Using Amazon's cloud computing service EC2 can be a really helpful solution, they provide scalable computing power and online storage. [Louis Aslett](http://www.louisaslett.com/RStudio_AMI/) has created several R images that greatly speed up the process of going online.
1. Save this script to a new folder in your dropbox account
1. Create an Amazon Aws account
2. Go to Louis Aslett's homepage and choose an image to load
4. start a free instance of the AWS machine.
5. Log onto the machine connect your dropbox including only the folder you have created
6. Run the script
The first couple times you log onto AWS it can be a bit fiddly, remembering to set the security settings correctly is important, if you are not using SSH the relevant ports need to be set to "0.0.0.0/0".
**TIP\:** Keep your data on dropbox and load it each time unless you have very large data sets this stops you paying loads in storage costs
#Asking Questions on Stackoverflow
Without SO programming would be an even more difficult and frustrating experience than it already is. SO has a lot of questions already answered, you will still probably want to ask some. However if you want to be an OG as well as an OP you should [read this](http://stackoverflow.com/help/how-to-ask) and follow a few basic rules.
1. Make sure you have actually tried. The SO community is there to answer questions not hold hands and react badly when it looks like someone hasn't attempted the question themself first.
2. Google it first! if there is already answer outthere especially if the answer is on SO already, your question will be voted down and closed.
3. Proivide a [minimal reproducible](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) example. This is the most important thing to do once you have gone through the other two points. For R the best way to create a reproducible example is using `dput`. The key is providing just enough information so that the question is answerable.
```{r dput, eval = FALSE, echo= T}
?dput
#The script produced can be pasted into SO, other people can then copy the code and assign it a variable
diamonds %>% head %>% dput
#Asign this structure to "test" and have a look at it
structure(list(Ozone = c(41L, 36L, 12L, 18L, NA, 28L, 23L, 19L,
8L, NA, 7L, 16L, 11L, 14L, 18L, 14L, 34L, 6L, 30L, 11L), Solar.R = c(190L,
118L, 149L, 313L, NA, NA, 299L, 99L, 19L, 194L, NA, 256L, 290L,
274L, 65L, 334L, 307L, 78L, 322L, 44L), Wind = c(7.4, 8, 12.6,
11.5, 14.3, 14.9, 8.6, 13.8, 20.1, 8.6, 6.9, 9.7, 9.2, 10.9,
13.2, 11.5, 12, 18.4, 11.5, 9.7), Temp = c(67L, 72L, 74L, 62L,
56L, 66L, 65L, 59L, 61L, 69L, 74L, 69L, 66L, 68L, 58L, 64L, 66L,
57L, 68L, 62L), Month = c(5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L), Day = 1:20), .Names = c("Ozone",
"Solar.R", "Wind", "Temp", "Month", "Day"), row.names = c(NA,
20L), class = "data.frame")
#By doing this, classes, variuable names and everything important about the data is preserved and people will find it much easier to help you.
```
#Authors Linkedin
[Jonathan Bourne](https://uk.linkedin.com/in/jonathan-bourne-2601a334)
[Derek Luckasko](https://www.linkedin.com/in/dereklukacsko)
#TEh ENDZ