-3

I'm using summary to get stats for a number list:

read.csv('nums.txt', header = F)
summary(x)

nums.txt:

value
1
2
3

How do i summarize this data by group/category using summary function?

nums.txt

category,value
A,1
A,2
A,3
B,4
B,5
B,6
Sathish
  • 20,660
  • 24
  • 63
  • 71

1 Answers1

1

If I google "r summary by" the first answer that comes up for me is a link to http://www.statmethods.net/stats/descriptives.html Which has a solution to your problem.

Another solution not mentioned there is as follows

 library(data.table)
 x <- data.table(x)

 x[, summary(Value), by=list(Group1, Group2)]   # assuming more than one group. Otherwise, just use by=Group1
Ricardo Saporta
  • 54,400
  • 17
  • 144
  • 178