I want to know the script when RStudio wants to separate CSV data characters into two digits from the right.

Asked 2 years ago, Updated 2 years ago, 107 views

I'd like to know the script when RStudio wants to separate CSV data characters into two digits from the right.

r rstudio

2022-09-30 16:11

1 Answers

Use tidyverse stringr.

 pacman::p_load(tidyverse, stringr)

>str_sub("string12345", end=-3)
[1] "string123"

If the csv reads into a tibble (data frame),
Let it flow down the pipe like this:

 pacman::p_load(tidyverse, stringr)

tibble<-read_csv("file.csv")

tumble%>%
  mute(kugiri_kekka<-str_sub(kuguritai, end=-3))


2022-09-30 16:11

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.