r - 使用ggplot和melt函数
问题描述
我正在遵循下面列出的示例(https://rpubs.com/thinh_ha/londonhouseprice)。我正在尝试按部分使用该组。
by_pt <- select(df, realprice1, class) %>%
group_by(class) %>%
summarise(Count=n(), Mean.Price=mean(realprice1), St.Dev.Price=sd(realprice1), Median.Price=median(realprice1))
ggplot(melt(by_pt), aes(x=value, y=variable, fill=class)) +
facet_wrap(~ variable, scales='free') +
geom_bar(position="dodge", stat='identity', width=0.3)
我的代码的第一部分创建了一个名为 by_pt 的数据框,它有两行和 5 列。第一列是类,第一列是 Sole 和 Second Joint。其余四个是在汇总函数中创建的统计信息。
但是,当我使用 ggplot 时,出现以下错误。
使用类作为 id 变量 match.names(clabs, names(xi)) 中的错误:名称与以前的名称不匹配
谁能解释为什么会这样?
解决方案
推荐阅读
- flutter - Flutter - 有没有办法在文本字段中添加超链接识别,如“Whatsapp 或谷歌笔记等”
- java - Java 三角函数
- angular - Angular 从提供者那里获取数据
- google-app-maker - 在 App Maker 中获取 Suggest Box 的输入数据
- c# - 如何在 Windows 10 中启用 TLS 1.3
- html - Xpath - 查找具有特定属性的表中的所有单元格
- android - 如何将多个 C++ cmake 项目链接到 Android Studio/gradle 项目?
- php - 无法安装 PHP 7.3:“找不到发布”
- sed - 如何删除斜线之间的单词?
- java - 当所有动作都可以用 ActionsClass 完成时,为什么我们需要动作接口