我正在使用rnorm()
生成随机变量,需要删除所有小于20的随机变量。
例如:
rnorm(4, mean=30, sd=18)
[1] 18 25 36 16
需要成为:
[1] 25 36
答案 0 :(得分:3)
我们可以对输出#!/usr/bin/env python
import numba as nb
import numpy as np
import time
temp = np.ones(25000000)
@nb.jit(fastmath=True)
def func(temp):
return [n for n in temp]
time1 = time.time()
result = func(temp)
print("Took: ", time.time()-time1, " seconds for ", len(temp), " items")
进行子集
vector
v2 <- v1[v1 >= 20]