我正在寻找一种方法来更改变量,该变量已在闪亮的应用程序中的反应性上下文之外初始化.
含义:我需要设置两个变量,具体取决于闪亮应用程序中发生的情况,TRUE或FALSE.
这需要从一个反应函数来完成.
例:
a <- FALSE
c <- FALSE
observeEvent(input$test, { #this triggers c to change to TRUE
a <- FALSE
c <- TRUE
)}
Run Code Online (Sandbox Code Playgroud)
有些用户点击了测试按钮label
> c
> TRUE
Run Code Online (Sandbox Code Playgroud) 我的资料
df1 <- structure(list(ID = c("A", "A", "A", "B", "B", "C"), c1 = 1:6,
c2 = 1:6, myDate = c("01.01.2015", "02.02.2014", "03.01.2014",
"09.09.2009", "10.10.2010", "06.06.2011")), .Names = c("ID",
"c1", "c2", "myDate"), class = "data.frame", row.names = c(NA,-6L))
Run Code Online (Sandbox Code Playgroud)
我想要的输出(注意:a df,保留所有列!):
ID c1 c2 myDate
A 3 3 03.01.2014
B 4 4 09.09.2009
C 6 6 06.06.2011
....
Run Code Online (Sandbox Code Playgroud)
我的密码
library(data.table)
setDT(df1)
df1[,myDate:=as.Date(myDate, "%d.%m.%Y")]
test2 <- df1[,.(myDate == min(myDate)), by = ID]
Run Code Online (Sandbox Code Playgroud)
这使我在相应的列(myDate)中逻辑匹配条件。但是,那还不df是,其他所有列都将丢失。我是该data.table软件包的新手,因此将不胜感激。
我在通过d3放置在传单地图上的圆上实现了工具提示,如下所示:
var tooltip = d3.select("body")
.append("div")
.attr("id", "mytooltip")
.style("position", "absolute")
.style("z-index", "10")
.style("visibility", "hidden")
.text("a simple tooltip");
feature.on("mouseover",function(d) {
d3.select(this)
.transition()
.ease("elastic")
.duration(500)
.attr('r', function (d){
return (d.properties.xy * 5)
.style("stroke", "black")
d3.select("#mytooltip")
.style("visibility", "visible")
.text(d.properties.xy1 + " " + d.properties.xy2)
});
feature.on("mousemove", function() {
return tooltip.style("top", (d3.event.pageY-10)+"px")
.style("left",(d3.event.pageX+10)+"px");
});
feature.on("mouseout",function(d) {
d3.select(this)
.transition()
.ease("elastic")
.duration(500)
.attr('r', function (d){
return (d.properties.xy);
})
.style("stroke", "none")
d3.select("#mytooltip")
.style("visibility", "hidden")
});
Run Code Online (Sandbox Code Playgroud)
我的特点是:
var feature = g.selectAll("circle")
.data(myData.features)
.enter()
//...
Run Code Online (Sandbox Code Playgroud)
我想知道如何设置显示的工具提示的样式?有没有办法给它一个背景,用粗体,斜体,不同的颜色等写东西?
headerBackTitle有没有办法设置的颜色Stacknavigator?
navigationOptions: ({ navigation }) => ({
...
headerBackTitle: "Back",
}),
...
Run Code Online (Sandbox Code Playgroud)
根据标题的背景颜色,标题headerBackTitle不可读。
如何检查 an 是否array包含 a date?
const dateArr = [new Date("12-12-2012"), new Date("06-06-2006"), new Date("01-01-2001")]
dateArr.includes(new Date("12-12-2012"))
Run Code Online (Sandbox Code Playgroud)
错误的
这是为什么?
我创建了一个这样的表
CREATE TABLE foo (
id serial CONSTRAINT id_pk PRIMARY KEY,
bar varchar(256),
test decimal(5,5)
);
Run Code Online (Sandbox Code Playgroud)
然后我想填充test列
INSERT INTO foo (test) VALUES (12345.12345)
Run Code Online (Sandbox Code Playgroud)
这给了我
数字字段溢出详细信息:精度为 5、小数位数为 5 的字段必须舍入到小于 1 的绝对值。
我不明白。但是,如果我将一列设置为decimal(5,5),则逗号左侧必须有五位数字,逗号右侧必须有五位数字。我有那个号码12345.12345。
为什么它给我这个错误?
在OS X 10.10上工作,从这里安装postgreSQL和PostGIS ,psql版本9.3.5.我很难让postgreSQL运行.
我在计算机上以管理员身份安装了软件包.我的用户名是christoph
我可以登录的唯一方法是:
$ psql -U postgres
Run Code Online (Sandbox Code Playgroud)
我想创建一个名为的用户christoph,作为我在计算机上的管理员名称.我试过(从终端,没有"登录到psql"):
$ sudo -u postgres createuser christoph
> sudo: unknown user: postgres
Run Code Online (Sandbox Code Playgroud)
然后我读了一下并尝试(从终端,没有"登录到psql"):
$ sudo -u _postgres createuser christoph
> Password: ****
> Could not connect to database postgres: FATAL: role "_postgres" does not exist
Run Code Online (Sandbox Code Playgroud)
为什么不工作?
我想在 R-Server 上安装 rgl,在 Ubuntu 上运行。在 bas 提示符下我安装了
sudo apt-get build-dep r-cran-rgl
Run Code Online (Sandbox Code Playgroud)
读取包列表...完成 构建依赖树 读取状态信息...完成 将安装以下额外包:
libglu1-mesa 将安装以下新包:
libglu1-mesa r-cran-rgl 0 升级,2 新安装, 0 删除,0 未升级。需要获得 1,645 kB 的档案。此操作后,将使用 3,875 kB 的额外磁盘空间。你要继续吗?[是/ 否] 是获取:1 http://archive.ubuntu.com/ubuntu/trusty/main libglu1-mesa amd64 9.0.0-2 [195 kB] 获取:2 http://archive.ubuntu.com/ Ubuntu的/trusty/universe r-cran-rgl amd64 0.93.996-1 [1,450 kB] 1 秒内获取 1,645 kB (1,047 kB/s) 选择以前未选择的包 libglu1-mesa:amd64。(正在读取数据库 ... 当前安装的 55586 个文件和目录。)准备解压 .../libglu1-mesa_9.0.0-2_amd64.deb ... 解压 libglu1-mesa:amd64 (9.0.0-2) ... 选择以前未选择的包 r-cran-rgl。准备解包 .../r-cran-rgl_0.93.996-1_amd64.deb ... 解包 r-cran-rgl (0.93.996-1) ... 设置 libglu1-mesa:amd64 (9.0.0-2) ) ... …
我有一个看起来像这样的坐标列表
myCoordinates
> [(2, -6), (21, 19)]
Run Code Online (Sandbox Code Playgroud)
我想将它们转换为shapely geometry对象,以便我可以对它们进行一些计算:
from shapely.geometry import Point
for i in myCoordinates:
c = [Point(i[0], i[1])]
print c
> [<shapely.geometry.point.Point object at 0x1044033d0>]
Run Code Online (Sandbox Code Playgroud)
然而,这只给了我一个(!)几何对象。
但我做的时候这个
circles = [Point(random.random(), random.random()).buffer(random.random() * 0.1) for i in range(3)]
Run Code Online (Sandbox Code Playgroud)
我得到三个几何对象。
print circles
> [<shapely.geometry.polygon.Polygon object at 0x1043f6890>, <shapely.geometry.polygon.Polygon object at 0x10442f8d0>, <shapely.geometry.polygon.Polygon object at 0x10442f910>]
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?为什么它只将一个 Point 转换为几何对象,而不是我列表中的两个?
我的数据框df看起来像这样
A B C D
1 78 12 43 12
2 23 12 42 13
3 14 42 11 99
4 49 94 27 72
Run Code Online (Sandbox Code Playgroud)
我需要将前两列转换为一个看起来完全像这样的列表:
[[1]]
[1] 78 12
[[2]]
[1] 23 12
[[3]]
[1] 14 42
[[4]]
[1] 49 94
Run Code Online (Sandbox Code Playgroud)
基本上是什么
list(c(78, 12), c(23, 12), c(14, 42), c(49, 94)
Run Code Online (Sandbox Code Playgroud)
会做.我试过这个
lapply(as.list(1:dim(df)[1]), function(x) df[x[1],])
Run Code Online (Sandbox Code Playgroud)
以及
lapply(as.list(1:nrow(df)), function(x) df)
Run Code Online (Sandbox Code Playgroud)
但那略有不同.有什么建议?
r ×4
javascript ×3
postgresql ×2
connection ×1
d3.js ×1
data.table ×1
dataframe ×1
geo ×1
geospatial ×1
list ×1
macos ×1
mouseevent ×1
opengl ×1
psql ×1
python ×1
react-native ×1
rgl ×1
shapely ×1
shiny ×1
sql ×1
sqldatatypes ×1
ubuntu ×1