obsidian-execute-code icon indicating copy to clipboard operation
obsidian-execute-code copied to clipboard

Problem in running codes in R

Open arnabkdey opened this issue 3 years ago • 1 comments

Hi,

I am having trouble executing simple functions in R. For example:

I first create a simple dataframe as such:

df <- data.frame( a = c(1:10), b = rep(c(0:1), 5), c = c(11:20) )

When I run this, the plug-in shows a pop-up saying Done! However, when I try to use the dataframe it throws errors:

head(df)

gives the following error:

function (x, df1, df2, ncp, log = FALSE) { if (missing(ncp)) .Call(C_df, x, df1, df2, log) else .Call(C_dnf, x, df1, df2, ncp, log) }

and

mean(df$a)

gives the following error:

Error in df$a : object of type 'closure' is not subsettable Calls: mean Execution halted

I would really appreciate any help in resolving this.

Thank you.

arnabkdey avatar Oct 18 '22 22:10 arnabkdey

Hi! I think I may know the problem: are the first and second statements in different code blocks?

If so: using variables from one code block in another block is a feature of Notebook Mode, which is only available for Python and Javascript right now. I can work on R-lang Notebook Mode, but I'm in midterms season at the moment, so it might be a bit until it lands & gets published.

If not: please provide the following information and I can help you with debugging the issue!

  • OS & version
  • Rscript version
  • Plugin version
  • A screenshot of your plugin settings, with R visible
  • How long have you had this issue?

chlohal avatar Oct 18 '22 22:10 chlohal

You are right - using the variables in the same code block solves the problem.

It would be great if the Notebook mode is available for R as well.

Thanks so much and good luck with mid-terms!!

arnabkdey avatar Oct 20 '22 13:10 arnabkdey

Great! I'm glad that it was fixed :)

Sure! I'm not sure when it'll be finished-- to be honest, I don't have a lot of experience with R-- but I will work on it when I can, and merge my work after #140 gets merged (that PR makes it much easier for us to add Notebook Mode to new languages)

Thank you!!!!

chlohal avatar Oct 20 '22 13:10 chlohal

Heyo! I wanted to let you know that I finished & submitted a PR. The feature should be available in master pretty soon (assuming I haven't made any glaring errors with the implementation!)

chlohal avatar Oct 24 '22 13:10 chlohal

That is just fantastic. This is going to be so great for my workflow. Thank you so much for your consideration and your work on this :)

arnabkdey avatar Oct 24 '22 16:10 arnabkdey