问题标签 [spread]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
28943 浏览

r - how spread() in tidyr handles factor levels

I was manipulating my data and found that I did something wrong at some point in the process. When I explored the issue, the problem came down to the following behavior of spread() in the tidyr package.

Here's a demonstrative example. Let us say we have a data frame like the following.

What I wanted to do was to convert this long-formatted data frame into wide format. And I thought spread() is a way to go. The result, however, was not what I expected.

If factor1 is "A" and factor2 is "level2", the value should be 2, but the resulting wide format says 3. Apparently, the num is ordered by the alphabetical order of factor2 (level1 > level10 > level2) and is placed into the wide format. But when it is, the factor2 labels retains the same order as they appear in the original data frame (level1 > level2 > level10).

Could anyone explain why this happens (and/or where I can find relevant information)?

0 投票
1 回答
438 浏览

vb.net - Using FarPoint Spreads in User Controls

i am using FarPoint Spreads in a Windows Forms Application.

To show a spread on several Forms, I created a user control which contains one of my spreads and manages the representation.

However the ActiveSheet Property of the Spread seems to always return the first sheet when my user control is not focused - no matter which sheet is actually selected.

Since the Spread still has the "correct" Sheet selected when the user control is out of focus, the information which was the last active spread has to be accessible somehow. Do you have any ideas how i can get (and modify) the active sheet?

Thank you!

0 投票
2 回答
7931 浏览

unity3d - Unity NavMesh 让多个敌人走不同的路径

我正在开发一个游戏,我有多个敌人都朝着同一个目标移动。我遇到的问题是所有的敌人都走相同的路径到达这个目标,这导致了敌人的不切实际的“聚集”。我的问题是:我怎样才能让它们分散一点以产生拥挤效果?我目前正在使用 Unity 的内置 NavMesh 系统。我知道必须有一种方法来惩罚一个敌人使用的路径来鼓励其他敌人采取替代路径,但我只是不知道如何实现它。任何帮助表示赞赏!(另外,我最了解 C# 中的代码,但我可以在一定程度上理解 JavaScript)

0 投票
2 回答
40 浏览

html - #div1 的阴影在 #div2 上蔓延

我有两个浮动的 div。它们彼此足够接近。当我在该 div 上使用 box-shadow 时,其中一个阴影会扩散到另一个阴影上。我希望他们不要散布在他们的影子上。我试过z-index,没有希望..

我的代码在这里:

CSS:

干杯。

0 投票
1 回答
271 浏览

matlab - 使用加权随机数 MATLAB 将一个矩阵元素传播到另一个矩阵元素

所以我试图将一个由 poissrnd 生成的矩阵元素传播到另一个矩阵元素,使用一些更大(更宽?)的概率函数(例如 100 种不同权重的不同可能性)来绘制它们,看看传播后的波动是否下楼。在看到它不能正常工作(波动变大)之后,我试图在一个非常简单的例子中找出我做错了什么。经过很长时间的测试,我仍然无法理解问题所在。这个例子是这样的:

  1. 我生成带有 poissrnd 的向量和用于传播的向量(在开始时用零填充)
  2. poiss 向量中的每个元素告诉我从以下可能的选项中生成多少个数字(元素值的 0.1):[1,2,3] 和相应的权重 [0.2,0.5,0.2]
  3. 我将我得到的另一个向量传播到 3 个元素上:对应的(第 k 个),一个在对应的之前,一个在对应的之后(例如,如果 k=3,元素应该像这样传播:大多数应该进入另一个向量的第三个元素,其余的应该进入第二个和第一个元素)
  4. 绘制 0.1*poiss 向量和扩展后的向量,以比较波动是否下降

我生成加权数字的方式来自这个线程:MATLAB中的加权随机数

这是我正在使用的代码:

波动还是比较大的,我也分不清是哪里出了问题……这种情况下生成加权数的方法有问题吗?因为看起来不是这样。我从第一个向量中累积数据的方式似乎也很好。有没有另一种方法可以做到(所以我可以优化它以使用“更大”的概率函数)?

对不起我糟糕的英语。

[编辑]:

这是一个简单的图片来说明我的意思(我希望它可以理解)

0 投票
1 回答
12617 浏览

r - tidyr 中的 spread() 函数

我有一个股票价格的CRSP列表如下

一旦我使用tidyr::spread(x,TICKER,RETX),它会返回一个大多数值为 NA 的矩阵。是否有任何其他功能可以重新排列矩阵,在一列中列出每个股票价格?或者如何通过几行来实现它?

更新:我发现这是导致问题的 PERMNO 列。在我摆脱 PERMNO 列之后,出现了另一个问题:

所以,我只是随机选择消息中提到的两行

结果数据集非常脏,并且包含重复的系列。更好的解决方案是使用 PERMNO 作为密钥。这是我得到的

这很令人沮丧,但我终于得到了一些东西。无论如何用匹配的 TICKER 替换数字列名。这是一个演示

0 投票
2 回答
310 浏览

r - Confusion with Spread in tidyr

I have a dataframe as follows:

The head of the dataframe looks like:

What I want to do is then convert this format to the wide format and I tried to use spread function in tidyr.

Before using the spread function I created a new variable called row so as to remove the duplication error.

Now, I used the spread function as follows:

It seems to work but not exactly what I expected. The sample_date is a POSIXct object and when it is transformed the hour, minute and second doesn't show up so the output looks messy.

The column names seems to be right but not the values. For each date, I have values for conductivity, dissolved oxygen, salinity etc... Please help me what needs to be done to fix this issue.

Update:

The new data updated

Then used the formula Akrun recommended:

Sorry for posting large dataset.

The outut I got is as follows:

0 投票
1 回答
70 浏览

mysql - 关于 Galera 集群与传播工具包的混淆

我对 Galera 集群感兴趣。Galera 团队声称他们为各种 GCS 提供了基于适配器的灵活设计。

http://galeracluster.com/products/technology/他们的网站说“可以调整许多 gcs 实现,我们已经尝试了传播和我们的内部实现:vsbes 和双子座”但我几乎无法在网上找到任何关于实现的资源将spread(一个分布式工具包)与Galera集群相结合。

当我设置一个小型 galera 集群时,它可以正常工作。当我更新一个 Mysql 时,其他 mysqls 也得到了更新。我很困惑为什么 Galera 需要使用 spread 以及如何做到这一点。任何人都有如何使用 Galera 实现传播的经验?

非常感谢。

0 投票
1 回答
958 浏览

algorithm - How to calculate/measure the spread of coordinates in an area using python

My question seems a little bit vague. Put it in this way:

I have a set of coordinates(latitude and longitude) in an area(a city) and I want to quantify their separation. for example, they will get a low score if they are all at the same location(actually this should be the lowest score), and they will get a high score if they are very separated. For example, if you imagine how a set of charges would arrange themselves on a circular conducting plate, that should maximise their separation- this state would get the highest "separation" score.

As I have thousands of coordinates in the area, so I want to find a very efficient way to calculate that. Another problem I am thinking about is that: my coordinates are all latitude and longitude which cannot reflect the distance in meter correspondingly (i.e., at different latitudes, same longitude difference corresponds to different distance in meter), so should I also consider this in the spread calculation?

So does anyone know of any algorithms or approaches or theory I can use to do this, in the most mathematically respectable way? I am a newbie in this concept and in python, and I appreciate it a lot if you could give me some ideas.

Thank you all, Gladys

0 投票
2 回答
1843 浏览

r - 使用 spread 用 tidyr 创建两个值列

我有一个看起来像这样的数据框(请参阅链接)。我想采用下面产生的输出,并通过将色调变量分布在 n 和平均变量上更进一步。似乎这个主题可能与此有关,但我无法让它发挥作用: 是否可以在类似于 dcast 的 tidyr 的多个列上使用传播?

我希望最终表将源变量放在一列中,然后将tone-n 和tone-avg 变量放在列中。所以我希望列标题是“源” - “For - n” - “Against - n” “For -Avg” - “Against - Avg”。这是为了发布,而不是为了进一步计算,所以它是关于呈现数据的。以这种方式呈现数据对我来说似乎更直观。谢谢你。