/ty放仔兽/yl
2016-Feb-17 15:06 UTC
[R] Error in cut.default(a, breaks = 100) : 'breaks' are not unique
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. Kind. Sebastian [[alternative HTML version deleted]]
Sarah Goslee
2016-Feb-17 20:16 UTC
[R] Error in cut.default(a, breaks = 100) : 'breaks' are not unique
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. >
Jeff Newmiller
2016-Feb-17 20:33 UTC
[R] Error in cut.default(a, breaks = 100) : 'breaks' are not unique
Range of values is a standard mathematical concept, unrelated to the number of values in your data set. Consider using the summary function to learn about the range of your data. Also, read the Posting Guide (which warns you to use pain text in formulating your emails to the list to avoid corruption of your email). Always try to supply self-contained examples of code that conveys what you understand so far. Read http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example for advice on communicating examples clearly. -- Sent from my phone. Please excuse my brevity. On February 17, 2016 7:06:19 AM PST, "/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. > > >Kind. Sebastian > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >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.[[alternative HTML version deleted]]