我在R中有两个列的数据帧。第一列包含subjectID,第二列包含主题所做的试用ID。
一个特定的subjectID可能已经做了超过1次的试验。我想添加一个列,它有一个计数器,开始对每个主题进行计数--试用,唯一值和增量1,直到它到达最后一行。
更确切地说,我有一张桌子:
ID T
A 1
A 1
A 2
A 2
B 1
B 1
B 1
B 1
我要下面的输出
ID T Index
A 1 1
A 1 2
A 2 1
A 2 2
B 1 1
B 1 2
B 1 3
B 1 4
我正在尝试通过CD和USB安装Ubuntu12.04。当我把它们放在我的笔记本电脑上时,它会显示如下:
This Kernel requires the following features not present on the CPU : PAE
Unable to boot - Please use a kernel appropriate for your CPU.
我笔记本电脑的规格: CPU : Intel奔腾M 725 1.6GHz VGA : Geforce FX Go5200 64 My内存: 1GB DDR
这是一台旧机器。
我的问题是,为什么会出现这个错误,如何解决呢?
欧拉项目14问:哪个起始数,在一百万以下,产生最长的Collatz序列?
我一直在尝试优化这个解决方案,使其在小于1s的情况下执行。前50名议员的议程。目前,它在1,2中为我执行,所以我想我希望它快20%。有什么窍门或其他方法吗?
from time import time
def rec_col(n, cache):
if n in cache:
return cache[n]
x = (rec_col(n//2, cache) if n % 2 == 0 else rec_col(3*n+1, cache))+1
cache[n] = x
我有一个简单的日志表,大约有50万行,表结构是
TABLE logs
(
id serial NOT NULL,
username character varying(32),
user_id integer,
description text NOT NULL,
"time" timestamp with time zone DEFAULT now(),
referrer character varying(128),
"type" character varying(25)
)
查询此表以获取description列内容方面最常
在Windows上使用Cygwin,我似乎遇到了一个问题,使用ls -l挂起异常长的时间,而使用ls时没有list参数,几乎没有时间返回。
[664] / *> which ls
/usr/bin/ls
[665] ~ *> time ls 1> /dev/null
real 0m0.065s
user 0m0.000s
sys 0m0.031s
[666] ~ *> time ls -l 1> /dev/null
real 0m10.836s
user 0m0.015s
sys 0m0.077s
造成这种情况的原因
我有一个改变玩家速度的类。代码如下:
using UnityEngine;
using System.Collections;
public class MultiplySpeed : MonoBehaviour {
public int multiplier = 2;
public Controls player;
bool flag = false;
void OnTriggerExit(Collider c){
if(c.tag == "Player"){
player = c.gameObject
对于给定的向量$(x_1,x_2,\ldots,x_n)$ i试图计算
我写了以下代码
for l = 1:n
for k = 1:n
error = error + norm(x(i)-x(j))
end
end
这段代码不快,特别是当$n$很大时。我知道我实际上是在重复计算。但我该如何避免呢?我怎样才能加速我的代码?
谢谢!