0

I am quite new to R therefor my question might be quite basic but searching through the forum I haven't really found the write answer. I have a data.frame of 24 variables and after computing the mean for each column I would like to calculate the IQR(0.25 and 0.75) for every column.

As far as I understood I have to transform the df in a matrix for IQR which I have done, and tried several options with do.call or apply but don't really manage.

Any help would be much appreciated!

Terru_theTerror
  • 4,918
  • 2
  • 20
  • 39
Tobias Tobi
  • 1
  • 1
  • 2
  • 5
    Welcome to StackOverflow! Please read the info about [how to ask a good question](http://stackoverflow.com/help/how-to-ask) and how to give a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610). This will make it much easier for others to help you. – Jaap Mar 19 '18 at 15:59
  • I suggest that the next time you try a better search. I found the duplicate with `[r] IQR columns" – IRTFM Mar 19 '18 at 19:37

2 Answers2

2

Try to adapt this code:

df<-data.frame(a=runif(100,10,20),
               b=runif(100,23,23))
lapply(df,quantile,probs=c(0.25,0.75))
$a
     25%      75% 
12.31132 17.72699 

$b
25% 75% 
 23  23 
Terru_theTerror
  • 4,918
  • 2
  • 20
  • 39
0

Summary gives you the mean, quartiles, extreme values for each columns

df<-data.frame(a=runif(100,10,20),
               b=runif(100,23,23))
summary(df)
Frostic
  • 680
  • 4
  • 11