-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathData aquisition
More file actions
166 lines (157 loc) · 6.58 KB
/
Copy pathData aquisition
File metadata and controls
166 lines (157 loc) · 6.58 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
R version 3.1.1 (2014-07-10) -- "Sock it to Me"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
[Previously saved workspace restored]
> getwd()
[1] "C:/Users/Justin/Documents"
> car_data <- read.csv("car_data.csv",header=T)
> car_data
Timestamp cars
1 9/11/2014 11:04 Chevrolet
2 9/11/2014 11:07 Ford
3 9/11/2014 11:11 Chevrolet
4 9/11/2014 11:17 Ford
5 9/11/2014 11:23 Ford
6 9/11/2014 11:24 Ford
7 9/11/2014 12:07 Chevrolet
8 9/11/2014 12:38 Ford
9 9/11/2014 12:39 Chevrolet
10 9/11/2014 12:42 Dodge
11 9/11/2014 12:50 Chevrolet
12 9/11/2014 13:29 Ford
13 9/11/2014 21:57 Dodge
14 9/11/2014 21:57 Chevrolet
15 9/11/2014 21:58 Ford
> car_data2 <- car_data$cars
> car_data2
[1] Chevrolet Ford Chevrolet Ford Ford Ford Chevrolet
[8] Ford Chevrolet Dodge Chevrolet Ford Dodge Chevrolet
[15] Ford
Levels: Chevrolet Dodge Ford
> car_data3 <- table(car_data2)
> car_data3
car_data2
Chevrolet Dodge Ford
6 2 7
> barplot (car_data3,main="Cars",xlab="Make",ylab="Frequency",col="black")
> utils:::menuInstallPkgs()
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://cran.cnr.Berkeley.edu/bin/windows/contrib/3.1/rjson_0.2.14.zip'
Content type 'application/zip' length 492031 bytes (480 Kb)
opened URL
downloaded 480 Kb
package ‘rjson’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\Justin\AppData\Local\Temp\RtmpoZHB8s\downloaded_packages
> library(rjson)
> json.file <- "http://api.wunderground.com/api/612a78e741be31b8/q/VA/Woodbridge.json"
> json.data <- fromJSON(paste(readLines(json.file), collapse=""))
> str(json.data)
List of 1
$ response:List of 3
..$ version : chr "0.1"
..$ termsofService: chr "http://www.wunderground.com/weather/api/d/terms.html"
..$ features : list()
> json.file <- "http://api.wunderground.com/api/612a78e741be31b8/conditions/q/VA/Woodbridge.json"
> json.data <- fromJSON(paste(readLines(json.file), collapse=""))
> str(json.data)
List of 2
$ response :List of 3
..$ version : chr "0.1"
..$ termsofService: chr "http://www.wunderground.com/weather/api/d/terms.html"
..$ features :List of 1
.. ..$ conditions: num 1
$ current_observation:List of 56
..$ image :List of 3
.. ..$ url : chr "http://icons.wxug.com/graphics/wu2/logo_130x80.png"
.. ..$ title: chr "Weather Underground"
.. ..$ link : chr "http://www.wunderground.com"
..$ display_location :List of 12
.. ..$ full : chr "Woodbridge, VA"
.. ..$ city : chr "Woodbridge"
.. ..$ state : chr "VA"
.. ..$ state_name : chr "Virginia"
.. ..$ country : chr "US"
.. ..$ country_iso3166: chr "US"
.. ..$ zip : chr "22191"
.. ..$ magic : chr "1"
.. ..$ wmo : chr "99999"
.. ..$ latitude : chr "38.63010025"
.. ..$ longitude : chr "-77.27259827"
.. ..$ elevation : chr "37.00000000"
..$ observation_location :List of 8
.. ..$ full : chr "Port Potomac, Woodbridge, Virginia"
.. ..$ city : chr "Port Potomac, Woodbridge"
.. ..$ state : chr "Virginia"
.. ..$ country : chr "US"
.. ..$ country_iso3166: chr "US"
.. ..$ latitude : chr "38.597878"
.. ..$ longitude : chr "-77.296165"
.. ..$ elevation : chr "92 ft"
..$ estimated : list()
..$ station_id : chr "KVAWOODB12"
..$ observation_time : chr "Last Updated on September 25, 11:07 AM EDT"
..$ observation_time_rfc822: chr "Thu, 25 Sep 2014 11:07:35 -0400"
..$ observation_epoch : chr "1411657655"
..$ local_time_rfc822 : chr "Thu, 25 Sep 2014 11:10:45 -0400"
..$ local_epoch : chr "1411657845"
..$ local_tz_short : chr "EDT"
..$ local_tz_long : chr "America/New_York"
..$ local_tz_offset : chr "-0400"
..$ weather : chr "Overcast"
..$ temperature_string : chr "64.0 F (17.8 C)"
..$ temp_f : num 64
..$ temp_c : num 17.8
..$ relative_humidity : chr "98%"
..$ wind_string : chr "From the WNW at 3.1 MPH"
..$ wind_dir : chr "WNW"
..$ wind_degrees : num 292
..$ wind_mph : num 3.1
..$ wind_gust_mph : num 0
..$ wind_kph : num 5
..$ wind_gust_kph : num 0
..$ pressure_mb : chr "1026"
..$ pressure_in : chr "30.29"
..$ pressure_trend : chr "0"
..$ dewpoint_string : chr "64 F (18 C)"
..$ dewpoint_f : num 64
..$ dewpoint_c : num 18
..$ heat_index_string : chr "NA"
..$ heat_index_f : chr "NA"
..$ heat_index_c : chr "NA"
..$ windchill_string : chr "NA"
..$ windchill_f : chr "NA"
..$ windchill_c : chr "NA"
..$ feelslike_string : chr "64.0 F (17.8 C)"
..$ feelslike_f : chr "64.0"
..$ feelslike_c : chr "17.8"
..$ visibility_mi : chr "10.0"
..$ visibility_km : chr "16.1"
..$ solarradiation : chr "--"
..$ UV : chr "2"
..$ precip_1hr_string : chr "-999.00 in ( 0 mm)"
..$ precip_1hr_in : chr "-999.00"
..$ precip_1hr_metric : chr " 0"
..$ precip_today_string : chr "0.69 in (18 mm)"
..$ precip_today_in : chr "0.69"
..$ precip_today_metric : chr "18"
..$ icon : chr "cloudy"
..$ icon_url : chr "http://icons.wxug.com/i/c/k/cloudy.gif"
..$ forecast_url : chr "http://www.wunderground.com/US/VA/Woodbridge.html"
..$ history_url : chr "http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=KVAWOODB12"
..$ ob_url : chr "http://www.wunderground.com/cgi-bin/findweather/getForecast?query=38.597878,-77.296165"
..$ nowcast : chr ""
> json.data$current_observation$dewpoint_string
[1] "64 F (18 C)"
> q()
>