我有一个数据表tmp,它看起来像这样(只是一个简短的例子):
dput(tmp)
structure(list(`2020-03-29-00` = list(42.51, 0, 0, 0, 12.32),
`2020-03-29-01` = list(46.8, 0, 0, 0, 10.03), `2020-03-29-03` = list(
c(46.8, 41.87), c(0, 0), c(0, 0), c(0, 0), c(10.03, 10.04
)), `2020-03-29-04` = list(45.63, 0, 0, 0, 9.24), `2020-03-29-05` = list(
40.86, 0, 0, 0, 9.06), `2020-03-29-06` = list(45.85,
0, 0, 0, 9.19), `2020-03-29-07` = list(43.68, 0, 0, 0,
10.39), `2020-03-29-08` = list(47.14, 0, 0, 0, 9.99),
`2020-03-29-09` = list(49.06, 0, 0, 0, 11.24)), row.names = c(NA,
-5L), class …Run Code Online (Sandbox Code Playgroud) 我正在绘制散点图,ggplot()如下所示:
library(data.table)
library(plotly)
library(ggplot2)
library(lubridate)
dt.allData <- data.table(date = seq(as.Date('2020-01-01'), by = '1 day', length.out = 365),
DE = rnorm(365, 4, 1), Austria = rnorm(365, 10, 2),
Czechia = rnorm(365, 1, 2), check.names = FALSE)
## Calculate Pearson correlation coefficient: ##
corrCoeff <- cor(dt.allData$Austria, dt.allData$DE, method = "pearson", use = "complete.obs")
corrCoeff <- round(corrCoeff, digits = 2)
## Linear regression function extraction by creating linear model: ##
regLine <- lm(DE ~ Austria, data = dt.allData)
## Extract k …Run Code Online (Sandbox Code Playgroud)