The readDNAStringSet() reads a set of sequences from a file into an XStringSet object. To see the help page of the XStringSet-class, use:
?XStringSet
There you will find why length(x) returned 1:
length(x): The number of sequences in x.
For an DNAStringSet object, the function you want is width(). If you want a DNAString, you may extract just one element of the DNAStringSet and assign it to a new variable:
xString <- x[[1]]
Now, length(xString) will show the sequence length.
type
width(x)
. This would print the lengths of all sequences in DNAstringset object.