I am analyzing bacterial 16S data extracted from vegetarian food samples and would like to combine two data frames of different row and column lengths into one data frame. The two data frames are:
taxa = 5081 entries and 6 columns
genus.species = 1661 entries and 2 columns
- Example of what "taxa" looks like:
Sequence Kingdom Phylum Class Order Family Genus
x Bacteria CyanoBacteria Oxyphotobacteria Chloroplast N/A N/A
- Example of what "genus.species" looks like:
Sequence Genus Species
x N/A N/A
I have tried appending empty rows to the end of the genus.species file so that it has the same number of rows than that of the taxa file but have been unsuccessful. Are there other ways to circumvent this issue?
genus.species <- assignSpecies(Food_Bac16S_Meg_nochim_sumtable,
"C:/Users/DELL/Desktop/University of Western Cape/Masters/Thesis/Analysis/Bacterial_16S_Data_Trimmed/silva_species_assignment_v132.fa",
allowMultiple=FALSE)
taxa <- assignTaxonomy(Food_Bac16S_Meg_sumtable,
"C:/Users/DELL/Desktop/University of Western Cape/Masters/Thesis/Analysis/Bacterial_16S_Data_Trimmed/silva_nr_v132_train_set.fa",
multithread=TRUE)
taxa_sp <- data.frame(taxa[,1], taxa[,2], taxa[,3], taxa[,4], taxa[,5], taxa[,6], genus.species[,2])
I expected that these two data frames will create one data frame that will go through all the sequences within the taxa file and will append the genus.species file to the end of the column of the correct sequences, however, I receive this error:
Error in data.frame(taxa[, 1], taxa[, 2], taxa[, 3], taxa[, 4], taxa[, :
arguments imply differing number of rows: 5081, 1661
So ultimately, how do I join two data frames into one if they have different row and column lengths? Any help will be much appreciated.