s-news
[Top] [All Lists]

Problem with importData function

To: <s-news@lists.biostat.wustl.edu>
Subject: Problem with importData function
From: "Doug Bolgiano" <DougB@psbc.org>
Date: Tue, 14 Aug 2007 09:10:14 -0700
Thread-index: AcfejZk5MSA/Ek+IQAWP6FR1pjmuow==
Thread-topic: Problem with importData function

I’m having a problem importing worksheets from an Excel file via the importData function.  The context is that we receive two Excel files from a coordinating center on a monthly basis.  Each file has 4 worksheets (pages) with the same number of rows (say, n1 or n2) and varying numbers of columns per page.  The format does not vary from month to month.  I have written a function that will import the data from one of the Excel files, given a file path, file name and the number of rows of data.  It uses four calls to the importData function, one for each page (worksheet) in the file.  The import of the first file (4 pages) completes successfully and the function returns a data frame that has the variables (columns) from all 4 pages. 

 

When the function starts to import the first page from the second file it generates an error message:

 

            Problem: Invalid random number seed: numbers must be between 0 and 63 .  Use traceback() to see the call stack .

 

Traceback() shows:

 

> traceback()

7: eval(action, sys.parent())

6: doErrorAction("Problem: Invalid random number seed: numbers must be b

etween 0 and 63",

5: openOrImportData(file, type, rowsToRead, startCol, endCol, colNameRow

,

4: importData(file = paste(PathNamestrng, FileName2strng, sep = ""),

3: getCBBdata.both("S:\\Operations Div\\CordBlood\\Transplant Outcome Da

ta\\April 2007",

2: eval(_expression_(test2.1 <- getCBBdata.both(

1: NULL

Message: Problem: Invalid random number seed: numbers must be between 0

and 63. 

 

Immediately before the error message is generated I print the value of ‘.Random.seed’  :

 

            [1] 17 30 41 26 34  3  4 20 61 21 13  1 . 

 

If I rerun the function after receiving the above error message, it does not complete the import of the first file but immediately generates the above error message.  It appears that ‘.Random.seed’ is being augmented improperly but manually setting the ‘.Random.seed’ value with ‘set.seed’ does not solve the problem.  I have included the function script below.

 

Can someone shed some light on what is going on and how to fix the problem? 

 

Thanks,

 

Doug Bolgiano
Biostatistician
Puget Sound Blood Center
Seattle, WA   98104

getCBBdata.both <- function(PathNamestrng, FileName1strng, lastRow1, FileName2strng, lastRow2)

{

curpg1 <- importData(file=paste(PathNamestrng, FileName1strng,sep=""), startCol = 1, endCol = 17, startRow = 4,

     endRow = lastRow1,  pageNumber = 1)

pg1dim <- dim(curpg1)

pg1add <- curpg1[,1:pg1dim[2]]

curpg2 <- importData(file=paste(PathNamestrng, FileName1strng,sep=""), startCol = 1, endCol = 15, startRow = 4,

     endRow = lastRow1,  pageNumber = 2)

pg2dim <- dim(curpg2)

pg2add <- curpg2[,5:pg2dim[2]]

##curpgs1.2 <- data.frame(pg1add, pg2add)

curpg3 <- importData(file=paste(PathNamestrng, FileName1strng,sep=""), startCol = 1, endCol = 21, startRow = 4,

     endRow = lastRow1,  pageNumber = 3)

pg3dim <- dim(curpg3)

pg3add <- curpg3[,5:pg3dim[2]]

##curpgs1.3 <- data.frame(curpgs1.2, pg3add)

curpg4 <- importData(file=paste(PathNamestrng, FileName1strng,sep=""), startCol = 1, endCol = 17, startRow = 4,

     endRow = lastRow1,  pageNumber = 4)

pg4dim <- dim(curpg4)

pg4add <- curpg4[,5:pg4dim[2]]

##curpgs1.4 <- data.frame(pg1add,pg2add,pg3add, pg4add)

##return(curpgs1.4)

print("Completed import of first file.")

print(.Random.seed)

set.seed()

print(.Random.seed)

curpg2.1 <- importData(file=paste(PathNamestrng, FileName2strng,sep=""), startCol = 1, endCol = 17, startRow = 4,

     endRow = lastRow2,  pageNumber = 1)

pg1dim <- dim(curpg2.1)

pg2.1add <- curpg2.1[,1:pg1dim[2]]

print("Completed import of 1st page, 2nd file.")

print(.Random.seed)

curpg2.2 <- importData(file=paste(PathNamestrng, FileName2strng,sep=""), startCol = 1, endCol = 15, startRow = 4,

     endRow = lastRow2,  pageNumber = 2)

pg2dim <- dim(curpg2.2)

pg2.2add <- curpg2.2[,5:pg2dim[2]]

##curpgs1.2 <- data.frame(pg1add, pg2add)

print(.Random.seed)

curpg2.3 <- importData(file=paste(PathNamestrng, FileName2strng,sep=""), startCol = 1, endCol = 21, startRow = 4,

     endRow = lastRow2,  pageNumber = 3)

pg3dim <- dim(curpg2.3)

pg2.3add <- curpg2.3[,5:pg3dim[2]]

##curpgs1.3 <- data.frame(curpgs1.2, pg3add)

print(.Random.seed)

curpg2.4 <- importData(file=paste(PathNamestrng, FileName2strng,sep=""), startCol = 1, endCol = 17, startRow = 4,

     endRow = lastRow2,  pageNumber = 4)

pg4dim <- dim(curpg2.4)

pg2.4add <- curpg2.4[,5:pg4dim[2]]

curpgs21.4 <- data.frame(pg2.1add,pg2.2add,pg2.3add, pg2.4add)

return(curpgs21.4)

##return(pg4dim)

}

 

 

*****************************************************************
This e-mail and any attachments may contain confidential and
privileged information. It has been scanned for viruses. If you
are not the intended recipient, please notify the sender
immediately by return e-mail, delete this e-mail and destroy any
copies. Any dissemination, use, review, disclosure, or
distribution of this information by a person other than the
intended recipient is unauthorized and may be illegal.
*****************************************************************

<Prev in Thread] Current Thread [Next in Thread>