As said in Ben’s answer, colClasses
is the easier way to do it. Here is an example:
read.table(text="col1 col2
0012 0001245",
head=T,
colClasses=c('character','numeric'))
col1 col2
1 0012 1245 ## col1 keep 00 but not col2
More Related Contents:
- How can you read a CSV file in R with different number of columns
- Issue when importing dataset: `Error in scan(…): line 1 did not have 145 elements`
- Quickly reading very large tables as dataframes
- Only read selected columns
- How can I read multiple (excel) files into R? [duplicate]
- How do you read multiple .txt files into R? [duplicate]
- Specify custom Date format for colClasses argument in read.table/read.csv
- read.csv warning ‘EOF within quoted string’ prevents complete reading of file
- How do I import a CSV file in R? [closed]
- How to index an element of a list object in R
- Reading multiple csv files from a folder into a single dataframe in R [duplicate]
- Import data into R with an unknown number of columns?
- How to check if CSV file has a comma or a semicolon as separator?
- import dat file into R
- Preserving large numbers
- How to read.table() multiple files into a single table in R?
- How can I read the header but also skip lines – read.table()?
- Trying to merge multiple csv files in R
- Reading a CSV file organized horizontally
- Importing “csv” file with multiple-character separator to R?
- Subset / filter rows in a data frame based on a condition in a column
- rank and order in R
- Removing non-ASCII characters from data files
- Proper idiom for adding zero count rows in tidyr/dplyr
- Add NAs to make all list elements equal length
- Exactly storing large integers
- How to deal with nonstandard column names (white space, punctuation, starts with numbers)
- Combinations by group in R
- Convert accented characters into ascii character
- Change the position of the strip label in ggplot from the top to the bottom?