Skip to content

write data using xlsReadWrite

7 messages · Ethan Brown, diyanah, David Winsemius

#
Hai, I'm trying to write these var output data from these codes inside excel
file. My directory to store the data is 
/D:\FYP\image /
but receive an error message :

/Error in write.xls(mydata, "D:\\FYP\\image.mydata.xls") : 
  object 'mydata' not found/

these are my codes, can you help give an advice or idea with my problem:

/library("biOps")
library("waveslim")
library("xlsReadWrite")
x <- readTiff("D:\\FYP\\image\\SignatureImage\\user186g1.tif")
y <- imgBlockMedianFilter(x, 5)
#Plot image
#plot(y)
y.modwt <- modwt.2d(y, "la8", 2)
## Level 2 decomposition
par(mfrow=c(2,2), pty="s")
##Plot wavelets
image(y.modwt$LH2, col=rainbow(128), axes=FALSE, main="LH2")
image(y.modwt$HH2, col=rainbow(128), axes=FALSE, main="HH2")
image(y.modwt$LL2, col=rainbow(128), axes=FALSE, main="LL2")
image(y.modwt$HL2, col=rainbow(128), axes=FALSE, main="HL2")
#-------------------------------------------------------------------#
##Get the dimension
##LH2
dimLH2 <- dim(y.modwt$LH2)
dimLH2x <- dimLH2[1]
dimLH2y <- dimLH2[2]
varLH2xlist <- c(rep(0, dimLH2x))
varLH2ylist <- c(rep(0, dimLH2y))
##Loop to get variance from x axis
for(i in seq(dimLH2x)){
    varLH2xlist[i] <- var(y.modwt$LH2[i,])
}
##Get the variance from the overall x variance
varLH2x <- var(varLH2xlist)
##Loop to get variance from y axis
for(i in seq(dimLH2y)){
    varLH2ylist[i] <- var(y.modwt$LH2[,i])
}
##Get the variance from the overall y variance
varLH2y <- var(varLH2ylist)
#-----------------------------------------------------------------#
##Get the dimension
##HH2
dimHH2 <- dim(y.modwt$HH2)
dimHH2x <- dimHH2[1]
dimHH2y <- dimHH2[2]
varHH2xlist <- c(rep(0, dimHH2x))
varHH2ylist <- c(rep(0, dimHH2y))
##Loop to get variance from x axis
for(i in seq(dimHH2x)){
    varHH2xlist[i] <- var(y.modwt$HH2[i,])
}
##Get the variance from the overall x variance
varHH2x <- var(varHH2xlist)
##Loop to get variance from y axis
for(i in seq(dimHH2y)){
    varHH2ylist[i] <- var(y.modwt$HH2[,i])
}
##Get the variance from the overall y variance
varHH2y <- var(varHH2ylist)
#-----------------------------------------------------------------#
##Get the dimension
##LL2
dimLL2 <- dim(y.modwt$LL2)
dimLL2x <- dimLL2[1]
dimLL2y <- dimLL2[2]
varLL2xlist <- c(rep(0, dimLL2x))
varLL2ylist <- c(rep(0, dimLL2y))
##Loop to get variance from x axis
for(i in seq(dimLL2x)){
    varLL2xlist[i] <- var(y.modwt$LL2[i,])
}
##Get the variance from the overall x variance
varLL2x <- var(varLL2xlist)
##Loop to get variance from y axis
for(i in seq(dimLL2y)){
    varLL2ylist[i] <- var(y.modwt$LL2[,i])
}
##Get the variance from the overall y variance
varLL2y <- var(varLL2ylist)
#-----------------------------------------------------------------#
##Get the dimension
##HL2
dimHL2 <- dim(y.modwt$HL2)
dimHL2x <- dimHL2[1]
dimHL2y <- dimHL2[2]
varHL2xlist <- c(rep(0, dimHL2x))
varHL2ylist <- c(rep(0, dimHL2y))
##Loop to get variance from x axis
for(i in seq(dimHL2x)){
    varHL2xlist[i] <- var(y.modwt$HL2[i,])
}
##Get the variance from the overall x variance
varHL2x <- var(varHL2xlist)
##Loop to get variance from y axis
for(i in seq(dimHL2y)){
    varHL2ylist[i] <- var(y.modwt$HL2[,i])
}
##Get the variance from the overall y variance
varHL2y <- var(varHL2ylist)
#-----------------------------------------------------------------#
##write excel file
write.xls(mydata, "D:\\FYP\\image.mydata.xls")/

--
View this message in context: http://r.789695.n4.nabble.com/write-data-using-xlsReadWrite-tp4629825.html
Sent from the R help mailing list archive at Nabble.com.
1 day later
#
You're trying to write an object that you've never created. If you
want to write `varHL2y`, which it appears you do, you would replace
that for `mydata` in your command.

Best,
Ethan
On Sun, May 13, 2012 at 1:33 AM, diyanah <yanadj28 at gmail.com> wrote:
1 day later
#
Thank you,

I came up with these. Problem solve.

varValue <- data.frame(varLH2x, varLH2y, varHH2x, varHH2y, varLL2x, varLL2y,
varHL2x, varHL2y)
res<-write.xlsx(varValue, "D:\\FYP\\image\\Cropped
Images\\user61\\genuineUser61temp.xlsx", sheetName="Sheet1",col.names=TRUE,
row.names=TRUE, append=FALSE)



--
View this message in context: http://r.789695.n4.nabble.com/write-data-using-xlsReadWrite-tp4629825p4630204.html
Sent from the R help mailing list archive at Nabble.com.
#
Hai,
I use these codes to read my data from the above data that I create, but how
can I get rid of the first V1, because it is row number, not one of my data
value. 
Second, how can I read row 1 and only column 1 (V2 value for example).

setwd("D:\\FYP\\image\\Cropped Images\\user61")
info
<-read.xlsx("forgerUser61.xlsx",sheetName="Sheet1",rowIndex=2:2,header=FALSE)
--
View this message in context: http://r.789695.n4.nabble.com/write-data-using-xlsReadWrite-tp4629825p4630209.html
Sent from the R help mailing list archive at Nabble.com.
#
On May 15, 2012, at 10:08 PM, diyanah wrote:

            
Why do you want to get rid of it? What harm is it doing? (Dataframes  
need to have rownames, many functions depend on that aspect of  
dataframes,  and if you do not provide them,  then default rownames  
get inserted.)
Use colClasses, nrows
?read.table
David Winsemius, MD
West Hartford, CT
#
Hai, I have change it to these, but error and I couldn't fix it. Do you have
any idea why?

file <- system.file("D:\\FYP\\image\\Cropped Images\\user61",
"forgerUser61.xlsx", package = "xlsx")
wb <- loadWorkbook("forgerUser61.xlsx")
sheets <- getSheets(wb)
sheet <- sheets[["all"]]
res <- readRows(sheet, startRow=4, endRow=5, startColumn=2, endColumn=3)
endColumn = 3) :
--
View this message in context: http://r.789695.n4.nabble.com/write-data-using-xlsReadWrite-tp4629825p4630231.html
Sent from the R help mailing list archive at Nabble.com.
6 days later
#
Hi Ive come up with this code to read my file, but receive an error that I ve
no idea how to fix. can some one help.
here is an example of my data in .xlsx

	      varLH2x	       varLH2y	       varHH2x	        varHH2y	       varLL2x	      
varLL2y	       varHL2x	       varHL2y
1	4967.552716	12278.95794	679.3101705	254.2841431	4480777.986	3792655.605
2149.541058	827.9458738
2	5629.682598	8439.341331	812.4770397	326.7078909	6257926.174	4259659.878
1959.730324	1396.045697
3	5358.412977	8522.830297	967.7044858	420.9888243	6189762.401	3684682.244
3483.700887	1293.746943




--
View this message in context: http://r.789695.n4.nabble.com/write-data-using-xlsReadWrite-tp4629825p4631019.html
Sent from the R help mailing list archive at Nabble.com.