<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"></head><body
 style="font-family: Arial; font-size: 14pt;" wsmode="compose" 
bgcolor="#FFFFFF" text="#000000">
<div style="font-size: 14pt;font-family: Arial;"><span><pre wrap="">Hi!
I am new to R and I have a lot of trouble in going from a phylip or fasta file to a genind object or fasta2DNAbin containing pop information.
My files are always phylip or fasta files, and sequences have a reference composed of an di-alpha followed by 4 numeric digits (e.g. CD1495). The first two letters determine the population to which the sequence belongs to.

Is there a quick way to do it instead of doing this, as the grouping factor can be easily deduced from the current individual labels, saving the task of read that info R separately?

#reading data
dna <- fasta2DNAbin('data.fas')
# setting pops
data.pop <- as.factor(rep(c('AD', 'CD', 'FR', 'GE', 'RE', 'OT', 'YU', 'AU'), c(17, <span __postbox-detected-content="__postbox-detected-date" class="__postbox-detected-content __postbox-detected-date" style="display: inline; font-size: inherit; padding: 0pt;">11, <span __postbox-detected-content="__postbox-detected-date" class="__postbox-detected-content __postbox-detected-date" style="display: inline; font-size: inherit; padding: 0pt;">12, <span __postbox-detected-content="__postbox-detected-date" class="__postbox-detected-content __postbox-detected-date" style="display: inline; font-size: inherit; padding: 0pt;">12, 25, 14,</span></span></span><span __postbox-detected-content="__postbox-detected-date" class="__postbox-detected-content __postbox-detected-date" style="display: inline; font-size: inherit; padding: 0pt;"><span __postbox-detected-content="__postbox-detected-date" class="__postbox-detected-content __postbox-detected-date" style="display: inline; font-size: inh
erit; padding: 0pt;"> 13,</span></span><span __postbox-detected-content="__postbox-detected-date" class="__postbox-detected-content __postbox-detected-date" style="display: inline; font-size: inherit; padding: 0pt;"> 20)))</span>

Many thanks
Rita</pre> </span></div>
</body>
</html>