Arashi Arashi - 7 months ago 34
R Question

R pulling data for one column(X, is a int) when a column(string) matches a unique string

I am pulling data from a sql server and need to manipulate the data tables for future stats analysis. The table i am pulling is 4 variables with 600+ observations. My goal is to find a way to get the values of columns X, Y , Z when a string in column(name) is matched. I want the list to only be the values of the X, Y , Z with no name column .

code so far:

my_db <- dbConnect(RMySQL::MySQL(),
dbname = "schema", #name of schema
host = "host", #name of host
user= "root", #name of user. typically root default
password = "password", # my password, unique to your MySQL Workbench
port = deafult # it is the default port
users <- dbReadTable(my_db, "schema_DT")

Joy Joy

I'm pretty sure this will do the trick:

filtered_data<-users %>% filter(special_column=="my string") %>% select(X,Y,Z)