我是Jekyll和Jekyll-Bootstrap的新人.
我发现这个按类别过滤:
<ul class="posts">
{% for post in site.posts %}
{% if post.categories contains 'demography' %}
<li><span>{{ post.date | date_to_string }}</span> » <a href="{{ BASE_PATH }}{{ post.url }}">{{ post.title }}</a></li>
{% endif %}
{% endfor %}
</ul>
Run Code Online (Sandbox Code Playgroud)
当我尝试组合标签和类别时,它不起作用:
<ul class="posts">
{% for post in site.posts %}
{% if post.categories contains 'demography' and post.tags contains 'R' %} %}
<li><span>{{ post.date | date_to_string }}</span> » <a href="{{ BASE_PATH }}{{ post.url }}">{{ post.title }}</a></li>
{% endif %}
{% endfor %}
</ul>
Run Code Online (Sandbox Code Playgroud)
任何的想法?
提前致谢!
我需要使用.dct文件读取.dat文件.有人用R做过吗?
格式为:
dictionary {
# how many lines per record
_lines(1)
# start defining the first line
_line(1)
# starting column / storage type / variable name / read format / variable label
_column(1) str8 aid %8s "respondent identifier"
...
}
Run Code Online (Sandbox Code Playgroud)
'阅读格式'如下:
%2f 2 column integer variable
%12s 12 column string variable
%8.2f 8 column number with 2 implied decimal places.
Run Code Online (Sandbox Code Playgroud)
存储类型如下所述:http://www.stata.com/help.cgi?datatypes
用于信息的其他网站:
http://library.columbia.edu/indiv/dssc/technology/stata_write.html
http://www.stata.com/support/faqs/data-management/reading-fixed-format-data/
.dat文件是一组与.dct文件中指定的变量对应的数字.(据推测这是固定宽度列中的数据).
这是一个真实的例子:
.dtc文件 http://goo.gl/qHZOk
stata站点的一个具体示例是:
该.dat文件(本例中为"test.raw")
C1245A101George Costanza …Run Code Online (Sandbox Code Playgroud) 我想用data.table做一个简单的循环.我有20个二分(0,1)变量(从var_1到var_20),我想为此做一个循环:
dat[var_1==1, newvar:=1]
dat[var_2==1, newvar:=2]
dat[var_3==1, newvar:=3]
...
dat[var_20==1, newvar:=21]
Run Code Online (Sandbox Code Playgroud)
我的主要问题是我不知道如何使用循环指定i(即var_1 == 1,var_2 == 2 ...).下面简短的例子:
var_1 <- c(1, rep(0,9))
var_2 <- c(0,1, rep(0,8))
var_3 <- c(0,0,1, rep(0,7))
dat <- data.table(var_1, var_2, var_3)
dat[var_1==1, newvar:=1]
dat[var_2==1, newvar:=2]
dat[var_3==1, newvar:=3]
Run Code Online (Sandbox Code Playgroud)
有关如何使用循环执行此操作的任何想法?谢谢!
我想使用ggridges.
# toy example
ggplot(iris, aes(x=Sepal.Length, y=Species, fill=..x..)) +
geom_density_ridges_gradient(jittered_points = FALSE, quantile_lines =
FALSE, quantiles = 2, scale=0.9, color='white') +
scale_y_discrete(expand = c(0.01, 0)) +
theme_ridges(grid = FALSE, center = TRUE)
Run Code Online (Sandbox Code Playgroud)
我想在 7 处为 virginica 添加一条垂直线,为 versicolor 添加 4 条,为 setosa 添加 5 条垂直线。关于如何做到这一点的任何想法?
我想计算变量的组均值,但不包括焦点受访者:
set.seed(1)
dat <- data.table(id = 1:30, y = runif(30), grp = rep(1:3, each=10))
Run Code Online (Sandbox Code Playgroud)
第一个记录(受访者)应平均为...第二个记录,依此类推:
mean(dat[c==1, y][-1])
mean(dat[c==1, y][-2])
mean(dat[c==1, y][-3])
Run Code Online (Sandbox Code Playgroud)
对于第二组相同:
mean(dat[c==2, y][-1])
mean(dat[c==2, y][-2])
mean(dat[c==2, y][-3])
Run Code Online (Sandbox Code Playgroud)
我试过了,但是没有用:
ex[, avg := mean(ex[, y][-.I]), by=grp]
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我正在尝试为循环事件创建一个名为strata的变量.我们的想法是定义一个对事件进行计数但填充先前记录的变量.定义计数的是变量事件,如下所示:
id event cov strata year
1 0 0 1 12
1 0 1 1 13
1 1 1 1 14
1 0 1 2 15
1 1 0 2 16
1 1 1 3 17
1 0 0 4 18
1 0 1 4 19
1 0 1 4 20
Run Code Online (Sandbox Code Playgroud)
至少对于事件记录,我尝试过这样的事情:
id <- c(rep(1,9), rep(2,5), rep(3,7))
event <- c(0,0,1,0,1,1,0,0,0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1)
cov <- c(0,1,1,1,0,1,0,1,1, 0, 0, 0, 0, 1, …Run Code Online (Sandbox Code Playgroud)