r - Output of quantile to a data frame -
This is a fairly basic question, but has not seen good answers on different forums. Say I have a simple vector
x = runif (10,1,4)> X [1] 3.292108 1.388526 2.774949 3.005725 3.904919 1.322561 2.660862 1.400743 [9] 2.252095 3.567267 & gt; Next I calculate some quantities,
& gt; Z = Quantity (X, C (0.1.0.8)) gt; Z 10% 80% 1.381929 3.347140 & gt; I need this output as the data output, so I tried the following
& gt; Y = data.frame (id = name (z), value = z) & gt; Y ID value 10% 10% 1.381929 80% 80% 3.347140 I think the "%" column has been repeated. Also when I try
& gt; Y $ id [1] [1] 10% level: 10% 80% While I expect it to be just "10%" or 0.1. Any help appreciated.
The names are only possibilities
y < - Data frame (id = c (0.1, 0.8), value = z) will work
so wrapping it in a function that is data .frame quantile_df
Comments
Post a Comment