Basic scripts

less than 1 minute read

In this blog post I will include basic notes of useful scripts

Subset columns

This next script uses grep to subset columns

subset.dataframe <- dataframe[grep("thing_to_search", dataframe$column_to_grep), 1:12] # at the end of script you set the range of columns to keep, in this case 1:12.

dataframe[dataframe$column_to_grep[which(dataframe$column) == "thing_to_search"],1:12] # another way

subset/find values in between two numbers

which(dataframe$column >= 1 & dataframe$column <= 10)] 

Leave a Comment