3

I have a text file with 100 names that I am trying to concatenate to create a large single string using the following code. However, my output is showing me a number for each name instead of the actual names itself.

It seems that when these names are being converted into character using the paste function, they are being converted into numbers. Any help will be greatly appreciated.

input=(read.csv("names.txt"))
final_output1 = paste(input, collapse = '')
3
  • 3
    Can you provide an excerpt of names.txt please? Commented Jun 17, 2015 at 17:30
  • 1
    Set stringsAsFactors = FALSE in read.csv. Commented Jun 17, 2015 at 17:33
  • 1
    If you have a single column paste(input[,1], collapse='') You can check the difference paste(data.frame(factor(letters)),collapse='') and paste(factor(letters),collapse='') Commented Jun 17, 2015 at 17:34

1 Answer 1

2

The read.csv() function has a "stringAsFactors" argument that you can set to FLASE.

input <- read.csv("names.txt", stringsAsFactors=FALSE)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.