Allaisone 1

2017-Nov-09 19:44 UTC

### [R] Calculating frequencies of multiple values in 200 colomns

Hi All I have a dataset of 200 columns and 1000 rows , there are 3 repeated values under each column (7,8,10). I wanted to calculate the frequency of each value under each column and then apply the function maf () given that the frequency of each value is known. I can do the analysis step by step like this :-> ValuesA B C ... 200 1 7 10 7 2 7 8 7 3 10 8 7 4 8 7 10 . . . 1000 For column A : I calculate the frequency for the 3 values as follows : count7 <- length(which(Values$A == 7)) count8 <- length(which(Values$A == 8)) count10 <- length(which(Values$A == 10)) count7 = 2, count8 = 1 , count10= 1. Then, I create a vector and type the frequencies manually : Freq<- c( count7=2 ,count8= 1,count10=1) Then I apply the function maf () :- maf(Freq) This gives me the result I need for column A , could you please help me to perform the analysis for all of the 200 columns at once ? Regards Allahisone [[alternative HTML version deleted]]

Bert Gunter

2017-Nov-09 20:56 UTC

### [R] Calculating frequencies of multiple values in 200 colomns

This is not a good way to do things! R has many powerful built in functions to do this sort of thing for you. Searching -- e.g. at rseek.org or even a plain old google search -- can help you find them. Also, it looks like you need to go through a tutorial or two to learn more about R's basic functionality. In this case, something like (no reproducible example given, so can't confirm): apply(Values, 2, function(x)maf(tabulate(x))) should be close to what you want . Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Thu, Nov 9, 2017 at 11:44 AM, Allaisone 1 <allaisone1 at hotmail.com> wrote:> > Hi All > > > I have a dataset of 200 columns and 1000 rows , there are 3 repeated > values under each column (7,8,10). I wanted to calculate the frequency of > each value under each column and then apply the function maf () given that > the frequency of each value is known. I can do the analysis step by step > like this :- > > > > Values > > > A B C ... 200 > > 1 7 10 7 > > 2 7 8 7 > > 3 10 8 7 > > 4 8 7 10 > > . > > . > > . > > 1000 > > > For column A : I calculate the frequency for the 3 values as follows : > > count7 <- length(which(Values$A == 7)) > > count8 <- length(which(Values$A == 8)) > > count10 <- length(which(Values$A == 10)) > > > count7 = 2, count8 = 1 , count10= 1. > > > Then, I create a vector and type the frequencies manually : > > > Freq<- c( count7=2 ,count8= 1,count10=1) > > > Then I apply the function maf () :- > > maf(Freq) > > > This gives me the result I need for column A , could you please help me > > to perform the analysis for all of the 200 columns at once ? > > > Regards > > Allahisone > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. >[[alternative HTML version deleted]]

### Reasonably Related Threads

- Calculating frequencies of multiple values in 200 colomns
- Calculating frequencies of multiple values in 200 colomns
- Calculating frequencies of multiple values in 200 colomns
- Calculating frequencies of multiple values in 200 colomns
- Complicated analysis for huge databases