0

I have a .R file where I have duplicate entries as shown below,

lib.R

library(highcharter)
library(shiny)
library(shinydashboard)
library(DT)


library(shinydashboard)
library(DT)

But Is there a way to make sure, this duplicates can be removed . Expected output

lib.R

library(highcharter)
library(shiny)
library(shinydashboard)
library(DT)
manu p
  • 952
  • 4
  • 10
  • You could do a round trip of copying the content of your script, then read it in from clipboard, de-duplicate and write the result back to the clipboard from where you can then paste it back to your script. – deschen Feb 24 '22 at 07:19
  • 2
    Try: `writeLines(unique(readLines("lib.R")), "lib.R")` – zx8754 Feb 24 '22 at 07:51
  • 1
    What you really need is to put your favourite packages into [.Rprofile](https://stackoverflow.com/questions/10300769/how-to-load-packages-in-r-automatically), so they are preload every time you start R. – zx8754 Feb 24 '22 at 21:02
  • @zx8754 did not get you . Can you explain please? – manu p Feb 25 '22 at 01:45

0 Answers0