[R] read a file of text with read.table
Frede Aakmann Tøgersen
frtog at vestas.com
Thu Jun 26 10:26:25 CEST 2014
Hi Carol
I cannot reproduce what you're seeing.
> tmp <- read.table(text = "absfjdslf
+ jfdldskjff
+ jfsldfjslk")
> str(tmp)
'data.frame': 3 obs. of 1 variable:
$ V1: Factor w/ 3 levels "absfjdslf","jfdldskjff",..: 1 2 3
> tmp <- read.table(text = "absfjdslf
+ jfdldskjff
+ jfsldfjslk",
+ colClasses = "character")
> str(tmp)
'data.frame': 3 obs. of 1 variable:
$ V1: chr "absfjdslf" "jfdldskjff" "jfsldfjslk"
Yours sincerely / Med venlig hilsen
Frede Aakmann Tøgersen
Specialist, M.Sc., Ph.D.
Plant Performance & Modeling
Technology & Service Solutions
T +45 9730 5135
M +45 2547 6050
frtog at vestas.com
http://www.vestas.com
Company reg. name: Vestas Wind Systems A/S
This e-mail is subject to our e-mail disclaimer statement.
Please refer to www.vestas.com/legal/notice
If you have received this e-mail in error please contact the sender.
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On Behalf Of carol white
> Sent: 26. juni 2014 09:33
> To: r-help at r-project.org
> Subject: [R] read a file of text with read.table
>
> It might be a primitive question but I have a file of text and there is no
> separator between character on each line and the strings on each line have
> the same length. The format is like the following
>
> absfjdslf
> jfdldskjff
> jfsldfjslk
>
> When I read the file with read.table("myfile",colClasses = "character"),
> instead of putting the strings in a table of number of rows x length of string,
> read.table saves the file in a table of number of rows x 1 and each element
> seems to be a factor. Why does read.table not account for colClasses =
> "character"?
>
> thanks,
>
> Carol
> [[alternative HTML version deleted]]
More information about the R-help
mailing list