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"))
library(tidyr)
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.
A minimal reproducible example consists of the following items:
A minimal dataset, necessary to reproduce the issue
The minimal runnable code necessary to reproduce the issue, which can be run
on the given dataset, and including the necessary information on the used packages.
Let's quickly go over each one of these with examples:
Minimal Dataset (Sample Data)
You need to provide a data frame that is small enough to be (reasonably) pasted on a post, but big enough to reproduce your issue.
Let's say, as an example, that you are working with the iris data frame
head(iris)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.…
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=' ')
system
Closed
April 8, 2023, 3:36am
4
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.