我想将ping时间绘制到特定服务器,因此我正在解析此String的输出:
[1] "PING google.de (216.58.213.195): 56 data bytes"
[2] "64 bytes from 216.58.213.195: icmp_seq=0 ttl=58 time=15.583 ms"
[3] "64 bytes from 216.58.213.195: icmp_seq=1 ttl=58 time=11.057 ms"
[4] "64 bytes from 216.58.213.195: icmp_seq=2 ttl=58 time=10.866 ms"
[5] ""
[6] "--- google.de ping statistics ---"
[7] "3 packets transmitted, 3 packets received, 0.0% packet loss"
[8] "round-trip min/avg/max/stddev = 10.866/12.502/15.583/2.180 ms"
Run Code Online (Sandbox Code Playgroud)
我正在使用正则表达式并搜索'time ='和'ms'来获取时间信息开始和结束的位置.然后我使用Substr来提取数字.实际上它有效,但这是我第一次尝试解析R中的字符串,我的感觉是我的解决方案可能更优雅.你可以帮帮我吗?TY
X <- system("ping -c 3 google.de",intern=TRUE)
start<-regexpr("time=",X)
end<-regexpr(" ms",X)
start<-start+5
end<-end-1
erg<-substr(X,start,end)
erg<-erg[2:4]
erg
erg<-as.numeric(erg)
hist(erg)
Run Code Online (Sandbox Code Playgroud) 我希望我的应用程序代表用户的墙发布(例如广告).我想创建一个php脚本,我将每周在我的服务器上执行一个cron作业.我的数据库中有用户ID.现在我希望脚本获取用户ID,然后在用户的墙上发布.(当然,如果用户仍然安装了应用程序并授予了发布流权限)
是否可以创建一个触发此脚本的脚本?
$ post = $ facebook-> api("/ $ user1/feed","POST",$ params); 或
$ post = $ facebook-> api("/ $ user2/feed","POST",$ params); 等等...?
谢谢你的建议
<?php
require 'src/facebook.php';
$app_id = 'yourappid';
$app_secret = 'yourappsecret';
$app_namespace = 'appname';
$app_url = 'https://apps.facebook.com/' . $app_namespace . '/';
$scope = 'email,publish_actions';
// Init the Facebook SDK
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
));
// Get the current user
$user = $facebook->getUser();
// If the user has not installed the app, redirect them …Run Code Online (Sandbox Code Playgroud) 我想从数据框中绘制 100% 堆积面积图,其中 df 的每一行总和为 1。示例数据框在这里:https : //pastebin.com/ADMQP6Nx
到目前为止,我在 SO 上找到的大多数解决方案都有不同的 data.frame 结构,其中分组变量定义为行而不是列,例如:
+--------+-------+-------+
| Period | Group | Value |
+--------+-------+-------+
| 1 | t1 | 0.3 |
| 1 | t2 | 0.1 |
| 1 | t3 | 0.4 |
| 1 | t4 | 0.2 |
| 2 | t1 | 0.5 |
| 2 | t2 | 0.1 |
| 2 | t3 | 0.3 |
| 2 | t4 | 0.2 | …Run Code Online (Sandbox Code Playgroud) 我的代码出了什么问题?
在主要方法中我这样做:
int [] test=new int[48];
test=etable(Right[]).clone();
Run Code Online (Sandbox Code Playgroud)
我想要的是,'test'数组与'etable'方法的输出完全相同.
我的方法称为'etable':
public static int [] etable(int [] right){
int [] blabla=new int[48];
...
return blabla[]
}
Run Code Online (Sandbox Code Playgroud)
感谢您的意见