Tidying data so that rows that don't begin with number are pasted onto the end of previous rows

Hi everyone, I'm trying to tidy my data so that each row begins with a number (like "1. ", "2. ", etc.), and the rows that currently do not begin with a number are pasted onto the end of the above row.

Here's what the data looks like:

mydata

# A tibble: 41 x 1
   value                                                                                                                                              
   <chr>                                                                                                                                              
 1 1. We’re missing one thing in Ottawa: the NHL’s true plan for the future. On a day where one of its owners was countersued for $1 billion, you’d t~
 2 Melnyk’s response to soon-to-be-former-partner John Ruddy’s lawsuit was to offer up profits in exchange for Ruddy financing the arena. Melnyk was ~
 3 2. Imagine being on Philadelphia’s Sunday flight back from Vancouver. You’re playing cards, watching movies, reading, editing video, sleeping, you~
 4 It led to a clumsy, messy dismissal almost 24 hours later, which is unlike this particular GM. It doesn’t fit with his history. As another GM said~
 5 The pushback to the story indicates there was going to be a coaching change, but Fletcher wasn’t going to do it Sunday. (If the team faced any dea~
 6 3. So, what happened? The theory is that after seeing the fallout and sleeping on it Sunday night, Fletcher decided to accelerate the process. It ~
 7 Now, it’s not like I think Isaac (or any of the other reporters who confirmed it) are making stuff up, because the information was everywhere. For~
 8 Late the night before Hakstol was hired, I got a tip that Hextall was going “off-the-board” with his coaching hire. Early next morning, I sent him~
 9 Your browser does not support the audio element.                                                                                                   
10 4. I’ve said it before, but will say it again: how Hakstol carried himself over the past two years was a master class on how to handle scrutiny. J~
# ... with 31 more rows

So the idea is that row 2 that begins with "Melnyk's response..." would be pasted at the end of row 1 and then row 3 would become row 2. Does that make sense?

Any idea how I'd do that? I assume it would have to be with some paste() or stringr::str_c() idea, though I'm not quite sure how at this point.

I appreciate any insight!

Here's the code:

mydata <- structure(list(value = c("1. We’re missing one thing in Ottawa: the NHL’s true plan for the future. On a day where one of its owners was countersued for $1 billion, you’d think the league would have something to say. But, nada. Combine that with Commissioner Gary Bettman’s tight-lipped comments at the Board of Governors, and there’s only one conclusion — they have a path, they are confident in that path and they’ll let us know when they feel like it.", 
"Melnyk’s response to soon-to-be-former-partner John Ruddy’s lawsuit was to offer up profits in exchange for Ruddy financing the arena. Melnyk was ridiculed for wanting a freebie, which certainly fits the narrative. But execs outside Ottawa scratched their heads at this strategy, because the arena is what you wish to control. It makes more money than the team. It was almost as if Melnyk was trying to prove Ruddy couldn’t build it either. There’s an endgame here, but it isn’t clear yet.", 
"2. Imagine being on Philadelphia’s Sunday flight back from Vancouver. You’re playing cards, watching movies, reading, editing video, sleeping, you name it, whatever, and all of a sudden a sonic boom hits. That’s Dave Isaac’s story from The Courier Post, indicating Dave Hakstol was out and Joel Quenneville was in. Think about how everyone on that plane had to be reacting as the information spread among the group, especially GM Chuck Fletcher and Hakstol. Those two would have been, what, one row apart?", 
"It led to a clumsy, messy dismissal almost 24 hours later, which is unlike this particular GM. It doesn’t fit with his history. As another GM said, “It would bother Chuck to have it play out this way.” Fletcher declined to comment further, not wanting to toss more gasoline on the fire, but after several conversations, here’s a thesis on what happened.", 
"The pushback to the story indicates there was going to be a coaching change, but Fletcher wasn’t going to do it Sunday. (If the team faced any deadline, it was probably to keep it far enough away from Christmas. You don’t want those headlines.) Around the NHL, the biggest indication that the Flyers were not 100 per cent ready was interim coach Scott Gordon not being at practice on Monday. That kind of detail would have been ironed out, instead of adding more weirdness to the saga.", 
"3. So, what happened? The theory is that after seeing the fallout and sleeping on it Sunday night, Fletcher decided to accelerate the process. It would have been grossly unfair to Hakstol to ask him to coach on Tuesday, especially with what the reaction could have been.", 
"Now, it’s not like I think Isaac (or any of the other reporters who confirmed it) are making stuff up, because the information was everywhere. For years, under Ed Snider, the Flyers were one of the best beats in sports. The team was (mostly) good, there was a ton of personality, people were honest with their opinions and, because of that, there was never a boring day. Under Ron Hextall, that changed. Information was tight, the guy was a vault. Very rarely did news break outside of team control.", 
"Late the night before Hakstol was hired, I got a tip that Hextall was going “off-the-board” with his coaching hire. Early next morning, I sent him a note — it was more of a fishing expedition, I didn’t have the name — saying there was word he was going on a different path. He didn’t reply at the time, but said later he did move up the announcement so as not to lose control of the process. We know his desire to keep most people at arms’ length was a factor in his dismissal, and what unfolded last weekend is evidence the vault is open. Until Fletcher figures out how to close it.", 
"Your browser does not support the audio element.", "4. I’ve said it before, but will say it again: how Hakstol carried himself over the past two years was a master class on how to handle scrutiny. Job security was a constant topic, and he looked totally unfazed by it.", 
"5. On Joel Quenneville and the Flyers: I’m not so sure this is anywhere close to a slam dunk. Quenneville is taking some time with his family in Colorado. Is he really in a rush to get back behind a bench? We know Philadelphia will pay very well, but, if his first goal is to contend right away, where would they rank as an option? His better choice is to wait and see how things play out over the next six months. A good team is going to lose early in the playoffs and say, “You know what, that guy could help us.”", 
"6. Carter Hart’s promotion wasn’t as crazy as it seemed when you stepped away from Monday’s circus and thought about it. They have two injured goalies and Michal Neuvirth was away from the club while his wife gave birth to a baby. There’s no guarantee Hart’s staying, but if a call-up made sense, it was under that scenario. The team rallied around him, preventing Detroit from getting a shot for 12 minutes, arguably their best defensive effort of the season. His performance energized the fans and building. The Flyers desperately needed that as much as anything else.", 
"7. Early-in-my-career advice: Watch the off-ice moves as much as the on-ice ones. Last week, Philadelphia hired Valerie Camillo as President of Business Operations for the team and the Wells Fargo Center. The Flyers got her from MLB’s Washington Nationals, and she reports directly to Comcast-Spectacor CEO Dave Scott. She has a very good reputation. That kind of move, especially in-season, is a sign that an organization isn’t thrilled. The pressures on the Flyers aren’t just on the ice.", 
"8. Scott Gordon’s a no-nonsense guy, so it won’t be summer camp under him. He’s pretty serious. But — and credit to Brian Burke for this — he was a part of the Beanpot Trot.", 
"9. The most important hire the Flyers made might be Rick Wilson. Ivan Provorov is a tremendous player. He’s just lost right now. When Hextall held his post-firing availability, he admitted to being surprised how much a contract season affected Provorov mentally. They have to get him going again or it is a major problem for them.", 
"10. Finally on Philly, word is a few other teams have reached out about Hextall’s availability. Maybe not as GM, but to join their organizations. There’s interest.", 
"11. After Bob Murray’s extension in Anaheim, I went through the list of GMs wondering who might be next. A logical guess is New Jersey’s Ray Shero. The team is off to a rough start, but the overall direction of the franchise is improved. John Hynes was a good hire. It makes sense.", 
"12. On Dec. 9, the Devils lost 6-5 to Anaheim on a night where they scored three times on their own net. We all know how brutal it’s been for Cory Schneider, who was in goal for that. Well, someone reached out to tell a story about the post-game.", 
"There was family outside the Devils’ dressing room waiting to meet Schneider. This guy felt terrible for them, because there was no way he thought the goalie would be in any kind of mood to talk, and, it is their only visit to Orange County this season. There was no need to worry. Despite everything that’s happened, Schneider was friendly, gracious and left the family beaming.", 
"13. There were rumours this past summer that Schneider’s hip surgery could be the end of his career. On a visit to Toronto earlier this season, he denied that. “No, it was never that bad,” he said.", 
"On this week’s 31 Thoughts Podcast, Roberto Luongo said he’s spoken to Schneider a few times. “I remember when I had my hip surgery, even though I came back and played at the start of the season, it’s tough. It takes two full years to be fully recovered from hip surgery. Even though you’re playing the first year, you’re feeling it, it’s hurting you, it’s bothering you…whether you like it or not, it’s a problem for sure.”", 
"14. Speaking of goalies, how much is the NHL changing right now? The league average save percentage is .908 as of Thursday morning. If that continues, it will be the first time below .910 since 2008-09.", 
"15. A number of Western Conference GMs are curious about what Colorado is going to do. They’re good enough to like their chances, but not yet deep enough to believe they can win it all. They’ve got a lot of assets to work the trade market with, but the biggest question is whether or not the Avalanche believe this is the year to try to win it all.", 
"16. Sounds like Carolina’s been debating Vladimir Tarasenko, but would St. Louis want Martin Necas?", 
"17. Vegas is rumoured to be interested in every WHL alumnus, but Brayden Schenn did play three years for assistant GM Kelly McCrimmon at Brandon. So that has some of the Golden Knights’ rivals wondering if there may be more to it.", 
"18. Columbus’s Jarmo Kekalainen and Detroit’s Ken Holland were two GMs seen at the Channel One Cup in Moscow. (Apparently, Montreal had a decent-sized delegation, too.) The Blue Jackets had defensive prospect Vladislav Gavrikov there, who apparently played very well for the victorious Russians. There is a push for some Russian free agents, but the highest-rated ones may not be free until the summer of 2020. There are rumblings that ex-NHLers Mikhail Grigorenko and Nikita Nesterov are contemplating returns, too.", 
"19. I’m not sure he would come back, but one Russian contact said he’d heard a few teams were interested in taking another look at Viktor Antipin. It didn’t work in Buffalo last year.", 
"20. Someone made an interesting comparison this week…Alexander Ovechkin to Steve Yzerman. Yzerman had a phenomenal career well before he won his first Stanley Cup in Year 14, lighting up the NHL season after season. We all know the story. He changed his game, won two more times, adding a gold medal for fun. People spoke a lot differently of his legacy after 1997 than before. We’re seeing the same path for Ovechkin, who climbed the mountain in Year 13. The only difference is Ovechkin’s numbers aren’t declining.", 
"21. The Capitals have made it clear that if they do make an Andre Burakovsky trade, they aren’t interested in futures (unless they know those futures can be used to add something right away). They are in it to repeat, and trading him for something that doesn’t add to those chances is not appealing for them. They are an analytically inclined organization, they know Burakovsky’s numbers are pretty good for someone who doesn’t get a ton of power play time.", 
"22. I did have a friend very excited this week that he found the Capitals at 12-1 and the Penguins at 30-1 to win it all.", 
"23. The league’s a more exciting place when Pittsburgh and Washington are spitting fire at each other. Guess neither team is satisfied after combining to win the past three Stanley Cups.", 
"24. Thursday morning, hours after watching the Tom Wilson-Jamie Oleksiak fight, an Eastern Conference GM said that his team wanted to sign Ryan Reaves last summer as “Tom Wilson protection” but Reaves cleary wanted to go back west.", 
"25. How important is Mark Stone? Heading into last Saturday’s game against Pittsburgh, only Ben Harpur and Zack Smith had better five-on-five goal differentials without Stone on the ice. Some of the swings were pretty wild, too. Thomas Chabot went from plus-17 to minus-14, Ryan Dzingel from plus-six to minus-six, Chris Tierney plus-four to minus-11 and Colin White plus-six to minus-four. That’s the sign of a terrific player.", 
"26. Aleksander Barkov played 27:42 last Saturday against Toronto. The only forward to play more in a 60-minute game this season is Patrick Kane. Kane did it twice, with a high of 27:49 during a 4-3 loss in Vegas on Dec. 6.", 
"27. Barkov has zero penalty minutes in 32 games. No one in NHL history has played 82 games without a single penalty minute. The last such comparable season was Butch Goring’s in 1980-81. He had zero in 78 games — along with 60 points. Sometimes, players are accused of not playing a tough enough game when their PIM totals are low, but no one is complaining about Barkov.", 
"The real story is that he’s drawn 25 penalties. That plus-25 differential is 10 better than Johnny Gaudreau and Nico Hischier, who are tied for second. I looked for historical comparables to Barkov’s differential and, according to Corsica.Hockey, Dustin Brown’s plus-58 in 2008-09 is the best on record. But he took a lot more penalties than Barkov (64 PIM) and didn’t score as much (53 points in 80 games). Penalties drawn doesn’t have a long history and Corsica only tracks back to 2007-08. What Barkov’s doing is unprecedented.", 
"28. Vancouver GM Jim Benning was tight-lipped and wouldn’t give any great detail as to why Olli Juolevi‘s injury timeline changed. You’ll remember that last year doctors looked at Shea Weber’s knee and said this is worse than we thought, so that can happen. What the Canucks are going to have to communicate to both current players and potential recruits is that there isn’t a problem with the way they’re diagnosing injuries.", 
"29. The Canucks aren’t ready yet to be a playoff team, but you know the organization wants to start challenging as quickly as possible. They’re a much better team now that they are closer to healthy and two very big parts of that are Alex Edler and Chris Tanev. So if you’re Vancouver what do you do?", 
"Edler’s a free agent, Tanev has one year left — you’re at a point where you have to consider extending them or trading them. Extending them makes you better in the short term, trading them gives you a chance to be better in the long term. The Canucks have made it clear they aren’t trading their best young players or prospects. These are your two most valuable trade chips that you’re potentially willing to use. So what do you do?", 
"30. During the Detroit/Philadelphia broadcast on Tuesday, Ken Daniels mentioned that there will be a Celebration of Life for Mick McGeough Friday night in Regina. At least one current referee will be given time off to attend, and the supervisors are going too. Hope that all of his family and friends are able to get some closure, and tell some great stories. There are a lot of them.", 
"31. No blog next week. Have a great Christmas everyone, Happy Holidays. Hope you get terrific presents. Always appreciate your willingness to read this."
)), .Names = "value", class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -41L))

How about this:

library(tidyverse)

# Get rows that begin with a number
start = which(grepl("^[0-9]*\\.", mydata$value))

# Paste together each sequence of rows that begin with a number 
#  followed by rows that don't begin with a number
mydata2 = map2_chr(start, 
                   c((start - 1)[-1], nrow(mydata)),
                   ~paste(mydata$value[.x:.y], collapse=" ")) %>% 
  data_frame(value=.)
> mydata %>% mutate(value=substr(value,1,80)) %>% slice(1:10) %>% as.data.frame
                                                                              value
1  1. We’re missing one thing in Ottawa: the NHL’s true plan for the future. On a d
2  Melnyk’s response to soon-to-be-former-partner John Ruddy’s lawsuit was to offer
3  2. Imagine being on Philadelphia’s Sunday flight back from Vancouver. You’re pla
4  It led to a clumsy, messy dismissal almost 24 hours later, which is unlike this 
5  The pushback to the story indicates there was going to be a coaching change, but
6  3. So, what happened? The theory is that after seeing the fallout and sleeping o
7  Now, it’s not like I think Isaac (or any of the other reporters who confirmed it
8  Late the night before Hakstol was hired, I got a tip that Hextall was going “off
9                                  Your browser does not support the audio element.
10 4. I’ve said it before, but will say it again: how Hakstol carried himself over 
> mydata2 %>% mutate(value=substr(value,1,80)) %>% slice(1:10) %>% as.data.frame
                                                                              value
1  1. We’re missing one thing in Ottawa: the NHL’s true plan for the future. On a d
2  2. Imagine being on Philadelphia’s Sunday flight back from Vancouver. You’re pla
3  3. So, what happened? The theory is that after seeing the fallout and sleeping o
4  4. I’ve said it before, but will say it again: how Hakstol carried himself over 
5  5. On Joel Quenneville and the Flyers: I’m not so sure this is anywhere close to
6  6. Carter Hart’s promotion wasn’t as crazy as it seemed when you stepped away fr
7  7. Early-in-my-career advice: Watch the off-ice moves as much as the on-ice ones
8  8. Scott Gordon’s a no-nonsense guy, so it won’t be summer camp under him. He’s 
9  9. The most important hire the Flyers made might be Rick Wilson. Ivan Provorov i
10 10. Finally on Philly, word is a few other teams have reached out about Hextall’
7 Likes

what the... how?

Awesome job! Thanks a ton.

I'll check tomorrow, but I think that solves it.

start = which(grepl("^[0-9]*\\.", mydata$value)) gives us the row indices of the rows that start with a number followed by a period. This returns:

[1] 1 3 6 10 11 12 13 14 15 16 17 18 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 37 38 40 41.

We therefore know we want to paste together rows 1 and 2 (since 2 is the row before 3), then rows 3, 4 and 5 (since 5 is the row before 6), then 6, 7, 8 and 9 (since 9 is the row before 10), etc. So, the row ranges for each set of rows we want to paste together is given by start[-length(start)] (the beginning of each range) and (start - 1)[-1] (the end of each range). We use map2_chr to successively paste together these row ranges and then convert the resulting character vector to a data frame.

Let me know if I can provide any additional explanation.

4 Likes

That was a fantastic answer, Joel. Really appreciate it.

Actually Joel, your solution is cutting off the last number (31) for some reason. Gonna try and figure that out myself. Probably shouldn't be a hard fix

  1. doesn't have a trailing un-numbered line; try adding one or a " "
1 Like

Solution:

library(tidyverse)

# Get rows that begin with a number
start = which(grepl("^[0-9]*\\.", mydata$value))

# Paste together each sequence of rows that begin with a number 
#  followed by rows that don't begin with a number
mydata2 = map2_chr(start, 
                   ifelse(length((start - 1)[-1]) == length(start), (start - 1)[-1], c((start - 1)[-1], length(start))),
                   ~paste(mydata$value[.x:.y], collapse=" ")) %>% 
  data_frame(value=.)

This should work...

Feel free to add this into your answer Joel and then I'll just give that the ol' check mark

Actually this isn't quite working. Whoops. Nevermind

Sorry, about that. I've updated my original answer to (I hope) properly address the last numbered row and any succeeding unnumbered rows.

1 Like

Awesome that worked really well. Thanks again for the help.

Here is how I would to it using tidyverse :package:

mydata creation as tibble
mydata <- structure(list(value = c("1. We’re missing one thing in Ottawa: the NHL’s true plan for the future. On a day where one of its owners was countersued for $1 billion, you’d think the league would have something to say. But, nada. Combine that with Commissioner Gary Bettman’s tight-lipped comments at the Board of Governors, and there’s only one conclusion — they have a path, they are confident in that path and they’ll let us know when they feel like it.", 
                                   "Melnyk’s response to soon-to-be-former-partner John Ruddy’s lawsuit was to offer up profits in exchange for Ruddy financing the arena. Melnyk was ridiculed for wanting a freebie, which certainly fits the narrative. But execs outside Ottawa scratched their heads at this strategy, because the arena is what you wish to control. It makes more money than the team. It was almost as if Melnyk was trying to prove Ruddy couldn’t build it either. There’s an endgame here, but it isn’t clear yet.", 
                                   "2. Imagine being on Philadelphia’s Sunday flight back from Vancouver. You’re playing cards, watching movies, reading, editing video, sleeping, you name it, whatever, and all of a sudden a sonic boom hits. That’s Dave Isaac’s story from The Courier Post, indicating Dave Hakstol was out and Joel Quenneville was in. Think about how everyone on that plane had to be reacting as the information spread among the group, especially GM Chuck Fletcher and Hakstol. Those two would have been, what, one row apart?", 
                                   "It led to a clumsy, messy dismissal almost 24 hours later, which is unlike this particular GM. It doesn’t fit with his history. As another GM said, “It would bother Chuck to have it play out this way.” Fletcher declined to comment further, not wanting to toss more gasoline on the fire, but after several conversations, here’s a thesis on what happened.", 
                                   "The pushback to the story indicates there was going to be a coaching change, but Fletcher wasn’t going to do it Sunday. (If the team faced any deadline, it was probably to keep it far enough away from Christmas. You don’t want those headlines.) Around the NHL, the biggest indication that the Flyers were not 100 per cent ready was interim coach Scott Gordon not being at practice on Monday. That kind of detail would have been ironed out, instead of adding more weirdness to the saga.", 
                                   "3. So, what happened? The theory is that after seeing the fallout and sleeping on it Sunday night, Fletcher decided to accelerate the process. It would have been grossly unfair to Hakstol to ask him to coach on Tuesday, especially with what the reaction could have been.", 
                                   "Now, it’s not like I think Isaac (or any of the other reporters who confirmed it) are making stuff up, because the information was everywhere. For years, under Ed Snider, the Flyers were one of the best beats in sports. The team was (mostly) good, there was a ton of personality, people were honest with their opinions and, because of that, there was never a boring day. Under Ron Hextall, that changed. Information was tight, the guy was a vault. Very rarely did news break outside of team control.", 
                                   "Late the night before Hakstol was hired, I got a tip that Hextall was going “off-the-board” with his coaching hire. Early next morning, I sent him a note — it was more of a fishing expedition, I didn’t have the name — saying there was word he was going on a different path. He didn’t reply at the time, but said later he did move up the announcement so as not to lose control of the process. We know his desire to keep most people at arms’ length was a factor in his dismissal, and what unfolded last weekend is evidence the vault is open. Until Fletcher figures out how to close it.", 
                                   "Your browser does not support the audio element.", "4. I’ve said it before, but will say it again: how Hakstol carried himself over the past two years was a master class on how to handle scrutiny. Job security was a constant topic, and he looked totally unfazed by it.", 
                                   "5. On Joel Quenneville and the Flyers: I’m not so sure this is anywhere close to a slam dunk. Quenneville is taking some time with his family in Colorado. Is he really in a rush to get back behind a bench? We know Philadelphia will pay very well, but, if his first goal is to contend right away, where would they rank as an option? His better choice is to wait and see how things play out over the next six months. A good team is going to lose early in the playoffs and say, “You know what, that guy could help us.”", 
                                   "6. Carter Hart’s promotion wasn’t as crazy as it seemed when you stepped away from Monday’s circus and thought about it. They have two injured goalies and Michal Neuvirth was away from the club while his wife gave birth to a baby. There’s no guarantee Hart’s staying, but if a call-up made sense, it was under that scenario. The team rallied around him, preventing Detroit from getting a shot for 12 minutes, arguably their best defensive effort of the season. His performance energized the fans and building. The Flyers desperately needed that as much as anything else.", 
                                   "7. Early-in-my-career advice: Watch the off-ice moves as much as the on-ice ones. Last week, Philadelphia hired Valerie Camillo as President of Business Operations for the team and the Wells Fargo Center. The Flyers got her from MLB’s Washington Nationals, and she reports directly to Comcast-Spectacor CEO Dave Scott. She has a very good reputation. That kind of move, especially in-season, is a sign that an organization isn’t thrilled. The pressures on the Flyers aren’t just on the ice.", 
                                   "8. Scott Gordon’s a no-nonsense guy, so it won’t be summer camp under him. He’s pretty serious. But — and credit to Brian Burke for this — he was a part of the Beanpot Trot.", 
                                   "9. The most important hire the Flyers made might be Rick Wilson. Ivan Provorov is a tremendous player. He’s just lost right now. When Hextall held his post-firing availability, he admitted to being surprised how much a contract season affected Provorov mentally. They have to get him going again or it is a major problem for them.", 
                                   "10. Finally on Philly, word is a few other teams have reached out about Hextall’s availability. Maybe not as GM, but to join their organizations. There’s interest.", 
                                   "11. After Bob Murray’s extension in Anaheim, I went through the list of GMs wondering who might be next. A logical guess is New Jersey’s Ray Shero. The team is off to a rough start, but the overall direction of the franchise is improved. John Hynes was a good hire. It makes sense.", 
                                   "12. On Dec. 9, the Devils lost 6-5 to Anaheim on a night where they scored three times on their own net. We all know how brutal it’s been for Cory Schneider, who was in goal for that. Well, someone reached out to tell a story about the post-game.", 
                                   "There was family outside the Devils’ dressing room waiting to meet Schneider. This guy felt terrible for them, because there was no way he thought the goalie would be in any kind of mood to talk, and, it is their only visit to Orange County this season. There was no need to worry. Despite everything that’s happened, Schneider was friendly, gracious and left the family beaming.", 
                                   "13. There were rumours this past summer that Schneider’s hip surgery could be the end of his career. On a visit to Toronto earlier this season, he denied that. “No, it was never that bad,” he said.", 
                                   "On this week’s 31 Thoughts Podcast, Roberto Luongo said he’s spoken to Schneider a few times. “I remember when I had my hip surgery, even though I came back and played at the start of the season, it’s tough. It takes two full years to be fully recovered from hip surgery. Even though you’re playing the first year, you’re feeling it, it’s hurting you, it’s bothering you…whether you like it or not, it’s a problem for sure.”", 
                                   "14. Speaking of goalies, how much is the NHL changing right now? The league average save percentage is .908 as of Thursday morning. If that continues, it will be the first time below .910 since 2008-09.", 
                                   "15. A number of Western Conference GMs are curious about what Colorado is going to do. They’re good enough to like their chances, but not yet deep enough to believe they can win it all. They’ve got a lot of assets to work the trade market with, but the biggest question is whether or not the Avalanche believe this is the year to try to win it all.", 
                                   "16. Sounds like Carolina’s been debating Vladimir Tarasenko, but would St. Louis want Martin Necas?", 
                                   "17. Vegas is rumoured to be interested in every WHL alumnus, but Brayden Schenn did play three years for assistant GM Kelly McCrimmon at Brandon. So that has some of the Golden Knights’ rivals wondering if there may be more to it.", 
                                   "18. Columbus’s Jarmo Kekalainen and Detroit’s Ken Holland were two GMs seen at the Channel One Cup in Moscow. (Apparently, Montreal had a decent-sized delegation, too.) The Blue Jackets had defensive prospect Vladislav Gavrikov there, who apparently played very well for the victorious Russians. There is a push for some Russian free agents, but the highest-rated ones may not be free until the summer of 2020. There are rumblings that ex-NHLers Mikhail Grigorenko and Nikita Nesterov are contemplating returns, too.", 
                                   "19. I’m not sure he would come back, but one Russian contact said he’d heard a few teams were interested in taking another look at Viktor Antipin. It didn’t work in Buffalo last year.", 
                                   "20. Someone made an interesting comparison this week…Alexander Ovechkin to Steve Yzerman. Yzerman had a phenomenal career well before he won his first Stanley Cup in Year 14, lighting up the NHL season after season. We all know the story. He changed his game, won two more times, adding a gold medal for fun. People spoke a lot differently of his legacy after 1997 than before. We’re seeing the same path for Ovechkin, who climbed the mountain in Year 13. The only difference is Ovechkin’s numbers aren’t declining.", 
                                   "21. The Capitals have made it clear that if they do make an Andre Burakovsky trade, they aren’t interested in futures (unless they know those futures can be used to add something right away). They are in it to repeat, and trading him for something that doesn’t add to those chances is not appealing for them. They are an analytically inclined organization, they know Burakovsky’s numbers are pretty good for someone who doesn’t get a ton of power play time.", 
                                   "22. I did have a friend very excited this week that he found the Capitals at 12-1 and the Penguins at 30-1 to win it all.", 
                                   "23. The league’s a more exciting place when Pittsburgh and Washington are spitting fire at each other. Guess neither team is satisfied after combining to win the past three Stanley Cups.", 
                                   "24. Thursday morning, hours after watching the Tom Wilson-Jamie Oleksiak fight, an Eastern Conference GM said that his team wanted to sign Ryan Reaves last summer as “Tom Wilson protection” but Reaves cleary wanted to go back west.", 
                                   "25. How important is Mark Stone? Heading into last Saturday’s game against Pittsburgh, only Ben Harpur and Zack Smith had better five-on-five goal differentials without Stone on the ice. Some of the swings were pretty wild, too. Thomas Chabot went from plus-17 to minus-14, Ryan Dzingel from plus-six to minus-six, Chris Tierney plus-four to minus-11 and Colin White plus-six to minus-four. That’s the sign of a terrific player.", 
                                   "26. Aleksander Barkov played 27:42 last Saturday against Toronto. The only forward to play more in a 60-minute game this season is Patrick Kane. Kane did it twice, with a high of 27:49 during a 4-3 loss in Vegas on Dec. 6.", 
                                   "27. Barkov has zero penalty minutes in 32 games. No one in NHL history has played 82 games without a single penalty minute. The last such comparable season was Butch Goring’s in 1980-81. He had zero in 78 games — along with 60 points. Sometimes, players are accused of not playing a tough enough game when their PIM totals are low, but no one is complaining about Barkov.", 
                                   "The real story is that he’s drawn 25 penalties. That plus-25 differential is 10 better than Johnny Gaudreau and Nico Hischier, who are tied for second. I looked for historical comparables to Barkov’s differential and, according to Corsica.Hockey, Dustin Brown’s plus-58 in 2008-09 is the best on record. But he took a lot more penalties than Barkov (64 PIM) and didn’t score as much (53 points in 80 games). Penalties drawn doesn’t have a long history and Corsica only tracks back to 2007-08. What Barkov’s doing is unprecedented.", 
                                   "28. Vancouver GM Jim Benning was tight-lipped and wouldn’t give any great detail as to why Olli Juolevi‘s injury timeline changed. You’ll remember that last year doctors looked at Shea Weber’s knee and said this is worse than we thought, so that can happen. What the Canucks are going to have to communicate to both current players and potential recruits is that there isn’t a problem with the way they’re diagnosing injuries.", 
                                   "29. The Canucks aren’t ready yet to be a playoff team, but you know the organization wants to start challenging as quickly as possible. They’re a much better team now that they are closer to healthy and two very big parts of that are Alex Edler and Chris Tanev. So if you’re Vancouver what do you do?", 
                                   "Edler’s a free agent, Tanev has one year left — you’re at a point where you have to consider extending them or trading them. Extending them makes you better in the short term, trading them gives you a chance to be better in the long term. The Canucks have made it clear they aren’t trading their best young players or prospects. These are your two most valuable trade chips that you’re potentially willing to use. So what do you do?", 
                                   "30. During the Detroit/Philadelphia broadcast on Tuesday, Ken Daniels mentioned that there will be a Celebration of Life for Mick McGeough Friday night in Regina. At least one current referee will be given time off to attend, and the supervisors are going too. Hope that all of his family and friends are able to get some closure, and tell some great stories. There are a lot of them.", 
                                   "31. No blog next week. Have a great Christmas everyone, Happy Holidays. Hope you get terrific presents. Always appreciate your willingness to read this."
)), .Names = "value", class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -41L))
library(tidyverse)

mydata %>%
  # extract num if present to create group. Keep original and convert as numeric
  extract(value, "num", regex = "^(\\d*)\\.", remove = FALSE, convert = TRUE) %>%
  # fill up group for following line
  fill(num, .direction = "down") %>%
  # concatenate by num
  group_by(num) %>%
  summarise(res = str_c(value, collapse = " ")) %>%
  # doesn't need num anymore
  select(-num)
#> # A tibble: 31 x 1
#>    res                                                                     
#>    <chr>                                                                   
#>  1 1. We’re missing one thing in Ottawa: the NHL’s true plan for the futur~
#>  2 2. Imagine being on Philadelphia’s Sunday flight back from Vancouver. Y~
#>  3 3. So, what happened? The theory is that after seeing the fallout and s~
#>  4 4. I’ve said it before, but will say it again: how Hakstol carried hims~
#>  5 5. On Joel Quenneville and the Flyers: I’m not so sure this is anywhere~
#>  6 6. Carter Hart’s promotion wasn’t as crazy as it seemed when you steppe~
#>  7 7. Early-in-my-career advice: Watch the off-ice moves as much as the on~
#>  8 8. Scott Gordon’s a no-nonsense guy, so it won’t be summer camp under h~
#>  9 9. The most important hire the Flyers made might be Rick Wilson. Ivan P~
#> 10 10. Finally on Philly, word is a few other teams have reached out about~
#> # ... with 21 more rows

Created on 2019-01-13 by the reprex package (v0.2.1)

6 Likes

Amazing answer, @cderv . I wish I could give 2 solutions check marks...

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.