小编rga*_*ama的帖子

安装plyr/rcpp时出错

我有两台计算机,其中一台我无法安装R的plyr包.这是我得到的错误:

* installing *source* package ‘plyr’ ...
** package ‘plyr’ successfully unpacked and MD5 sums checked
** libs
g++ -I/usr/share/R/include -DNDEBUG   -I"/usr/lib/R/site-library/Rcpp/include"   -fpic  -O2 -pipe -g  -c RcppExports.cpp -o RcppExports.o
RcppExports.cpp: En la función ‘SEXPREC* plyr_loop_apply(SEXP, SEXP)’:
RcppExports.cpp:15:9: error: ‘input_parameter’ no es un miembro de ‘Rcpp::traits’
RcppExports.cpp:15:40: error: expected primary-expression before ‘int’
RcppExports.cpp:15:40: error: expected ‘;’ before ‘int’
RcppExports.cpp:16:9: error: ‘input_parameter’ no es un miembro de ‘Rcpp::traits’
RcppExports.cpp:16:49: error: expected primary-expression before ‘>’ token
RcppExports.cpp:16:50: error: ‘::type’ no se ha …
Run Code Online (Sandbox Code Playgroud)

r plyr rcpp

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

有没有一种很好的方法来共享模块之间的随机种子(在python中)?

我有一个包含不同主文件的项目(针对不同的模拟).当我运行其中一个主文件时,它应该将种子设置为随机(和numpy.random),并且项目中的所有模块都应该使用该种子.

我找不到一个很好的方法来做到这一点.我有一个文件globals.py与此:

import random

myRandom=None


def initSeed(seed):
    global myRandom
    myRandom =random.Random(seed)
Run Code Online (Sandbox Code Playgroud)

然后从一个主要的我做:

if __name__ == "__main__":

    seed=10
    globals.initSeed(seed)
...
Run Code Online (Sandbox Code Playgroud)

然后在主要调用的模块中,我做:

from globals import myRandom
Run Code Online (Sandbox Code Playgroud)

但myRandom在模块中的值为None(即使我在main中修改了它!).为什么,以及如何解决它?有更好的方法吗?

python random seed globals

7
推荐指数
1
解决办法
2056
查看次数

未显示参考文献(乳胶)

我有一个非常奇怪的问题。在我的一篇论文中,根本没有打印对章节的引用。我用 pdflatex 进行编译,它的工作没有任何抱怨,并且它会输出 pdf,但没有任何对部分的引用。

我只是在一个部分之后使用 \label{sec:mysec} ,并在文本中的任何地方使用 \ref{sec:mysec} ,这是典型的用法。我已经使用它很多年了,但是在这个特定的文档中,必须与阻止乳胶显示引用的东西进行交互。

如果有帮助,这些是我要导入的包:

\documentclass[a4paper,man,natbib,floatsintext]{apa6}
\usepackage[utf8]{inputenc} 
\usepackage{multirow}
\usepackage{graphicx} 
\usepackage{rotating}  
\usepackage{amsmath} 
\usepackage{amssymb} 
\usepackage{color} 
\usepackage{array}
Run Code Online (Sandbox Code Playgroud)

我不知道它是从哪里来的。任何提示都将非常受欢迎。

多谢!

label latex ref

4
推荐指数
1
解决办法
5943
查看次数

在python中迭代utf-8字符

我使用python 3.6来读取用utf-8编码的文件,用西班牙语(因此,包括字母ñ).我使用utf-8编解码器打开文件,并正确加载:在调试时,我可以在加载的文本中看到ñ.

但是,当我迭代字符时,ñ被读作两个字符,n和〜.具体来说,当我跑:

for c in text:
        hexc = int(hex(ord(c)), 16)
        if U_LETTERS[lang][0] <= hexc <= U_LETTERS[lang][1] \
            or hexc in U_LETTERS[lang][2:] \
            or hexc == U_SPACE:
                filtered_text+=c
Run Code Online (Sandbox Code Playgroud)

并且文本包括ñ,变量c将其视为n(因此,hexc为110而不是241),然后它需要〜(和hexc为771).我想当以这种方式迭代时,内部转换为8位字符.这样做的正确方法是什么?

提前致谢.

python utf-8 character-encoding python-3.6

2
推荐指数
1
解决办法
436
查看次数

我如何在python-pandas中平均ACROSS组?

我有这样的数据集:

Participant   Type   Rating 
1              A       6
1              A       5
1              B       4
1              B       3
2              A       9
2              A       8
2              B       7
2              B       6
Run Code Online (Sandbox Code Playgroud)

我想得到这个:

Type   MeanRating
A        mean(6,9)
A        mean(5,8)
B        mean(4,7)
B        mean(3,6)
Run Code Online (Sandbox Code Playgroud)

因此,对于每种类型,我想要每组中较高值的平均值,然后是每组中第二个较高值的平均值,等等.

我想不出用python pandas做这个的正确方法,因为这些方法似乎总是在组内应用,但不适用于它们.

python pandas

1
推荐指数
1
解决办法
89
查看次数

标签 统计

python ×3

character-encoding ×1

globals ×1

label ×1

latex ×1

pandas ×1

plyr ×1

python-3.6 ×1

r ×1

random ×1

rcpp ×1

ref ×1

seed ×1

utf-8 ×1