From a1e5be0e8cb0e91a27cb30583423097bfd7e3474 Mon Sep 17 00:00:00 2001 From: Steven Hobs Date: Mon, 24 Mar 2025 18:46:22 +0800 Subject: [PATCH] update --- .Rprofile | 8 ++++++- .vscode/settings.json | 50 ++++++++++++++++++++++--------------------- src/test-plot.R | 14 ++++++------ 3 files changed, 40 insertions(+), 32 deletions(-) diff --git a/.Rprofile b/.Rprofile index bafa7a6..b3e8f33 100644 --- a/.Rprofile +++ b/.Rprofile @@ -1,2 +1,8 @@ # R 配置 -options("repos" = c(CRAN = "https://mirrors.cernet.edu.cn/CRAN/")) + +options("repos" = c(CRAN = "https://mirrors.cernet.edu.cn/CRAN/")) # 包的镜像源 + +if (Sys.getenv("VSCODE_DEBUG_SESSION") == "1") { # Debugger关联 + Sys.setenv(TERM_PROGRAM = "vscode") + source(file.path(Sys.getenv(if (.Platform$OS.type == "windows") "USERPROFILE" else "HOME"), ".vscode-R", "init.R")) +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 2cfedc0..e755f52 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,27 +1,29 @@ /* VSCode 项目配置 */ { - "r.rpath.linux": ".conda/bin/R", - "r.libPaths": [ - ".conda/bin/R/library" - ], - "r.rterm.linux": "${workspaceFolder}/.conda/bin/R", - "r.rterm.option": [ - "--no-save", - "--no-restore" - ], - "r.plot.useHttpgd": true, - "r.lsp.diagnostics": true, - "r.alwaysUseActiveTerminal": true, - "r.bracketedPaste": true, - "r.sessionWatcher": true, - "[r]": { - "editor.defaultFormatter": "REditorSupport.r", - "editor.formatOnSave": true - }, - "[rmd]": { - "editor.defaultFormatter": "REditorSupport.r", - "editor.formatOnSave": true - }, - "files.eol": "\n", - "terminal.integrated.defaultProfile.linux": "R Terminal", + "r.rpath.linux": ".conda/bin/R", + "r.libPaths": [ + ".conda/bin/R/library" + ], + "r.rterm.linux": "${workspaceFolder}/.conda/bin/radian", + "r.rterm.option": [ + "--no-save", + "--no-restore" + ], + "r.plot.useHttpgd": true, + "r.lsp.diagnostics": true, + "r.alwaysUseActiveTerminal": true, + "r.bracketedPaste": true, + "r.sessionWatcher": true, + "[r]": { + "editor.defaultFormatter": "REditorSupport.r", + "editor.formatOnSave": true + }, + "[rmd]": { + "editor.defaultFormatter": "REditorSupport.r", + "editor.formatOnSave": true + }, + "terminal.integrated.defaultProfile.linux": "R Terminal", + "files.eol": "\n", + "editor.tabSize": 2, + "editor.detectIndentation": false } \ No newline at end of file diff --git a/src/test-plot.R b/src/test-plot.R index 15e3961..3541e47 100644 --- a/src/test-plot.R +++ b/src/test-plot.R @@ -7,11 +7,11 @@ y <- rnorm(100) # 生成 100 个正态分布随机数作为 y 值 # 创建散点图 plot(x, y, - main = "Scatter Plot of Random Data", # 图表标题 - xlab = "X-axis Label", # X 轴标签 - ylab = "Y-axis Label", # Y 轴标签 - col = "blue", # 点的颜色 - pch = 19 + main = "Scatter Plot of Random Data", # 图表标题 + xlab = "X-axis Label", # X 轴标签 + ylab = "Y-axis Label", # Y 轴标签 + col = "blue", # 点的颜色 + pch = 19 ) # 点的形状 # 添加回归线 @@ -19,6 +19,6 @@ abline(lm(y ~ x), col = "red") # 添加线性回归线,红色 # 添加图例 legend("topright", - legend = c("Data Points", "Regression Line"), - col = c("blue", "red"), pch = c(19, NA), lty = c(NA, 1) + legend = c("Data Points", "Regression Line"), + col = c("blue", "red"), pch = c(19, NA), lty = c(NA, 1) )