Impulsleistung
Impulsleistung

Reputation: 325

Pipeline %>% in R

I want to use the pipeline %>% from TIDYVERSE/PURRR to make this more readable:

myChargingDevices<-data.frame(fromJSON(jsonFile))
myChargingDevices<-myChargingDevices %>%
  mutate(myTime=ymd_hms(lastUpdateCheck))

myChargingDevices<-myChargingDevices[order(myChargingDevices$myTime,decreasing = TRUE),]
myChargingDevices$lastUpdateCheck<-NULL

Any ideas to do this more convenient?

Thanks in advance

Upvotes: 2

Views: 119

Answers (1)

gdkrmr
gdkrmr

Reputation: 698

Like this:

myChargingDevices <- jsonFile %>%
  fromJSON %>%
  data.frame %>%
  mutate(myTime = ymd_hms(lastUpdateCheck)) %>%
  arrange(desc(myTime)) %>%
  select(-lastUpdateCheck)

I cannot test it, because you do not give reproducible code.

Upvotes: 5

Related Questions