This seems to produce your sample output.
# It is essential that there be NO FACTORS
A<-read.table("fileA.txt",header=T,stringsAsFactors=F)
B<-read.table("fileB.txt",header=T,stringsAsFactors=F)
# build template with position in the appropriate ranges
template <- do.call(rbind,lapply(1:nrow(B),
function(i) cbind(location=B[i,]$location,
position=seq(B[i,]$start,B[i,]$end-1),
label=B[i,]$label)
))
template <- data.frame(template, stringsAsFactors=F)
# add position column to A, return as C
C <- merge(A,template,by=c("location","label"),all=T)
is.between <- function(x,low,hi) return(x>=low & x<=hi)
C <- C[is.between(C$position,C$start,C$end-1),]
C <- C[,c("location","position",value="value","label")]
C
# location position value label
# 1 X 78007 21 juliet
# 7 X 78008 8 juliet
# 8 X 78009 8 juliet
# 9 X 78010 8 juliet
# 10 X 78011 8 juliet
# 11 X 77998 0 romeo
# 12 X 77999 0 romeo
# 20 X 78000 56 romeo
# 21 X 78001 56 romeo
# 22 X 78002 56 romeo
# 23 X 78003 56 romeo
# 31 X 78004 12 romeo
# ...