R code that works perfectly on Rstudio does not run here

771407
Databricks Partner

Hi,

I have a "simple" R script that I need to import into Databricks and am running into errors.

For example:

TipoB <- Techtb %>% dplyr::filter(grepl('being evaluated', Comentarios))

#TipoB$yearsSpec <- NA

TipoB$yearsSpec <- str_replace(TipoB$Comentarios,'[^♂]*being evaluated[^0-9]*',"")

TipoB$yearsSpec <- str_replace(TipoB$yearsSpec,'[ | \\n| \\t][^♂]*',"")

TipoB$yearsSpec <- str_replace(TipoB$yearsSpec,",",".")

TipoB$yearsSpec <- str_replace(TipoB$yearsSpec,"\\+","")

TipoB$yearsSpec <- str_replace(TipoB$yearsSpec,"YRS","")

TipoB$yearsSpec <- str_replace(TipoB$yearsSpec,"~","")

TipoB$yearsSpec <- as.numeric(TipoB$yearsSpec)

I manage to create the TipoB table normally. But then I can't create new columns as I do on Rstudio. I even tried to create an empty column before inserting the data but it did not work. I get this error:

SyntaxError: invalid syntax

File "<command-2335304911107903>", line 1

TipoB$yearsSpec <- NA

^

SyntaxError: invalid syntax

I can read the TipoB table so I know it is there. But why would I not be able to use the "$" symbol? Can anyone help and show me where I'm messing up?

Thanks a lot!

Debayan
Databricks Employee
Databricks Employee

Hi, Could you please provide some more details on the configuration of the DBR version? R studio version? etc.

771407
Databricks Partner

R studio version 2022.12.0.

R latest version available on 08/FEB/2023.

I don't know where to find the DBR version and configuration. Can you direct me?

jose_gonzalez
Databricks Employee
Databricks Employee

when you create a cluster, you will need to select aa DBR version. look for "Databricks Runtime version"

View solution in original post