5 RStudio, Posit & VS Code
Use RSnowflake and snowflakeR from desktop R tooling
snowflake, R, RStudio, Posit, VS Code, workspace notebooks, snowflakeR, RSnowflake, mlops
5.1 Overview
Most R users work in RStudio, Posit Workbench, Positron, or VS Code. Both packages support that workflow: RSnowflake integrates with the Connections Pane and dbplyr; snowflakeR runs the same ML APIs as in Workspace once Python is configured.
Prerequisite: complete Local R Setup (packages, Python env, authentication). This chapter does not repeat those steps except where an IDE needs a specific setting.
You do not need Workspace Notebooks to use Snowflake from R.
5.2 Learning Objectives
- Configure Python/reticulate (conda or pip/venv)
- Set up VS Code for an RStudio-like experience
- Use the Snowflake VS Code extension for SQL and object browsing
- Know Posit Workbench Native App and container-hosted RStudio options
- Choose between RSnowflake and Posit’s
odbcpackage with the Snowflake ODBC driver
5.3 RStudio & Posit Workbench
5.3.1 Python for snowflakeR
- Complete Local R Setup — choose conda, venv, or
sfr_install_python_deps(). - Set the interpreter — pick one:
~/.Renviron:RETICULATE_PYTHON=/path/to/python(restart R)- Tools → Global Options → Python — select your venv or conda env
- Per session:
reticulate::use_virtualenv(...)oruse_condaenv(...)beforelibrary(snowflakeR)
5.3.2 RSnowflake Connections Pane
With RSnowflake installed, open Connections in RStudio (or Posit Workbench):
- New Connection → Snowflake (or
dbConnect(Snowflake(), name = "...")). - Browse databases, schemas, tables, and preview data.
- Use dbplyr in scripts or R Markdown.
library(DBI)
library(RSnowflake)
library(dplyr)
con <- dbConnect(Snowflake(), name = "default")
orders <- tbl(con, in_schema("ANALYTICS", "ORDERS")) |>
filter(order_date >= "2024-01-01") |>
collect()5.4 RSnowflake vs odbc + Snowflake ODBC
On desktop RStudio, Posit Workbench, and Positron, you have two well-supported ways to run DBI and dbplyr against Snowflake. Both are good options; many teams standardize on one for operations and keep the other in mind for edge cases.
| Layer | RSnowflake | odbc + Snowflake ODBC |
|---|---|---|
| R package | RSnowflake | CRAN odbc |
| Under the hood | SQL REST API (+ optional ADBC for bulk I/O) | unixODBC / iODBC → Snowflake ODBC driver |
| Extra install | None beyond R (optional adbcsnowflake for Arrow bulk) |
OS driver manager + Snowflake ODBC driver (install guide) |
| Posit-specific drivers | Not required | Posit Professional Drivers (paid products) or Snowflake’s driver from Snowflake’s site — see Posit: Snowflake |
| Connections pane | New Connection → Snowflake (RSnowflake) | ODBC DSN / driver-based connection (traditional path) |
connections.toml |
Supported via dbConnect(Snowflake(), name = "...") |
Supported via dbConnect(odbc::snowflake(), connection_name = "...") |
| dbplyr / DBI | Yes | Yes — same verbs, different driver |
| snowflakeR (ML APIs) | Orthogonal — install Python + snowflakeR either way | Same |
5.4.1 Practical differences to plan for
| Topic | RSnowflake | odbc + Snowflake ODBC |
|---|---|---|
| Admin / CI footprint | R package (+ optional ADBC build for bulk) | Driver binaries, odbc.ini / DSN, often IT-managed |
| Stage file upload/download | The SQL REST API does not support Snowflake PUT and GET commands (upload/download files to internal stages). Use ADBC bulk table loads, SQL COPY, or stage volume mounts in containers instead (Query — limits) |
ODBC/JDBC drivers often support stage-oriented file workflows teams already use |
| Writing large data.frames to tables | RSnowflake upload_method = "auto" (default) chooses the fastest path: ADBC bulk upload when installed, else Snowpark in Workspace, else batched SQL INSERT (Query — bulk) |
Depends on driver and DSN; no RSnowflake-specific routing |
| Workspace Notebooks | First-class: session OAuth via SNOWFLAKE_HOST; default without ODBC install |
ODBC was impractical in notebooks until CRE — driver + unixODBC do not fit setup_notebook(); bake into CRE if you must use odbc |
| Workspace bulk I/O | Optional ADBC in CRE (Snowflake’s optimized Arrow path) | ODBC in CRE possible; not the direction Snowflake optimizes for new bulk work |
| WebR / WASM | HTTPS SQL API works without a native driver | Needs ODBC in the environment — usually impractical |
| Identifier case | Defaults to uppercase (ODBC-aligned); RSnowflake.identifier_case |
Snowflake ODBC behaviour; same quoting pitfalls |
| Ecosystem age | Snowflake Labs, SQL API era | Long-running Posit + enterprise ODBC playbooks |
Neither package replaces snowflakeR for Feature Store, Model Registry, or Snowpark ML — you still add Python + snowflakeR when you need those APIs.
5.4.2 Example: odbc::snowflake()
The odbc package provides a Snowflake-specific connector that reads the same ~/.snowflake/connections.toml as the Python connector and can pick up ambient OAuth where the platform provides it:
library(DBI)
library(odbc)
con <- dbConnect(odbc::snowflake(), connection_name = "default")
library(dplyr)
tbl(con, in_schema("ANALYTICS", "ORDERS")) |>
filter(ORDER_DATE >= "2024-01-01") |>
head(10) |>
collect()Interactive SSO on a laptop:
5.4.3 When teams pick which
| Prefer RSnowflake when… | Prefer odbc when… |
|---|---|
| You want no ODBC install on analyst laptops | IT already rolls out the Snowflake ODBC driver to all machines |
| You align with Snowflake-Labs R + Workspace bootstrap in this guide | You rely on Posit Connect credential patterns (connectcreds) or legacy ODBC DSNs |
| You need SQL API semantics documented in chapter 11 | You need driver-level stage/file workflows from R that assume ODBC |
| WebR or minimal client footprint matters | You have years of validated ODBC runbooks in production |
Many teams use RSnowflake for new notebooks and dplyr, and keep ODBC for Shiny on Connect, older projects, or platforms where the driver is pre-installed (e.g. some Posit Workbench images).
5.4.4 Workspace: why SQL API won, and what CRE changes
Historically in Snowflake Workspace, the odbc package plus Snowflake ODBC driver was a poor fit: installing and configuring unixODBC and the driver at notebook runtime was slow, brittle, and hard to secure compared with HTTPS. That is a major reason RSnowflake (SQL API) exists for in-notebook R. ADBC did not share ODBC’s deployment shape — it installs as an R/Go driver package (bootstrap or CRE) and is Snowflake’s preferred Arrow-native path for large bulk I/O alongside the SQL API.
| Path | Workspace without CRE | Workspace with CRE |
|---|---|---|
| RSnowflake (SQL API) | Bootstrap or tarball | Pre-baked in image — skip bootstrap |
| ADBC | Bootstrap (languages.r.addons.adbc) + EAI for Go modules |
Pre-baked — recommended for bulk |
odbc + ODBC driver |
Impractical via bootstrap | Possible if platform team installs driver + DSN in the CRE image — not via setup_notebook() |
See RSnowflake in Workspace — bootstrap.
5.4.5 snowflakeR in RStudio projects
my-ml-project/
├── .Renviron # RETICULATE_PYTHON=...
├── R/
│ ├── 00_connect.R
│ ├── 01_features.R
│ └── 02_train.R
└── my-ml-project.Rproj
5.4.6 Positron
Positron uses the same R + Python model. Configure RETICULATE_PYTHON in .Renviron; Connections Pane behavior matches RStudio when enabled.
5.5 Posit Workbench Native App on Snowflake
Posit Workbench is available as a Native App on Snowflake — a full RStudio/Posit IDE inside your Snowflake account, with data locality and in-account auth.
| Aspect | Local RStudio | Posit Native App |
|---|---|---|
| Location | Your laptop | Snowflake account |
| Auth | connections.toml / SSO |
Inherited Snowflake session |
| Packages | Install RSnowflake + snowflakeR | Same — install in Workbench session |
| Best for | Day-to-day dev | Teams requiring in-account IDE |
snowflakeR and RSnowflake work the same way: install R packages in the Workbench session, configure Python for snowflakeR, connect with standard APIs.
Deploying and licensing Posit Native App is a separate product process — this guide only covers R package usage once Workbench is available.
5.6 RStudio Server on SPCS (custom container)
Run RStudio Server as a custom SPCS service when you need full RStudio UX inside Snowflake but do not use Posit Workbench Native App.
- Pros: native R session, Connections pane, custom image
- Cons: you operate Docker, compute pool, ingress, and scaling
Full walkthrough: RStudio Server on SPCS — deploy kit in snowflakeR/inst/rstudio-spcs, vignettes rstudio-spcs and spcs-custom-services.
Posit Workbench Native App (above) is the managed Marketplace alternative.
5.7 VS Code
5.7.1 Core R extensions
| Extension | Purpose |
|---|---|
| R | R terminal, run selection/chunk, help |
| R Debugger | Breakpoints, step debugging (optional) |
| Quarto | .qmd authoring if you use Quarto |
| R Syntax | Syntax highlighting (often bundled) |
Install languageserver in R for linting/hover (optional but improves IDE feel):
VS Code R extension settings (example):
{
"r.rterm.option": ["--no-save", "--no-restore"],
"r.lsp.enabled": true,
"python.defaultInterpreterPath": "${env:HOME}/.virtualenvs/r-snowflakeR/bin/python",
"[r]": {
"editor.formatOnSave": false
}
}Use pip/venv or conda path in python.defaultInterpreterPath — see Local R Setup.
5.7.2 Snowflake extension
Install the Snowflake Extension for VS Code:
- Account explorer (databases, schemas, tables)
- SQL worksheets against Snowflake
- Complements RSnowflake in R scripts — browse in sidebar, analyze in R
Workflow: Snowflake extension for exploration and ad hoc SQL; RSnowflake/dbplyr in .R files for reproducible pipelines; snowflakeR for ML APIs.
5.7.3 Local Jupyter with R (optional)
IRkernel::installspec() for notebook UI locally — distinct from Snowflake Workspace.
5.8 Terminal R
Ideal for CI/CD with key-pair auth in TOML.
5.9 Choosing local IDE vs Workspace
| Prefer local IDE / Posit App when… | Prefer Workspace when… |
|---|---|
| Team uses RStudio/Posit daily | Notebook-first, in-account Git |
| Posit Native App deployed | Mixed Python+R cells with Snowpark |
| Heavy Connections Pane / Rmd | Strict no-credential-on-laptop policy |
Many teams use both: develop in RStudio or Posit Native App, schedule via Tasks/SPCS.
5.10 Same packages, same objects
Feature views, registry models, and tables written from R are visible to R and Python users — regardless of IDE.
5.11 Next steps
Workspaces overview — Snowflake Notebooks.