knit('test2.rnw')
processing file: test2.rnw
|>>>>>>>>>>>>> | 20%
|>>>>>>>>>>>>>>>>>>>>>>>>>> | 40%
label: setup (with options)
List of 2
$ include: logi FALSE
$ cache : logi FALSE
sh: kpsewhich: command not found
|>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 60%
|>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 80%
|>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>| 100%
ordinary text without R code
output file: /Users/xxx/Desktop/R_meetup/documentation/test2.tex
Warning message:
In test_latex_pkg("framed", system.file("misc", "framed.sty", package = "knitr")) :
unable to find LaTeX package 'framed'; will use a copy from knitr
>
Run Code Online (Sandbox Code Playgroud)
我在OSX Lion 10.7.3上
kpsewhich的路径:
$ which kpsewhich
/usr/texbin/kpsewhich
$ which …Run Code Online (Sandbox Code Playgroud) 我一直在苦苦挣扎一周,试图找出如何使用Sweave或Brew在R中生成报告.我应该在一开始就说我之前从未使用过Tex,但我理解它的逻辑.
我已多次阅读本文档.但是,我甚至无法得到一个简单的解析示例.Brew成功将简单标记文件(只是标题和一些文本)转换为.tex文件(无错误).但它永远不会将tex转换成pdf.
> library(tools)
> library(brew)
> brew("population.brew", "population.tex")
> texi2dvi("population.tex", pdf = TRUE)
Run Code Online (Sandbox Code Playgroud)
最后一步总是失败:
Error in texi2dvi("population.tex", pdf = TRUE) :
Running 'texi2dvi' on 'population.tex' failed.
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我想要编写的报告非常简单.我总结了157种不同的分析.每个都有4个地块,1个表和一个摘要.我只是想
output plot 1,2,3,4
output table
\pagebreak
...
Run Code Online (Sandbox Code Playgroud)
而已.任何人都可以帮我进一步吗?我用osx,没有安装Tex.
谢谢
这是mysql表中的一些示例数据
a b distance
15 44 250
94 31 250
30 41 250
6 1 250
95 18 250
72 84 500
14 23 500
55 24 500
95 8 500
59 25 500
40 73 500
65 85 500
32 50 500
31 39 500
22 25 500
37 11 750
98 39 750
15 57 750
9 22 750
14 44 750
69 22 750
62 50 750
89 35 750
67 65 750
74 37 750
52 …Run Code Online (Sandbox Code Playgroud) 我正在使用glmulti包将模型拟合到几个数据集.如果我一次适合一个数据集,一切都有效.
例如:
output <- glmulti(y~x1+x2,data=dat,fitfunction=lm)
Run Code Online (Sandbox Code Playgroud)
工作得很好.
但是,如果我创建一个这样的包装函数:
analyze <- function(dat)
{
out<- glmulti(y~x1+x2,data=dat,fitfunction=lm)
return (out)
}
Run Code Online (Sandbox Code Playgroud)
根本行不通.我得到的错误是
error in evaluating the argument 'data' in selecting a method for function 'glmulti'
Run Code Online (Sandbox Code Playgroud)
除非有一个名为dat的数据框,否则它不起作用.如果我使用results=lapply(list_of_datasets, analyze),它不起作用.什么给出了什么?没有我说的包装器,我无法通过此函数来填充数据集列表.如果有人对于为什么会发生这种情况或者如何解决这个问题有想法或想法,那就太好了.
例2:
dat=list_of_data[[1]]
analyze(dat)
Run Code Online (Sandbox Code Playgroud)
工作良好.因此从某种意义上说,它忽略了参数,只是在字面上寻找名为dat的数据框.无论我称之为什么,它都表现得一样.
我很习惯使用,SQL但有一个不可能的时间理解SPARQL.对于初学者,我甚至不了解如何查看数据的结构(MySQL我会这样做describe <table name>)所以我可以查询相应的字段.
有没有办法将整个RDF数据集导入MySQL数据库中的相应表?
除非是,是有办法SELECT *,从所有的表(或其他等效描述符),这样我可以得到所有的输出数据为CSV(并从那里?)
我试图查询的RDF数据集有一个SPARQL端点,甚至是如何SPARQL的指南,但我很难理解它.
例如:
PREFIX meannot: <http://rdf.myexperiment.org/ontologies/annotations/>
PREFIX sioc: <http://rdfs.org/sioc/ns#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX mebase: <http://rdf.myexperiment.org/ontologies/base/>
SELECT DISTINCT ?annotator_name
WHERE {
?comment mebase:annotates <http://www.myexperiment.org/workflows/52> .
?comment rdf:type meannot:Comment .
?comment mebase:has-annotator ?annotator
?annotator sioc:name ?annotator_name
}
Run Code Online (Sandbox Code Playgroud)
对我来说没什么意义.为什么在某些WHERE语句结束时有一段时间而在其他语句中没有??comment mebase:has-annotator ?annotator简单的英语是什么意思?选择注释器名称作为注释器名称的注释器名称?是吧?
对于您可以指出的任何资源,我将不胜感激.
我经常使用Hadley的软件包stringr来清理杂乱的生态数据(规范物种名称,标签格式不佳等).最近我开始学习sed,awk并且被这些工具的强大程度所震撼,特别是在处理大量数据文件时.
我的问题:
是否有其他强大的文本处理包(base功能之外,以及那些stringr)对数据清理有用?
是否可以sed从R内运行命令/脚本?如果是这样,怎么样?能给我举个例子?
有没有人试图sed为R包写一个包装器.如果没有,这将是一件值得追求的事情(对我自己或更有能力的程序员来说是一个辅助项目)?
假设我有一个data.frame看起来像这样的融化:
variable value
1 A -0.19933093
2 A -1.19043346
3 A -1.32248172
4 A -1.98644507
5 A -0.07930953
6 B -0.10074686
7 B 0.72451483
8 B -0.40914044
9 B 0.02913376
10 B 0.16062491
Run Code Online (Sandbox Code Playgroud)
我如何得到它:
A B
-0.19933093 -0.10074686
-1.19043346 0.72451483
-1.32248172 -0.40914044
-1.98644507 0.02913376
-0.07930953 0.16062491
Run Code Online (Sandbox Code Playgroud)
看起来微不足道,但我在回答是空白.dcast而且acast似乎没有这样做.我的目标是在较大的数据集上执行此操作,并将最终产品转换为a matrix,列名称为变量名称.我尝试玩(daply和laply融化前)没有太多运气.
我有一系列的ggplots,我想安排如下所示,并插入到解析过的文档中knitr.我不想拥有一个非常小的人像,而是希望将其旋转到横向,以便尽可能地填充页面.有任何想法吗?
library(ggplot2)
library(grid)
df <- data.frame(x = 1:100, y =rnorm(100))
plota <- ggplot(df, aes(x, y)) + geom_point(size = 4)
pushViewport(viewport(layout = grid.layout(3, 5)))
vplayout <- function(x, y) viewport(layout.pos.row = x, layout.pos.col = y)
print(plota, vp = vplayout(1:2, 1:2))
print(plota, vp = vplayout(1, 3))
print(plota, vp = vplayout(1, 4))
print(plota, vp = vplayout(1, 5))
print(plota, vp = vplayout(2, 3))
print(plota, vp = vplayout(2, 4))
print(plota, vp = vplayout(2, 5))
print(plota, vp = vplayout(3, 1))
print(plota, vp = …Run Code Online (Sandbox Code Playgroud) 如何重新创建data.frame我融化的reshape2?
可重复的例子
library(reshape2)
library(plyr)
data(iris)
df <- melt(iris, id.vars="Species")
head(df)
Species variable value
1 setosa Sepal.Length 5.1
2 setosa Sepal.Length 4.9
3 setosa Sepal.Length 4.7
4 setosa Sepal.Length 4.6
5 setosa Sepal.Length 5.0
6 setosa Sepal.Length 5.4
# Great, I'd like to get the original iris back
Run Code Online (Sandbox Code Playgroud)
我尝试过的 dcast
dcast(df, Species~variable, value.var = "value")
# should work but doesn't
Run Code Online (Sandbox Code Playgroud)
临时解决方案
# This works but clearly it shouldn't be this hard.
ddply(df, .(Species), function(x) {
Species <- …Run Code Online (Sandbox Code Playgroud) 所以这段代码:
library(plyr)
library(doMC)
registerDoMC(cores=2)
x=1:100
llply(x, some_function, .parallel=TRUE)
Run Code Online (Sandbox Code Playgroud)
失败并出现如下错误:
__THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__ ()
Run Code Online (Sandbox Code Playgroud)
当我从终端运行R时,错误消失.所以它是关于GUI的东西打破了它.不幸的是,我与合作者共享此代码,所以我不能要求他们从终端运行它.这个论坛帖子说看起来好像这个问题w/doMC后端来自我一直在寻找"/Applications/R.app/Contents/Resources/GUI- tools.R",但我并不是故意在R中这样做.应用程序.有没有办法解决这种冲突的行为?
我的Mac规格:还运行R GUI 2.13.1.OSX 10.7.1,带有64位R.app的doMC版本1.2.3.还有一台配备Intel Core 2 Duo的MB Pro 2.53