使用数据框
x
Date Val
1/1/2012 7
2/1/2012 9
3/1/2012 20
4/1/2012 24
5/1/2012 50
a <- seq(as.Date(tail(x, 1)$Date), by="month", length=5)
a <- data.frame(a)
x.lm <- lm(x$Val ~ x$Date)
x.pre<-predict(x.lm, newdata=a)
Run Code Online (Sandbox Code Playgroud)
我得到这个错误:
Warning message:
'newdata' had 5 rows but variable(s) found have 29 rows
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
这是输出输出:
dput(x)
structure(list(Date = structure(c(14610, 14641, 14669, 14700,
14730, 14761, 14791, 14822, 14853, 14883, 14914, 14944, 14975,
15006, 15034, 15065, 15095, 15126, 15156, 15187, 15218, 15248,
15279, 15309, 15340, 15371, 15400, 15431, 15461), class = "Date"), …Run Code Online (Sandbox Code Playgroud) 我喜欢将ui-layout-west部分固定宽度,并喜欢隐藏可调整大小的条形图.我尝试了这个,但我仍然看到了ui-layout-pane的正确边框.
在CSS上:
.ui-layout-west {
background: #F8F8FF !important;
width: 300px !important;
}
Run Code Online (Sandbox Code Playgroud)
在Java脚本上:
west: {
enableCursorHotkey: false,
closable: false,
resizable: false,
panespacing: 0
}
Run Code Online (Sandbox Code Playgroud)
有关如何移除可靠条形或隐藏它的任何想法?
我正在使用ggplot来绘制一些数据,我注意到传说文本很长并且不适合窗口.
+ opts(legend.position = 'bottom', legend.direction = 'horizontal', size=0.1) +
guides(colour = guide_legend(nrow = 3), size=1)
Run Code Online (Sandbox Code Playgroud)
ggplot中是否有一个选项可以包含图例文本以适合窗口.
> dput(head(t))
structure(list(Team = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = "Union", class = "factor"),
Date = structure(c(1L, 1L, 1L, 2L, 2L, 2L), .Label = c("2012-01-06",
"2012-02-06", "2012-03-06", "2012-04-06", "2012-05-06", "2012-07-06",
"2012-09-06", "2012-10-06", "2012-11-06", "2012-12-06"), class = "factor"),
STime = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = "07:03", class = "factor"),
ETime = structure(c(6L, 7L, 8L, 5L, 5L, 1L), .Label = c("01:13",
"03:13", "06:13", "09:13", "10:13", "11:13", "12:13", "13:13",
"15:13", "16:13", "18:13"), class = "factor")), .Names = c("Team", …Run Code Online (Sandbox Code Playgroud) 我正在尝试将此时间戳转换为POSIXct
t1 <- c("19-Jun-13 06.00.00.00 PM")
Run Code Online (Sandbox Code Playgroud)
如果我这样做:
t1 <- as.POSIXct(t1, format="%d-%b-%y %H:%M:%S")
Run Code Online (Sandbox Code Playgroud)
这会转换这个时间戳吗?那是否最终考虑了AM/PM?
我在本地有一个JSON格式化数据的文件.我已经创建了一个小PHP脚本,以便在调用via时回显出该文件的输出AJAX.数据文件的大小是59k.我按照highcharts建议禁用动画和阴影.当我加载图表时,渲染需要非常长的时间.我已粘贴下面的脚本.我能做些什么来更快地渲染这个图表?就目前而言,这绝对是不可接受的.
echo_file.php 输出看起来像这样:
[{"name":"loess","data":[[1373241600000,3.49571041760408],[1373241660000,3.4844505982485],[1373241720000,3.47324293684199],[1373241780000,3.46208745646435],[1373241840000,3.45098418019539],[1373241900000,3.43993313111491],[1373241960000,3.42893433230273],[1373242020000,3.41798780683864],[1373242080000,3.4070935778
43611722495],[1373243400000,3.18069824879358],[1373243460000,3.17101320762565],[1373243520000,3.16138101680096],[1373243580000,3.15180169939934],[1373243640000,3.14227527850057],[1373243700000,3.13280177718446],[1373243760000,3.12338121853083],[1373243820000,3.11401362561948],[1373243880000,3.10469902153021]]}]
Run Code Online (Sandbox Code Playgroud)
这是脚本:
$(document).ready(function() {
var seriesOptions = [],
yAxisOptions = [],
colors = Highcharts.getOptions().colors;
function myAjax() {
$.ajax({
url: 'echo_file.php',
datatype: 'json',
success: function(data) {
seriesOptions=data;
createChart();
},
cache: false
});
}
setInterval(myAjax, 300000);
function createChart() {
$('#container').highcharts('StockChart', {
chart: {
animation: false,
shadow: false
},
title : {
text : 'CPU Utilization'
},
plotOptions: {
series: {
lineWidth: 2
}
},
rangeSelector: {
enabled: true,
buttons: [{ …Run Code Online (Sandbox Code Playgroud) 我试图安装一个没有依赖项的python模块.
我跑:
python setup.py install
Run Code Online (Sandbox Code Playgroud)
但是这个安装依赖项,任何想法怎么能这样做?
我正在使用jstree插件来构建我的树.我的网页上有一个搜索框,我需要用户能够搜索jstree节点.
<fieldset id="search">
<input type="text" name="search_field" id="search_field" value="" />
<button id="search_tree">Search</button>
</fieldset>
Run Code Online (Sandbox Code Playgroud)
单击搜索时,应扩展jstree节点,如果找到,则应突出显示节点.如果未找到,则应向用户显示错误,如"未找到".我的代码扩展了下面的所有节点.有没有一种简单的方法来搜索jstree中的所有节点?
<script type="text/javascript">
$(document).ready(function(){
$("#search_tree").click(function () {
var value=document.getElementById("search_field").value;
$("#tree").jstree("search",value);
});
$("#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"]
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
实例[...]为null或不是对象.这是一个jstree错误.有任何想法吗?
我需要生成20到50之间的随机数,增量为5.例如,数字必须为20,25,30,25,50,45等.数字之间的差异应为5.
我试过这个:
x<-floor(runif(50,20,50))
Run Code Online (Sandbox Code Playgroud)
这给了我20到50之间的任何数字.在R中有一个简单的方法吗?
我声明一个空数据框,如下所示:
df <- data.frame()
Run Code Online (Sandbox Code Playgroud)
然后我处理一些文件,作为过程,我需要构建我的df数据框架。我需要不断向其中添加列:
例如,我处理一些文件并构建一个名为 的数据框new_df,我现在需要将其添加new_df到我的df:
我试过这个:
latest_df <- cbind(latest_df, new_df)
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
data.frame(..., check.names = FALSE) 中的错误:参数暗示不同的行数:0、1
r ×6
jquery ×2
ggplot2 ×1
highcharts ×1
javascript ×1
jstree ×1
knitr ×1
lm ×1
predict ×1
python ×1