daily_activity_no_dptd <- daily_activity_no_dptd %>%
group_by(Id, New_Date) %>%
filter(SedentaryMinutes!= 1440) %>%
mutate(User = factor(case_when(VeryActiveMinutes + FairlyActiveMinutes) >= 60 & Calories >= 2400 ~ "Excessive User", (VeryActiveMinutes + FairlyActiveMinutes + SedentaryMinutes + LightActiveMinutes) > 1200 & Calories > 1600 ~ "Moderate User", TRUE ~ "Average User", levels = c("Average User", "Moderate User", "Excessive User"))) %>%
drop_na() %>%
summary()
So the message I am getting while running down this code is this
Error in `mutate()`:
! Problem while computing `User = factor(...)`.
ℹ The error occurred in group 1: Id = 1503960366, New_Date = 2016-04-12.
Caused by error in `match()`:
! 'match' requires vector arguments
Backtrace:
1. ... %>% summary()
9. base::factor(...)
Error in mutate(., User = factor(case_when(VeryActiveMinutes + FairlyActiveMinutes) >= :
ℹ The error occurred in group 1: Id = 1503960366, New_Date = 2016-04-12.
Caused by error in `match()`:
! 'match' requires vector arguments
Can anyone please help me find where I am doing the error.
Thank you in advance :)
It is not clear what you are trying to do but this line has misplaced parenthesis. I think it should be:
mutate(User = factor(case_when(VeryActiveMinutes + FairlyActiveMinutes >= 60 & Calories >= 2400 ~ "Excessive User",
VeryActiveMinutes + FairlyActiveMinutes + SedentaryMinutes + LightActiveMinutes > 1200 & Calories > 1600 ~ "Moderate User",
TRUE ~ "Average User"),
levels = c("Average User", "Moderate User", "Excessive User"))) %>%
Also, this group_by()
command has no effect on the outcome, what is your intention with this?
based on the user time and calories burnt by users, I am making a column of different type of users. group_by(Id, New_Date) is basically I was arranging trying to arrange them by the updated New_date format which I had made before running this code.
The missing parenthesis I added later and still it shows error
new_daily_activity <- new_daily_activity %>%
group_by(Id, New_Date) %>%
filter(SedantaryMinutes !=1440) %>%
mutate(User = factor(case_when((VeryActiveMinutes + FairlyActiveMinutes >=60 & Calories >=2400 ~ "Excessive User", (VeryActiveMinutes + Fairly ActiveMinutes + SedantaryMinutes+LightlyActiveMinutes) >1080 & Calories >1600 ~ "Moderate User", TRUE ~ "Average User"), levels = c("Average User", "Moderate User", "Excessive User"))) %>%
drop_na() %>%
summary(new_daily_activity)
Now it is showing this error
Error: unexpected ',' in:
" filter(SedantaryMinutes !=1440) %>%
mutate(User = factor(case_when((VeryActiveMinutes + FairlyActiveMinutes >=60 & Calories >=2400 ~ "Excessive User","
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.