I have five dataframes, each with 8 columns and 10000 rows. The data for each dataframe was drawn from random t-distributions with varying mean
and sd
specifications. Each column corresponds to one of these specifications. Meanwhile, each case is one t-value drawn from the specific t-distribution. I did this by hand, without an automatic process. (Any suggestion on how to do this easier?)
For each column in a dataframe, I'd like to calculate percentages of observations that lie between specific ranges, >0,=<0.6; >0.6,=<0.7; >0.7, =<0.8 and so on until >1.4.
I tried the for loop but that is still difficult for me to understand how it works, so I failed at that too.
isim20$ival_05 <- cut(isim20[,1], c(0,0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, max(isim20[,1])))
isim20$ival_08 <- cut(isim20[,2], c(0,0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, max(isim20[,2])))
...
, where
isim20
is my dataframe
ival_05
and ival_08
are two variables (columns) for which I'd like to calculate the percentages given by the ranges in the cut
command.
I got stuck at this point because I fail to understand how can I calculate the percentage of each value range for each column at once (to avoid doing this by hand). In addition to that, I have to repeat everything for all five data frames.
Thank you for all your suggestions!