---
title: "Installation"
output: rmarkdown::html_vignette
resource_files:
  - figures/goldenviz-report.html
vignette: >
  %\VignetteIndexEntry{Installation}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(message = FALSE, warning = FALSE)
```

GoldenVizR is designed to install like a standard R package.

## Install from CRAN

```r
install.packages("GoldenVizR")
```

## Development version

If you are testing the development version from the source repository:

```r
remotes::install_github("WajdiBenSaad/GoldenViz_R")
```

Load the package with:

```r
library(GoldenVizR)
```

GoldenVizR analyzes `ggplot2` objects, so most workflows also load `ggplot2`:

```r
library(ggplot2)
```

## Check your installation

Run this small example to confirm that GoldenVizR can inspect a `ggplot2`
chart:

```{r installation-check, fig.width=6, fig.height=4}
library(ggplot2)
library(GoldenVizR)

p <- ggplot(mtcars, aes(wt, mpg, colour = factor(cyl))) +
  geom_point(size = 2.4) +
  labs(
    title = "Fuel economy by weight",
    subtitle = "Motor Trend cars",
    x = "Weight",
    y = "Miles per gallon",
    colour = "Cylinders",
    caption = "Source: mtcars"
  ) +
  theme_minimal(base_size = 12)

p
```

Then analyze the chart:

```{r installation-report}
report <- analyze_plot(p)
report$summary
```

Expected chart output:

```{r installation-static-image, echo=FALSE, out.width="75%"}
knitr::include_graphics("figures/installation-check.png")
```

You should see a `goldenviz_report` with 25 checked rules and status counts.
The exact counts can change as the analyzer improves, but the report should
contain the same top-level fields:

```{r installation-report-fields}
names(report)
```

You can also view the result as a formatted HTML report:

```{r installation-html-report, eval=FALSE}
render_report(report)
save_report(report, "goldenviz-report.html")
view_report(report)
```

The HTML report can be embedded directly in rendered documentation:

<iframe
  class="gv-report-frame"
  src="figures/goldenviz-report.html"
  title="Embedded GoldenVizR HTML report"
  loading="lazy">
</iframe>

## Development setup

If you are contributing to GoldenVizR from a local checkout:

```r
install.packages(c(
  "devtools", "roxygen2", "testthat", "ggplot2",
  "pkgdown", "knitr", "rmarkdown", "lintr", "styler"
))

devtools::load_all()
devtools::test()
```
