小编pyg*_*pyg的帖子

`poly()`如何生成正交多项式?如何理解"coefs"归来?

我对正交多项式的理解是它们采用的形式

y(x)= a1 + a2(x - c1)+ a3(x - c2)(x - c3)+ a4(x - c4)(x - c5)(x - c6)......最多为期望的条款

其中a1,a2 是每个正交项的系数(在拟合之间变化),并且c1,c2 是正交项内的系数,确定使得这些项保持正交性(使用相同x值的拟合之间一致)

我理解poly()用于拟合正交多项式.一个例子

x = c(1.160, 1.143, 1.126, 1.109, 1.079, 1.053, 1.040, 1.027, 1.015, 1.004, 0.994, 0.985, 0.977) # abscissae not equally spaced

y = c(1.217395, 1.604360, 2.834947, 4.585687, 8.770932, 9.996260, 9.264800, 9.155079, 7.949278, 7.317690, 6.377519, 6.409620, 6.643426)

# construct the orthogonal polynomial
orth_poly <- poly(x, degree …
Run Code Online (Sandbox Code Playgroud)

regression r matrix linear-regression lm

9
推荐指数
1
解决办法
2359
查看次数

dplyr::slice_max() 中 order_by 参数的功能

在和函数的文档中,它说参数可以是要排序的变量或变量函数。slice_min()slice_max()order_by

变量函数是什么意思,以及如何在实际意义上应用它?例如,它可以用来提供分类值的自定义顺序吗?

我已经尝试过在网上彻底搜索信息,但无济于事,所以我向你们求助。谢谢。

r dplyr

5
推荐指数
1
解决办法
2813
查看次数

Chapter(s) before table of contents in Bookdown PDF output

I'd like for a chapter to appear before the table of contents (but after the title page) in the pdf_book output of Bookdown.

一种方法是将章节添加到.tex文件中并使用before_body:. 但是,这意味着该章节将不会出现gitbook(我也需要)。我不想同时保留同一章的a.tex.Rmdversion。

理想的解决方案是将章节保存在.Rmd文件中,并将其内容提取到before_bodyfor 中pdf_book。这样它仍然可以用于gitbook. 虽然我不确定我该怎么做,或者确实可能吗?

有解决办法吗?还是超出了Bookdown的灵活性极限?

任何帮助将不胜感激,谢谢!

pandoc knitr r-markdown bookdown

3
推荐指数
1
解决办法
1627
查看次数

ggplot2 log10 轴上十的整数次幂处中断

使用将轴转换ggplot2为 log10scales::trans_breaks()有时(如果范围足够小)会在 10 的非整数幂处产生不漂亮的中断。

是否有一种通用方法可以将这些中断设置为仅在 10^x 处发生,其中 x 都是整数,并且理想情况下是连续的(例如 10^1、10^2、10^3)?

这是我的意思的一个例子。

library(ggplot2)

# dummy data
df <- data.frame(fct = rep(c("A", "B", "C"), each = 3),
                 x = rep(1:3, 3),
                 y = 10^seq(from = -4, to = 1, length.out = 9))

p <- ggplot(df, aes(x, y)) +
  geom_point() +
  facet_wrap(~ fct, scales = "free_y") # faceted to try and emphasise that it's general purpose, rather than specific to a particular axis range
Run Code Online (Sandbox Code Playgroud)

不需要的结果 - y 轴中断为 …

r ggplot2

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

标签 统计

r ×3

bookdown ×1

dplyr ×1

ggplot2 ×1

knitr ×1

linear-regression ×1

lm ×1

matrix ×1

pandoc ×1

r-markdown ×1

regression ×1