Last active
March 7, 2016 16:43
-
-
Save porthunt/c9200756083e50f18981 to your computer and use it in GitHub Desktop.
String conversion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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