您在寻找这样的东西吗?
pivot_longer
用于收集一列中的var以启用架子。
library(tidyverse)
tribble(
~ID, ~Time, ~Score, ~Var1, ~Var2, ~Var3,
1, 1, 100, 1, 2, 1,
1, 2, 150, 1, 2, 1,
2, 1, 200, 2, 3, 4,
2, 2, -10, 2, 3, 4,
2, 3, -70, 2, 3, 4,
3, 1, 100, 1, 2, 2,
3, 2, 200, 1, 2, 2
) |>
pivot_longer(starts_with("Var"), names_to = "var", values_to = "level") |>
ggplot(aes(Time, Score, group = level)) +
geom_line() +
facet_grid(level ~ var)
由 reprex软件包(v2.0.1)
function ofInterest(param: {p: DesiredType} & any){
// now we I'm totally sure that property 'p' exists in param
... = param.p
}
诀窍是将 param
定义为所需的特定类型和任何
之间的联合。这样,我们始终知道,该参数具有预期属性(IE),而我们仍然给客户端将功能与几乎任何形状的对象一起使用。
解决 @Alexy的回答,因为他似乎拒绝这样做...
SELECT
[Portfolio Company Key] AS portfolio_company_id,
[Quarter Date Key] AS quarter_date_id,
MAX(IIF([Measure Name] = 'Realized Value', Value, NULL)) AS realized_value,
MAX(IIF([Measure Name] = 'Unrealized Value',
Value, NULL)) AS unrealized_value,
MAX(IIF([Measure Name] = 'Total Fair Value', Value, NULL)) as total_fair_value,
MAX(IIF([Measure Name] = 'Multiple', Value, NULL)) as multiple,
MAX(IIF([Measure Name] = 'Gross IRR%', Value, NULL)) as gross_irr_percentage,
MAX(IIF([Measure Name] = 'Multiple used in valuation', Value, NULL)) as multiple_used_in_valuation,
MAX(IIF([Measure Name] = 'Net Financial Debt', Value, NULL)) as net_financial_debt,
MAX(IIF([Measure Name] = 'Net Financial Debt / EBITDA', Value, NULL)) as net_financial_debt_ebitda,
MAX(IIF([Measure Name] = 'EV', Value, NULL)) as enterprise_value,
MAX(IIF([Measure Name] = 'Fund Investment Cost', Value, NULL)) as fund_investment_cost
FROM
[dbo].[vQIRData]
WHERE
[MeasureType] = 'Fair Market Valuation'
GROUP BY
[Portfolio Company Key],
[Quarter Date Key]
ORDER BY
portfolio_company_id
请注意; 不同的
被删除,逻辑在功能上与使用 pivot
相同,但重复性稍微稍微重复,同时在更复杂的情况下也更加灵活。
我没有意识到JS需要与QML相同的语法来访问超类的属性。
以下作用很好:
obj.Component.destruction.connect(() => console.log('destruction!'))
如果您需要更精确或较低的睡眠时间,并且在等待时不要介意忙于周期(100%CPU核心使用),请考虑自己制作:
import time
def sleep(duration, get_now=time.perf_counter):
now = get_now()
end = now + duration
while now < end:
now = get_now()
当您提出疑问时,通过参考文献是一个好习惯。参考文献的目的是“观看”在状态和重建中进行更改,因此,通常,参考文献在窗口小部件的构建内部(commuterWidgets)。
总而言之,我试图弄清楚您为什么需要通过它。
我认为您需要这样的解决方案来阅读其他提供商,对吗?
您只能将裁判作为参数传递,以允许班级阅读其他提供商。通过参考文献,您可以创建参考文献和参考文献。但是,请注意在哪里使用Ref.Watch,因为不建议在提供商本身内使用它。看看RiverPod详细文档在这里
,您可以创建一个从提供者那里获取参考值的类,如下所示:
final createController = Provider((ref) => CreateProvider(ref));
class CreateProvider {
CreateProvider(this.ref) {
_init();
}
//Init to initialize values
_init() async {
}
//Ref to access other providers
final Ref ref;
}
拥有Ref,您可以访问在提供商范围内注册的其他提供商。
只需添加(单击)=“ Sidenav.toggle()”
在您的 Mat-Sidenav
标签中。都是
我看到已经几个月了,但是我遇到了同样的问题,这就是我学到的。
当您编译要调试的C/C ++程序时,您需要在调试模式下编译它,该模式告诉编译器在程序中包含调试符号。如果直接使用GCC编译,则可以使用 -G
标志。但是,我假设您正在使用cmake,在这种情况下,您只需添加 set(cmake_build_type debug)
> cmakelists.txt(在这里找到了其他一些选项)
可能不用说,但是在以这种方式进行重新编译后,您需要通过握住bootsel按钮并将其直接插入计算机(即,不是通过调试器PICO)来将新程序重新加载到目标PICO中。
我还发现,在执行此操作之后,将断点设置为仍然没有预期的特定行,我也必须实际指定文件的名称,例如: break main.c:15
在此数据中绘制数据并渲染组件时,您应该考虑到尚未可用或无效的数据的情况。
具体来说,您正在尝试渲染此数据:
return (
<div className="weather-feature">
<h1>hi</h1>
<p className="location">{weatherData.location.name}</p>
<p className="temp">{weatherData.current.temp_c}</p>
<p className="weather-desc">{weatherData.current.condition.text}</p>
</div>
但是它在第一个渲染上不会可用(即 weatherdata
首先没有位置
属性,因为您的默认值属性 usestate
值是 undefined
)。
有很多方法,您选择的最终取决于您的项目和偏好。
您可以使用“ noreferrer”>可选链接作为一种简单的保护在检查嵌套属性时相对于null引用:
return (
<div className="weather-feature">
<h1>hi</h1>
<p className="location">{weatherData.location?.name}</p>
<p className="temp">{weatherData.current?.temp_c}</p>
<p className="weather-desc">{weatherData.current?.condition?.text}</p>
</div>
或者,如果 weatherdata
还没有准备好,则可以返回其他内容。这种事情的好工具是 swr
:
import useSWR from 'swr'
function Weather()
{
const { weatherData, error } = useSWR(weatherUrl, fetcher)
if (error) return <div>failed to load</div>
if (!weatherData) return <div>loading...</div>
return <div>hello {weatherData.location}!</div>
}
作为附带说明,要考虑的事情是您的使用效果
依赖项:
useEffect(() => {
(
async function(){
try {
const response = await axios.get(weatherUrl);
setWeatherData(response.weatherData);
} catch (error) {
setError(error);
}
}
)();
}, [])
使用空的依赖性数组,您的效果仅在安装和卸载上运行。如果您希望它基于某些其他变量更改,请将这些变量添加到依赖项数组中。
我假设您希望您的程序每次运行时都会生成 num
Die Thr Ther Thr Ther Thr Ther Ther。您的代码看起来很不成熟(不是灰心),所以我认为您仍在学习。荣誉。
您可以使用以下方式:
import random
def throwDies(num):
for c in range(num):
throw = random.randint(1,6) #gets a random number between 1 and 6 inclusive
print("Throw number %d is #%d"%(c,throw))
x = int(input("Enter the number of throws to make: "))
throwDies(x)
我重现了您的问题,并出现了同样的错误。我为修复它所做的只是在单击元素之前滚动到元素。
尝试一下
driver.find_element(By.XPATH, "//div[@id=\'Content_C164_Col00\']/div/div/div[2]/div/div/div/div/div/button/span/span/span[3]").click()
driver.find_elements(By.CLASS_NAME, "fxs_c_datepicker_button")[1].click()
actions = ActionChains(driver)
button = driver.find_element(By.CLASS_NAME, "fxs_btn.fxs_btn_cta.fxs_fRight")
actions.move_to_element(button)
button.click()
,我还注意到几秒钟后,网站上出现了弹出窗口。确保单击一个,因为它可能会拦截单击“应用”按钮。
更新:
这是从打开网站到选择日期并单击“应用”按钮的完整代码。
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
# Opening browser and maximizing it
driver.get("https://www.fxstreet.com/economic-calendar")
driver.maximize_window()
# Click 'Continue to site'
driver.find_element(By.CLASS_NAME, "fxs_prestitial-continue").click()
# Wait until popup appears and cancel it
driver.implicitly_wait(10)
driver.find_element(By.XPATH, "//button[@id='onesignal-slidedown-cancel-button' and text()='Cancel']").click()
# Click the datepicker button and choose date
driver.find_element(By.XPATH, "//div[@id=\'Content_C164_Col00\']/div/div/div[2]/div/div/div/div/div/button/span/span/span[3]").click()
driver.find_elements(By.CLASS_NAME, "fxs_c_datepicker_button")[1].click()
# Creating actions instance
actions = ActionChains(driver)
# Scrolling to 'Apply' button and clicking it
button = driver.find_element(By.CLASS_NAME, "fxs_btn.fxs_btn_cta.fxs_fRight")
actions.move_to_element(button)
button.click()
一个简单的铅测试将使您在这种情况下要求无效的结果
SELECT *,
CASE WHEN LEAD(HITS) OVER (PARTITION BY ID ORDER BY HITS) IS NULL THEN 1 ELSE 0 END 'IN&OUT'
FROM T
意味着此ID没有以后的输入。
为了绘制它,通常需要以较长的格式获得数据。
tidyverse
- 使用pivot_longer
,然后ggplot
看起来像:plot:
数据:
In order to plot it you'd typically need to have the data in a long format. A
tidyverse
-solution usingpivot_longer
and thenggplot
could look like:Plot:
Data:
如何在r中绘制我的tibble,如下所示?