B0ombo0mp0w
B0ombo0mp0w

Reputation: 1

R Script : How to keep the original format

I'm new to R and struggling abit with R auto convert my text string to number and this removed the ' 0 ' in some of my text.

I noticed this happened when i read in my txt file;

dataTheFlash <- read.csv(
  paste(strWF,"B_Allen_Is.txt",sep=""),  
  header = TRUE,
  sep=";",
  stringsAsFactors=FALSE
)

Is there anything i can do to keep my original content?

Many Thanks

Upvotes: 0

Views: 121

Answers (1)

RPyStats
RPyStats

Reputation: 316

You can specify which columns you want to keep as characters using the colClasses argument to read.csv.

dataTheFlash <- read.csv(
  paste(strWF,"B_Allen_Is.txt",sep=""),  
  header = TRUE,
  sep=";",
  stringsAsFactors=FALSE,
  colClasses = c('name_of_column'='character')
)

Upvotes: 1

Related Questions