我正在尝试创建一个自动R函数,它可以通过外部Latex程序创建一个可以运行的乳胶文件(不需要对Latex代码进行任何进一步的修改).我知道KnitR和Sweave,但我需要更简单的东西.基本上对于任何可以通过xtable打印出来的对象我想添加
%A1在顶部
\documentclass{article}
\pagestyle{empty}
\begin{document}
Run Code Online (Sandbox Code Playgroud)
最后%A2
\end{document}
Run Code Online (Sandbox Code Playgroud)
这意味着我可以运行我的分析并(当我需要时)创建一个可以由基于Latex的程序操作的外部文件.我对将所有表放入一个文档并不感兴趣,但我希望它们分开(因此需要\ begin {document}和\ end {document}.我一直在尝试使用add.to.rows(xtable函数)但我无处可去.
例:
data(tli)
tli.table <- xtable(tli[1:10,])
digits(tli.table)[c(2,6)] <- 0
print(tli.table,floating=FALSE)
Run Code Online (Sandbox Code Playgroud)
你如何添加A1和A2,结果是:
\documentclass{article}
\pagestyle{empty}
\begin{document}
\begin{table}[ht]
\centering
\begin{tabular}{rrlllr}
\hline
& grade & sex & disadvg & ethnicty & tlimth \\
\hline
1 & 6 & M & YES & HISPANIC & 43 \\
2 & 7 & M & NO & BLACK & 88 \\
3 & 5 & F & YES & HISPANIC & 34 \\
4 & 3 …Run Code Online (Sandbox Code Playgroud) 我正在使用Stata IC 13,需要对大型数据集的不同变量进行不同类型的分析。问题是我的数据集非常大,因此出现以下错误
此版本的Stata最多允许2,048个变量
有没有一种方法可以命名要导入的变量以解决此问题(使用Stata,而不是其他程序)?
我需要一种灵活的方式来通过变量名导入变量,而不是必须将我的原始数据集分成许多小子集。我听说过替代方法,但是我对Stata还是比较陌生,因此,如果有人可以向我展示如何每天克服此限制的代码示例,我将不胜感激。
让我们举一个愚蠢的例子。假设我只想从该数据集中导入pared和public变量。
use http://www.ats.ucla.edu/stat/data/ologit.dta, clear
Run Code Online (Sandbox Code Playgroud)
你会怎么做?
I'm creating lots of datasets with a loop and I need to make sure that all these different datasets are properly named and stored in the workspace. My question is the following. Let's say I have a dataset (here airquality), I want to create 4 datasets and store them in the workspace
Split dataset
airquality$N<-letters[airquality$Month]
head(airquality)
AllDatasets<-split(airquality,airquality$N)
names(AllDatasets)
Run Code Online (Sandbox Code Playgroud)
Now I want to extract each dataset with a loop, for example
#Conceptual loop
for (i in (1:names(AllDatasets))){
#Create dataset AllDatasets[i] and …Run Code Online (Sandbox Code Playgroud)