Hello all I have a table a sample of which is as follows:
Categories Variable (x) Frequencies 1 1 1 1 1 0.009 0.867 0.567 0.765 0.445 1003 1200 987 134 890 2 2 2 2 2 0.007 0.768 0.789 0.544 0.987 899 707 865 678 889 3 3 3 3 3 0.898 0.887 0.560 0.098 0.987 544 677 934 467 876 40 40 40 40 40 0.786 0.342 0.456 0.987 0.123 843 987 675 467 223 Basically I have 40 categories and each category has several hundred variables. I want to calculate the average per category, that is variable * frequency/Summation of frequencies. I want to do it for each category separately. Since i have many categories i do not want to use the subset() function 40 times. Is it possible to do it within a single data frame? Really appreciate any help. Thank you. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.