You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# If the movie list page doesn't exist, keep going
186
187
except:
187
188
print "\nerror with " + letter + "\n"
@@ -194,7 +195,7 @@ For each movie, we will...
194
195
195
196
196
197
{% highlight r %}
197
-
# For each movie...
198
+
# For each movie...
198
199
# do.call(rbind, ...) to reorganize the results in a nice data frame
199
200
data <- do.call(rbind, pblapply(urls.by.movie, FUN = function(URL) {
200
201
{% endhighlight %}
@@ -205,7 +206,7 @@ data <- do.call(rbind, pblapply(urls.by.movie, FUN = function(URL) {
205
206
# extract the movie name, kill counts, etc.
206
207
out_file = open("film-death-counts.csv", "wb")
207
208
out_file.write("Film,Year,Kill_Count,IMDB_url\n")
208
-
209
+
209
210
for film_page in list_of_films:
210
211
try:
211
212
# The information we're looking for on the page:
@@ -320,15 +321,15 @@ for film_page in list_of_films:
320
321
# Using gsub, remove everything in parenthesis and all non number characters
321
322
Body_Count <- gsub("\\(.*?\\)", " ", Body_Count)
322
323
Body_Count <- gsub("[^0-9]+", " ", Body_Count)
323
-
324
+
324
325
# In case the total count has been split, we want to separate these numbers
325
326
# from each other so that we can add them up later. Using strsplit, split the
326
327
# character string at spaces
327
328
Body_Count <- unlist(strsplit(Body_Count, " "))
328
-
329
+
329
330
# For now, we have extracted characters. Transform them into numbers.
330
331
Body_Count <- as.numeric(Body_Count)
331
-
332
+
332
333
# Sum up the numbers (in case they have been split into separate categories.
333
334
Body_Count <- sum(Body_Count, na.rm = TRUE)
334
335
{% endhighlight %}
@@ -380,6 +381,6 @@ ___
380
381
381
382
#### 4 - Bonus for the braves ####
382
383
383
-
Today's challenge was code and text heavy. No pretty pictures to please the eye. So, for all the brave people who made it to the end, here is a cat picture :-)
384
+
Today's challenge was code and text heavy. No pretty pictures to please the eye. So, for all the brave people who made it to the end, here is a cat picture :-)
0 commit comments