小编Ser*_*hia的帖子

R中直方图中的确切二进制数

我在R中制作直方图时遇到了麻烦.问题是我告诉它制作5个分区,但它会产生4个分区,然后我告诉它制作5个分区,它会产生8个分区.

data <- c(5.28, 14.64, 37.25, 78.9, 44.92, 8.96, 19.22, 34.81, 33.89, 24.28, 6.5, 4.32, 2.77, 17.6, 33.26, 52.78, 5.98, 22.48, 20.11, 65.74, 35.73, 56.95, 30.61, 29.82);

hist(data, nclass = 5,freq=FALSE,col="orange",main="Histogram",xlab="x",ylab="f(x)",yaxs="i",xaxs="i")
Run Code Online (Sandbox Code Playgroud)

关于如何修复它的任何想法?

statistics r histogram

14
推荐指数
3
解决办法
5万
查看次数

在CMD检查期间,Roxygen示例中的“找不到功能”

我正在RStudio中的一个软件包上运行CMD检查,其中的一部分分析@examples了内联Roxygen文档中的内容。

我收到此错误:

checking examples ... ERROR
Running examples in ‘packagename-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: checkDate
> ### Title: Ensure that a date string is a valid date
> ### Aliases: checkDate
> 
> ### ** Examples
> 
> checkDate("2017-05-06")
Error: could not find function "checkDate"
Run Code Online (Sandbox Code Playgroud)

在我的.R文件中,文档定义为:

#' Ensure that a date string is a valid date
#'
#' @param dateString A string (eg. "2017-12-04").
#' @return …
Run Code Online (Sandbox Code Playgroud)

r devtools roxygen2

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

在单独的行上返回Redshift JSON数组的元素

我有一个Redshift表,看起来像这样:

 id | metadata
---------------------------------------------------------------------------
 1  | [{"pet":"dog"},{"country":"uk"}]
 2  | [{"pet":"cat"}]
 3  | []
 4  | [{"country":"germany"},{"education":"masters"},{"country":"belgium"}]
Run Code Online (Sandbox Code Playgroud)
  • 所有数组元素只有一个字段。
  • 不能保证特定字段将出现在数组的任何元素中。
  • 字段名称可以在数组中重复
  • 数组元素可以任意顺序

我想找一张看起来像这样的桌子:

 id |   field   |  value
------------------------
 1  | pet       | dog
 1  | country   | uk
 2  | pet       | cat
 4  | country   | germany
 4  | education | masters
 4  | country   | belgium
Run Code Online (Sandbox Code Playgroud)

然后,我可以将其与对输入表其余部分的查询结合起来。

我曾尝试过使用Redshift JSON函数,但由于无法在Redshift中编写函数/使用循环/具有变量,我真的看不到这样做的方法!

请让我知道是否可以澄清其他问题。

json amazon-redshift

4
推荐指数
3
解决办法
5552
查看次数

由于 Xcode 命令行工具更新,无法安装 stringi

  • 系统:macOS Sierra 10.12.6
  • 代码:9.2 (2347)
  • R : 3.4.0
  • RStudio:1.1.383

我正在尝试安装最新版本的 stringi (1.1.6)。这是不可能的,因为最近更新了 Xcode。收到的错误configure: error: C compiler cannot create executables在这里有完整的输出:

Installing package into ‘/usr/local/lib/R/3.4/site-library’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/stringi_1.1.6.tar.gz'
Content type 'application/x-gzip' length 3647049 bytes (3.5 MB)
==================================================
downloaded 3.5 MB

* installing *source* package ‘stringi’ ...
** package ‘stringi’ successfully unpacked and MD5 sums checked
checking for local ICUDT_DIR... icu55/data
checking for R_HOME... /usr/local/Cellar/r/3.4.0_1/R.framework/Resources
checking for R... /usr/local/Cellar/r/3.4.0_1/R.framework/Resources/bin/R
checking for R >= 3.1.0 …
Run Code Online (Sandbox Code Playgroud)

xcode r stringi

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

从Redshift中删除当前日期的秒数(PostgreSQL)

在Amazon Redshift中,我希望将当前时间戳转换为0秒.那就是这样的:

2013-12-17 12:27:50
Run Code Online (Sandbox Code Playgroud)

对此:

2013-12-17 12:27:00
Run Code Online (Sandbox Code Playgroud)

我尝试过以下方法:

SELECT dateadd(second, -(date_part(second, getdate())), getdate());
ERROR:  function pg_catalog.date_add("unknown", double precision, timestamp without time zone) does not exist
HINT:  No function matches the given name and argument types. You may need to add explicit type casts.

SELECT dateadd(second, -cast(date_part(second, getdate()) as double precision), getdate());
ERROR:  function pg_catalog.date_add("unknown", double precision, timestamp without time zone) does not exist
HINT:  No function matches the given name and argument types. You may need to add explicit type …
Run Code Online (Sandbox Code Playgroud)

sql postgresql amazon-redshift

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

MongoDB聚合/展开/组/项目查询组合

我有以下格式的集合中的记录:

"_id" : "2013-05-23",
    "authors_who_sold_books" : [
        {
            "id" : "Charles Dickens",
            "num_sold" : 1,
            "customers" : [
                {
                   "time_bought" : 1368627290,
                   "customer_id" : 9715923
                }
            ]
        },
        {
            "id" : "JRR Tolkien",
            "num_sold" : 2,
            "customers" : [
                {
                    "date_bought" : 1368540890,
                    "customer_id" : 9872345
                },
                {
                    "date_bought" : 1368537290,
                    "customer_id" : 9163893
                }
            ]
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

每个日期都有一个记录,其中许多日期将包含同一作者.我正在查询返回以下内容:

{
    "_id" : "Charles Dickens",
    "num_sold" : 235,
    "customers" : [
        {
            "date_bought" : 1368627290,
            "customer_id" : 9715923
        },
        { …
Run Code Online (Sandbox Code Playgroud)

ruby mongodb aggregation-framework

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