This are general coding errors.

For else issue, R expects else brackets in the same line. Try changing:

}
else
{

for

}else{


And the problem with exporting the bed file, I thing that the problem is 
that you don't have the variable "name" defined in the description attribute

export.bed(peaks, score=NULL, name="Peaks", *description=name*, 
filepath=outputfile, splitByChrom=FALSE)


I hope this fix your problems

Regards

Oscar

	[[alternative HTML version deleted]]

