落日海湾

文章 评论 浏览 28

落日海湾 2025-02-20 23:56:13

您只需使用rlang软件包即可从rlang软件包中使用curly-curly {{}}来实现这一目标的一种方法,这是一个安全的选项,

library(tidyr)
library(rlang)

iris <- tibble::as_tibble(iris)


# using curly curly from {rlang} ------------------------------------------

func <- function(df, keycols) {
  
  new_df <- unite(df, "key", {{keycols}}, sep = " ", remove = FALSE, na.rm = FALSE)
  
  return(new_df)
  
}

func(iris, c(Sepal.Length, Sepal.Width)) # passing directly the columns

#> # A tibble: 150 × 6
#>    key     Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#>    <chr>          <dbl>       <dbl>        <dbl>       <dbl> <fct>  
#>  1 5.1 3.5          5.1         3.5          1.4         0.2 setosa 
#>  2 4.9 3            4.9         3            1.4         0.2 setosa 
#>  3 4.7 3.2          4.7         3.2          1.3         0.2 setosa 
#>  4 4.6 3.1          4.6         3.1          1.5         0.2 setosa 
#>  5 5 3.6            5           3.6          1.4         0.2 setosa 
#>  6 5.4 3.9          5.4         3.9          1.7         0.4 setosa 
#>  7 4.6 3.4          4.6         3.4          1.4         0.3 setosa 
#>  8 5 3.4            5           3.4          1.5         0.2 setosa 
#>  9 4.4 2.9          4.4         2.9          1.4         0.2 setosa 
#> 10 4.9 3.1          4.9         3.1          1.5         0.1 setosa 
#> # … with 140 more rows

func(iris, c("Sepal.Length", "Sepal.Width")) # passing columns as character vector

#> # A tibble: 150 × 6
#>    key     Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#>    <chr>          <dbl>       <dbl>        <dbl>       <dbl> <fct>  
#>  1 5.1 3.5          5.1         3.5          1.4         0.2 setosa 
#>  2 4.9 3            4.9         3            1.4         0.2 setosa 
#>  3 4.7 3.2          4.7         3.2          1.3         0.2 setosa 
#>  4 4.6 3.1          4.6         3.1          1.5         0.2 setosa 
#>  5 5 3.6            5           3.6          1.4         0.2 setosa 
#>  6 5.4 3.9          5.4         3.9          1.7         0.4 setosa 
#>  7 4.6 3.4          4.6         3.4          1.4         0.3 setosa 
#>  8 5 3.4            5           3.4          1.5         0.2 setosa 
#>  9 4.4 2.9          4.4         2.9          1.4         0.2 setosa 
#> 10 4.9 3.1          4.9         3.1          1.5         0.1 setosa 
#> # … with 140 more rows

在2022-07-08创建的 reprex软件包(v2.0.1)

要了解该解决方案的原因和方式,请在此处查看用dplyr < /p>

One way you could achieve this simply by using curly-curly {{}} from rlang package which is a safe option,

library(tidyr)
library(rlang)

iris <- tibble::as_tibble(iris)


# using curly curly from {rlang} ------------------------------------------

func <- function(df, keycols) {
  
  new_df <- unite(df, "key", {{keycols}}, sep = " ", remove = FALSE, na.rm = FALSE)
  
  return(new_df)
  
}

func(iris, c(Sepal.Length, Sepal.Width)) # passing directly the columns

#> # A tibble: 150 × 6
#>    key     Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#>    <chr>          <dbl>       <dbl>        <dbl>       <dbl> <fct>  
#>  1 5.1 3.5          5.1         3.5          1.4         0.2 setosa 
#>  2 4.9 3            4.9         3            1.4         0.2 setosa 
#>  3 4.7 3.2          4.7         3.2          1.3         0.2 setosa 
#>  4 4.6 3.1          4.6         3.1          1.5         0.2 setosa 
#>  5 5 3.6            5           3.6          1.4         0.2 setosa 
#>  6 5.4 3.9          5.4         3.9          1.7         0.4 setosa 
#>  7 4.6 3.4          4.6         3.4          1.4         0.3 setosa 
#>  8 5 3.4            5           3.4          1.5         0.2 setosa 
#>  9 4.4 2.9          4.4         2.9          1.4         0.2 setosa 
#> 10 4.9 3.1          4.9         3.1          1.5         0.1 setosa 
#> # … with 140 more rows

func(iris, c("Sepal.Length", "Sepal.Width")) # passing columns as character vector

#> # A tibble: 150 × 6
#>    key     Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#>    <chr>          <dbl>       <dbl>        <dbl>       <dbl> <fct>  
#>  1 5.1 3.5          5.1         3.5          1.4         0.2 setosa 
#>  2 4.9 3            4.9         3            1.4         0.2 setosa 
#>  3 4.7 3.2          4.7         3.2          1.3         0.2 setosa 
#>  4 4.6 3.1          4.6         3.1          1.5         0.2 setosa 
#>  5 5 3.6            5           3.6          1.4         0.2 setosa 
#>  6 5.4 3.9          5.4         3.9          1.7         0.4 setosa 
#>  7 4.6 3.4          4.6         3.4          1.4         0.3 setosa 
#>  8 5 3.4            5           3.4          1.5         0.2 setosa 
#>  9 4.4 2.9          4.4         2.9          1.4         0.2 setosa 
#> 10 4.9 3.1          4.9         3.1          1.5         0.1 setosa 
#> # … with 140 more rows

Created on 2022-07-08 by the reprex package (v2.0.1)

To understand why and how this solution works, look here programming with dplyr

R:将字符向量作为函数参数

落日海湾 2025-02-20 17:04:18

Micronaut在编译时生成开放式API定义,因此不可能具有动态属性。唯一的方法是设置这些值是使用注释 https://micronaut-projects.github.io/micronaut-openapi/latest/guide/guide/index.html

Micronaut generates the Open-API definition at the compilation time, so it's not possible to have dynamic properties. The only way is to set those values is to use annotations https://micronaut-projects.github.io/micronaut-openapi/latest/guide/index.html

如何通过代码设置OpenAPI配置,而不是在Micronaut中使用注释

落日海湾 2025-02-20 14:18:16

经过数小时的研究,我终于找到了满足我需求的代码。

.woocommerce div.product div.images a img {
height: 400px;
object-fit: contain;
object-position: top;
}

After many hours of research I finally found the code that meet my needs.

.woocommerce div.product div.images a img {
height: 400px;
object-fit: contain;
object-position: top;
}

如何将不同尺寸的图像适合“框”在WooCommerce中,单产品页面图像滑块

落日海湾 2025-02-19 08:46:26

您需要根据所需的顺序使用案例语句来得出新的列,并使用该列来对下面的结果进行排序。

select Name,col1,col2,col3
from(
Select *,case when Name='John' then 1
              when Name='paul' then 2
              when Name= 'Greg' then 3
              when Name = 'Jane' then 4
              else 5
        end as sortid
from test
) a
order by sortid, Name

You Need to derive a new column as per the required order using case statement and use that column to sort the result like below.

select Name,col1,col2,col3
from(
Select *,case when Name='John' then 1
              when Name='paul' then 2
              when Name= 'Greg' then 3
              when Name = 'Jane' then 4
              else 5
        end as sortid
from test
) a
order by sortid, Name

通过多列订购

落日海湾 2025-02-19 07:13:42

这对我有用!我从循环中取出gsap.timeline,并使用了gsap.set内部循环延迟。

let cT;

let changeText = (hold) => {
  let cText = gsap.utils.toArray('.text');

  cT = gsap.timeline({
    repeat: -1,
    defaults: {
      ease: 'none',
      duration: 0.5,
    },
  });

  gsap.set(cText, { autoAlpha: 1 });

  cText.forEach((obj, i) => {
    gsap.set(cText, {
      delay: 0.5 * i + hold * i,
      repeatDelay: (cText.length - 1) * (0.5 + hold) - 0.5
    });
    cT.from(obj, { yPercent: -60, opacity: 0 });
    cT.to(obj, { yPercent: 60, opacity: 0 }, '+=' + hold);
  });
};

changeText(3);


let pauseBtn = document.getElementById('pause');

pauseBtn.onclick = function () {
  cT.paused(!cT.paused());
  pauseBtn.innerHTML = cT.paused() ? 'Play' : 'Pause';
};
.side-text {
  position: relative;
}

.text {
  position: absolute;
  visibility: hidden;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.10.4/gsap.min.js"></script>
     <div class="side-text">
            <h5 class="text">First</h5>
            <h5 class="text">Second</h5>
            <h5 class="text">Third</h5>
            <h5 class="text">Fourth</h5>
          </div>
          
       <div class="text-center">
      <button type="button" id="pause" class="btn btn-primary">Pause</button>
    </div>

This worked for me! I took out gsap.timeline from the loop and used gsap.set inside loop for delays.

let cT;

let changeText = (hold) => {
  let cText = gsap.utils.toArray('.text');

  cT = gsap.timeline({
    repeat: -1,
    defaults: {
      ease: 'none',
      duration: 0.5,
    },
  });

  gsap.set(cText, { autoAlpha: 1 });

  cText.forEach((obj, i) => {
    gsap.set(cText, {
      delay: 0.5 * i + hold * i,
      repeatDelay: (cText.length - 1) * (0.5 + hold) - 0.5
    });
    cT.from(obj, { yPercent: -60, opacity: 0 });
    cT.to(obj, { yPercent: 60, opacity: 0 }, '+=' + hold);
  });
};

changeText(3);


let pauseBtn = document.getElementById('pause');

pauseBtn.onclick = function () {
  cT.paused(!cT.paused());
  pauseBtn.innerHTML = cT.paused() ? 'Play' : 'Pause';
};
.side-text {
  position: relative;
}

.text {
  position: absolute;
  visibility: hidden;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.10.4/gsap.min.js"></script>
     <div class="side-text">
            <h5 class="text">First</h5>
            <h5 class="text">Second</h5>
            <h5 class="text">Third</h5>
            <h5 class="text">Fourth</h5>
          </div>
          
       <div class="text-center">
      <button type="button" id="pause" class="btn btn-primary">Pause</button>
    </div>

暂停动画在GSAP(Greensock)不起作用

落日海湾 2025-02-18 18:57:59

当我没有为我使用的平台安装Firebase(带有FlutterFire)时,我收到了此错误。例如,我已经为iOS和Android配置了Firebase,但没有为Web配置,并且当我尝试通过Chrome加载应用程序时,会丢弃此错误。

尝试从应用程序目录中的“ FlutterFire配置”,这应该使您可以解决此问题!

I received this error when I didn't install Firebase (with Flutterfire) for the platform I was using. For example, I had configured Firebase for iOS and Android but not for Web, and when I tried to load my app via Chrome, it would throw this error.

Try 'flutterfire configure' from your app directory which should allow you to resolve this!

未为Windows配置的DefaultFireBaseOptions

落日海湾 2025-02-18 17:14:53

编辑:问题是在样式属性中:AlignItems:'Center'。当那被带走时,导航再次开始工作。

我首先确认您的自定义导航器可与本机堆栈一起使用。本机堆栈使用OS的导航在页面之间导航。这个问题可能在于您的自定义导航器和OS的本机导航器发生冲突。

考虑使用@react-navigation/stack在此处查看这是否会改变导航的行为。

这是您对
这是

Edit: The problem was in the style property: alignItems: 'center'. When that was taken away, navigation began working again.

I would first confirm that your custom made navigator works with native-stack. Native stack uses the OS' navigation to navigate between pages. The issue may lie in your custom navigator and the OS' native navigator to be in conflict.

Consider using @react-navigation/stack here to see if this changes the behavior of your navigation.

Here is a relevant post for you to browse.
Here is the documentation on stack-navigator.

无法使用React Native Navigation渲染导航屏幕,堆栈导航器

落日海湾 2025-02-18 09:06:13

转动TABPANEL和主组件分开。
这样,问题将得到解决。

const TabPanel = (props) => {...}
const MainComponent = () =>{.... import the TabPanel, and the tabs}

反应MUI

Turn the TabPanel and the main component separated.
In this way the issue will be fixed.

const TabPanel = (props) => {...}
const MainComponent = () =>{.... import the TabPanel, and the tabs}

React MUI

React MUI选项卡组件会导致重新渲染并删除儿童状态

落日海湾 2025-02-17 22:38:44

当您要模糊的元素内部有一个元素时,这是不可能的。您可以使用IT相对的容器元素位置,将两个元素彼此隔开,并将它们放置在绝对的位置。

.container {
  position: relative;
  /* style to your needs */
  width: 100px;
  height: 100px;
}

.blur {
  position: absolute;
  
  /* some styling */
  width: 100%;
  height: 100%;
  background: lime;
  filter: blur(5px);
}

.content {
  position: absolute;
  
  /* some styling */
  font-family: sans-serif;
  top: 50%;
  left: 50%;
  transform: translatex(-50%) translatey(-50%);
  margin: 0;
}
<div class="container">
  <div class="blur"></div>
  <p class="content">My not blurred out content</p>
</div>

It's not possible when you have an element inside the element you want to blur. You could use a container element position it relative, place two elements next to each other inside it and position them absolute.

.container {
  position: relative;
  /* style to your needs */
  width: 100px;
  height: 100px;
}

.blur {
  position: absolute;
  
  /* some styling */
  width: 100%;
  height: 100%;
  background: lime;
  filter: blur(5px);
}

.content {
  position: absolute;
  
  /* some styling */
  font-family: sans-serif;
  top: 50%;
  left: 50%;
  transform: translatex(-50%) translatey(-50%);
  margin: 0;
}
<div class="container">
  <div class="blur"></div>
  <p class="content">My not blurred out content</p>
</div>

模糊的父母,但孩子不继承HTML CSS

落日海湾 2025-02-17 21:50:45

为了获得错误,您的第一行在第三个代码段中应如下:

 hm <- pheatmap(test, show_colnames=FALSE, silent=TRUE)

简单解决方案:

 library(pheatmap)
 library(grid)

 test = matrix(rnorm(200), 20, 10)
 test[1:10, seq(1, 10, 2)] = test[1:10, seq(1, 10, 2)] + 3
 test[11:20, seq(2, 10, 2)] = test[11:20, seq(2, 10, 2)] + 2
 test[15:20, seq(2, 10, 2)] = test[15:20, seq(2, 10, 2)] + 4
 colnames(test) = paste("Test", 1:10, sep = "")
 rownames(test) = paste("Gene", 1:20, sep = "")

 col_names = list(" ", " ", " ", " ", " ", " ", " ", " ", " ", " ") # use one space
 hm <- pheatmap(test, show_colnames=TRUE, silent=TRUE, labels_col = col_names)
 hm$gtable$grobs[[5]]$gp$col <- rep(c("black", "red"), each = 10)
 leg <- legendGrob(c("Exp1", "Exp2"), nrow = 2, pch = 15, gp = gpar(fontsize = 10, col = c("black", "red")))
 hm2 <- arrangeGrob(hm$gtable, leg, ncol = 2, widths = c(5,1))
 grid.draw(hm2)

To get the error your first line in the third code snippet should be as follows:

 hm <- pheatmap(test, show_colnames=FALSE, silent=TRUE)

The simple solution:

 library(pheatmap)
 library(grid)

 test = matrix(rnorm(200), 20, 10)
 test[1:10, seq(1, 10, 2)] = test[1:10, seq(1, 10, 2)] + 3
 test[11:20, seq(2, 10, 2)] = test[11:20, seq(2, 10, 2)] + 2
 test[15:20, seq(2, 10, 2)] = test[15:20, seq(2, 10, 2)] + 4
 colnames(test) = paste("Test", 1:10, sep = "")
 rownames(test) = paste("Gene", 1:20, sep = "")

 col_names = list(" ", " ", " ", " ", " ", " ", " ", " ", " ", " ") # use one space
 hm <- pheatmap(test, show_colnames=TRUE, silent=TRUE, labels_col = col_names)
 hm$gtable$grobs[[5]]$gp$col <- rep(c("black", "red"), each = 10)
 leg <- legendGrob(c("Exp1", "Exp2"), nrow = 2, pch = 15, gp = gpar(fontsize = 10, col = c("black", "red")))
 hm2 <- arrangeGrob(hm$gtable, leg, ncol = 2, widths = c(5,1))
 grid.draw(hm2)

r pheatmap:在省略列名时如何为特定的行名进行着色?

落日海湾 2025-02-17 12:44:04

将发电机表达式传递到sum效果很好。

sum(dim['length'] * dim['breadth'] for dim in data['dimensions'])

brokenbenchmark的答案可以很好地工作,但是如果不需要区域列表,则使用发电机表达式与列表相比理解避免创建列表。

Passing a generator expression to sum works nicely.

sum(dim['length'] * dim['breadth'] for dim in data['dimensions'])

The answer by BrokenBenchmark works nicely, but if the interim list of areas is not necessary, using the generator expression vs. the list comprehension avoids the creation of a list.

从Python词典访问多个数据

落日海湾 2025-02-17 10:12:18

您可以导入日历创建一个字典,然后使用repegx = true替换:

import calendar
d = dict(zip(calendar.day_name, calendar.day_abbr))
df.replace(d, regex=True)

You can import calendar create a dictionary then use replace with regex=True:

import calendar
d = dict(zip(calendar.day_name, calendar.day_abbr))
df.replace(d, regex=True)

替换数据框中的多个字符串(python / pandas)

落日海湾 2025-02-17 01:47:24

可能有

  1. 您的桌子不正确。 查看MySQL错误日志使用:show table;,如果可以看到,请使用Select *
  2. 您可以在数据库中

There maybe have

  1. Your table is not correct. You can see your MySQL error log
  2. use: show table; in your database, If you can see it, Please use select * from table

SQL命令行显示空集,尽管数据库中的表格

落日海湾 2025-02-17 00:46:53

虽然这里的所有答案都是正确的 - 捕获错误并在nodejs中记录它们的好习惯,但实际上您正在编写Nodejs环境下运行的ExpressJS应用程序,因此您应该遵循端点的Expressjs指南,其中端点的端点是图书馆。

这是一个链接 https://expressjs.com/en/guide/eror andling。 html

这样,您不需要以前的答案之一中的一个catchasync,您甚至不需要处理端点代码中可能发生的大多数错误...(除非当然,您想将它们用于休闲(例如未找到错误的错误和适当的错误代码)),因为expressjs定义的错误处理程序应在发生时为您处理错误。

While all of the answers here are right - its good practice to catch errors and log them in nodejs, you are in fact writing expressjs application running under nodejs environment, and as such you should follow the guide of expressjs of handling errors in endpoints in that library.

Here is a link https://expressjs.com/en/guide/error-handling.html

With this, you dont need any catchAsync from one of the previous answers, you dont even to need to handle most of the errors that might happen in the endpoints code... (Unless you of course want to use them to your leisure (like NotFound errors and proper error code for it)) as the error handler defined for expressjs should handle the errors for you whenever they occure.

与异步/等待中的REST API处理错误处理的最佳实践?

落日海湾 2025-02-16 16:40:42

使用刷新令牌时获得无效的赠款,通常意味着刷新令牌已过期或已被撤销。

过期刷新令牌的可能原因。

  1. 用户已撤销您的访问权限,
  2. 您的访问权限超过50个出色的刷新令牌,
  3. 该应用程序仍处于测试阶段,这意味着刷新令牌在7天后到期。

Getting invalid grant when using a refresh token normally means that the refresh token is expired or was revoked.

Possible reasons for expired refresh tokens.

  1. the user has revoked your access
  2. you have more then 50 outstanding refresh tokens for this user
  3. The app is still in the testing phase which means refresh tokens expire after seven days.

Google Fit离线 - 访问令牌问题

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文