Question: The file COS-206-data.csv (Course Documents) is a text file that contains comma-separated values (CSV). https://www.mediafire.com/?7mvxkb67t997nmt Write R code(s) to read the contents of COS-206-data.csv and

The file COS-206-data.csv (Course Documents) is a text file that contains comma-separated values (CSV).

https://www.mediafire.com/?7mvxkb67t997nmt

Write R code(s) to read the contents of COS-206-data.csv and store them in a data frame called data.

Continuing with question 1 above, using the dataframe called data that you created,

create a new column called Range that is the difference between High and Low columns.

Delete the original High and Low columns. The first 6 rows of data should now looks like below.

Date

Open

Close

Volume

Adj. Close

Range

1

2014-12-11

19.43

19.35

30400

19.35

0.51

2

2014-12-10

19.97

19.30

49300

19.30

0.83

3

2014-12-09

19.11

19.98

56400

19.98

1.03

4

2014-12-08

19.55

19.26

23700

19.26

0.41

5

2014-12-05

19.38

19.55

25200

19.55

0.21

6

2014-12-04

19.54

19.43

28400

19.43

0.32

Now sort data by the Range column. The first 6 rows should look like below.

Date

Open

Close

Volume

Adj. Close

Range

12

2014-11-25

19.59

19.60

45000

19.60

0.10

14

2014-11-21

19.73

19.62

44500

19.62

0.17

5

2014-12-05

19.38

19.55

25000

19.55

0.21

11

2014-11-26

19.64

19.52

17800

19.52

0.21

17

2014-11-18

19.64

19.53

54300

19.53

0.28

9

2014-12-01

19.25

19.37

64700

19.37

0.32

Using the reshape2 library and choosing Date as id.vars, convert the dataframe generated in question 3 to long form. The first 6 rows should look like below.

Date

Variable

Value

1

2014-11-25

Open

19.59

2

2014-11-21

Open

19.73

3

2014-12-05

Open

19.38

4

2014-11-26

Open

19.64

5

2014-11-18

Open

19.64

6

2014-12-01

Open

19.25

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!