Is there any way to select values within 5 certain ranges for a given column, and to each different dataframe, apply in a new column, a label?
I mean, I have a list a of dataframes. All dataframes have 2 columns and share the same first column, but differs in the second (header and values). For example:
>> df1
GeneID A
1 0.3
2 0.0
3 143
4 9
5 0.6
>> df2
GeneID B
1 0.2
2 0.3
3 0.1
4 0.7
5 0.4
....
I would like to:
For each dataframe on the list, perform a calculation which gives the probability of that value occur within 1 of 5 different range. Append a new column with those values;
For each dataframe on the list, attach the respective range label in another new column.
Where the ranges are:
*Range_Values* -> *Range_Label*
**[0]** -> 'l1'
**]0,1]** -> 'l2'
**]1,10]** -> 'l3'
**]10,100]** -> 'l4'
**>100** 'l5'
This 2 steps approaches would led to something like:
>> list_dfs[df1]
GeneID A Prob_val Exp_prof
1 0.3 0.4 'l2'
2 0.0 0.2 'l1'
3 143 0.2 'l5'
4 9 0.2 'l3'
5 0.6 0.4 'l2'