Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@porthunt
Last active March 7, 2016 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save porthunt/c9200756083e50f18981 to your computer and use it in GitHub Desktop.
Save porthunt/c9200756083e50f18981 to your computer and use it in GitHub Desktop.
String conversion
setwd("C:/Users/user/Desktop") #Use the path that your file is in.
names <- readLines("ALL.txt") #Read file
listOfNames <- ""
for (i in names) { listOfNames <- paste(listOfNames,",",i) }
listOfNames <- gsub(" ", "", listOfNames) #Remove whitespaces
substr(listOfNames, 2, nchar(listOfNames)) #Remove first comma
# Given a file with strings in the following format:
#
# A
# B
# C
#
# It transforms into A,B,C
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment