R/ns.windows.R

Defines functions ns.windows

Documented in ns.windows

ns.windows <-
function(event=event,censor=censor,marker=marker,nsub,sspeed)
	{	data = data.frame(event,censor,marker)
		dataorder = data[order(data$marker),]
    		
		ntotal = length(marker)
      	xtotal = ceiling(ntotal/sspeed)
      	wdata = vector("list",xtotal); wband = nsam = winsize = xwin = NA
     		
		i = j = 1
     		repeat{
			wband[i] = min(j-1,nsub,ntotal-j)
       		wdata[[i]] = dataorder[c((j-wband[i]):(j+wband[i])),]
        		nsam[i] = dim(wdata[[i]])[1]  
        		xwin[i] = dataorder$marker[j]
        		winsize[i] = max(wdata[[i]]$marker)-min(wdata[[i]]$marker)
        		i <- i+1
        		j <- j+sspeed
        		if(j>ntotal) 
			break()	}

   	return(list(xwin = xwin, ntotal = xtotal, wdata = wdata, nsam = nsam, winsize = winsize))	}

Try the WPC package in your browser

Any scripts or data that you put into this service are public.

WPC documentation built on May 2, 2019, 6:52 a.m.