是否可以在一个过程中声明一个静态变量,并使用Excel VBA在几个不同的过程中使用此变量?
即
Public myvar as integer
Sub SetVar()
static myvar as integer
myvar=999
end sub
sub Usevar()
dim newvar as integer
newvar=myvar*0.5
end sub
Run Code Online (Sandbox Code Playgroud)
我需要通过其他程序看到myvar,而不是改变或"迷失".如果myvar未被声明为静态变量,则上面的代码可以工作,但是更多代码然后变量"丢失".如果使用静态声明,则usevar过程不会看到myvar.并且VBA不接受"Public Static myvar as integer".
谢谢你的帮助
宙斯
很棒的 igraph 包,但我正在努力保存这些图。我已经在网上拖网但没有成功。这是一些示例代码,如何保存结果图?
Test <- data.frame(
FirstName=c("Bob","Charlie","Beth","Sam"),
Age=c(23,56,41,33))
Friends <- c(1,2,1,4,2,4,3,4)
g <- graph.empty (4, directed = FALSE)
V(g)$color <- "lightblue" #Nodes$NodeColour
V(g)$label <- as.character(Test$FirstName)
g <- add.edges(g, Friends)
plot(g,
vertex.label.color="black",
vertex.shape="sphere",
vertex.label.cex = 0.5,
vertex.size=24,
layout=layout.circle)
title("Friend Network",cex.main=1,col.main="blue")
#how do you save plot as a png?
Run Code Online (Sandbox Code Playgroud) 我在一个闪亮的应用程序中使用datatables包并且它运行良好,但是当我编辑单元格/值时,焦点从当前行更改为第一行.该表很长,因此必须滚动回正在编辑的行是一个问题.有没有办法选择某一行?然后我可以在表重新加载后返回正在编辑的行.
这是有光泽的数据表渲染的代码.有什么建议吗?
output$book_table <- DT::renderDT(RVTables$book %>%
filter(deal == as.numeric(input$deal_choice)),
selection = 'single',
editable = TRUE,
rownames = FALSE,
options = list(
autoWidth = TRUE,
ordering = FALSE,
pageLength = 12,
scrollX = TRUE,
scrollY = TRUE,
bLengthChange = FALSE,
searching = FALSE
)
)
Run Code Online (Sandbox Code Playgroud)
编辑:
我找到了一种选择行的方法,但我无法动态更新它.
row_edit<-3
output$book_table <- DT::renderDT(RVTables$book %>%
filter(deal == as.numeric(input$deal_choice)),
selection = list(mode='single',selected=row_edit)
editable = TRUE,
rownames = FALSE,
options = list(
autoWidth = TRUE,
ordering = FALSE,
pageLength = 12,
scrollX = TRUE,
scrollY …Run Code Online (Sandbox Code Playgroud) Tim是否可以从clsMatrix类中提取行键列表?像这样的东西......
Sub KEYS()
Dim KEY_LIST As Variant
KEY_LIST = TABLES("UDLY").dR.KEYS
End Sub
Run Code Online (Sandbox Code Playgroud)
然后,我可以在表中循环以提取符合特定条件的数据子集.
Tim,您的代码适用于一个2D矩阵,但我有5个表可供参考,以便项目工作.我尝试使用if ... then else语句,但它是笨拙的并且不起作用 - 从BOOK表中查找数据的第二次传递找不到row和col字典引用.你能建议一个更好的方法吗?谢谢你的帮助.
Option Explicit
Private dR, dC
Private m_arr, UDLY, BOOK
'
Sub Init(TABLE As String)
Dim i As Long
Dim RNGE As Range
Dim DATA As Variant
Dim arr As Variant
If TABLE = "UDLY" Then Set RNGE = Worksheets("SETTINGS").Range("UDLY_TABLE")
If TABLE = "BOOK" Then Set RNGE = Worksheets("BOOK").Range("BOOK_TABLE")
arr = RNGE.Value
Set dR = CreateObject("Scripting.Dictionary")
Set dC = CreateObject("Scripting.Dictionary")
'add the …Run Code Online (Sandbox Code Playgroud) 我试图将数据保存在类模块中声明的字典中.我在类模块中使用了字典,因为组的数量和关联的数据点在开始时是未知的.下面的代码编译,但dRATIO.exists模块和类模块中的语句都返回false(但是在第一次传递时,类模块中的debug语句给出了正确的值,之后出现错误),然后Function GetRATIO返回999.有什么建议吗?
'CODE IN A CLASS MODULE CALLED clsIVDATA
Option Explicit
Public dRATIO
Public dIV
'
Sub Init(RATIO As Variant, IV As Variant, KEY As String)
'Dim I As Long
Dim VAL As String
Dim RowKeys
Dim COLKEYS
Set dRATIO = CreateObject("Scripting.Dictionary")
Set dIV = CreateObject("Scripting.Dictionary")
dRATIO.ADD ITEM:=RATIO, KEY:=KEY
dIV.ADD ITEM:=RATIO, KEY:=KEY
Debug.Print dRATIO.Exists("1")
Debug.Print dRATIO.ITEM("1")
End Sub
Function GetRATIO(KEY As String)
If dRATIO.Exists(KEY) Then
GetRATIO = dRATIO(KEY)
Else
GetRATIO = 999 'or raise …Run Code Online (Sandbox Code Playgroud) 我试图两次过滤大数据帧(DF1 and DF2),然后将两个过滤的数据帧合并(DF1+DF2->DF3)多次到一个数据帧,并将结果合并到一个数据帧中(DF=DF3[1]+DF3[2]...DF[n]),但是内存不足(8Gb).初始和最终数据框架可轻松放在笔记本电脑上,因此其处理耗尽内存.
什么方法最快,需要最少的内存?我应该在部分中运行代码并重新组合,获得更大的枪,还是这是关系数据库的工作MapReduce?
下面的代码说明了这个问题.
#create combination df
Combn <- data.frame(t(combn(as.vector(rep(LETTERS[1:26])),2))) %>%
mutate_all(as.character)
#create data df
Nrows <- 1000000
Data <- data.frame(Symbol=rep(LETTERS[1:26])) %>%
mutate(Symbol=as.character(Symbol)) %>%
bind_rows(replicate(Nrows-1,.,simplify=FALSE)) %>%
arrange(Symbol) %>%
group_by(Symbol) %>%
mutate(Idx=seq(1:Nrows)) %>%
mutate(Px=round(runif(Nrows)*20))
FnPDList <- function(Combn,Data){
Dfs <- list()
for(i in 1:nrow(Combn)){
print(i)
Symbol.1 <- Combn$X1[i]
Symbol.2 <- Combn$X2[i]
Sym.2 <- Data %>%
filter(Symbol==Symbol.2)
Df <- Data %>%
filter(Symbol==Symbol.1) %>%
left_join(Sym.2,by="Idx",suffix=c(".1",".2"))
Dfs[[i]] <- Df
}
return(Dfs)
}
#splitting into n parts …Run Code Online (Sandbox Code Playgroud) 有没有办法设置数据表选项来减少列填充?此链接建议autoWidth=TRUE与 with 一起使用scrollX=TRUE,但在我的代码中不起作用。
正如您在下图中所看到的,列之间有很大的差距,迫使用户滚动,如果可能,我希望避免这种情况。这个链接和这个链接在java中有同样的问题
这是呈现数据表的代码。
output$book_table <- DT::renderDT(RVTables$book %>%
filter(deal==as.numeric(input$deal_choice)),
selection = list(mode="single",selected=row_edited),
editable = TRUE,
rownames = FALSE,
options=list(
autoWidth=TRUE,
scrollX = TRUE,
ordering=FALSE,
pageLength=12,
scrollY = TRUE,
bLengthChange= FALSE,
searching=FALSE
)
)
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助。
我正在尝试keras使用此网站在 RStudio 上安装深度学习包。我安装keras使用
install.packages("keras")
library(keras)
install_keras()
Run Code Online (Sandbox Code Playgroud)
但是当我尝试打开MNIST数据集时
mnist <- dataset_mnist()
我不断收到错误
错误:ModuleNotFoundError:没有名为“absl”的模块
我以为 keras 安装了 tensorflow 但我需要单独安装 tensorflow 吗?
我正在尝试使用 math.numerics 找到三次多项式的根ax^3+bx^2+cx+d=0。这个包很棒,但我很难开始使用它。请有人解释一下如何找到根,以及如何从Github运行示例包的简单解释?
我添加了对包的引用
using MathNet.Numerics;
Run Code Online (Sandbox Code Playgroud)
这就是我尝试过的:
var roots = FindRoots.Cubic(d, c, b, a);
double root1=roots.item1;
double root2=roots.item2;
double root3=roots.item3;
Run Code Online (Sandbox Code Playgroud)
但我收到错误"The type 'Complex' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Numerics'"。使用 System.Numerics 添加会出现错误,并且不能解决问题。
请问有什么建议吗?
我正在尝试将容器化在 Docker 映像中的简单 R Shiny 应用程序部署到由 Google Cloud Platform 托管的虚拟机上,但我遇到了问题。
这些文件存储在 Github 存储库中,Docker 镜像是使用 GCP/ Cloud Build上的触发器构建的。Docker 文件基于rocker /shiny 格式。
构建被正确触发并开始构建,但构建在 10 分钟后一直超时。
TIMEOUT ERROR: context deadline exceeded
Run Code Online (Sandbox Code Playgroud)
是否有我可以添加到 Dockerfile 以延长构建时间的命令,还是我的 Dockerfile 错误?
我正在尝试按照本教程进行操作,但是在尝试在主群集上安装RStudio时仍然出现错误。(请参阅“ 安装RStudio服务器...”部分的项目3)。
当我跑线时
$ sudo gdebi rstudio-server-1.2.1335-amd64.deb
安装开始,但随后失败
Jun 03 03:10:16 cluster-c141-m systemd[1]: Starting RStudio Server...
Jun 03 03:10:16 cluster-c141-m rserver[20313]: /usr/lib/rstudio-server/bin/rserver: error while loading shar…ectory
Jun 03 03:10:16 cluster-c141-m systemd[1]: rstudio-server.service: Control process exited, code=exited status=127
Jun 03 03:10:16 cluster-c141-m systemd[1]: Failed to start RStudio Server.
Jun 03 03:10:16 cluster-c141-m systemd[1]: rstudio-server.service: Unit entered failed state.
Jun 03 03:10:16 cluster-c141-m systemd[1]: rstudio-server.service: Failed with result 'exit-code'.
Run Code Online (Sandbox Code Playgroud)
感谢您的任何建议。
r ×6
excel ×3
shiny ×3
vba ×3
dictionary ×2
dt ×2
c# ×1
class ×1
cubic ×1
docker ×1
dockerfile ×1
dplyr ×1
excel-vba ×1
igraph ×1
installation ×1
keras ×1
left-join ×1
math.net ×1
module ×1
nested-lists ×1
polynomials ×1
public ×1
rstudio ×1
shared ×1