it doesn't work because you're trying to save something of the wrong length
into your data frame

I used agr1$quantile <- quantile(agr1$cnt, probs=c(.50, .75, .90, .95, .99))
>

# these two numbers should be the same
nrow( agr1 )
length( agr1$quantile )

# these two numbers should be the same
length( c(.50, .75, .90, .95, .99) )
length( quantile(agr1$cnt, probs=c(.50, .75, .90, .95, .99)) )

# but all four of those numbers aren't the same.  there's one answer for
each percentile, not one answer for each row.

# if you want the entire column in your agr1 data frame to contain the same
number,
# you could potentially add quantiles one at a time
agr1$median <- quantile( agr1$cnt , 0.5 )
agr1$p75 <- quantile( agr1$cnt , 0.75 )
# but that may look silly, since it's the same number over and over
head( agr1 )
# why not save them elsewhere?  :)

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
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.

Reply via email to