0

I tried to create a sum function that ignores NA values for practicing. My code is:

my.sum <- function(x){
sum.f = 0
y <- !is.na(x)
z <- x[y]
n <- length(z)
  for (i in 1 : n) {
      sum.f <- sum.f  + z[i]
            }
return(sum.f)
} 

When I run the code directly in R Console, I see the code as expected:

> > my.sum <- function(x){
> + sum.f = 0
> + y <- !is.na(x)
> + z <- x[y]
> + n <- length(z)
> +   for (i in 1 : n) {
> +       sum.f <- sum.f  + z[i]
> +             }
> + return(sum.f)
> + }

But when I run the code in Tinn-R, I see this instead:

my.sum <- function(x){
> + sum.f = 0
> + y <- !is.na(x)
> + z <- x[y]
> + n <- length(z)
> +   for (i in 1 : n) {
> +       sum.f <- sum.f  + z[i]
> +             .... [TRUNCATED]

What is the meaning of [TRUNCATED] in the Tinn-R console and why did I get it?

divibisan
  • 11,659
  • 11
  • 40
  • 58

1 Answers1

1

Inside of Tinn-R if the option R echo (on/off) is on, when you send a selection, if it has more than one line, Tinn-R send to R interpreter an instruction like this:

> source(.paths[5], echo=TRUE, max.deparse.length=60)

The argument max.deparse.length control the maximal number of characters output for the deparse of a single expression. In my example it is 60. So after 60 character echoed R print:

>.... [TRUNCATED]

You can easely change this value in Tinn-R at: Options/Application/R/Basic in the topic: Option (max.deparse.length (echo=TRUE))

jcfaria
  • 312
  • 3
  • 14