data("wine")
colnames(wine)
## Split the wine dataset into three subsets for the three Cultivars
## and remove the Cultivar column from the datasets.
winecolnames <- !(colnames(wine) %in% "Cultivar")
wine1 <- wine[wine$Cultivar == 1, winecolnames]
wine2 <- wine[wine$Cultivar == 2, winecolnames]
wine3 <- wine[wine$Cultivar == 3, winecolnames]
wine <- wine[ , winecolnames]
## Write the datasets without the Cultivar information into the tab
## delimited ASCII files.
write.table(wine, file = "wine.txt", sep = "t",
eol = "", row.names = FALSE, col.names = FALSE)
write.table(wine1, file = "wine1.txt", sep = "t",
eol = "", row.names = FALSE, col.names = FALSE)
write.table(wine2, file = "wine2.txt", sep = "t",
eol = "", row.names = FALSE, col.names = FALSE)
write.table(wine3, file = "wine3.txt", sep = "t",
eol = "", row.names = FALSE, col.names = FALSE)
Run the code above in your browser using DataLab