Hi,

The solution that works now is

                closeAllConnections()

But even if I replace the 'list' with the 'array' I get a similar error.

"Exception is  Error in UseMethod(\"close\"): no applicable method for
'close' applied to an object of class \"c('double', 'numeric')\"\n"

#Write each CPU's utilization data into a
#separate file
filelist.array <- function(n){
  cpufile <- list()
  cpufiledescriptors <- array(n,dim=c(0,n))
  length(cpufile) <- n
  for (i in 1:n) {
    cpufile[[i]] <- paste("output", i, ".txt", sep = "")
        cpufiledescriptors[i]<-file( cpufile[[i]], "a" )
  }
    listoffiles <- list(cpufile=cpufile,
cpufiledescriptors=cpufiledescriptors)
        return (listoffiles)
}

Thanks,
Mohan


                                                                            
                                                                            
                                                                            
   Re: [R] List of lists                                                    
                                                                            
                                                                            
   Jim Lemon                                                                
              to:                                                           
                 mohan.radhakrishnan                                        
                                                           31-07-2013 05:19 
                                                                         PM 
                                                                            
                                                                            





On 07/31/2013 04:18 PM, mohan.radhakrish...@polarisft.com wrote:
> Hi Jim,
>
>      close(filedescriptors$cpufiledescriptors[[1]])
>      close(filedescriptors$cpufiledescriptors[[2]])
>      close(filedescriptors$cpufiledescriptors[[3]])
>
>    I might be doing something wrong. Error is
>
>     Error in UseMethod("close") :
>    no applicable method for 'close' applied to an object of class "c
> ('integer', 'numeric')"
>
Hi Mohan,
I just ran the code within your function "filelist.array" and then was
able to close the connections I had created. I entered your function in R:

filelist.array<- function(n){
     cpufile<- list()
     cpufiledescriptors<- list()
     length(cpufile)<- n
     for (i in 1:n) {
       cpufile[[i]]<- paste("output", i, ".txt", sep = "")
                                  cpufiledescriptors[[i]]<-file( cpufile[[i]],
"a" )
     }
       listoffiles<- list(cpufile=cpufile,
  cpufiledescriptors=cpufiledescriptors)
                                  return (listoffiles)
}

and then:

filedescriptors<-filelist.array(3)
close(filedescriptors$cpufiledescriptors[[1]])
close(filedescriptors$cpufiledescriptors[[2]])
close(filedescriptors$cpufiledescriptors[[3]])

and it worked fine. Perhaps a typo in your code somewhere?

Jim




This e-Mail may contain proprietary and confidential information and is sent 
for the intended recipient(s) only.  If by an addressing or transmission error 
this mail has been misdirected to you, you are requested to delete this mail 
immediately. You are also hereby notified that any use, any form of 
reproduction, dissemination, copying, disclosure, modification, distribution 
and/or publication of this e-mail message, contents or its attachment other 
than by its intended recipient/s is strictly prohibited.

Visit us at http://www.polarisFT.com

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to