0

I have a dataframe like the following one :

dom_output <- data.frame(
  Site = c("alpha", "beta", "charlie", "delta","alpha", "beta", "charlie", "delta"),
  Value = c(11,22,33,44,55,66,77,88),
  label  = c("Watermelon","Vanilla","Default","Default","Watermelon","Vanilla","Default","Default")
)

I want to split it different data frames based on Site . So the new data frame names should be based of the Site. I know how to filter and select it but how do I do it in a loop and name the df based on the split value itself.

So I would have 4 df alpha,beta,charlie, delta.

SNT
  • 1,283
  • 3
  • 32
  • 78
  • Do you mean `split(dom_output, dom_output$Site)`? – Maurits Evers Sep 17 '19 at 22:19
  • @SNT I've closed your question as a dupe for now, because from what I understand this seems to be a simple case of `split`. Leave a comment if I misunderstood and I'll re-open. – Maurits Evers Sep 17 '19 at 22:21
  • So I just have 4 types under site now. But i want to identify the unique in sites and split based on it. And when split, each split data should have its own dataframe where the dataframe name is the split value itself. Thank you@MauritsEvers – SNT Sep 18 '19 at 03:35
  • That's exactly what `split(dom_output, dom_output$Site)` does. Take a look at the documentation for `split`. – Maurits Evers Sep 18 '19 at 12:40

0 Answers0