i have a dataset which needs to be cleaned 1
 *******
 *******
 *******
 *******
 s h
 hhhhh
 2
 *******
 jsh k
 *******
 *******
 *******
 *******this is how it's supposed to look id a1 a2 a3 a4 a5 a6 a7
1 1 * * * * * * *
2 1 * * * * * * *
3 1 * * * * * * *
4 1 * * * * * * *
5 1 <na> <na> s <na> <na> h <na>
6 1 <na> h h h h h <na>
7 2 * * * * * * *
8 2 j s h <na> <na> <na> k
9 2 * * * * * * *
10 2 * * * * * * *
11 2 * * * * * * *
12 2 * * * * * * *
cleaning raw data
try this using read.fwfd <- read.fwf(textconnection(
" 1 
*******
*******
*******
*******
 s h 
 hhhhh 
 2 
*******
jsh k
*******
*******
*******
*******"), 
 widths = rep(1, 7),
 na = c(" "),
 stringsasfactors = false)

id <- as.numeric(d[seq(1, nrow(d), 7), 5])
id <- rep(id, each = 6)

d <- d[seq(1, nrow(d), 7), ]
d <- cbind(id, d)
names(d)[-1] <- paste0("a", 1:7)
d

 id a1 a2 a3 a4 a5 a6 a7
3 1 * * * * * * *
4 1 * * * * * * *
5 1 * * * * * * *
6 1 <na> <na> s <na> <na> h <na>
7 1 <na> h h h h h <na>
8 1 <na> <na> <na> <na> 2 <na> <na>
9 2 * * * * * * *
10 2 j s h <na> <na> <na> k
11 2 * * * * * * *
12 2 * * * * * * *
13 2 * * * * * * *
14 2 * * * * * * *