小编hli*_*nee的帖子

致命的Git:不支持协议'https'

我正在阅读Github的分叉指南:https : //guides.github.com/activities/forking/, 并且正在尝试将存储库克隆到我的计算机上。但是,运行命令:

$ git clone https://github.com/./Spoon-Knife.git
Cloning into 'Spoon-Knife'...
fatal: protocol 'https' is not supported
Run Code Online (Sandbox Code Playgroud)

还尝试使用SSH:

$ git clone git@github.com:./Spoon-Knife.git
Cloning into 'Spoon-Knife'...
Warning: Permanently added the RSA host key for IP address '.' to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)

我需要在计算机上更改某些配置设置,还是GitHub有问题?

编辑:我已经用“。”替换了我的用户名和IP地址。

git

76
推荐指数
7
解决办法
6万
查看次数

单个变量前面的波浪号(〜)是什么意思?

我正在浏览Hadley Wickham的"R for Data Science",他~var在ggplot调用中使用它.

我理解y ~ a + bx,在哪里~描述了依赖变量和自变量之间的公式/关系,但是什么~var意思呢?更重要的是,为什么你不能只把变量本身?见下面的代码:

ggplot(data = mpg) + 
  geom_point(mapping = aes(x = displ, y = hwy)) + 
  facet_wrap(~ class, nrow = 2)
Run Code Online (Sandbox Code Playgroud)

要么

demo <- tribble(
  ~cut,         ~freq,
  "Fair",       1610,
  "Good",       4906,
  "Very Good",  12082,
  "Premium",    13791,
  "Ideal",      21551
)

ggplot(data = demo) +
  geom_bar(mapping = aes(x = cut, y = freq), stat = "identity")
Run Code Online (Sandbox Code Playgroud)

r ggplot2

8
推荐指数
2
解决办法
1215
查看次数

将“加载”对象转换为数据框 (R)

我正在尝试将“加载”类型的对象转换为 R 中的数据帧。但是,我尝试通过 as_tibble() 或 as.data.frame() 对其进行强制没有奏效。这是代码:

iris_pca <- prcomp(iris[1:4], center = TRUE, scale. = TRUE)
iris_pca$rotation[,1:2] %>% 
  varimax() %>% 
  .$loadings
Run Code Online (Sandbox Code Playgroud)

这打印出来:

Loadings:
             PC1    PC2   
Sepal.Length  0.596 -0.243
Sepal.Width         -0.961
Petal.Length  0.570  0.114
Petal.Width   0.565       

                PC1  PC2
SS loadings    1.00 1.00
Proportion Var 0.25 0.25
Cumulative Var 0.25 0.50
Run Code Online (Sandbox Code Playgroud)

如何将这些数据放入数据框中?

r pca dataframe tibble

7
推荐指数
1
解决办法
940
查看次数

在函数调用中用变量替换字符串参数

我试图调用一个函数,该函数需要一个字符串作为参数之一.但是,尝试替换包含该字符串的变量会引发错误.

library(jtools)

# Fit linear model
fitiris <- lm(Petal.Length ~ Petal.Width * Species, data = iris)

# Plot interaction effect: works!
interact_plot(fitiris, pred = "Petal.Width", modx = "Species")

# Substitute variable name for string: doesn't work!
predictor <- "Petal.Width"
interact_plot(fitiris, pred = predictor, modx = "Species")

Error in names(modxvals2) <- modx.labels : 
  attempt to set an attribute on NULL
Run Code Online (Sandbox Code Playgroud)

interaction r linear-regression

4
推荐指数
1
解决办法
112
查看次数

Rmarkdown HTML 渲染问题

我正在尝试打印 HTML 表格列表,但由于某种原因,当我编织文档时,我得到的是原始 HTML 代码用于输出,而不是渲染的表格。例子:

---
title: "html-render-issue"
output: html_document
---
Run Code Online (Sandbox Code Playgroud)
library(tidyverse)
library(gtsummary)

# this table renders correctly:
tbl_summary(iris)

# but this table does not!!
tables <- list(tbl_summary(iris), tbl_summary(cars))
print(tables)
Run Code Online (Sandbox Code Playgroud)

我不明白为什么会发生这种情况,我尝试使用 for 循环对列表进行索引

for (i in 1:2) {
  print(tables[[i]])
}
Run Code Online (Sandbox Code Playgroud)

但这似乎也不起作用!缺少做tables[[1]]; tables[[2]]等(这确实有效),有没有办法迭代列表并获得我想要的输出?

html r knitr r-markdown gtsummary

4
推荐指数
1
解决办法
551
查看次数

dplyr NSE:将数据框中的多列居中

我试图使用 dplyr 在数据框中“居中”多个列,但我不断收到“二元运算符的非数字参数”评估错误。我认为这是因为当我的函数需要一个裸变量名时我试图传递一个字符串。但是,使用 syms() 函数没有帮助。

center <- function(var) {
  var <- enquo(var)
  var_ctrd <- paste0(quo_name(var), "_ctrd")
  dataset <- dataset %>% 
    group_by(Gender) %>% 
    mutate(!! var_ctrd := !! var - mean(!! var, na.rm = TRUE))
}

# Pull out character vector of modifier names
mod_names <- dataset %>% 
  select(NeckLengthCm:FlexExtDiff_Peak_abs) %>% 
  colnames()

# Iterate over modifiers
walk(syms(mod_names), center)
Run Code Online (Sandbox Code Playgroud)

有谁知道如何解决这个问题或者是否有更好的解决方案?

r dplyr non-standard-evaluation rlang

2
推荐指数
1
解决办法
1756
查看次数