与 tidyverse 和脊线图的斗争

问题描述

我是一名编程初学者,我正在尝试制定温度数据的脊线图,使用 tidyverse 按月对温度进行分组。初始数据如下所示:

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

我正在尝试使用此代码按月对数据进行分组:

class(weather)  #what class is dataset = dataframe
head(weather)  #structure of the dataset  
attach(weather)  #attach column names
weather.month <- weather %>%
  mutate(month = weather$Day) %>%  #sort data by month
  group_by(month)
head(weather.month)  #view dataset with new month column
class(weather.month$month) #view class of column month = character

通过这段代码,我得到了下面的图片

ggplot(weather.month,aes(x = `High`,y = 'month',fill = stat(x))) +
  geom_density_ridges_gradient(scale = 3,rel_min_height = 0.01) +
  scale_fill_viridis_c(name = "Temp. [F]",option = "C") +
  labs(title = 'Temperatures in brookings in 2019')

enter image description here

我正在尝试获得这样的图像:

enter image description here

我假设我没有正确地对数据进行分组,但我不知道如何解决它....有什么建议吗?

解决方法

如评论中所述,发布 UserId 的输出以帮助社区为您提供帮助。此外,包括您在脚本中加载的 CREATE TRIGGER dbo.trg_LogUserLogon ON dbo.Users FOR UPDATE AS -- inspect the Inserted (new values,after UPDATE) and Deleted (old values,before UPDATE) -- pseudo tables to find out which rows have had an update in the LastLogonTime column INSERT INTO dbo.LoginLog (Name,Password,LastLogonTime) SELECT i.Name,i.Password,i.LastLogonTime FROM Inserted i INNER JOIN -- join the two sets of data on the primary key (which you didn't specify) -- could be i.UserId = d.UserId or something similar Deleted d on i.PrimaryKey = d.PrimaryKey WHERE -- only select those rows that have had an update in the LastLogonTime column i.LastLogonTime <> d.LastLogonTime ,让人们知道您使用的函数来自哪里。但是,正如@ mhovd 所建议的,您必须取消引用变量名称。由于您没有以可重现的格式发布数据,因此我使用内置数据集 dput(your.Data) 举了一个例子:

library

给你:

enter image description here