Hello,

Try the following.

x <- scan(text="
-100 -100-3456-3456-3456-100 -100
23 -3456-3456-189 34 56 78
-100 34 56 21 44 65 78
", what = "")


fun <- function(x){
     f <- function(.x){
         if(grepl("-[[:digit:]]+", .x)){
             g <- gregexpr("-[[:digit:]]+", .x)
             .y <- as.numeric(unlist(regmatches(.x, g)))
         }else{
             .y <- as.numeric(.x)
         }
         .y
     }
     unlist(unname(sapply(x, f)))
}

fun(x)


Hope this helps,

Rui Barradas
Em 30-11-2012 12:55, Jaime Otero Villar escreveu:
> Hi,
>
> I was wondering if it's possible to separate elements in multiple rows 
> that actually should appear in different columns. I have a file where 
> in certain lines there are elements not separated, and they certainly 
> should appear in different columns (an example of the file is 
> attached). The point is that I do not want to manually add a space in 
> the txt file, however, I did not manage to do it automatically in R...
>
> Thanks in advance for any insight.
>
> Jaime
>
>
>
>
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


	[[alternative HTML version deleted]]


