Mutate, doesn't show additional column in the "R" script when I invoke it by "View"

Hi,

I used the "mutate" function on the console and i could see an additional column, but if I do it the same code in R script and invoke the "View" function still not showing the extra column!
Any idea why?
many thanks

Can you share part of your df using dput(head(yourdf, 10))and the code you wrote?

Hi Flm,
That was quick, but I guess you kind of give me the answer with your question. :slight_smile:
Anyway, this is the code:
"> dput(head(fruit_ranks2, 10))
structure(list(fruit1 = c("banana", "apple", "pear", "watermelo",
"peach"), my_favourite = c(2, 4, 5, 1, 3)), row.names = c(NA,
5L), class = "data.frame")"
Thanks for your code too :slight_smile:


So WHY in the script I do not see the score line? thx

function outputs are returned to the calling environments... but if not assigned to any name then you wont be able to refer to what has been returned, such as to pass it to View().

In R, the assigment operator is <-
if you want to keep using fruit_ranks2 rather than fruit_ranks3 you will need

fruit_ranks2 <- mutate(fruit_ranks2, score=my_favourite*10)

Thanks, it all makes sense now.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.