小编Dav*_*d B的帖子

如何使ggplot2图更漂亮?

我使用它后面的R代码生成了以下图: 替代文字

ggplot(lengths, aes(length, fill = library)) + geom_density(alpha = 0.2) + coord_cartesian(xlim = c(0, 60000)) 
Run Code Online (Sandbox Code Playgroud)

现在我想使情节更漂亮一点:

  1. 使x轴显示每5000个单位的长度(而不是每20000个)
  2. 在三个峰顶(约3000,5000和35000)上添加x值.

我怎样才能做到这一点?

更新 以回应詹姆斯: 替代文字

plot r ggplot2

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

如何验证从Perl执行的R脚本的正常终止?

我编写了一个shebang R脚本,并希望从Perl脚本执行它.我目前正在使用system ($my_r_script_path, $r_script_arg1, $r_script_arg2, ...),我的问题是如何验证R脚本正常终止(没有错误或警告).

我猜我应该让我的R脚本在最后返回一些真值,只要一切正常,然后在Perl中捕获这个值,但我不知道该怎么做.

谢谢!

perl r return-value

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

如何让App :: cpanminus工作?

我刚刚安装了ubuntu 10.10的新副本.我按照brian d foy推荐的大纲安装了perl 5.12.2 ,然后通过调用安装了cpanminus curl -L http://cpanmin.us | perl5.12.2 - --sudo App::cpanminus.

现在,cpan5.12.2工作正常,但每当我尝试使用cpanm5.12.2安装模块时,它都找不到它.例如:

$ sudo cpanm5.12.2 -v File::Copy::Recursive
You have make /usr/bin/make
You have LWP 5.837
You have /bin/tar: tar (GNU tar) 1.23
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore …
Run Code Online (Sandbox Code Playgroud)

ubuntu perl cpan

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

是List :: MoreUtils :: none越野车?

我认为none子程序List::MoreUtils不起作用.根据文件,

无块列表逻辑上否定任何.如果LIST中的项目不符合通过BLOCK给出的条件,或者LIST为空,返回true值.依次为LIST中的每个项目设置$ _

现在,尝试:

use strict;
use warnings;
use 5.012;
use List::MoreUtils qw(none);

my @arr = ( 1, 2, 3 );
if ( none { $_ == 5 } @arr ) {
    say "none of the elements in arr equals 5";
}
else {
    say "some element in arr equals 5";
}
Run Code Online (Sandbox Code Playgroud)

工作正常,但替换@arr为空(my @arr = ();或简单my @arr;),你得到一个错误的答案.

这是怎么回事?

更新:我有List :: MoreUtils ver 0.22.更新到最新版本似乎没问题.虽然奇怪!

perl list

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

如何正确减少mod_perl的冗余请求数?

在一个相当大的遗留项目中,我已经将几个毛茸茸的模块重构为Moose类.这些模块中的每一个都需要数据库访问(懒惰)获取其属性.由于这些对象使用得相当多,我想减少冗余请求的数量,例如对于未更改的数据.

现在,我该如何正确地做到这一点?我有几个选择:

  1. 在我的Moose类中实现缓存,通过一个角色将它们存储在memcached5-10分钟的到期时间(可能不是太困难,但是对于懒惰属性来说很棘手)更新:KiokuDB可能在这里有所帮助,必须阅读有关属性的内容
  2. 迁移到DBIx::Class(无论如何都需要完成)并在此级别上实现缓存(DBIC可能会消除大部分的痛苦)
  3. 不知怎的,让我的对象在mod_perl进程内持久存在(不知道如何做到这一点:()

你会怎么做?你认为什么是理智的方式?是否在对象或ORM级别上缓存数据?

perl caching moose kiokudb

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

R脚本行号错误?

我在一年前找到了这篇文章,我正在使用R version 2.11.1 (2010-05-31),但仍然收到没有行号的错误消息.

有解决方案吗

debugging r

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

如何在Perl中序列化闭包?

我认为使用一个例子可能是最好的问题:

use strict;
use warnings;
use 5.010;
use Storable qw(nstore retrieve);

local $Storable::Deparse = 1;
local $Storable::Eval    = 1;

sub sub_generator {
    my ($x) = @_;

    return sub {
        my ($y) = @_;
        return $x + $y;
    };
}

my $sub = sub_generator(1000);
say $sub->(1); # gives 1001
nstore( $sub, "/tmp/sub.store" );
$sub = retrieve("/tmp/sub.store");
say $sub->(1); # gives 1
Run Code Online (Sandbox Code Playgroud)

当我转储时,/tmp/sub.store我看到:

$VAR1 = sub {
            package Storable;
            use warnings;
            use strict 'refs';
            my($y) = @_;
            return $x + …
Run Code Online (Sandbox Code Playgroud)

perl serialization closures store function

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

如何在Perl中实现二进制搜索?

我想在Perl中实现二进制搜索算法.我的'数组'按递减顺序排序(不是实际数组,而是获取索引并返回值的函数).问题是可能存在一系列相同的值.如果我的搜索值在这样的范围内,我想返回包含它的第一个索引.

这就是我写的:

# get_val should be a *decreasing* function for idexes $i in min..max,
# formally: for any $i,$j s.t. $max>=$i>$j>=$min :
# $get_val_subref($i, $extra) <= $get_val_subref($j, $extra)
# min and max are the inclusive boundaries for the search
# get_val sub should get an index in min..max and an extra data reference, and return
# the value for the given index
# returns the smallest index $i in min..max for which $get_val_subref($j, $extra)
# returns $searched_val, or undef if …
Run Code Online (Sandbox Code Playgroud)

perl binary-search

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

如何构建所有懒惰的Moose功能?

我在Moose对象中有一堆懒惰的功能.

一些建筑商需要一些时间来完成.

我想nvoke所有构建器(转储"完整"对象).我可以一次性构建所有延迟功能,还是必须手动调用每个功能以使其运行?

perl moose

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

如何将Excel/OpenOffice/LibreOffice图表导出到SVG?

我正在使用一种流行的电子表格应用程序(Excel/OpenOffice/LibreOffice Graph)来创建一些漂亮的图表.

是否可以从任何这些程序将图表导出为SVG格式?

excel charts svg openoffice.org libreoffice

6
推荐指数
2
解决办法
7887
查看次数