我有以下情节:
m <- structure(list(Var1 = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L,
1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L,
3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L,
5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L), .Label = c("FE", "AG",
"NO", "SPH", "SEP", "H/I", "CMP"), class = "factor"), Var2 = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, …Run Code Online (Sandbox Code Playgroud) 是否可以使用带有通配符的snakemake并展开:
rule a:
input:
"input/{first}.txt",
expand("data/{second}.txt", second=A_LIST)
output:
expand("output/{first}_{second}, second=A_LIST)
Run Code Online (Sandbox Code Playgroud) 我认为这可能部分是一个 R 问题,部分是一个统计问题,所以如果有更好的地方,请原谅(如果是这样,请告诉我在哪里)。
假设我有一个my_measurements这样的数据集:
> glimpse(my_measurements)
Observations: 200
Variables: 2
$ sample_id <int> 18, 22, 30, 59, 74, 126, 133, 137, 147, 186, 189, 195, 203, 248, 294, 303, 320, 324, 353, 3...
$ value <dbl> 0.9565217, 1.0000000, 0.7500000, 0.7142857, 1.0000000, 0.8571429, 1.0000000, 1.0000000, 0.8...
Run Code Online (Sandbox Code Playgroud)
其中每个sample_id都有相应的测量值,该测量值value介于 0 和 1 之间(例如,它们可能是某物的比例)。
它的完整dput()输出是:
structure(list(sample_id = c(18L, 22L, 30L, 59L, 74L, 126L, 133L,
137L, 147L, 186L, 189L, 195L, 203L, 248L, 294L, 303L, 320L, 324L,
353L, …Run Code Online (Sandbox Code Playgroud) 我有6个情节,我试图在网格上一起绘制.我能够绘制出3个主要对齐良好的对齐,以便y轴全部在同一点开始,如下所示:
但是在我将第二列图表添加到网格(三角形)后,我在第一列中丢失了对齐.所以看起来有点像这样:
这是绘制此网格的代码.我一直在使用align参数和一点宽度,但没有运气让它们一起工作:
plot_grid(pq1_plop, pq1_status, pq2_plop, pq2_status, pq3_plop, pq3_status,
align = "hv",
nrow = 3,
ncol = 2,
rel_widths = c(10, 1)
)
Run Code Online (Sandbox Code Playgroud)
有没有办法在左侧轴对齐的情况下绘制这些图?情节数据:
> dput(pq1_agged)
structure(list(mean_name = structure(2:6, .Label = c("", "Arrival Logistics and Greetings",
"Organization of Activity", "Schedule and Offering", "Space Adequacy",
"Transitions"), class = "factor"), mean_2018 = c(3.60416668653488,
3.31623927752177, 2.75, 3.125, 3.55555558204651), SY_mean = c(3.3468468479208,
3.62688970565796, 3.24204542961988, 3.58294574604478, 0), PSELI_mean = c(3.38333333333333,
3.65522875505335, 3.08235294678632, 3.53529411203721, 0), mean_2017 = c(3.625,
3.75000002980232, 3.02499997615814, 3.59166663885117, 4), aptsayoy = c("apt",
"apt", …Run Code Online (Sandbox Code Playgroud) 例如,
library(ggplot2)
ggplot(mpg, aes(displ, cty)) + geom_point() + facet_grid(cols = vars(drv))
Run Code Online (Sandbox Code Playgroud)
如何更改条带和主图之间的距离?(例如,在条带和主图之间创建一个间隙。)
但我不需要更改条带大小(与此编辑条带大小 ggplot2 不同)。
MySQL抛出管道中断,MySQL服务器消失了错误。我的数据库表包含文本字段,我每隔1小时就会在其中插入大HTML。
我应该考虑设置哪个MySQL变量。
这是当前配置:
[mysqld]
datadir=/home/monk/mysql
socket=/home/monk/mysql/mysql.sock
user=mysql
default_time_zone='+06:00'
innodb_buffer_pool_size=35G
innodb_buffer_pool_instances=15
query_cache_type=ON
query_cache_size=64M
join_buffer_size=524288
tmp_table_size=32M
max_heap_table_size=32M
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
max_allowed_packet=1G
# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
wait_timeout = 2000
interactive_timeout = 2000
#bind-address=127.0.0.1
##skip-networking~
Run Code Online (Sandbox Code Playgroud) 下面的代码生成从左下角到右上角的热图
library(ggplot2)
library(reshape2)
set.seed(111)
n <- 10
m <- matrix(rnorm(n^2), n, n)
m <- cor(m)
m <- melt(m)
ggplot(m, aes(Var1, Var2, fill = value)) +
geom_tile()
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用dplyr和bigrquery从Big Query中的数据集中查询多个表.数据集包含多个表,一个表用于一年中每天的数据.我可以使用以下代码从单个表(例如,1天的数据)进行查询,但似乎无法一次跨多个表(例如,一个月或一年的数据).任何帮助将不胜感激.
connection <- src_bigquery("my_project", "dataset1")
first_day <- connection %>%
tbl("20150101") %>%
select(field1) %>%
group_by(field1) %>%
summarise(number = n()) %>%
arrange(desc(number))
Run Code Online (Sandbox Code Playgroud)
谢谢,
胡安
#Create subset of a dataset
df <- subset(dat,select = c(id,obs,day_clos,posaff,er89,qol1))
### remove rows with missing values on a variable
df <- subset(df, !is.na(day_clos))
df <- subset(df, !is.na(er89))
df <- subset(df, !is.na(qol1))
df <- subset(df,!is.na(posaff))
any(is.na(df)) ## returns FALSE
Then my data looks like this
id obs day_clos posaff er89 qol1
1 0 16966.61 2.000000 2.785714 3
1 1 16967.79 1.666667 2.785714 4
1 2 16968.82 1.666667 3.142857 3
1 3 16969.76 1.166667 3.071429 4
1 4 16970.95 2.083333 3.000000 4 …Run Code Online (Sandbox Code Playgroud) 我正在创建一个数据框,其中包含从 2000 年到 2010 年每个州每年发生的某种事件的数量(假设它们是枪支事件):
states <- c('Texas', 'Texas', 'Arizona', 'California', 'California')
incidents <- c(1, 1, 2, 1, 4)
years <- c(2000, 2008, 2004, 2002, 2007)
DF <- data.frame(states, incidents, years)
> DF
states incidents years
1 Texas 1 2000
2 Texas 1 2008
3 Arizona 2 2004
4 California 1 2002
5 California 4 2007
Run Code Online (Sandbox Code Playgroud)
我想插入行来完成数据集,例如德克萨斯州 2001 年、2002 年、2003 年、... 2007 年以及 2009 年和 2010 年的零。同样,除了 2004 年之外,亚利桑那州的所有年份都为零。加利福尼亚也是如此。
我怎样才能做到这一点?
r ×8
ggplot2 ×5
alignment ×1
dataframe ×1
density-plot ×1
dplyr ×1
facet-grid ×1
facet-wrap ×1
mysql ×1
plot ×1
snakemake ×1