我做了一个sidebarLayout in shiny,允许在溢出的情况下在mainPanel中滚动.sidebarPanel的位置保持固定,以便在向下滚动主面板时消失.但是,我希望它能够与 mainPanel 一起滚动,这样用户就不需要再次向上滚动来更改设置.我该怎么做呢?
基本设置:
ui = fluidPage(
tags$style(type='text/css', 'body { overflow-y: scroll; }'),
titlePanel(
# ...
),
sidebarLayout(
sidebarPanel(
# ...
width = 3),
mainPanel(
# ...
width = 9 )
))
server = function(input,output,session) {
# ...
}
shinyApp(ui=ui, server=server)
Run Code Online (Sandbox Code Playgroud) 我想对数据帧进行多项式特征展开-例如,使用(x1,x2,x3)的df的二次展开应使用(x1,x2,x3,x1 ^ 2,x2 ^ 2,x3 ^ 2,x1x2,x1x3,x2x3)。我目前正在使用,poly(df$x1, df$x2, df$x3, degree=2, raw=T)但是如果我有大量的列,这需要不必要的输入。(并且poly(df[,1:20], degree=2, raw=T)不起作用。)执行此操作的最佳方法是什么?
编辑:我有太多列poly(vector is too large错误)。得到它以一个简单的for循环工作:
polyexp = function(df){
df.polyexp = df
colnames = colnames(df)
for (i in 1:ncol(df)){
for (j in i:ncol(df)){
colnames = c(colnames, paste0(names(df)[i],'.',names(df)[j]))
df.polyexp = cbind(df.polyexp, df[,i]*df[,j])
}
}
names(df.polyexp) = colnames
return(df.polyexp)
}
Run Code Online (Sandbox Code Playgroud)
只需添加其他循环即可计算高阶项。
我无法使正射投影通过旋转d3.drag()。它没有响应:
var projection = d3.geoOrthographic()
.scale(100)
.translate([500, 300])
.rotate([55,-40])
.center([0,0])
.clipAngle(90);
var geoPath = d3.geoPath().projection(projection);
svg.call(d3.drag().on('drag', dragged));
function dragged() {
var transform = d3.event.transform;
var r = {x: ?(transform.x), y: ?(transform.y)};
projection.rotate([origin.x + r.x * k, origin.y + r.y]);
updatePaths(svg, graticule, geoPath);
};
Run Code Online (Sandbox Code Playgroud)
我尝试用dragged()a 替换,console.log()即使在这种情况下也没有任何反应(显然没有调用该函数)。我d3.zoom()以类似的方式实施,没有任何问题。我究竟做错了什么?
jsFiddle:https ://jsfiddle.net/sirallen/2L4ajskL/