Download presentation
Presentation is loading. Please wait.
1
Reading a CSV file in R
2
Download a CSV (comma-separated values) file
Download a CSV (comma-separated values) file. Right click on it and choose properties.
3
Highlight the location, right click on it and copy
4
Turn the back slashes into forward slashes and add the filename (including its extension) and use it the read.csv method The second “argument” of the read.csv method says TRUE the data file includes headers as the first line. The third “argument” of the read.csv method says that the delimiter (thing separating the data elements) is a comma
5
The head method shows the first several rows of data.
6
Showing file extensions: Find the Control Panel
7
Switch from categories to Large or small icons
8
Choose File Explorer Options
9
Click on View tab and uncheck the Hide extensions setting. Click Apply.
10
The field names that came in from the CSV file were weird (the original file has parentheses), so I used the names method to rename them.
11
Plot the data with Volume on the x axis.
12
Resulting plot
13
Obtain a linear model for the data.frame
14
Summary of linear model in Console
15
Compare to Excel 1
16
Compare to Excel 2
17
Use abline to display the fit
18
Display the equation
19
If you have an Excel file and want a CSV, then click on File/ Save As
20
Click Browse. Use the Save As type drop-down to choose CSV
21
If the data is in the “working directory” – found by using getwd() – then the file name is enough
22
Another possible change is to use the field names in the axis labels
23
Take the heart rate data below (same as on Friday from the first week of class). Use Excel to convert it to a CSV format file. Read that data into R and make a plot with a linear fit with the equation displayed on the graph. Speed_in_kph Pulse_in_bpm 57 1.6 69 3.1 78 4 80 5 85 6 87 6.9 90 7.7 92 8.7 97 12.4 108 15.3 119
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.