Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R、 一个图中的两层直方图 seed\u ant_R_Histogram - Fatal编程技术网

R、 一个图中的两层直方图 seed\u ant

R、 一个图中的两层直方图 seed\u ant,r,histogram,R,Histogram,这里,我希望这能帮到你 seed_ant <- read.table(...) thatch_ant <- read.table(...) seed_mass <- seed_ant$Mass seed_mass[578:1195] <- 0 thatch_mass <- thatch_ant$Mass combined <- cbind(seed_mass, thatch_mass) combined_mass <- data.frame(combin

这里,我希望这能帮到你

seed_ant <- read.table(...)
thatch_ant <- read.table(...)
seed_mass <- seed_ant$Mass
seed_mass[578:1195] <- 0
thatch_mass <- thatch_ant$Mass
combined <- cbind(seed_mass, thatch_mass)
combined_mass <- data.frame(combined)
ggplot(combined_mass, aes(x=combined, ylilm=c(0,350))) + 
    geom_histogram(alpha=0.2, position="identity")

A删除
ylilm=c(0350)
时会发生什么?另外,我不确定这一个
组合质量,你不能通过将向量的值设置为
0
来缩短向量。尝试
seed\u mass我只是不知道怎么写'dat',所以我只是做了一个组合质量的数据框,我知道这是错误的,我应该怎么写dat和x=?我没有缩短它们,我只是想让发送质量的长度等于thatch\u mass,你可以让data=Null。类似于
ggplot(,aes(x=…)
我真的很抱歉打扰你,我能再问你一个问题吗?当然。任何能帮上忙的人都会喜欢做那件事的。更正,去掉那些零。最简单的方法是
colB-thx这么多。。。我真的很感谢你的帮助,我为此奋斗了两天
A <- rnorm(1000)  # this is seed_mass
B <- rexp(1000) # this is thatch_mass

colB <- rep(LETTERS[1:2], each = 1000) # this is to tell them apart
colA <- c(A,B) # combine them together
dt <- data.frame(colA, colB) # create Data frame
ggplot(dt, aes(x = colA, fill = colB)) + 
  geom_histogram(col = "black", alpha = 0.5, 
                 position = "identity") +
  scale_fill_discrete(name = "your title", 
                      breaks=c("A", "B"), 
                      labels = c("1","2")) # plot