[R] Backslash

2005-05-23 Thread Josef Eschgfaeller
Why sometimes one has to put a double backslash in regular expressions, but often simple backslashes work too? Is only a \ required for giving a metacharacter its usual meaning? --- u=grep('\\{[\\-u]x',a,perl=T) # equivalent to

Re: [R] Drawing a circle

2005-05-19 Thread Josef Eschgfaeller
Mario Morales wrote: I need to draw a circle I would do it with complex numbers and polar coordinates: Circle = function (t,a) {a*cos(t)+1i*a*sin(t)} interval=c(-8,8) plot(interval,interval,type=n,xlab=,ylab=, asp=1,axes=F) t=seq(0,2*pi,by=0.01) center=2+3i; radius=5

[R] Data frames

2005-04-25 Thread Josef Eschgfaeller
I have two questions about data frames: (1) How can one extract a simple matrix from a data frame? I tried Matrixfromdf = function (frame,without=1) {a=frame[colnames(frame)[-without]] v=unlist(a,use.names=F) matrix(v,ncol=ncol(a))} but it works well only for without=1, perhaps

[R] Re: Data frames

2005-04-25 Thread Josef Eschgfaeller
Perhaps this works for creating a new void dataframe: Newvoid = function (...) {a=c(...); m=length(a) initial=matrix(rep(NA,m),byrow=T,ncol=m) tab=data.frame(initial) colnames(tab)=a; subset(tab,F)} Josef Eschgfäller -- Josef Eschgfäller Dipartimento Matematico Universita' di Ferrara

[R] Precision

2005-04-06 Thread Josef Eschgfaeller
How precise is R numerically? For example I wrote the following function for calculating the volume of the ball inscribed in the unit cube in m dimensions. In order to see what happens in 40 dimensions, I created an output of 24 digits. But how many are precise? Thanks Josef Eschgfäller Ferrara

Re: [R] Introduce a new function in a package?

2005-04-06 Thread Josef Eschgfaeller
~/.Rprofile You could also write in .Rprofile soemthing like this: for (x in dir(Mylibrary,full.names=T,recursive=T)) source(x) where Mylibrary is a directory which contains your functions without making a package. Josef Eschgfäller__

Re: [R] Introduce a new function in a package?

2005-04-06 Thread Josef Eschgfaeller
Leaving an object `x' around from .Rprofile is not at all a good idea, Actually I thought to put it inside a function. Josef Eschgfäller __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting

[R] gmp

2003-11-19 Thread Josef Eschgfaeller
I'm trying to write some GMP functions but am not sure about how and where to use pointers. -- // alfa.c # include R.h # include gmp.h void Createinteger (char *A, mpz_t *N) {mpz_init(*N); mpz_set_str(*N,A,10);} void