mercredi 23 juin 2021

select columns with patterns in data.table

I have a data table with many columns like real_0_h, real_1_h, real_2_h and so on. Unfortunately, I have other columns named for instance real_dose.

my code looks like that (data.table package): melt(dt, id.vars = c("id", "dose"), measure.vars = patterns("^real_")).

Like that, obviously real_dose will be selected as well, but I want to refer to real_0_h:real_24_h only (dplyr syntax). How is it done?

Aucun commentaire:

Enregistrer un commentaire