Is there any way to read a file by every n characters?

14 views
Skip to first unread message

Zhenjiang Lan

unread,
Aug 27, 2012, 6:11:19 PM8/27/12
to ggplot2
Hi,

I know this question is not relative to ggplot2, but...

I want to read a file into R, with no separator, every n (1,2,3,4...)
characters as a column. for example:

file:

123456789
987654321
111111111

I want to get a table like

123 456 789
987 654 321
111 111 111

(n=3 here.)

Any function can do this? I search but found nothing...

Thanks!

R. Michael Weylandt

unread,
Aug 27, 2012, 6:19:53 PM8/27/12
to Zhenjiang Lan, ggplot2
Take a look at ?read.fwf which might get what you need.

(FWF = "Fixed width format")

Cheers,
Michael
> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2

Paulo Eduardo Cardoso

unread,
Aug 27, 2012, 6:50:02 PM8/27/12
to ggp...@googlegroups.com
See this.
Reply all
Reply to author
Forward
0 new messages