A user has the following dataframe and wants to select only particular labels such as ‘hesc’, or ‘bj fibroblast’.How to do that? Following is the data
To select rows which contains ‘hesc’, we can do the following
expr[expr$cell_type == "hesc", ]
To select rows having either ‘hesc’ or ‘bj fibroplast’, we can do the following
expr[expr$cell_type %in% c("hesc", "bj fibroblast"), ]
We can also use subset function to choose the rows as
subset(expr, cell_type == "hesc") subset(expr, cell_type %in% c("bj fibroblast", "hesc"))
We can also use filter function from dplyr library as
filter(expr, cell_type %in% c("bj fibroblast", "hesc"))