r - save data, code together? -


i reading in file in spss format (.por), cleaning in r , exporting clean .csv file. possible save code using read/clean/export data save along data? in other words, want able load datafile @ later point , able recall how created.

if want console, here's hack:

foo<-attributes(myfunc)$srcref write.table(as.character(foo),'myfunc.txt') 

edit: answer paul's question, here's output 1 of 'toys' . elements of each row (one element per pair of quotation marks) tab-separated.

"x" "1" "function(x, numdig=3, na.rm=true,printit=true)" "2" "{" "3" "   x<-as.vector(x)" "4" "   if (na.rm)   x <- x[!is.na(x)]" "5" "   skewx<-theskew(x)" "6" "   kurtosisx<-thekurt(x)" "7" "   #allstats<-list(min=min(x), max=max(x), mean=mean(x), median=median(x),sdev=sd(x), skew=theskew(x), kurtosis=thekurt(x))" "8" "   #looks nicer w/ dataframe rather pure list" "9" "   allstats<-data.frame(cbind(min=min(x), max=max(x), mean=mean(x), median=median(x),sdev=sd(x), skew=theskew(x), kurtosis=thekurt(x)),row.names='')" "10" "  #too long 1 line" "11" "  if(printit)" "12" "      {" "13" "      print(format(allstats[1:4],digits=numdig))" "14" "      print(format(allstats[5:7],digits=numdig))" "15" "  }" "16" "  return(invisible(allstats))" "17" "  }" 

i have not tried find console hack convert text function code, bet simple gsub('"','',textobject[,2]) work.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -