I collect data from different sensors in different places, data output is something like:
df<-data.frame(date=c(2011,2012,2013,2014,2015),"Sensor1 Temp"=c(15,18,15,14,19),"Sensor1 Pressure"=c(1001, 1000, 1002, 1004, 1000),"Sensor1a Temp"=c(15,18,15,14,19),"Sensor2 Temp"=c(15,18,15,14,19),"Sensor2 Pressure"=c(1001, 1000, 1002, 1004, 1000))
The problem (I think) is similar to: Using select_ and starts_with R
I want to search for sensors, for example, by location, so I have a list to search by file frame, as well as a timestamp. But the search falls apart when I search for more than one sensor (or type of sensor, etc.). Is there a way to use dplyr (NSE or SE) to achieve this?
Findsensor = c("Sensor1")
test <- df %>% select_(.dots = ~starts_with(Findsensor))
Findsensor = c("date", "Sensor1", "Sensor2")
test <- df %>% select_(.dots = ~starts_with(Findsensor))
This is part of a larger pipe (hence using dplyr) and you want to integrate the selection with Shiny, so flexibility is important. The search may be different locations or sensors, or some other variable based on the search for characters.
!
: Dplyr select_ starts_with 2