SSkilltecabyclaudinhocode
Enviar skill
← Voltar para o catálogo

r-analytics

Dados e Análise

R language data analysis and visualization skill. Use when user asks to (1) run R scripts or code, (2) install/update R packages, (3) perform data analysis with R, (4) create visualizations with ggplot2/plotly, (5) statistical analysis, (6) data manipulation with tidyverse/dplyr/data.table. Triggers on keywords like "R语言", "R脚本", "ggplot", "tidyverse", "数据分析", "可视化".

5estrelas
Ver no GitHub ↗Autor: LeoLin990405Licença: MIT

R Analytics

R language data analysis and visualization toolkit.

Quick Reference

Run R Code

# Run inline code
Rscript -e 'print("Hello R")'

# Run script file
Rscript script.R

# Run with arguments
Rscript script.R arg1 arg2

Package Management

# Update all packages
Rscript -e 'options(repos = c(CRAN = "https://cloud.r-project.org")); update.packages(ask = FALSE, checkBuilt = TRUE)'

# Install package
Rscript -e 'install.packages("tidyverse", repos = "https://cloud.r-project.org")'

# Install multiple packages
Rscript -e 'install.packages(c("ggplot2", "dplyr", "tidyr"), repos = "https://cloud.r-project.org")'

Data Analysis Workflow

1. Load Data

# CSV
df <- read.csv("data.csv")
df <- readr::read_csv("data.csv")  # faster, tibble output

# Excel
df <- readxl::read_excel("data.xlsx", sheet = 1)

# JSON
df <- jsonlite::fromJSON("data.json")

2. Data Manipulation (dplyr)

library(dplyr)

df %>%
  filter(column > 10) %>%           # filter rows
  select(col1, col2) %>%            # select columns
  mutate(new_col = col1 * 2) %>%    # create column
  group_by(category) %>%            # group
  summarise(mean_val = mean(value)) # aggregate

3. Visualization (ggplot2)

library(ggplot2)

# Scatter plot
ggplot(df, aes(x = x_col, y = y_col)) +
  geom_point() +
  labs(title = "Title", x = "X Label", y = "Y Label") +
  theme_minimal()

# Bar chart
ggplot(df, aes(x = category, y = value, fill = category)) +
  geom_bar(stat = "identity") +
  theme_minimal()

# Line chart
ggplot(df, aes(x = date, y = value, color = group)) +
  geom_line() +
  theme_minimal()

# Save plot
ggsave("plot.png", width = 10, height = 6, dpi = 300)
ggsave("plot.pdf", width = 10, height = 6)

4. Statistical Analysis

# Summary statistics
summary(df)

# Correlation
cor(df$x, df$y)
cor.test(df$x, df$y)

# Linear regression
model <- lm(y ~ x1 + x2, data = df)
summary(model)

# T-test
t.test(group1, group2)

# ANOVA
aov_result <- aov(value ~ group, data = df)
summary(aov_result)

Common Packages

PackagePurpose
tidyverseMeta-package: ggplot2, dplyr, tidyr, readr, etc.
ggplot2Visualization
dplyrData manipulation
tidyrData tidying
readrFast CSV reading
readxlExcel files
data.tableFast data manipulation
plotlyInteractive plots
shinyWeb apps
rmarkdownReports

Output Formats

# Save data
write.csv(df, "output.csv", row.names = FALSE)
readr::write_csv(df, "output.csv")

# Save R object
saveRDS(obj, "data.rds")
obj <- readRDS("data.rds")

Resources

Scripts

  • scripts/update_packages.R - Update all installed packages

References

Quick Reference:

  • references/packages.md - Common packages quick reference
  • references/awesome-packages.md - Curated packages by domain (ML, viz, web, finance, etc.)
  • references/resources-index.md - URLs, cheat sheets, community resources

R for Data Science (2e) - Tidyverse workflow:

FileTopics
references/r4ds-1-visualize.mdggplot2: geoms, aesthetics, facets, scales, themes
references/r4ds-2-transform.mddplyr: filter, select, mutate, summarize, group_by
references/r4ds-3-wrangle.mdtidyr (pivot), stringr, forcats, lubridate
references/r4ds-4-import.mdreadr, readxl, joins, binding
references/r4ds-5-program.mdFunctions, across(), map(), iteration

Advanced R (2e) - Deep R programming:

FileTopics
references/advr-1-foundations.mdNames/values, vectors, subsetting, control flow, functions, environments, conditions
references/advr-2-functional.mdFunctionals (map/reduce), function factories, function operators
references/advr-3-oop.mdS3, R6, S4 object-oriented programming
references/advr-4-metaprogramming.mdExpressions, quasiquotation, evaluation, code translation
references/advr-5-techniques.mdDebugging, profiling, performance optimization, Rcpp

R Graphics Cookbook - Visualization recipes:

  • references/graphics-cookbook.md - Bar graphs, line graphs, scatter plots, distributions, annotations, colors

Ecosystems:

  • references/tidyverse-ecosystem.md - Core packages, import tools, modeling, patterns
  • references/bioconductor.md - Installation, GenomicRanges, RNA-seq, annotation

Sub-Skills (Domain-Specific)

Sub-SkillDescription
sub-skills/r-data/Data manipulation, formats, databases (dplyr, data.table, DBI)
sub-skills/r-viz/Visualization (ggplot2, plotly, leaflet, HTML widgets)
sub-skills/r-ml/Machine learning (tidymodels, xgboost, caret, deep learning)
sub-skills/r-nlp/Natural language processing (tidytext, quanteda, tm)
sub-skills/r-web/Web technologies & reproducible research (Shiny, rmarkdown)
sub-skills/r-stats/Bayesian analysis, optimization, finance (Stan, quantmod)
sub-skills/r-bio/Bioinformatics (Bioconductor, DESeq2, GenomicRanges)
sub-skills/r-network/Network analysis (igraph, tidygraph, visNetwork)
sub-skills/r-spatial/Spatial analysis (sf, terra, leaflet, tmap)
sub-skills/r-dev/R development (devtools, testthat, roxygen2, Rcpp)
sub-skills/r-parallel/Parallel computing & performance (future, Rcpp, Spark)
sub-skills/r-resources/Learning resources (books, courses, cheat sheets)

Como adicionar

/plugin marketplace add LeoLin990405/r-analytics-skill

O comando exato pode variar conforme o repositório. Confira o README no GitHub.

Comentários · Nenhum comentário

Entre para comentar. Entrar

  • Ainda não há comentários. Seja o primeiro.