[R] Latex fonts in R graphics
Hello, R users. I am trying to embed Computer modern fonts to an R plot and I get the following error. CM - Type1Font(CM, + c(paste(cm-lgc/fonts/afm/public/cm-lgc/, + c(fcmr8a.afm, fcmb8a.afm, fcmri8a.afm, fcmbi8a.afm), sep=), + ./cmsyase.afm)) pdf(cm.pdf, width=3, height=3, family=CM) plot(1:length(y), y, xlab=ss, ylab=expression(x[2])) ## for any vector y dev.off() null device 1 embedFonts(cm.pdf, outfile=cmembed.pdf, fontpaths=c(cm-lgc/fonts/type1/public/cm-lgc, .)) Error in embedFonts(cm.pdf, outfile = cmembed.pdf, fontpaths = c(cm-lgc/fonts/type1/public/cm-lgc, : status -1 in running command 'gswin32c.exe -dNOPAUSE -dBATCH -q -dAutoRotatePages=/None -sDEVICE=pdfwrite -sOutputFile=C:\DOCUME~1\user\LOCALS~1\Temp\RtmpccEtgV\Rembed28163716 -sFONTPATH=cm-lgc/fonts/type1/public/cm-lgc;. cm.pdf' In addition: Warning message: In system(cmd) : gswin32c.exe not found Operating system: Windows XP, SP2. cm-lgc has been unzipped in the working directory C:/Program Files/R/R-2.10.1 and the AFM, PFB files are also in same directory. Any help? __ 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.
[R] Tex fonts in R plots
Hello, R users. I would like to display the font of Math Mode of MikTex 2.3, WinEdt 5.4 in R plots, e.g. in xlab, ylab or legend. How can I do that? Thank you in advance. __ 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.
[R] mapply
Hello, R users. I would like to count the number of triples (r_i, s_j, t_k) with r_i, s_j, t_k distinct and abs((r_i-t_k)-u)=0 and abs((s_j-t_k)-v)=0, where r_i, s_j, t_k are the elements of three vectors a,b,c with different lengths and u,v=1:n. I have solved this problem writing a subroutine in Fortran an calling .Fortran(). I would like to find another way to use functions like mapply. I tried this one: xx - mapply( function(u,v) { kk - outer(a, c, function(s,t) abs((s-t)-u)==0) ll - outer(b, c, function(s,t) abs((s-t)-v)==0) sum( outer( which(kk==TRUE, TRUE)[,2], which(ll==TRUE, TRUE)[,2], function(s,t) s==t) ) }, rep(1:n, each=n), rep(1:n, times=n)) xx - matrix(xx, nrow=n, ncol=n, byrow=TRUE) It works but it is rather slow. Taking into account that my vectors have lengths 3000, and n is from 50 to 200, can I do something to improve the running time of the above code? __ 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.
[R] avoid a loop
Hello, R users. I have the following code: a=1:10 b=-3:15 n=5 x - rep(0,n) for (i in 1:n) x[i] - sum( outer(a,b, function(s,t) abs(a-b-i)==0) ) Can someone tell me if I could avoid the for command? Thank you in advance. __ 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.
[R] definition of a function
Hello, R subscribers. I would like to define a function like this one: Fun - function(x)sin(x)/x with value 1 at x=0. How can I do that? Is there a way to plot it symbolically, without using x as a vector? e.g. x - seq(from=-10, to=10, length=100) plot(x, Fun(x)) Thank you in advance. __ 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.