情况
我有一个df包含两个变量的数据框,ReportYear和Salary.
dput(df)
structure(list(ReportYear = structure(c(2012, 2012, 2012, 2012,
2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012,
2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012,
2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012,
2012, 2012, 2012, 2012, 2012), class = c("summaryDefault", "table"
)), Salary = structure(c(198000, 495500, 745000, 1417000, 1662000,
5483000, 260100, 460000, 697000, 1595000, 2160000, 5778000, 331000,
790000, 1260000, 1736000, 1670000, 9310000, 270000, 459500, …Run Code Online (Sandbox Code Playgroud) 给出一个 shinydashboard
ui.R
library(shinydashboard)
library(shiny)
dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
valueBoxOutput(outputId = "vb")
)
)
Run Code Online (Sandbox Code Playgroud)
server.R
library(shinydashboard)
library(shiny)
function(input, output, session) {
output$vb <- renderValueBox({
valueBox(subtitle = "Hello",
value = "hi",
width = 6,
color="blue"
)
})
}
Run Code Online (Sandbox Code Playgroud)
题
是否有可能改变valueBox?的高度?
我尝试过使用tags但无法让它们工作,所以我显然错过了一些东西:
dashboardPage(
dashboardHeader(),
dashboardSidebar(
# tags$head(tags$style("#vb{height:500px}"))
),
dashboardBody(
# tags$head(tags$style("#vb{height:500px}")),
# div(style="height: 500px",
# valueBoxOutput(outputId = "vb")
# )
valueBoxOutput(outputId = "vb")
)
)
Run Code Online (Sandbox Code Playgroud) How do you define the material on a custom geometry from vertex data, so that it renders the same as 'typical' SCNNodes?
In this scene there are
The red and blue spheres render as I would expect. The two points / spheres in the custom geometry are black.
Why? …
我在MS Access 365中开发了一个数据库,创建了所有表和对象,并成功地将数据库(使用向导)拆分为前端和后端.
前端打开并运行良好.
但是,我无法打开后端进行设计更改.我得到的错误是:
安全通知http://i62.tinypic.com/2lsjw45.png
我已经搜索并阅读了有关创建数字签名的信息,试图在拆分之前在本地创建一个"签名并打包"数据库,但是还没有任何工作.
有谁知道如何让它工作,所以我可以打开后端数据库文件?
数据
在这里,我使用mongolite将虚拟数据插入到测试 mongodb 数据库中:
library(mongolite)
## create dummy data
df <- data.frame(id = c(1,2,3,4),
region = c("r1", "r1", "r2", "r2"))
> df
id region
1 1 r1
2 2 r1
3 3 r2
4 4 r2
## insert into database
mong <- mongo(collection = "test", db = "test", url = "mongodb://localhost")
mong$insert(df)
Run Code Online (Sandbox Code Playgroud)
题
如何使用该aggregate方法查找每个区域的记录数?
Mongo Shell 查询
此查询在 mongo shell 中运行时返回正确答案
db.test.aggregate({ $group : { _id : "$region", number_records : { $sum : 1}}})
Run Code Online (Sandbox Code Playgroud)
我现在如何将其翻译成正确的语法mongolite …
数据
给定一个数据框架
df <- data.frame("id"=c(1,2,3), "a"=c(10.0, 11.2, 12.3),"b"=c(10.1, 11.9, 12.9))
> df
id a b
1 1 10.0 10.1
2 2 11.2 11.9
3 3 12.3 12.9
> str(df)
'data.frame': 3 obs. of 3 variables:
$ id: num 1 2 3
$ a : num 10 11.2 12.3
$ b : num 10.1 11.9 12.9
Run Code Online (Sandbox Code Playgroud)
题
对第一行进行子集化时,将删除in列中的.0小数部分10.0a
> df[1,]
id a b
1 1 10 10.1
> str(df[1,])
'data.frame': 1 obs. of 3 variables:
$ id: …Run Code Online (Sandbox Code Playgroud) 题
使用mongolite包R,如何查询给定日期的数据库?
示例数据
考虑一个test包含两个条目的集合
library(mongolite)
## create dummy data
df <- data.frame(id = c(1,2),
dte = as.POSIXct(c("2015-01-01","2015-01-02")))
> df
id dte
1 1 2015-01-01
2 2 2015-01-02
## insert into database
mong <- mongo(collection = "test", db = "test", url = "mongodb://localhost")
mong$insert(df)
Run Code Online (Sandbox Code Playgroud)
Mongo shell查询
要在给定日期之后查找条目,我会使用
db.test.find({"dte" : {"$gt" : new ISODate("2015-01-01")}})
Run Code Online (Sandbox Code Playgroud)
如何在R使用中重现此查询mongolite?
R尝试
到目前为止我已经尝试过
qry <- paste0('{"dte" : {"$gt" : new ISODate("2015-01-01")}}')
mong$find(qry)
Error: Invalid JSON object: {"dte" : …Run Code Online (Sandbox Code Playgroud) 是否可以boost::geometry使用 a定义对象boost::variant?
此代码无法编译,因为它不喜欢在geom::read_wkt().
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/linestring.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/variant/variant.hpp>
#include <boost/variant.hpp>
namespace geom = boost::geometry;
typedef geom::model::d2::point_xy<double> point_type;
typedef geom::model::linestring<point_type> linestring_type;
typedef geom::model::polygon<point_type> polygon_type;
typedef boost::variant
<
point_type,
linestring_type,
polygon_type,
>
geometryVariant;
int main() {
std::string wkt = "LINESTRING(0 0, 1 1, 2, 2)";
geometryVariant gv;
geom::read_wkt(wkt, gv);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我明确定义linestring_type它工作正常
int main() {
std::string wkt = "LINESTRING(0 0, 1 1, 2, 2)";
linestring_type ls;
geom::read_wkt(wkt, ls); …Run Code Online (Sandbox Code Playgroud)