TOMC
TOMC

Reputation: 163

How to access a Databricks directory with R

I have a Databricks directory containing R scripts : "/Shared/my_dir" that I want to access from R.

If I do :

setwd("/Shared/my_dir")

→ I get an error message : "cannot change working directory".

But if I do for example : % run /Shared/my_dir/script1.R → It works fine.

Thank you.

Upvotes: 1

Views: 637

Answers (1)

Alex Ott
Alex Ott

Reputation: 87174

When you have code as notebooks, it's not stored on the file system - it's stored inside some database in Databricks Control Plane, so "normal" file level operations won't work with them. %run is not a file level operation, it was created for work with notebooks.

The only exception is when your code in Databricks Repos - in that case, files in a repository are available as /Workspace/Repos/.... (see doc), but it works only with files, not with notebooks.

Upvotes: 1

Related Questions