Perfect. Thanks!


On Tue, Mar 18, 2014 at 2:26 PM, Thomas Lumley <tlumley@uw.edu> wrote:

> On Tue, Mar 18, 2014 at 12:43 PM, Dustin Fife <fife.dustin@gmail.com>wrote:
>
>> I've got a dataset with really long column names (e.g.,
>> CYJ.OSU.OAV.UJC.BUT.RDI). What I'd like to do is replace the fourth period
>> with a break ("\n") so that when it plots, it will not run off the page.
>> Here's what I've got so far:
>>
>> #### create fake names function
>> fake.names = function(x){
>>     paste0(LETTERS[sample(1:26,3)], collapse="")
>> }
>> #### create the fake names
>> fake = paste0(unlist(lapply(1:6, fake.names)), collapse=".")
>>
>>
> Backreferences
>
> cat(
>   gsub("(([[:alnum:]]+\\.){3})([[:alnum:]]+)\\.",
>              "\\1\\2\n",
>               fake
>           )
> )
>
> That is, match three word/period sequences, match a word, match a period,
> and output the first two things.
>
>   -thomas
>
> --
> Thomas Lumley
> Professor of Biostatistics
> University of Auckland
>

	[[alternative HTML version deleted]]


