R Studio crashing when using separate() function

I am working on the Google Data Analytics capstone and everytime I try to run this code:

separate(heartrate_seconds_merged,Time,into=c('Date','Time'),sep=' ')

I get an error that either R Studio unexpectedly crashed or went to sleep. Any suggestions on how to fix this?

Hi @sfluker30 , see this example for work with separate() function.

colors_df <- data.frame(colors = c("red,green,blue", "orange,purple", "pink,yellow,gray"))


colors_df %>%
  separate(colors, into = c("color1", "color2", "color3"), sep = ",")

# color1   color2  color3
# 1    red  green    blue
# 2  orange purple   <NA>
# 3   pink yellow   gray

Try to put a reproducible example of data and code for better help you all the community.

I'm having the same problem with the same exact dataset. When I get the error, the Environment also defaults to an older version that is missing my "heartrate" dataframe but includes older dataframes that I'd deleted.

@M_AcostaCH , the dataset is from the "heartrate_seconds_merged" file that is part of the FitBit Fitness Tracker Data hosted here. Below is the code I used to try and separate the Time column.

heartrate <- read.csv(file = "Datasets/heartrate_seconds_merged.csv")
heartrate <- separate(heartrate, Time, into=c('HRDate', 'HRTime'), sep=' ')

I also did the same thing with the "sleepDay_merged" file, and I did not run into the same error, so I don't know why it's wrong. Here's the code for the sleepDay separation for comparison.

sleep <- read.csv(file = "Datasets/sleepDay_merged.csv")
sleep <- separate(sleep, SleepDay, into=c('SleepDate', 'SleepTime'), sep=' ')

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.