Variable modification using Pipe operator

Hello,
Could please tell me the mistake I made in this script?
iris <-
iris |>
mutate(
Sepal.Length = as.numeric(x = Sepal.Length),
Sepal.Width = as.numeric(x = Sepal.Width),
Petal.Length = as.numeric(x = Petal.Length),
Petal.Width = as.numeric(x = Petal.Width),
Species = as.factor(x = Species)
)

The result I got here :

iris <-

  • iris |>
  • mutate(
    
  • Sepal.Length = as.numeric(x = Sepal.Length),
    
  • Sepal.Width = as.numeric(x = Sepal.Width),
    
  • Petal.Length = as.numeric(x = Petal.Length),
    
  • Petal.Width = as.numeric(x = Petal.Width),
    
  • Species = as.factor(x = Species)
    
  • )
    

I don't see any problem with your code and I don't understand what you mean to say with the results you show. When I run your code, there is not visible output, which is expected. Please explain what I am missing.

library(tidyverse)
iris <-
  iris |>
  mutate(
    Sepal.Length = as.numeric(x = Sepal.Length),
    Sepal.Width = as.numeric(x = Sepal.Width),
    Petal.Length = as.numeric(x = Petal.Length),
    Petal.Width = as.numeric(x = Petal.Width),
    Species = as.factor(x = Species)
  )

Created on 2024-02-18 with reprex v2.0.2

1 Like

Hello,
Thanks for your reply.
In fact, my concern is that when I run the code the sign + appears meaning that something is missing the script.

+ in blue text in your console just means that one line follows another in a connected way. it doesnt mean anything is missing.

Hello
Thanks for your answer. It helps me.
I thought whenever the sign + in blue appears it means something is missing to my code.

if theres a trailing + (i.e. the last symbol) in the console from code you submitted, then it is a sign that you submitted incomplete code, as the system is waiting for the rest, and mostly likely its from some unbalanced use of quotes or brackets etc.

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.