我正在使用Rstudio来分析数据。而且 - 为什么我会发布这个 - 我卡住了!
数据是社区发展的时间序列及其随时间变化的特征。例如,n_members(大小)可能会随着时间的推移而增加。
变量'randomseed'和'lhsExperimentNumber'的每个组合是1个观察值。总共有80,000个观测值。每个观察的时间序列从1(月)到204(月)。这个时间的特征在于变量X.run.number
我想要的是什么: 查看随时间变化的因变量和自变量的变化。 例如:我想看看n_members(大小)在不同情况下(例如exit_window)随时间的演变。我通常使用dplyr和ggplot2,我想在ggplot中制作一些迷人的图像。
我的问题: - 我只是R的初学者,所以在这里看到正确的策略对我来说有点棘手 - 如果我只有1个观察随着时间的推移而发展,那将会更容易,但现在我有80,000个观测值,每个观测值随着时间的推移逐渐发展。所以我真的不知道如何处理数据以制作合理的图表。
你们怎么解决这个问题?也许你可以帮我解决一些提示(那太棒了!)
我使用dput重现我的数据集的前10个观察结果:
library(ggplot2)
library(dplyr)
coop_dat <- structure(list(X.run.number. = c(2L, 3L, 4L, 1L, 2L, 3L, 4L,
1L, 3L, 3L), rewire_prop = c(0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1), prior_trust_std = c(0.1, 0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.1, 0.1), max_trust = c(2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L), maxCR_trust = c(0.2, 0.2, 0.2, 0.2, 0.2, 0.2,
0.2, 0.2, 0.2, 0.2), Ostrom. = structure(c(2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L), .Label = c("false", "true"), class = "factor"),
social_network = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L), .Label = "\"small-world\"", class = "factor"),
external_ROI_influence = structure(c(2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L), .Label = c("false", "true"), class = "factor"),
randomseed = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), lhsExperimentNumber = c(1L,
2L, 3L, 0L, 1L, 2L, 3L, 0L, 2L, 2L), X.step. = c(0L, 0L,
0L, 0L, 1L, 1L, 1L, 1L, 2L, 3L), size_start_cooperative = c(12L,
4L, 20L, 17L, 12L, 4L, 20L, 17L, 4L, 4L), degree_prior = c(7L,
21L, 40L, 15L, 7L, 21L, 40L, 15L, 21L, 21L), degree_coop = c(17L,
47L, 20L, 31L, 17L, 47L, 20L, 31L, 47L, 47L), prior_trust_average = c(0.40574414878618,
0.631650829650462, 0.369752783104777, 0.585182260912843,
0.40574414878618, 0.631650829650462, 0.369752783104777, 0.585182260912843,
0.631650829650462, 0.631650829650462), number_of_meetings = c(10L,
5L, 2L, 2L, 10L, 5L, 2L, 2L, 5L, 5L), n_interactions = c(20L,
3L, 9L, 19L, 20L, 3L, 9L, 19L, 3L, 3L), exit_window = c(5L,
1L, 3L, 4L, 5L, 1L, 3L, 4L, 1L, 1L), info_peer_behavior = c(0.396114811487496,
0.627111892865505, 0.148686024846975, 0.281594149058219,
0.396114811487496, 0.627111892865505, 0.148686024846975,
0.281594149058219, 0.627111892865505, 0.627111892865505),
memory = c(8L, 11L, 20L, 1L, 8L, 11L, 20L, 1L, 11L, 11L),
n_shares_total_sum = c(0L, 0L, 0L, 0L, 21L, 13L, 32L, 31L,
13L, 13L), n_shares_total_mean = c(0, 0, 0, 0, 1.75, 3.25,
1.6, 1.82352941176471, 3.25, 3.25), members_at_meeting = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 2L, 0L), trust_coop_total = c(0,
0, 0, 0, 0.0457418505048186, 0.0563109517340759, 0.0349050771003757,
0.0587220121136852, 0.0563109517340759, 0.0563109517340759
), rep_total = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ROI = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), current_strategy = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), price = c(0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L), REfocus = c(0, 0, 0, 0, 0, 0,
0, 0, 0, 0), endpoint = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L), HG_membertypes = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
n_members = c(0L, 0L, 0L, 0L, 12L, 4L, 20L, 17L, 4L, 4L),
n_ids = c(0L, 0L, 0L, 0L, 12L, 4L, 20L, 17L, 4L, 4L), n_prods = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), n_cons = c(0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L), n_members_exit = c(0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L)), .Names = c("X.run.number.",
"rewire_prop", "prior_trust_std", "max_trust", "maxCR_trust",
"Ostrom.", "social_network", "external_ROI_influence", "randomseed",
"lhsExperimentNumber", "X.step.", "size_start_cooperative", "degree_prior",
"degree_coop", "prior_trust_average", "number_of_meetings", "n_interactions",
"exit_window", "info_peer_behavior", "memory", "n_shares_total_sum",
"n_shares_total_mean", "members_at_meeting", "trust_coop_total",
"rep_total", "ROI", "current_strategy", "price", "REfocus", "endpoint",
"HG_membertypes", "n_members", "n_ids", "n_prods", "n_cons",
"n_members_exit"), row.names = c(NA, 10L), class = "data.frame")
编辑:
现在我有这个简单的ggplot代码:
ggplot(dat) +
geom_line(aes(x=month, y=trust_coop_total))
生成此图表:
你可以看到这不是一个折线图。它更像是一堆垂直线条。我想要的是解读每个样本的趋势。如上所述,每个样本是lhsExperimentnumber和X.run.number的组合。有太多的样本,线图会很大,但与geom_jitter的alpha = 1/10命令结合使用可能会很好。但是,geom_jitter会忽略样本本身的趋势。
我该怎么做才能获得好的趋势图?