Problems with battery overflow using ifelse function

Asked

Viewed 30 times

0

Hello, all right?

I’m having trouble generating a function based on ifelse(), because there is a battery burst above 49 conditions. I tend to calculate averages every 5 me. for this I need to use the function to make the "amplitudes".

data example:

eval(parse(text=
  paste(c("cut.M5<-c(",rep("",287)),'"',c(rep(0,12),rep(1:23,each=12)),"H ",c(0,seq(5,55,5)),"M 0S",'"',c(rep(",",287),')'),sep=""))
  )
x=paste(rep(seq(0,24,1),each=60),"H ",1:60,"M 0S",sep="")

example of the function:

eval(parse(text=paste(c("tempo.5m<-function(x){",rep("",286)),'ifelse(x>=cut.M5[',1:287,'] & x<cut.M5[',2:288,'],cut.M5[',1:287,'] ',c(rep(",",286),paste(',ifelse(x>cut.m5[288],cut.m5[288],"não")',paste(rep(")",287),collapse = " "),"}",collapse = "") ),sep=""))
  )

As they generate more than 49 conditions... there is the battery burst, someone knows another way to perform this marking?

  • 3

    See if dplyr::case_when solves this problem.

  • solved yes, thank you!!!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.