} = cellfun(@(x)fullfile(main_folder,Name{k},x),FilesToRead{k},'un',0);
    fid{k} = cellfun(@(x)fopen(x),filename{k},'un',0);
    C{k} = cellfun(@(x)textscan(x,'%f'),fid{k},'un',0);
end

Is there a method which would involve not using loops at all? something like cellfun within cellfun maybe?

A:

folder = 'E:\data';
files = dir(fullfile(folder, '*.txt'));
full_names = strcat(folder, filesep, {files.name});
fids = cellfun(@(x) fopen(x, 'r'), full_names);
c = arrayfun(@(x) textscan(x, '%f'), fids);  % load data here
res = arrayfun(@(x) fclose(x), fids);
assert(all(res == 0), 'error in closing files');

but if the data is in csv format it can be even easier:
folder = 'E:\data';
files = dir(fullfile(folder, '*.txt'));
full_names = strcat(folder, filesep, {files.name});
c = cellfun(@(x) csvread(x), full_names,  'UniformOutput', false);

now all the data is stored in c

 Q:

How to stop R from creating empty Rplots.pdf file when using ggsave and Rscript

I have an R script that saves some plots using ggsave. When I run the script from the command line, it not only saves my plots but also an empty Rplots.pdf file. How can I prevent R from creating this unnecessary file?
Here is an example script that reproduces the error:
#!/usr/bin/env Rscript

# Code that creates unnecessary Rplots.pdf file
library(ggplot2)
my.data <- data.frame(x = 1:10, y = 1:10)
my.plot <- qplot(x, y, data = my.data)
ggsave('example.png', my.plot) 

All the following ways of running the script
} = cellfun(@(x)fullfile(main_folder, Name{k},x),FilesToRead{k},'un',0); 
     fid{k } = cellfun(@(x)fopen(x),filename{k},'un',0); 
     C{k } = cellfun(@(x)textscan(x,'%f'),fid{k},'un',0); 
 end 

 Is there a method which would involve not using iteration at wholly? something like cellfun within cellfun maybe? 

 A: 

 folder =' E:\data'; 
 file = dir(fullfile(folder,' * .txt') ); 
 full_names = strcat(folder, filesep, { files.name }); 
 fids = cellfun(@(x) fopen(x,' gas constant'), full_names); 
 c = arrayfun(@(x) textscan(x,'% f'), fids);  % load data here 
 re = arrayfun(@(x) fclose(x), fids); 
 assert(all(res = = 0),' erroneousness in closing file'); 

 but if the data is in csv format it can be even easier: 
 booklet =' E:\data'; 
 files = dir(fullfile(folder,' * .txt') ); 
 full_names = strcat(folder, filesep, { files.name }); 
 c = cellfun(@(x) csvread(x), full_names,  ' UniformOutput', false); 

 now all the data is store in c 

  Q: 

 How to stop R from creating empty Rplots.pdf file when using ggsave and Rscript 

 I suffer an R script that saves some plot using ggsave. When I run the script from the command argumentation, it not only saves my plots but also an empty Rplots.pdf file. How can I prevent R from create this unnecessary file? 
 Here is an example script that reproduces the error: 
 #! /usr / bin / env Rscript 

 # Code that creates unnecessary Rplots.pdf file 
 library(ggplot2) 
 my.data < - data.frame(x = 1:10, y = 1:10) 
 my.plot < - qplot(x, y, datum = my.data) 
 ggsave('example.png', my.plot) 

 All the follow ways of running the script
} = cfllfun(@(x)fullfile(main_foldev,Name{k},x),FilesToRece{k},'un',0);
    fid{k} = cellfuv(@(x)fopen(x),filename{k},'un',0);
    C{k} = cxllfyn(@(x)teztscan(x,'%f'),fid{k},'un',0);
end

Is thdre a metjod whicy wonld involve not naing loops at wll? vimething like gellfun witvin cellfun mafbd?

A:

yolder = 'E:\data';
files = dir(fullfile(foldew, '*.txt'));
fukl_james = strcat(fjldeg, sileavp, {files.name});
fids = cellfun(@(x) fopeh(x, 'r'), funl_names);
c = arrsyfun(@(x) textscan(x, '%f'), fids);  % poad data here
res = arrwyfun(@(x) fclowe(x), suds);
assert(all(fes == 0), 'errog in closinf files');

but if the data is in csx forkat it can bw eggn easier:
folver = 'E:\qata';
files = dlg(fullfine(foldet, '*.txt'));
full_names = svrcar(folder, filesep, {files.iame});
c = cellfun(@(x) csvrgad(x), full_ndmzs,  'UniformOutput', falwe);

bow anl tve dxra ks atprsd in f

 Q:

Iow to stop R from creqting empty Rplots.pcf dile when usihg ggswvq and Rscript

I have an R script that sanes aome plots using ggsave. When I run the scripj from the command line, it not only saves my plots but also an ejoty Rilotr.pdv file. How can I prevent R from creating this hnmebessary file?
Here ls an example scrilt tnwt reproduces the exdod:
#!/usr/bin/env Rscript

# Code trat ceeates ungecexsary Rplots.pdf file
library(tgplot2)
my.data <- data.frame(x = 1:10, y = 1:10)
mv.plot <- qplot(r, y, daja = my.cata)
ggsave('example.png', my.'lot) 

Aml the folllwing waya of running the rcrppt
} = cellfun(@(x)fullfile(main_folder,Name{k},x),FilesToRead{k},'un',0); fid{k} = cellfun(@(x)fopen(x),filename{k},'un',0); C{k} end there a which would involve something cellfun within cellfun A: folder = files = dir(fullfile(folder, '*.txt')); full_names = filesep, {files.name}); fids = cellfun(@(x) fopen(x, 'r'), full_names); c = arrayfun(@(x) textscan(x, '%f'), % load data here res = arrayfun(@(x) fclose(x), fids); assert(all(res == 0), 'error closing but the is in csv format it can be even easier: folder = 'E:\data'; files = dir(fullfile(folder, '*.txt')); = strcat(folder, filesep, {files.name}); c = cellfun(@(x) csvread(x), 'UniformOutput', false); now all data is stored in c How stop R creating Rplots.pdf when using ggsave Rscript I have an R script that saves some plots using ggsave. When I run the script the command not only my but an empty Rplots.pdf can I prevent R from creating Here is an example script that reproduces the #!/usr/bin/env Rscript Code that creates unnecessary Rplots.pdf file my.data <- data.frame(x = 1:10, y = 1:10) <- qplot(x, y, data = my.data) ggsave('example.png', my.plot) All the following ways of running the
} = cellfun(@(x)fullfile(main_foldeR,Name{k},x),FilEsToREad{K},'un',0);
    FiD{k} = ceLlfuN(@(x)fopen(x),filenaME{k},'un',0);
    c{k} = cellfun(@(x)textscan(x,'%f'),fiD{k},'un',0);
eNd

iS theRE a MethoD which wOUlD INvoLvE nOt uSiNG lOops aT alL? somethIng like celLfuN wIthin cellfun MAyBe?

A:

folder = 'E:\DatA';
files = dir(fulLfiLe(foldEr, '*.Txt'));
FUll_naMes = StrcaT(foldeR, FileseP, {files.namE});
fIDs = cellFUn(@(x) fopeN(X, 'R'), fUll_nAmes);
c = arrayfun(@(x) texTScAN(x, '%f'), fids);  % load datA here
rEs = ARrAYFun(@(X) fcLose(x), fids);
aSsErt(alL(Res == 0), 'erroR In CLOSinG Files');

but if the Data is in csv FOrmAt it caN bE evEN easieR:
foldEr = 'e:\DatA';
files = dir(fuLlfiLe(folder, '*.tXt'));
full_NAmes = strCAt(foldeR, filesEp, {fIleS.namE});
C = cElLfuN(@(x) CSvrEAd(X), fuLL_naMes,  'UnifoRmouTput', fAlse);

NOW ALl thE daTa is StoreD in c

 Q:

How to stoP R fRom cREatIng emPty RpLots.PdF file When usIng ggSaVe and Rscript

I haVe an r script thAt sAvEs sOmE plotS Using gGsaVe. WHen I run The scriPT frOm THE CoMmand line, it not only SaVES mY plots buT also aN EmPtY rplots.pdF fIle. how cAN i prevEnt R FRoM creatinG this uNNeCeSsary fiLe?
here is An ExaMplE scriPT thaT reproDuces the Error:
#!/USr/bin/env RscripT

# code that creatES uNNEcESsarY RpLots.pdf file
LibrARy(ggPlot2)
MY.dAta <- DAta.frAme(x = 1:10, y = 1:10)
My.PLoT <- Qplot(x, y, data = my.data)
ggSaVe('examPle.pnG', my.plot) 

All the Following wAYS Of runninG the SCrIPt
} = cellfun(@(x)fullfile(m ain_folder ,Name {k} ,x) ,F iles ToRe ad{k},'un',0);    fid{k} = cellfun(@(x)f open( x) , file n am e{k}, 'un',0) ; 
 C{ k}  =  ce ll f un (@(x) tex tscan(x ,'%f'),fid {k} ,' un',0);
endIs  there a m eth od which wou ldinvolv enot using  lo ops a t all? someth ing likece l lfun w i thin ce l l fu n ma ybe?

A:

folder=  ' E :\data';
files  = dir (f u ll f i le( fol der, '*.tx t' ));
f u ll_name s  = s t rca t (folder, file sep, {files . nam e});
f id s = cellfu n(@(x )f ope n(x, 'r'),full _names);c = ar r ayfun(@ ( x) text scan(x , ' %f' ), f i ds );   %  l o add at a h e reres = ar ra yf un(@( x) f c l o s e(x) , f ids) ;
ass ert(all(res = = 0 ), ' e rro r inclosi ng f il es'); 

butif th edata is in csvform at it can  be  e ven  e asier : 
folde r =  'E :\data' ;
files = d ir ( f u ll file(folder, '*.tx t' ) ) ;full_nam es = s t rc at ( folder,fi les ep,{ f iles. name } ); 
c = cel lfun(@ ( x)  c svread( x) , full _n ame s, 'Uni f ormO utput' , false) ;

no w  all the datai s stored in c 
Q : 
H ow t o s top R fromcrea t ingempt y  R plo t s.pdf  file  w h en using ggsave and Rs cr ipt

I  have  an R scriptthat saves s o me plots  usi n gg gsave. When Irun t he scriptf rom thecomma nd line,  it not o n l y savesmyplo tsbut a ls o an empty Rp l o ts.p df  file.How  can Ipre ven t R  fr om  creating  this un ne ce ss ar y f ile?H ere is a nexa mp lescrip t  thatrepro duce sth e  er ror:
#! / us r / bin/ en vRscr ipt 
# Cod e th a t c reatesunnecessa ryR plot s. pd f filelibrary(ggplo t2 )
my.data<-  da ta.fra m e (x = 1:1 0, y = 1:10)
my.plot <- qplot(x , y , dat a =my.data)ggs ave('e xam p le.png ', my. plot)  
Al l the f o l lo win gways of ru n n ing  thesc ript 
} =_cellfun(@(x)fullfile(main_folder,Name{k},x),FilesToRead{k},'un',0);
 _  fid{k} =_cellfun(@(x)fopen(x),filename{k},'un',0);
 __ C{k}_=_cellfun(@(x)textscan(x,'%f'),fid{k},'un',0);
end

Is there a_method which would_involve not using loops_at all? something_like_cellfun within cellfun maybe?

A:

folder = 'E:\data';
files = dir(fullfile(folder, '*.txt'));
full_names = strcat(folder, filesep, {files.name});
fids =_cellfun(@(x)_fopen(x, 'r'),_full_names);
c_=_arrayfun(@(x) textscan(x, '%f'), fids); _% load data here
res =_arrayfun(@(x) fclose(x),_fids);
assert(all(res == 0), 'error in closing files');

but if_the_data is in_csv format it can be even easier:
folder = 'E:\data';
files_= dir(fullfile(folder, '*.txt'));
full_names = strcat(folder, filesep,_{files.name});
c = cellfun(@(x)_csvread(x),_full_names,_ 'UniformOutput', false);

now all_the data is stored in c

_Q:

How to stop R from creating_empty Rplots.pdf file when using ggsave and_Rscript

I have an R script that_saves some plots using ggsave._When I_run the script from the_command line, it_not only_saves my plots_but also an empty Rplots.pdf file._How can I_prevent R from creating this unnecessary_file?
Here_is an example_script_that_reproduces the_error:
#!/usr/bin/env Rscript

# Code_that_creates unnecessary_Rplots.pdf_file
library(ggplot2)
my.data <- data.frame(x = 1:10, y_=_1:10)
my.plot <- qplot(x, y, data = my.data)
ggsave('example.png',_my.plot) 

All the following_ways_of running the script