# Installation and Setup Guide for rainerosr

## Installation

### Option 1: Install from Local Directory

```r
# Install devtools if you don't have it
install.packages("devtools")

# Install rainerosr from the local directory
devtools::install_local("/path/to/rainerosr")
```

### Option 2: Install from GitHub (after uploading)

```r
# Install from GitHub
devtools::install_github("yourusername/rainerosr")
```

## Dependencies

The package requires the following R packages:
- ggplot2 (>= 3.4.0)
- dplyr (>= 1.1.0)
- lubridate (>= 1.9.0)

These will be automatically installed when you install rainerosr.

## Quick Test

After installation, test that everything works:

```r
library(rainerosr)

# Create test data
test_data <- data.frame(
  time = as.POSIXct(c("2024-01-01 10:00", "2024-01-01 10:15", 
                      "2024-01-01 10:30", "2024-01-01 10:45")),
  depth = c(5.2, 8.3, 4.1, 2.5)
)

# Calculate I30
result <- calculate_i30(test_data, "time", "depth")
print(result)

# If this works, you're all set!
```

## Building from Source

If you want to build the package yourself:

```r
# Navigate to the parent directory containing 'rainerosr'
setwd("/path/to/parent/directory")

# Build the package
devtools::build("rainerosr")

# Check the package
devtools::check("rainerosr")

# Install the built package
devtools::install("rainerosr")
```

## Running Tests

To run the test suite:

```r
devtools::test("rainerosr")
```

## Building Documentation

To rebuild the documentation:

```r
# Generate documentation from roxygen comments
devtools::document("rainerosr")

# Build vignettes
devtools::build_vignettes("rainerosr")
```

## Troubleshooting

### Common Issues

1. **Missing dependencies**: Install manually
   ```r
   install.packages(c("ggplot2", "dplyr", "lubridate"))
   ```

2. **Compilation errors**: Make sure you have the latest version of R
   ```r
   R.version.string
   ```

3. **Vignette building issues**: Install additional packages
   ```r
   install.packages(c("knitr", "rmarkdown"))
   ```

## Getting Help

- View function help: `?calculate_i30`
- Browse vignettes: `browseVignettes("rainerosr")`
- View README: `vignette("getting-started", package = "rainerosr")`

## Next Steps

1. Read the README.md for an overview
2. Work through the vignette: `vignette("getting-started")`
3. Try the examples in the function documentation
4. Apply to your own data!
