我试图找到解决方案,以融合数字框架与字符colnames,并保持因子变量融化df.
我的数据的一个子集:
df <- structure(list(bloc = c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L,
6L, 6L), name = c("Cristina", "Robijn", "Robijn", "Cristina",
"Robijn", "Cristina", "Cristina", "Robijn", "Robijn", "Cristina",
"Cristina", "Robijn"), d1 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0), d7 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), d10 = c(1, 0,
0, 5, 0, 0.1, 1, 0, 0, 0.1, 0.1, 0), d13 = c(0, 0, 0, 0, …Run Code Online (Sandbox Code Playgroud) 我正在尝试绘制一个放大的插图,其中的线条和方框显示了该图的哪一部分被缩放。这在 R 中可能吗?
这是我想用 Python 完成的一个示例。
一些示例代码:
p <-
qplot(1:10, 1:10)
g <-
p +
coord_cartesian(ylim = c(8, 10), xlim = c(8, 10)) +
theme(axis.title.x = element_blank(),
axis.title.y = element_blank())
p +
annotation_custom(
grob = ggplotGrob(g),
xmin = 7,
xmax = 10,
ymin = 1,
ymax = 5
)
Run Code Online (Sandbox Code Playgroud) 修改数据:
structure(list(hour = c(0L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 0L,
1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 1L, 1L, 1L, 0L, 1L, 1L, 0L, 0L), cs = c(0L, 0L, 0L, 0L,
0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L,
1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L
), cs_acum = …Run Code Online (Sandbox Code Playgroud)