我正在尝试使用VBA编码 - 这是我很新的 - 从PDF(不是图像)获取一系列.doc文档,也就是说,我试图循环各种PDF文件并将它们保存在MS Word中格式.我的经验是,这个单词很好地读取了我所拥有的PDF文档:word大部分时间都保持了PDF文件的正确布局.我不确定这是否是解决这个问题的正确选择,我要求另一个建议 - 如果可能的话,使用R.
无论如何,这里是我在这里找到的代码:
Sub convertToWord()
Dim MyObj As Object, MySource As Object, file As Variant
file = Dir("C:\Users\username\work_dir_example" & "*.pdf") 'pdf path
Do While (file <> "")
ChangeFileOpenDirectory "C:\Users\username\work_dir_example"
Documents.Open Filename:=file, ConfirmConversions:=False, ReadOnly:= _
False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _
"", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _
Format:=wdOpenFormatAuto, XMLTransform:=""
ChangeFileOpenDirectory "C:\Users\username\work_dir_example"
ActiveDocument.SaveAs2 Filename:=Replace(file, ".pdf", ".docx"), FileFormat:=wdFormatXMLDocument _
, LockComments:=False, Password:="", AddToRecentFiles:=True, _
WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False, CompatibilityMode:=15
ActiveDocument.Close
file = …Run Code Online (Sandbox Code Playgroud) 我遇到了与此问题中描述的完全相同的问题,其中我遇到了类似的错误。但我按照说明进行操作,更改了回调网址,然后出现了新问题。我通过浏览器进入授权部分,但我一直卡在加载页面上,并出现警告“正在将您重定向回应用程序。这可能需要一些时间。” 浏览器没有被重定向,而是停止并警告它无法访问该页面 - 而且,RStudio 在它之后立即崩溃。我应该怎么办?我尝试搜索类似的问题,但一直找不到解决方案。
虽然这有点重复,但这是 R 中的代码:
library(twitteR)
Consumer_key <- "key"
Consumer_secret <- "secret"
setup_twitter_oauth(Consumer_key,Consumer_secret, access_token=NULL,access_secret=NULL)
[1] "Using browser based authentication"
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Run Code Online (Sandbox Code Playgroud) 无法phantomjs使用开始新会话rsDriver。其他浏览器工作正常,但是当我尝试phantomjs它的选项时它不起作用,我无法完全理解错误输出的含义。我该如何解决这个问题?
require(RSelenium)
remDr=rsDriver(port = 4460L, browser = c("phantomjs"))
checking Selenium Server versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking chromedriver versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking geckodriver versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking phantomjs versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
[1] "Connecting to remote server"
Selenium message:Unable to create session from {
"desiredCapabilities": {
"browserName": "phantomjs",
"javascriptEnabled": true,
"nativeEvents": true,
"version": "",
"platform": "ANY"
},
"capabilities": {
"firstMatch": [ …Run Code Online (Sandbox Code Playgroud) 一些预编程模型会自动删除其回归输出中的线性因变量(例如lm())R。对于bife包,这似乎是不可能的。如第 5 页上的CRAN中的包描述所述:
如果 bife 不收敛,这通常是一个或多个回归量与固定效应之间线性相关的迹象。在这种情况下,您应该仔细检查您的模型规格。
现在,假设手头的问题涉及进行许多回归,并且无法充分检查每个回归输出——必须假设某种关于回归量的经验法则。有哪些替代方法可以或多或少地自动删除线性相关回归量并实现足够的模型规范?
我设置了一个代码作为下面的例子:
#sample coding
x=10*rnorm(40)
z=100*rnorm(40)
df1=data.frame(a=rep(c(0,1),times=20), x=x, y=x, z=z, ID=c(1:40), date=1, Region=rep(c(1,2, 3, 4),10))
df2=data.frame(a=c(rep(c(1,0),times=15),rep(c(0,1),times=5)), x=1.4*x+4, y=1.4*x+4, z=1.2*z+5, ID=c(1:40), date=2, Region=rep(c(1,2,3,4),10))
df3=rbind(df1,df2)
df3=rbind(df1,df2)
for(i in 1:4) {
x=df3[df3$Region==i,]
model = bife::bife(a ~ x + y + z | ID, data = x)
results=data.frame(Region=unique(df3$Region))
results$Model = results
if (i==1){
df4=df
next
}
df4=rbind(df4,df)
}
Error: Linear dependent terms detected!
Run Code Online (Sandbox Code Playgroud) 我有以下我一直在做的事情的示例,这在形式上很简单,但我想检查一下我的代码的潜在替代方案是什么——如果可能的话,为了更快。这是示例:
Time1=Sys.time()
v=rep(c("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P"),
each=1000)
m=matrix(0,ncol=length(v),nrow=length(v))
for (j in 1:length(v)) {
for(i in 1:length(v)) {
if (v[j]==v[i]) {
m[j,i]=1
} else {
next
}
}
}
Time2=Sys.time()
Time2-Time1
# Time difference of 1.405404 mins
Run Code Online (Sandbox Code Playgroud)
我正在创建一个简单的关系矩阵 - 其中向量v1可以被解释为被放置为线和列以及结果相等的矩阵映射。如果它们相等,我们得到m[j,i]=1;如果不相等,m[j,i]=0. 正如我所说,我想让这段代码运行得更快。我试图想出一种方法将它编码为一个apply函数,但我现在还没有弄清楚。不过,我想知道除了我所说的之外是否还有其他选择。
编辑:我对文本做了一些更正,并试图澄清这个问题。