如何更换(,)使用R中的sub?
我们定义x为:
x="abc(def"
Run Code Online (Sandbox Code Playgroud)
然后,当我尝试(用其他东西替换时,会发生错误:
sub("(","",x)
Run Code Online (Sandbox Code Playgroud)
错误是:
'Missing ')''
如何计算VBA中所选(大)范围内的不同值(数字和字符串混合)的数量?
我以这种方式思考:
1.将数据读入一维数组.
2.排序数组(快速或合并排序)需要测试哪个
3.如果排序数组,只需计算不同值的数量:if(a[i]<>a[i+1]) then counter=counter+1.
这是解决这个问题最有效的方法吗?
编辑:我想在Excel中执行此操作.
为什么R代码{}通常比()下面的代码更快?
n=10000000
w1=numeric(n)
w2=numeric(n)
r=rnorm(n)
t1=Sys.time()
for(i in 1:n)
w1[i]=((r[i]^2))*(1*1)
t1-Sys.time()
t1=Sys.time()
for(i in 1:n)
w2[i]={{r[i]^2}}*{1*1}
t1-Sys.time()
Run Code Online (Sandbox Code Playgroud) 通过Excel将Excel连接到'ABC',通过DDE连接R和Excel也可以,但是如何将R连接到'ABC'应用程序?
我有应用程序提供DDE接口,从Excel我可以使用此DDE参考从中检索值:
='ABC'|DDE!_nazwa_value
Run Code Online (Sandbox Code Playgroud)
从R我试图使用tcltk2库,如下:
tcltk2::tk2dde.request(service="ABC", topic="DDE", item="_nazwa_value")
Run Code Online (Sandbox Code Playgroud)
但是发生错误:
Error in structure(.External(.C_dotTcl, ...), class = "tclObj") :
[tcl] remote server cannot handle this command.
[1] "Error in structure(.External(.C_dotTcl, ...), class = \"tclObj\") : \n [tcl] remote server cannot handle this command.\n\n"
attr(,"class")
[1] "try-error"
attr(,"condition")
<simpleError in structure(.External(.C_dotTcl, ...), class = "tclObj"): [tcl] remote server cannot handle this command.
Run Code Online (Sandbox Code Playgroud)
我只是想用tcltk dde功能来检索应用程序数据,我认为item我的一部分tk2dde.request是错误的,但我已经尝试了各种修改(不_举例),你知道解决这个问题的任何线索或资源?
编辑
出现问题我在服务器主题列表上看不到ABC服务器和DDE主题:
tk2dde.services()但Excel仍然可以使用连接和检索值='ABC'|DDE!_nazwa_value,DDE查询也看不到它
我正在尝试为我的脚本制作非常简单的GUI.简而言之问题看起来像这样:
dataset 是数据框,我想绘制一列作为时间,并使用简单的GUI来选择next/previus列.
dataset <-data.frame(rnorm(10), rnorm(10), rnorm(10))
columnPlot <- function(dataset, i){
plot(dataset[, i])
}
如何使用不同的tcltk呼叫?fploti
我在哪里可以找到.zip格式的旧R包?
以CRAN为例: http://cran.r-project.org/src/contrib/Archive/shapefiles
只有.tar.gz文件来源,我必须安装旧版本,shapefiles因为已经删除了一些文件.
如何从R级别检查R的当前安装是否是最新的?找到已安装R的版本很容易,但如何检查最新版本的数量是多少?这种信息是否可以通过CRAN获得?
我正在寻找一种快速列出文件夹子文件夹中所有文件的方法.基于FileSystemObject的方法太慢 - 从网络驱动器(内联网)列出416文件名大约需要6分钟,因为据我所知,Dir()函数不允许循环遍历子文件夹.
我正在尝试读取数据并解决简单问题,数据:
3 - number of lines to read in
1 1
2 2 2
3 4
Run Code Online (Sandbox Code Playgroud)
在输入每一行之后,我想获得输入数量的总和,但每行中的整数数量是未知的.使用上面的数据后,屏幕应如下所示:
3
1 1
Sum: 2
2 2 2
Sum: 6
3 4
Sum: 7
Run Code Online (Sandbox Code Playgroud)
但是根据我的算法,我得到了输出:
3
1 1
Sum: 1
2 2 2
Sum: 4
3 4
Sum: 3
Run Code Online (Sandbox Code Playgroud)
我已经写代码,但它不能正常工作(如上):
版
我提高了我的代码,并知道它正常工作,不附带任何条件等,适当的代码如下:
#include<iostream>
using namespace std;
int main()
{
int x;
int t, sum;
cin >> t;
for(int i=0; i<t; i++) {
sum=0;
while(true)
{
cin >> x;
sum = sum + x; …Run Code Online (Sandbox Code Playgroud)