我不是在 Mac 上复制这个答案的行为。我希望在自己的行上拆分元素。任何的想法?
$ echo "string1:string2:string3:string4:string5" | sed s/:/\\n/g
string1nstring2nstring3nstring4nstring5
Run Code Online (Sandbox Code Playgroud) Cytoscape 的新功能。我有一张图,其中包含主导主网络和一些与我要删除的主网络未连接的较小网络。浏览文档我看不到明显的解决方案。我猜测可能需要一种自定义方法来循环所有节点,检查它们与主集群中最中心节点的图形距离,如果该距离未定义,则删除该节点以及它连接到的所有其他节点。但渴望从其他有更多图书馆经验的人那里得到指导。非常感谢任何建议。我注意到这个未回答但相关的问题。
这是一个示例图。虽然我无法在jsfiddle上工作,但这里是工作版本:
<!DOCTYPE>
<html>
<head>
<title>cytoscape-dagre.js demo</title>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
<script src="https://unpkg.com/cytoscape/dist/cytoscape.min.js"></script>
<script src="https://unpkg.com/dagre@0.7.4/dist/dagre.js"></script>
<script src="cytoscape-dagre.js"></script>
<style>
#cy {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
z-index: 999;
}
</style>
<script>
window.addEventListener('DOMContentLoaded', function(){
var cy = window.cy = cytoscape({
container: document.getElementById('cy'),
boxSelectionEnabled: false,
autounselectify: true,
layout: {
name: 'dagre'
},
style: [
{
selector: 'node',
style: {
'background-color': '#11479e'
}
},
{
selector: 'edge',
style: {
'width': …Run Code Online (Sandbox Code Playgroud) 是否可以HTMLInternalDocument通过它们的id和class信息从对象中提取元素?例如让我们拿一个文件:
<!DOCTYPE html>
<html>
<head>
<title>R XML test</title>
</head>
<body>
<div id="obj1">
<p id="txt1">quidquid</p>
<p id="txt2">Latine dictum</p>
</div>
<div class="mystuff">
<p>sit altum</p>
<p>videtur</p>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
并读入R如下:
require(XML)
file <- "C:/filepath/index.html"
datain <- htmlTreeParse(readLines(file), useInternalNodes = TRUE)
Run Code Online (Sandbox Code Playgroud)
我想提取元素id='txt2'和的内容class='mystuff'。
我尝试了各种方法,但均未成功,它们似乎都遍历了繁琐的工作。是否有使用class / id的快捷方式?我有一个想法,它可能涉及先使用getNodeSet某个应用方法(例如xmlApply&xmlAttrs),然后再尝试使用任何方法。感谢任何指针。
我想将以下文本附加到Linux中的文件:
echo He said "I can't append this" >> file.txt
cat file.txt
He said I can't append this
Run Code Online (Sandbox Code Playgroud)
以下适用于Ubuntu但不适用于Yocto(Poky).
root@system:~/# x='abc'
root@system:~/# y=''
root@system:~/# [[ $(echo $x) != '' ]] && echo true
true
root@system:~/# [[ $(echo $y) != '' ]] && echo true
sh: : unknown operand
Run Code Online (Sandbox Code Playgroud)
在Ubuntu中,最后一行不返回任何内容(如预期的那样).任何想法为什么它在Yocto中抛出错误?
我需要增加已旋转的轴刻度标签的空间。下面的代码说明了,这是一个有效的 jsfiddle。这可以通过 crossfilter 实现还是我们必须进入 d3?
HTML
<script src="https://rawgit.com/square/crossfilter/master/crossfilter.js"></script>
<script src="https://d3js.org/d3.v3.js"></script>
<script src="https://rawgit.com/dc-js/dc.js/develop/dc.js"></script>
<span>
<div id="petchart"></div>
</span>
Run Code Online (Sandbox Code Playgroud)
JS
j = [{'pet': 'Felis catus'}, {'pet': 'Canis lupus familiaris'}, {'pet': 'none'},
{'pet': 'Felis catus'}, {'pet': 'Melopsittacus undulatus'},
{'pet': 'Canis lupus familiaris'}, {'pet': 'Canis lupus familiaris'}];
cf = crossfilter(j);
pets_chart = dc.barChart("#petchart");
petDimension = cf.dimension(function(d) {return d.pet;});
petCountGroup = petDimension.group();
pets_chart
.dimension(petDimension)
.group(petCountGroup)
.x(d3.scale.ordinal().domain(["Felis catus","Canis lupus familiaris","Melopsittacus undulatus","none"]))
.xUnits(dc.units.ordinal)
.width(300).height(250)
.colors(['#1f77b4']).colorAccessor(function(d, i){ return i; })
.xAxis().ticks(2);
dc.renderAll();
Run Code Online (Sandbox Code Playgroud)
CSS
g .x.axis text { …Run Code Online (Sandbox Code Playgroud) 与此OP相同的问题,但必须是一个单独的原因.
以下脚本:
#!/bin/sh
arr=("cat" "dog" "bird")
Run Code Online (Sandbox Code Playgroud)
以交互方式工作(debian)但在crontab调用时失败:
/bin/sh: 2: /path/zero_check.sh: Syntax error: "(" unexpected
Run Code Online (Sandbox Code Playgroud)
我试过#!/bin/bashshebang,并且声明数组declare -a arr=("cat" "dog" "bird"),没有效果.
知道为什么吗?
我想在可能的情况下将标签精确地绘制在点上方(没有重叠),但 ggrepel 似乎坚持在略高于或略低于点的情况下绘制。例如
require(ggplot); require(ggrepel)
ggplot(iris[1:10,], aes(Sepal.Length, Sepal.Width)) +
geom_point(pch=1, size=8) +
geom_text_repel(aes(label=Species), segment.color=NA,
point.padding=unit(0, "lines"))
Run Code Online (Sandbox Code Playgroud)
您当然可以减少force争论,但是标签在重叠时不会相互排斥。
partition_filter中的参数未能wr.s3.read_parquet()过滤 S3 上的分区 Parquet 数据集。这是一个可重现的示例(可能需要正确配置的boto3_session参数):
数据集设置:
\nimport pandas as pd\nimport awswrangler as wr\nimport boto3\n\ns3_path = "s3://bucket-name/folder"\n\ndf = pd.DataFrame({"val": [1,3,2,5], "date": [\'2021-04-01\',\'2021-04-01\',\'2021-04-02\',\'2021-04-03\']})\n\nwr.s3.to_parquet(\n df = df,\n path = s3_path,\n dataset = True,\n partition_cols = [\'date\']\n)\n#> {\'paths\': [\'s3://bucket-name/folder/date=2021-04-01/38399541e6fe4fa7866181479dd28e8e.snappy.parquet\',\n#> \'s3://bucket-name/folder/date=2021-04-02/0a556212b5f941c7aa3c3775d2387419.snappy.parquet\',\n#> \'s3://bucket-name/folder/date=2021-04-03/cb71397bea104787a50a90b078d564bd.snappy.parquet\'],\n#> \'partitions_values\': {\'s3://aardvark-gdelt/headlines/date=2021-04-01/\': [\'2021-04-01\'],\n#> \'s3://bucket-name/folder/date=2021-04-02/\': [\'2021-04-02\'],\n#> \'s3://bucket-name/folder/date=2021-04-03/\': [\'2021-04-03\']}}\nRun Code Online (Sandbox Code Playgroud)\n然后可以在控制台中查看 S3 数据:
\n\n但使用日期过滤器读回会返回 4 条记录:
\nwr.s3.read_parquet(path = s3_path,\n partition_filter = lambda x: x["date"] >= "2021-04-02"\n)\n#> val\n#> 0 1\n#> 1 3\n#> 2 2\n#> 3 5\n …Run Code Online (Sandbox Code Playgroud) 我似乎无法从空间对象的图中移除边距.在这种情况下,发布到其他类型图表的解决方案似乎不起作用.Par mai和oma参数也失败了.非常感谢您的建议.
library(maptools)
data(wrld_simpl)
bbox = cbind(c(179,179,-179,-179,179), c(89,-89,-89,89,89))
png('test.png', width=1000, height=500)
par(mai=c(0,0,0,0), oma=c(0,0,0,0))
plot(wrld_simpl, col='grey', bg='white', border=NA)
lines(bbox, col='red', lwd=3)
dev.off()
browseURL('test.png')
Run Code Online (Sandbox Code Playgroud)
红色边界框应该在图形输出边框内部绘制.
