randy3k / radian

A 21 century R console
MIT License
2k stars 76 forks source link

eval function issue #312

Closed rromoli closed 2 years ago

rromoli commented 3 years ago

I run linux debian debian buster on my workstation and vscode as editor. I get several error while I eval a function. I get an error for each line such as they are not from the same function but such as each line is independent:

This is a function:

sumstats <- function(z) {
  MEAN <- apply(z, 2, mean)
  MEDIAN <- apply(z, 2, median)
  SD <- apply(z, 2, sd)
  SE <- apply(z, 2, function(x) {sd(x) / sqrt(length(x))})
  CV <- apply(z, 2, function(x) {sd(x) / mean(x)})
  result <- data.frame(MEAN, MEDIAN, SD, SE, CV)
  return(result)
}

and this is the radian out:

r$> sumstats <- function(z) { 
          MEAN <- apply(z, 2, mean) 
    }                                                                                                                                                                              
  result <- data.frame(MEAN, MEDIAN, SD, SE, CV)

  return(result)
}
r$>   MEDIAN <- apply(z, 2, median)                                                                                                                                                
Error in apply(z, 2, median) : object 'z' not found

r$>   SD <- apply(z, 2, sd)                                                                                                                                                        
Error in apply(z, 2, sd) : object 'z' not found

r$>   SE <- apply(z, 2, function(x) {sd(x) / sqrt(length(x))})                                                                                                                     
Error in apply(z, 2, function(x) { : object 'z' not found

r$>   CV <- apply(z, 2, function(x) {sd(x) / mean(x)})                                                                                                                             
Error in apply(z, 2, function(x) { : object 'z' not found

r$>   result <- data.frame(MEAN, MEDIAN, SD, SE, CV)                                                                                                                               
Error in data.frame(MEAN, MEDIAN, SD, SE, CV) : object 'MEAN' not found

r$>   return(result)                                                                                                                                                               
Error: object 'result' not found

r$> }                                                                                                                                                                              
Error: unexpected '}' in "}"

r$> 

Using the classic R console all works great.

Any suggestion?

randy3k commented 3 years ago

Did you copy and paste the code to radian?

rromoli commented 3 years ago

No, I use Ctrl+enter to send code to radian

randy3k commented 2 years ago

Does copy and paste work fine?

rromoli commented 2 years ago

Yes, copy/paste works, but It slow down the job...

randy3k commented 2 years ago

Then it’s an issue of vscode and how it sends the code to radian.

rromoli commented 2 years ago

ok, thanks

rromoli commented 2 years ago

move to vscode