[R] Error in cut.default(a, breaks = 100) : 'breaks' are not unique

Sarah Goslee sarah.goslee at gmail.com
Wed Feb 17 21:16:43 CET 2016


It should cover the range of values - from below the minimum to above
the maximum of your data.
One break would do it, or 10, or whatever. It doesn't matter how many
breaks you have, it matters that they have a sufficient range.
So you might make breaks like
seq(floor(min(x)), ceiling(max(x)), length.out = 10)
if you want equal lengths.

Sarah



On Wed, Feb 17, 2016 at 10:06 AM, /ty放仔兽/yl <yoyohashao at qq.com> wrote:
> Dear R users,
> as my first post for this mailing list, I'd like to ask questions about 'break' in cut.default.
>
>
> I am using pheatmap in RStudio. Pheatmap is a function to draw clustered heatmap in R.
>
>
> According to the manual, breaks is 'a sequence of numbers that covers the range of values in data matrix and is one element longer than color vector. Used for mapping values to colors. Useful, if needed to map certain values to certain colors, to certain values. If value is NA then the breaks are calculated automatically.'
>
>
> I left it NA but received an error message. I then assigned a seq to it by typing breaks=c(0,1,2,3,4,5,6,7,8,9), which didn't work as well (my col.pal has 9 elements so I made a breaks with 10 elements).
>
>
> One thing I felt confused was that it said breaks should cover the range of values in data matrix. My data has 20 obs. of 23 variables. Which number would cover it? And how should I understand 'cover' in this context.
>
>
> Sorry to bother you guys. I am quite a rookie to R.
>



More information about the R-help mailing list