Moore, Meagan
2010-Sep-01 02:59 UTC
[R] problems with JGR and standard R GUI closing during calculations
Hi R help, I am having problems running calculations in both the standard R GUI (ver 2.11.0) and the Java GUI for R (1.7-2) in Windows XP Service Pack 3 (2.2 GHz processor with 2 GB of RAM). When I try to import my data and run calculations on it, the GUI closes within a minute, sometimes almost instantaneously after I try to import data to then run the rest of my script. Has anyone had this problem before? Or does anyone recommend a different GUI for intense number crunching? I have included details of my script below for further reference. Any advice is much appreciated. Thanks, Meagan Script objective/specific problem: Trying to read 'fCCN' values every second off of 'SMPS' data every 5 mins to calculate output of 'activation diameter' every second).Total time series is about 3 weeks, however, even when I try shortening the data to about half a day or so, I still have the same problem. Sometimes the GUI will close right away, sometimes it will read the first time series of data and close when I try to read the second time series in. This is before I even try to really run the calculation where I am trying to read a value from one time series off of the other. Script: ###load libraries library(chron) ###define functions ## read SMPS read.smps <- function(filename,patt="%m/%d/%Y %H:%M:%S") { f <- file(filename,open="rt") header <- scan(f,what="",quiet=TRUE,sep="\t",nlines=1) smps <- read.table(f,check.names=FALSE,comment.char="",sep="\t", colClasses=c("character",rep("numeric",length(header)-1))) close(f) list(size=as.numeric(header[-1]), time=as.chron(smps[,1],patt), dat=`dimnames<-`(as.matrix(smps[,-1]),list(smps[,1],header[-1]))) } ## read fCCN file read.fCCN <- function(filename,patt="%m/%d/%Y %H:%M:%S") { dat <- read.table(filename,check.names=FALSE,comment.char="", sep="\t",header=TRUE,colClasses=c("character", "numeric")) dat$times <- as.chron(dat$times,patt) dat } ## to get activation diameters getDact <- function(size,perc,fccn) approx(perc,size,(1-fccn)*100)$y ## format times for output formatTimes <- function (x, patt = "%m/%d/%Y %H:%M:%S") { posixtime <- as.POSIXct(paste(as.Date(dates(x)), times(x)%%1)) format(posixtime, patt) } ###import data ***(where the GUI will close)**** smps <- read.smps("SMPS_OL_cuml_v2.txt") fccn <- read.fCCN("fCCN_ONLY_forSMPS_v1.txt") ###output table by fCCN times ## loop DactTable <- data.frame(times=fccn$times,Dact=NA) for( x in 2:length(smps$time) ) { ## find fCCN times corresonding to SMPS selection <- (fccn$times >= smps$time[x-1] & fccn$times <= smps$time[x]) ## if any, calculate activation diameters, otherwise, NA if( any(selection) ) DactTable[selection,"Dact"] <- getDact(smps$size,smps$dat[x-1,],fccn$fCCN[selection]) } ## format the table DactTable$times <- formatTimes(DactTable$times) write.table(DactTable, file="Dact-output3.txt",sep="\t",quote=FALSE, row.names=FALSE,col.names=TRUE) *********************** Meagan J.K. Moore Chemistry and Biochemistry UC San Diego Graduate Student moore at ucsd.edu