我正在进行插入查询,如果已经存在唯一键,则需要将大多数列更新为新值.它是这样的:
INSERT INTO lee(exp_id, created_by,
location, animal,
starttime, endtime, entct,
inact, inadur, inadist,
smlct, smldur, smldist,
larct, lardur, lardist,
emptyct, emptydur)
SELECT id, uid, t.location, t.animal, t.starttime, t.endtime, t.entct,
t.inact, t.inadur, t.inadist,
t.smlct, t.smldur, t.smldist,
t.larct, t.lardur, t.lardist,
t.emptyct, t.emptydur
FROM tmp t WHERE uid=x
ON DUPLICATE KEY UPDATE ...;
//update all fields to values from SELECT,
// except for exp_id, created_by, location, animal,
// starttime, endtime
Run Code Online (Sandbox Code Playgroud)
我不确定该UPDATE
子句的语法应该是什么.我如何引用该SELECT
子句中的当前行?
我正在通过尝试理解其他人的代码来学习jQuery.我碰到了这个:
jQuery.fn.myFunc = function(options, callback) {
//stuff
jQuery(this)[settings.event](function(e) {
var self = this,
$self = jQuery( this ),
$body = jQuery( "body" );
//etc.
}
//more stuff
}
Run Code Online (Sandbox Code Playgroud)
我的理解是$
指jQuery对象.那么,为什么把$
与$self
和$body
?和是self
一样的$self
吗?
该tm
包扩展c
,使得如果给定一组PlainTextDocument
的IT自动创建Corpus
.不幸的是,似乎每个都PlainTextDocument
必须单独指定.
例如,如果我有:
foolist <- list(a, b, c); # where a,b,c are PlainTextDocument objects
Run Code Online (Sandbox Code Playgroud)
我这样做是为了得到一个Corpus
:
foocorpus <- c(foolist[[1]], foolist[[2]], foolist[[3]]);
Run Code Online (Sandbox Code Playgroud)
我有一个列表的列表'PlainTextDocument
,看起来像这样:
> str(sectioned)
List of 154
$ :List of 6
..$ :Classes 'PlainTextDocument', 'TextDocument', 'character' atomic [1:1] Developing assessment models Developing models
.. .. ..- attr(*, "Author")= chr "John Smith"
.. .. ..- attr(*, "DateTimeStamp")= POSIXlt[1:1], format: "2013-04-30 12:03:49"
.. .. ..- attr(*, "Description")= chr(0)
.. .. …
Run Code Online (Sandbox Code Playgroud) 我为一家拥有国家办事处的大公司建立了一个电子购物网站.
我想做的是以下几点
是否只能使用Web界面?我的意思是没有任何本地申请.怎么做?请解释.
我有以下数据:
bin groupname total_dist
0 rowA 377
0 rowA 306.6
0 rowB 2.1
0 rowB 110.6
1 rowA 918.1
1 rowA 463.2
1 rowB 798.2
1 rowB 1196
2 rowA 1295.1
2 rowA 1269.1
2 rowB 698
2 rowB 1022.1
Run Code Online (Sandbox Code Playgroud)
使用R,我想打一个条形图那里是行rowA酒吧和rowB中的一间酒吧的每个垃圾桶.我可以将total_dist分组为一个或另一个(plot(total_dist~bin)
或plot(total_dist~groupname)
).但我无法弄清楚如何将它们结合起来.
我想要一些看起来类似于这个例子的东西:
假设我有一个像这样的R列表:
> summary(data.list)
Length Class Mode
aug9104AP 18 data.frame list
Aug17-10_acon_7pt_dil_series_01 18 data.frame list
Aug17-10_Picro_7pt_dil_series_01 18 data.frame list
Aug17-10_PTZ_7pt_dil_series_01 18 data.frame list
Aug17-10_Verat_7pt_dil_series_01 18 data.frame list
Run Code Online (Sandbox Code Playgroud)
我想使用处理列表中的每个data.frame l_ply
,但我还需要将名称(例如aug9104AP)与data.frame一起传递到处理函数中.就像是:
l_ply(data.list,function(df,...) {
cli.name<- arg_to_access_current_list_item_name
#make plots with df, use cli.name in plot titles
#save results in a file called cli.name
}, arg_to_access_current_list_item_name
)
Run Code Online (Sandbox Code Playgroud)
应该arg_to_access_current_list_item_name
是什么?
我有一个jQuery函数,当点击它的图例时,它会切换字段集内容的可见性,只留下字段集边框(如果有的话)和图例显示:
$('legend.togvis').click(function() {
$(this).siblings().toggle();
return false;
});
Run Code Online (Sandbox Code Playgroud)
除非fieldset包含文本节点,否则它很有效.
<fieldset><legend class='togvis'>Click Me</legend>
<p>I toggle when the legend is clicked.</p>
But I'm a recalcitrant text node and refuse to toggle.
</fieldset>
Run Code Online (Sandbox Code Playgroud)
为了切换文本节点,我尝试了这个:
$('legend.togvis').click(function() {
$(this).parent().contents().not('legend').toggle();
return false;
});
Run Code Online (Sandbox Code Playgroud)
其作用与第一个函数相同.还有这个:
$('legend.togvis').click(function() {
$(this).parent().contents(":not(legend)").toggle();
return false;
});
Run Code Online (Sandbox Code Playgroud)
这引发了错误
Message: 'style.display' is null or not an object
Line: 5557
Char: 3
Code: 0
URI: http://code.jquery.com/jquery-1.4.4.js
Run Code Online (Sandbox Code Playgroud)
有关如何获取字段集的整个内容(减去图例)以在单击图例时切换的任何想法?
ETA解决方案,非常感谢Eibx
$('legend.togvis').click(function() {
$(this).parent().contents().filter(
function() { return this.nodeType == 3; }).wrap('<span></span>');//wrap any stray text nodes
$(this).siblings().toggle();
});
Run Code Online (Sandbox Code Playgroud) 我想在我的堆积区域图集的背景中添加暗/亮相位信息,以突出显示光线如何影响曲线的形状.我的数据框看起来像这样:
> str(MDist.median)
'data.frame': 2880 obs. of 6 variables:
$ groupname: Factor w/ 8 levels "rowA","rowB",..: 1 1 1 1 1 1 1 1 1 1 ...
$ fCycle : Factor w/ 6 levels "predark","Cycle 1",..: 1 1 1 1 1 1 1 1 1 1 ...
$ fPhase : Factor w/ 2 levels "Light","Dark": 2 2 2 2 2 2 2 2 2 2 ...
$ starttime: num 0.3 60 120 180 240 300 360 420 480 540 ... …
Run Code Online (Sandbox Code Playgroud) 以下代码只要工作,before
并且after
字符串没有正则表达式特有的字符:
before <- 'Name of your Manager (note "self" if you are the Manager)' #parentheses cause problem in regex
after <- 'CURRENT FOCUS'
pattern <- paste0(c('(?<=', before, ').*?(?=', after, ')'), collapse='')
ex <- regmatches(x, gregexpr(pattern, x, perl=TRUE))
Run Code Online (Sandbox Code Playgroud)
R有一个函数来转义在正则表达式中使用的字符串吗?
这个过程可以从MySQL命令行远程和本地主机上运行,并且在从PHP调用时可以正常工作.在所有情况下,补助金都是足够的:
CREATE PROCEDURE `myDB`.`lee_expout` (IN e int, IN g int)
BEGIN
select lm.groupname, lee.location, starttime, dark,
inadist,smldist,lardist,emptydur,inadur,smldur,lardur,emptyct,entct,inact,smlct,larct
from lee join leegroup_map lm using (location)
where exp_id= e and std_interval!=0 and groupset_id= g
order by starttime,groupname,location;
END
Run Code Online (Sandbox Code Playgroud)
我试图从R调用它:
library(DBI)
library(RMySQL)
db <- dbConnect(MySQL(), user="user", password="pswd",
dbname="myDB", host="the.host.com")
#args to pass to the procedure
exp_id<-16
group_id<-2
#the procedure call
p <- paste('CALL lee_expout(', exp_id, ',', group_id,')', sep= ' ')
#the bare query
q <- paste('select lm.groupname, lee.location, starttime, dark,
inadist,smldist,lardist,emptydur,inadur,smldur,lardur,emptyct,entct,inact,smlct,larct
from lee …
Run Code Online (Sandbox Code Playgroud)