##This code shows you how to find species rows and clean up names from Galaxy ##tabular reports for one sample
##File was renamed from long Galaxy history name to something easier to type
#Read in file from Unit 2, use tab to autocomplete file name
allTax <- read.table('Toothbrush.tabular', sep="\t", fill = TRUE,colClasses=c("character","numeric"))
#Create dataframe with just species rows using logical filter
sRows <- allTax[grepl("d__.*s__",allTax$V1),]
#Use gsub to simplify Species name to only text after |s
sRows$V1 <- gsub("d__.*s__","",sRows$V1)
#Format column names and write file
names(sRows) <- c('Species','Count')
write.csv(sRows,"Species.csv",row.names=FALSE,quote=FALSE)