I am having a problem with output formatting in my program. The cat()
function, when combined with the conversion to binary, produces spaces
between each of the digits. I have included the code, and a snippet of the
output. The code has NOT been cleaned up yet, I am just hunting for correct
functionality. Thanks.
input <- read.csv('input.csv', header=FALSE)
run_total <- NROW(input)
run <- 1
xpointer <- 1
xxpointer <- 2
ypointer <- 1
yypointer <- 2
file.remove("generated.txt")
sink("generated.txt", append = TRUE)
cat(rev(as.integer(intToBits(as.integer(input[xpointer,1]))[1:17])),
collapse="")
cat(",")
cat(input[ypointer,2])
cat("\n")
while(run < run_total)
{
        x1 <- input[xpointer,1]
        x2 <- input[xxpointer,1]
        y1 <- input[ypointer,2]
        y2 <- input[yypointer,2]
        num_segmentsy <- (y2-y1)
        num_segmentsx <- (abs(x2-x1))
        num_segments <- num_segmentsx
        ystep <- num_segmentsy/num_segmentsx
        xstep <- 1
        num_points <- num_segments - 1
        created <- 0
        ypoint <- y1
        xpoint <- x1
        while(created < num_points)
        {
                ypoint <- ypoint + ystep
                xpoint <- xpoint + xstep
                cat(rev(as.integer(intToBits(as.integer(xpoint))[1:17])),
collapse="")
                cat(",")
                cat(ypoint)
                cat("\n")
                created <- created + 1
        }
        cat(rev(as.integer(intToBits(as.integer(x2))[1:17])),
collapse="")
        cat(",")
        cat(y2)
        cat("\n")
        xpointer <- xpointer + 1
        xxpointer <- xxpointer + 1
        ypointer <- ypointer + 1
        yypointer <- yypointer + 1
        run <- run +1
}
sink()
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ,0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ,0.1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 ,0.2
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 ,0.3
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 ,0.4
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 ,0.5
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 ,0.6
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 ,0.7
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 ,0.8
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 ,0.9
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 ,1
Thanks so much, in advance.
-- 
Jason Thibodeau
	[[alternative HTML version deleted]]