diff --git a/.gitignore b/.gitignore index 3daa1c7..4d4a299 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -/.conda/ \ No newline at end of file +.conda/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 5614ef2..dd16ab7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,12 +1,15 @@ /* VSCode 项目配置 */ { - "r.rpath.linux": "${workspaceFolder}/.conda/bin/R", + "terminal.integrated.env.linux": { + "R_HOME": "${workspaceFolder}/.conda/lib/R", + }, + "r.rpath.linux": ".conda/bin/R", "r.rterm.linux": "${workspaceFolder}/.conda/bin/radian", "r.rterm.option": [ - "--no-save", - "--no-restore", - "--r-binary=${workspaceFolder}/.conda/bin/R" + "--ask-save" ], + "r.debugger.commandLineArgs": [], + "r.debugger.checkVersion": "recommended", "r.plot.useHttpgd": true, "r.lsp.diagnostics": true, "r.alwaysUseActiveTerminal": true, @@ -20,8 +23,9 @@ "editor.defaultFormatter": "REditorSupport.r", "editor.formatOnSave": true }, - // "terminal.integrated.defaultProfile.linux": "R Terminal", # 终端默认开启 R终端 "files.eol": "\n", "editor.tabSize": 2, - "editor.detectIndentation": false + "editor.detectIndentation": false, + "remote.autoForwardPorts": false, + // "terminal.integrated.defaultProfile.linux": "R Terminal", // 终端默认开启 R终端 } \ No newline at end of file diff --git a/README.md b/README.md index 2939c85..9eabe9a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# Conda中的R语言环境 +# Conda虚拟环境中的R语言项目模板 + +用于创建项目独有的R隔离环境,实现R语言的细粒度控制。 ## 安装前提 @@ -11,7 +13,7 @@ - R - R Debugger -- Miniforge / Miniconda / Anaconda 虚拟环境管理 +- Miniforge / Miniconda / Anaconda 虚拟环境管理(即可执行`conda`命令) > [!NOTE] > 自行检查conda的镜像源配置,以加速库的下载安装。 @@ -20,13 +22,14 @@ ## 操作步骤 -0. 克隆本项目到指定的位置 +0. 克隆本项目到指定的位置,或者下载代码zip包: `git clone https://git.unvec.site/stevenhobs/R-with-Conda <项目路径>` + `cd <项目路径> && rm -r .git/` # 删除.git记录 1. 初始化conda虚拟环境 - `conda create -p .conda -c conda-forge r-base r-languageserver r-devtools r-httpgd r-rlang r-jsonlite radian` + `conda create -y -p .conda -c conda-forge r-base r-languageserver r-devtools r-httpgd r-rlang r-jsonlite radian` 2. 初始化R语言调试器,两种方式任选其一 diff --git a/src/rmarkdown-example.Rmd b/src/rmarkdown-example.Rmd new file mode 100644 index 0000000..9e93bb6 --- /dev/null +++ b/src/rmarkdown-example.Rmd @@ -0,0 +1,62 @@ +--- +title: "R Markdown 示例" +author: "Your Name" +date: "`r Sys.Date()`" +output: html_document +--- + +```{r setup, include=FALSE} +knitr::opts_chunk$set(echo = TRUE) +``` + +# 简介 + +这是一个 R Markdown 文档的示例。R Markdown 是一种用于创建可重复报告的格式,它结合了 Markdown 语法和 R 代码块。 + +# R 代码示例 + +我们可以在这里嵌入 R 代码: + +```{r cars} +summary(cars) +``` + +## 包含图形 + +我们也可以生成图形: + +```{r pressure, echo=FALSE} +plot(pressure) +``` + +## 表格 + +这里是一个表格示例: + +```{r} +head(mtcars) +``` + +# 数学公式 + +我们可以使用 LaTeX 语法来编写数学公式: + +$$ +E = mc^2 +$$ + +# 列表 + +- 项目 1 +- 项目 2 +- 项目 3 + +# 链接和图片 + +你可以添加 [链接](https://rmarkdown.rstudio.com/) 和图片: + +![R Logo](https://www.r-project.org/logo/Rlogo.svg) + +# 结论 + +R Markdown 是一个强大的工具,用于创建可重复的研究报告和演示文稿。 diff --git a/src/test-plot.R b/src/test-plot.R index 3541e47..9746242 100644 --- a/src/test-plot.R +++ b/src/test-plot.R @@ -7,7 +7,7 @@ y <- rnorm(100) # 生成 100 个正态分布随机数作为 y 值 # 创建散点图 plot(x, y, - main = "Scatter Plot of Random Data", # 图表标题 + main = "随机数据的散点图", # 图表标题 xlab = "X-axis Label", # X 轴标签 ylab = "Y-axis Label", # Y 轴标签 col = "blue", # 点的颜色