小编use*_*980的帖子

从字符串向量中提取数字

我有这样的字符串:

years<-c("20 years old", "1 years old")
Run Code Online (Sandbox Code Playgroud)

我想只grep这个向量中的数字.预期输出是一个向量:

c(20, 1)
Run Code Online (Sandbox Code Playgroud)

我该怎么做呢?

regex r

78
推荐指数
11
解决办法
11万
查看次数

你如何从R发送电子邮件

我想发送来自R的电子邮件.这是我到目前为止所拥有的:

library(sendmailR)


from <- "eamil@example.com"
to <- "email2@example.com"
subject <- "Performance Result"
body <- "This is the result of the test:"                     
mailControl=list(smtpServer="snmpt server address")

sendmail(from=from,to=to,subject=subject,msg=body,control=mailControl)
Run Code Online (Sandbox Code Playgroud)

当我执行此脚本时,我的R会话挂起.有什么想法可能会发生什么?

r

57
推荐指数
5
解决办法
7万
查看次数

将数据帧转换为json

我有一个数据框,我想转换为json格式:

我的数据框叫做res1:

library(rjson)

structure(list(id = c(1, 2, 3, 4, 5), value = structure(1:5, .Label = c("server1", 
"server2", "server3", "server4", "server5"), class = "factor")), .Names = c("id", 
"value"), row.names = c(NA, -5L), class = "data.frame")
Run Code Online (Sandbox Code Playgroud)

当我做:

toJSON(res1)
Run Code Online (Sandbox Code Playgroud)

我明白了:

{"id":[1,2,3,4,5],"value":["server1","server2","server3","server4","server5"]}
Run Code Online (Sandbox Code Playgroud)

我需要这个json输出是这样的,任何想法?

[{"id":1,"value":"server1"},{"id":2,"value":"server2"},{"id":3,"value":"server3"},{"id":4,"value":"server4"},{"id":5,"value":"server5"}]
Run Code Online (Sandbox Code Playgroud)

json r rjson

29
推荐指数
3
解决办法
4万
查看次数

在ggplot2中为每个facet_wrap网格放置一个图例

我有这个数据框:

        Date Server FileSystem PercentUsed
1  12/1/2011      A          /          60
2   1/2/2012      A       /var          50
3   2/1/2012      A        tmp          90
4  2/10/2012      A        /db          86
5  2/13/2012      A       /app          90
6  12/1/2011      B         C:          67
7   1/2/2012      B         D:          67
8   2/1/2012      B         F:          34
9  2/10/2012      B   /restore          89
10 2/13/2012      B         G:          56
11 12/1/2011      C          /          90
12  1/2/2012      C       /tmp          78
13  2/1/2012      C      /data          67
14 2/10/2012      C   /Storage          34
15 2/13/2012      C  /database          12 …
Run Code Online (Sandbox Code Playgroud)

r legend facet ggplot2 facet-wrap

25
推荐指数
3
解决办法
1万
查看次数

如何在python中创建时间序列数据的线性回归预测

我需要能够基于线性回归模型创建一个用于预测的python函数,并在时间序列数据上使用置信带:

该函数需要一个参数来指定预测的距离.例如1天,7天,30天,90天等.根据参数,它将需要创建带有置信区段的Holt-Winters预测:

我的时间序列数据如下所示:

print series

[{"target": "average", "datapoints": [[null, 1435688679], [34.870499801635745, 1435688694], [null, 1435688709], [null, 1435688724], [null, 1435688739], [null, 1435688754], [null, 1435688769], [null, 1435688784], [null, 1435688799], [null, 1435688814], [null, 1435688829], [null, 1435688844], [null, 1435688859], [null, 1435688874], [null, 1435688889], [null, 1435688904], [null, 1435688919], [null, 1435688934], [null, 1435688949], [null, 1435688964], [null, 1435688979], [38.180000209808348, 1435688994], [null, 1435689009], [null, 1435689024], [null, 1435689039], [null, 1435689054], [null, 1435689069], [null, 1435689084], [null, 1435689099], [null, 1435689114], [null, 1435689129], [null, 1435689144], [null, 1435689159], [null, 1435689174], [null, 1435689189], [null, 1435689204], …
Run Code Online (Sandbox Code Playgroud)

python

23
推荐指数
3
解决办法
1万
查看次数

删除数据框中大于95百分位数的数据

我有这样的数据:

DF:

Group   Point
A       6000
B       5000
C       1000
D        100
F        70
Run Code Online (Sandbox Code Playgroud)

在我绘制这个df之前,我只想删除数据框中超过95百分位数的值.有谁告诉我该怎么做?

r

15
推荐指数
2
解决办法
3万
查看次数

在jstree中包装叶文本

我正在使用jstree插件基于xml文件填充我的树.某些节点文本大于容器div.有没有办法文本包装jstree节点文本?

$(document).ready(function(){
     $("#tree").jstree({  
         "xml_data" : {  

             "ajax" : {  

                 "url" : "jstree.xml" 

             },  

             "xsl" : "nest"


         },  
         "themes" : {  

             "theme" : "classic",  

            "dots" : true,  

             "icons" : true 

         },  

        "search" : {  

                 "case_insensitive" : true,  

                 "ajax" : {  

                     "url" : "jstree.xml" 

                 }  

             },  
              "plugins" : ["themes", "xml_data", "ui","types", "search"] 


    }).bind("select_node.jstree", function (event, data) {

        $("#tree").jstree("toggle_node", data.rslt.obj);
Run Code Online (Sandbox Code Playgroud)

jstree

15
推荐指数
2
解决办法
7621
查看次数

如何使用R中的ssh连接到远程服务器

是否可以使用用户名和密码连接到远程ssh服务器并读取文件?我做了一些研究,并没有得到任何关于此的信息.我很欣赏任何见解.

ssh r

15
推荐指数
2
解决办法
2万
查看次数

在ggplot中设置日期范围

我的数据框是z:

> dput(z)
structure(list(Month = structure(c(14975, 15095, 15156, 15187, 
15248), class = "Date"), Value = c(1, 1, 1, 6, 1)), .Names = c("Month", 
"Value"), row.names = c(NA, 5L), class = "data.frame")


ggplot(z, aes(Month, Value)) + 
    geom_bar(fill="orange",size=.3,  stat="identity", position="identity") +
    geom_smooth(data=z,aes(Month,Value,group=1), method="lm", size=2, color="navyblue") + 
    scale_x_date(breaks = "1 month", labels=date_format("%b-%Y"))
Run Code Online (Sandbox Code Playgroud)

这工作正常,但我真的很喜欢我的数据范围在2011年1月1日到2013年1月1日之间.我的示例日期是2011年1月1日至2011年1月10日.是否有一种简单的方法可以在ggplot中强制从2011年1月1日到2013年1月1日的日期范围?

r date ggplot2

13
推荐指数
3
解决办法
3万
查看次数

你怎么在knitr打印表

我正在尝试使用knitr以表格格式打印数据框xtable:

```{r xtable,fig.width=10, fig.height=8, message=FALSE, results = 'asis', echo=FALSE, warning=FALSE, fig.cap='long caption', fig.scap='short',tidy=FALSE}

print(xtable(d),format="markdown")
```
Run Code Online (Sandbox Code Playgroud)

这是数据框d:

d <- structure(list(Hostname = structure(c(8L, 8L, 9L, 5L, 6L, 7L, 
1L, 2L, 3L, 4L), .Label = c("db01", "db02", "farm01", "farm02", 
"tom01", "tom02", "tom03", "web01", "web03"), class = "factor"), 
    Date = structure(c(6L, 10L, 5L, 3L, 2L, 1L, 8L, 9L, 7L, 4L
    ), .Label = c("10/5/2015 1:15", "10/5/2015 1:30", "10/5/2015 2:15", 
    "10/5/2015 4:30", "10/5/2015 8:30", "10/5/2015 8:45", "10/6/2015 8:15", 
    "10/6/2015 8:30", "9/11/2015 …
Run Code Online (Sandbox Code Playgroud)

r knitr

11
推荐指数
2
解决办法
8048
查看次数

标签 统计

r ×8

ggplot2 ×2

date ×1

facet ×1

facet-wrap ×1

json ×1

jstree ×1

knitr ×1

legend ×1

python ×1

regex ×1

rjson ×1

ssh ×1