R是一种免费的开源编程语言和软件环境,用于统计计算,生物信息学,可视化和通用计算。请提供最小和可重复的示例以及所需的输出。对数据使用`dput()`并使用`library()`调用指定所有非基本包。不要为数据或代码嵌入图片,而是使用缩进的代码块。有关统计相关问题,请使用https://stats.stackexchange.com。
InVignette(“编程”,package =“ dplyr”)有以下示例代码 my_summarise2<- function(data, expr) { data %>%总结( 平均值=平均值({{expr}})...
当使用read.csv rstudio不在工作目录中时,已确认了使用getWD()
已将WD设置为“ D:/rstudio/Working Directory”,但是当尝试使用read.csv()时,我会收到错误: 钻石<- read.csv("~/diamonds.csv") Error in file(file, "rt") :
用自定义重叠创建滚动窗口 我想沿多个滚动窗口分析时间序列数据。作为第一步,我想提取所述窗口的开始和末日。可悲的是,使用动物园:Rollapply似乎缺少C ...
似乎缺少一个关键参数,即重叠,似乎固定在
# Load the necessary library library(dplyr) library(r2rtf) # Specify the URL of the image image_url <- "https://images.vexels.com/content/129159/preview/2d-colorful-bar-chart-infographic-9e35d8.png" # Define the filename for saving image_filename <- "bar_chart.png" # Download the image download.file(image_url, image_filename, mode = "wb") # Confirm the file has been created if (file.exists(image_filename)) { cat("Image saved as 'bar_chart.png' in the working directory.\n") } else { cat("Failed to save the image.\n") } filename2 <- paste0(getwd(), "/bar_chart.png") title2 <- "Figure 18.2: Proportion of patients achieving ESC/EAS and NICE guideline recommended LDL-C goals at baseline and 1-year follow-up (LDL-C dataset)" filename2 %>% r2rtf::rtf_read_figure() %>% r2rtf::rtf_page(orientation = "landscape", margin = c(1, 1, 1.25, 1.25, 1.25, 1.25)) %>% r2rtf::rtf_page_header(text ="Data Base Lock date: FINAL", text_font_size = 8, text_font = 9, text_justification = "l") %>% r2rtf::rtf_page_footer(text = "R program: p_figure_18_x_barchart.R Production date: 10OCT2024 Page \\pagenumber of \\pagefield", text_font_size = 8, text_font = 8, text_justification = "l") %>% r2rtf::rtf_title(title = title2, text_font_size = 8, text_font = 9, text_justification = "l", text_indent_left = 0, text_indent_reference = "page_margin") %>% r2rtf::rtf_figure(fig_width = 9, fig_height = 4.5) %>% r2rtf::rtf_encode(doc_type = "figure") %>% r2rtf::write_rtf(file = paste0(mypath, "p_figure_18_2_barchart.rtf"))
lrm中的eRROR(死亡〜偏移(2 *年龄),data = detter_data): 未找到对象“ sformula”
--- title: "Pashto text" format: pdf: toc: true number-sections: false colorlinks: true pdf-engine: lualatex include-in-header: text: | \usepackage{fontspec} \usepackage[bidi=basic]{babel} \babelprovide[import=ps,mapdigits]{pashto} \babelfont[pashto]{rm}[Renderer=HarfBuzz]{Amiri} --- ```{r setup, echo=FALSE, include=FALSE} cat("\\selectlanguage{pashto} دا پښتو متن دی") cat("\\n") ```
...... 我有一个看起来像这样的数据框架: # A tibble: 6 × 8 N S DG P locus replicate MLE_s_BwS MLE_s_WF <int> <dbl> <int> <int> <int> <int> <dbl> <dbl> 1 100 0 1 1 0 0 -0.174 -0.183 2 100 0 1 1 1 0 0.143 0.143 3 100 0 1 1 2 0 -0.0758 -0.0758 4 100 0.1 10 1 3 0 -0.141 -0.141 5 100 0.1 10 1 4 0 0.102 0.102 6 100 0.1 10 1 5 0 0.102 0.102
--- title: "Untitled" author: "L" date: "2025-03-13" output: pdf_document --- ```{r} set.seed(84) dt <- data.frame(month = rep(c(1:12), 10), value = sample(c("A", "B", "C"), 120, replace = TRUE)) addmargins(round(prop.table(table(dt$value, dt$month), 1)*100,2))
I存储在数据框架中,Excel公式作为字符串。其中一些字符串是超链接。从这些超链接公式中,我只想提取显示的文本并在适当的位置进行数据帧的单元格。
X1 X2 3798 2009-12-29 0 3799 2009-12-30 0 3800 2009-12-31 0 3802 2010-01-02 0 3803 2010-01-03 2.1 3804 2010-01-04 0 3805 2010-01-05 0 3806 2010-01-06 0 3807 2010-01-07 0 3808 2010-01-08 0 3809 2010-01-09 0 3810 2010-01-10 6.8 3811 2010-01-12 0 3812 2010-01-13 0 3813 2010-01-14 17.7 3814 2010-01-16 0 3815 2010-01-17 0 3816 2010-01-18 1.5 3817 2010-01-19 0 3818 2010-01-20 0 3819 2010-01-21 0 3820 2010-01-22 0 3821 2010-01-23 0 3822 2010-01-24 0 3823 2010-01-25 0 3824 2010-01-26 0 3825 2010-01-27 4.5 3826 2010-01-28 0 3827 2010-01-29 0 3828 2010-01-31 0 3829 2010-02-01 0 3830 2010-02-03 0 3831 2010-02-04 0 3832 2010-02-05 0 3833 2010-02-07 0 3834 2010-02-08 0 3835 2010-02-09 1.2