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')" Thanks, Mohan Re: [R] List of lists Jim Lemon to: mohan.radhakrishnan, R-help@r-project.org 31-07-2013 03:05 AM On 07/30/2013 10:05 PM, mohan.radhakrish...@polarisft.com wrote: > > Hi, > I am creating a list of 2 lists, one containing filenames > and the other file descriptors. When I retrieve them I am unable to close > the file descriptor. > > I am getting this error when I try to call close(filedescriptors > [[2]][[1]]). > > Error in UseMethod("close") : > no applicable method for 'close' applied to an object of class "c > ('integer', 'numeric')" > > print(filedescriptors[[2]][[1]]) seems to be printing individual elements. > > Thanks, > Mohan > > 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) > } > > > > #Test function > > test.filelist.array<- function() { > filedescriptors<- filelist.array(3) > print(filedescriptors[[2]][[1]]) > print(filedescriptors[[2]][[2]]) > print(filedescriptors[[2]][[3]]) > > } > > Hi Mohan, When you have opened connections as above, you need to pass the connection, not just one element, to "close": close(listoffiles$cpufiledescriptors[[1]]) 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.