admin管理员组文章数量:1410712
I am a beginner in R, and have only been doing it for a couple weeks. Recently I have been trying to engage with more advanced R material for my work in bioinformatics. I found out about ggplot and ggtree, so I started reading about them and practice on some simpler examples.
I have been trying out some pre-written example codes before applying it to my own work for my research.
What confuses me is that I did not even use the function 'scale_fill_gradient()' yet I keep getting this error message every time I try to run it. I even tried to attach this to my original code and pressed 'tab' to see if there is anything I could try the function with but nothing seems to work.
Apologies if this seems like a stupid question to a fundamental issue, but as I said I have no previous programming experience. However, some R knowledge is required for my research.
Thank you very much!
I tried looking up solution on here, and even though there were posts mentioning issues with the very same error code, I cannot really interpret it.
The code is as follows:
library(treeio) # Bioconductor
library(ggtree) # Bioconductor
library(viridis)
nwk <- system.file("extdata", "sample.nwk", package="treeio")
tree <- read.tree(nwk)
circ <- ggtree(tree, layout = "circular")
df <- data.frame(first=c("a", "b", "a", "c", "d", "d", "a", "b", "e", "e", "f", "c", "f"),second= c("z","z","z","z", "y", "y", "y", "y", "x", "x", "x", "a", "a"))
rownames(df) <- tree$tip.label
df2 <- as.data.frame(matrix(rnorm(39), ncol=3))
rownames(df2) <- tree$tip.label
colnames(df2) <- LETTERS[1:3]
p1 <- gheatmap(circ, df, offset=.8, width=.2, colnames_angle=95, colnames_offset_y = .25) + scale_fill_viridis(option="D", name="discrete\nvalue")
library(ggnewscale)
p2 <- p1 + new_scale_fill()
gheatmap(p2, df2, offset=15, width=.3, colnames_angle=90, colnames_offset_y = .25) +
scale_fill_viridis(option="A", name="continuous\nvalue")
And the error message:
Scale for fill is already present.
Adding another scale for fill, which will replace the existing scale.
Error in `scale_fill_gradientn()`:
! Discrete values supplied to continuous scale.
ℹ Example values: "f", "e", "e", "f", and "c"
本文标签:
版权声明:本文标题:ggplot2 - "Discrete values supplied to continuous scale" Error in R. Not sure why as I did not even use that s 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744791262a2625302.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论