[R] Function modification: how to calculate values for every combination?

2007-09-02 Thread Lauri Nikkinen
Hello, I have a function like this: fun - function (x, y) { a - log(10)*y b - log(15)*x extr - a-b extr } fun(2,3) [1] 1.491655 x - c(1,2,3) y - c(4,5,6) fun(x, y) [1] 6.502290 6.096825 5.691360 How do I have to modify my function that I can

Re: [R] Function modification: how to calculate values for every combination?

2007-09-02 Thread Paul Smith
On 9/2/07, Lauri Nikkinen [EMAIL PROTECTED] wrote: I have a function like this: fun - function (x, y) { a - log(10)*y b - log(15)*x extr - a-b extr } fun(2,3) [1] 1.491655 x - c(1,2,3) y - c(4,5,6) fun(x, y) [1] 6.502290 6.096825

Re: [R] Function modification: how to calculate values for every combination?

2007-09-02 Thread Lauri Nikkinen
Yeah, exactly. Thanks. The solution was too obvious :-) Cheers, Lauri 2007/9/2, [EMAIL PROTECTED] [EMAIL PROTECTED]: Hello, I have a function like this: fun - function (x, y) { a - log(10)*y b - log(15)*x extr - a-b extr }

Re: [R] Function modification: how to calculate values for every combination?

2007-09-02 Thread Paul Smith
On 9/2/07, Paul Smith [EMAIL PROTECTED] wrote: I have a function like this: fun - function (x, y) { a - log(10)*y b - log(15)*x extr - a-b extr } fun(2,3) [1] 1.491655 x - c(1,2,3) y - c(4,5,6) fun(x, y) [1] 6.502290

Re: [R] Function modification: how to calculate values for every combination?

2007-09-02 Thread Erich Neuwirth
outer(x,y,fun) Lauri Nikkinen wrote: Hello, I have a function like this: fun - function (x, y) { a - log(10)*y b - log(15)*x extr - a-b extr } fun(2,3) [1] 1.491655 x - c(1,2,3) y - c(4,5,6) fun(x, y) [1] 6.502290 6.096825

Re: [R] Function modification: how to calculate values for every combination?

2007-09-02 Thread Gabor Grothendieck
Just to add to this be sure you do have names if you want them and read about vectorization in ?outer in case fun was just an example and your actual fun is more complex: x - c(1,2,3) names(x) - x y - c(4,5,6) names(y) - y outer(x, y, fun) # as in previous answer # or outer(-log(15) * x,

Re: [R] function to find coodinates in an array

2007-08-17 Thread Martin Maechler
GaGr == Gabor Grothendieck [EMAIL PROTECTED] on Thu, 16 Aug 2007 23:46:28 -0400 writes: GaGr Get the indices using expand.grid and then reorder GaGr them: set.seed(1); X - array(rnorm(24), 2:4) # input GaGr X # look at X GaGr do.call(expand.grid, sapply(dim(X),

[R] function to find coodinates in an array

2007-08-16 Thread Ana Conesa
Dear list, I am looking for a function/way to get the array coordinates of given elements in an array. What I mean is the following: - Let X be a 3D array - I find the ordering of the elements of X by ord - order(X) (this returns me a vector) - I now want to find the x,y,z coordinates of each

Re: [R] function to find coodinates in an array

2007-08-16 Thread Moshe Olshansky
A not very good solution is as below: If your array's dimensions were KxMxN and the linear index is i then n - ceiling(i/(K*M)) i1 - i - (n-1)*(K*M) m - ceiling(i1/K) k - i1 - (m-1)*K and your index is (k,m,n) I am almost sure that there is a function in R which does this (it exists in Matlab).

Re: [R] function to find coodinates in an array

2007-08-16 Thread Henrik Bengtsson
See arrayIndex() in the R.utils package, e.g. X - array((2*3*4):1, dim=c(2,3,4)) idx - 1:length(X) ijk - arrayIndex(idx, dim=dim(X)) print(ijk) [,1] [,2] [,3] [1,]111 [2,]211 [3,]121 [4,]221 [5,]131 [6,]231 [7,]1

Re: [R] function to find coodinates in an array

2007-08-16 Thread Marc Schwartz
If I am correctly understanding the problem, I think that this is what you want: set.seed(1) # Create a 3x3x3 array ARR - array(sample(100, 27), c(3, 3, 3)) ARR , , 1 [,1] [,2] [,3] [1,] 27 89 97 [2,] 37 20 62 [3,] 57 86 58 , , 2 [,1] [,2] [,3] [1,]6 61

Re: [R] function to find coodinates in an array

2007-08-16 Thread François Pinard
[Ana Conesa] I am looking for a function/way to get the array coordinates of given elements in an array. What I mean is the following: - Let X be a 3D array - I find the ordering of the elements of X by ord - order(X) (this returns me a vector) - I now want to find the x,y,z coordinates

Re: [R] function to find coodinates in an array

2007-08-16 Thread Gabor Grothendieck
Get the indices using expand.grid and then reorder them: set.seed(1); X - array(rnorm(24), 2:4) # input X # look at X do.call(expand.grid, sapply(dim(X), seq))[order(X),] On 8/16/07, Ana Conesa [EMAIL PROTECTED] wrote: Dear list, I am looking for a function/way to get the array coordinates

[R] Function for reading in multidimensional tables / data.frames

2007-08-15 Thread Werner Wernersen
Hi, I was wondering if there is already some function implemented into R that reads in tables with more than 2 dimensions. There is probably something neat out there... Thanks, Werner Wissenswertes zum Thema PC, Zubehör oder Programme. BE A BETTER INTERNET-GURU! www.yahoo.de/clever

Re: [R] Function for reading in multidimensional tables / data.frames

2007-08-15 Thread Werner Wernersen
Never mind, using scan() and putting it into an array of the specific dimensions is sufficient for my case. But it still would be interesting to know if there is some function to read in more complex data objects. Thanks, Werner Hi, I was wondering if there is already some function

Re: [R] Function for trim blanks from a string(s)?

2007-08-07 Thread S Ellison
Stripping either or both ends can be achieved by the somewhat tortuous but fairly general stripspace-function(x) sub(^\\s*([^ ]*.*[^ ])\\s*$, \\1,x) which uses a replacement buffer to keep the useful part of the string. Prof Brian Ripley [EMAIL PROTECTED] 06/08/2007 21:23:49 I am sure Marc

[R] Function for trim blanks from a string(s)?

2007-08-06 Thread adiamond
I feel like an idiot posting this because every language I've ever seen has a string function that trims blanks off strings (off the front or back or both). Ideally, it would process whole data frames/matrices etc but I don't even see one that processes a single string. But I've searched and I

Re: [R] Function for trim blanks from a string(s)?

2007-08-06 Thread Marc Schwartz
On Mon, 2007-08-06 at 12:15 -0700, adiamond wrote: I feel like an idiot posting this because every language I've ever seen has a string function that trims blanks off strings (off the front or back or both). Ideally, it would process whole data frames/matrices etc but I don't even see one

Re: [R] Function for trim blanks from a string(s)?

2007-08-06 Thread Gabor Grothendieck
Use trim from: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/40714.html or trim from gdata or trimWhiteSpace from limma in BioConductor. RSiteSearch(trim) and help.search(trim) can locate such functions. s - c( abc , def ) # vector m - cbind(a = s, b = s) # matrix DF - as.data.frame(m) #

Re: [R] Function for trim blanks from a string(s)?

2007-08-06 Thread Marc Schwartz
On Mon, 2007-08-06 at 21:23 +0100, Prof Brian Ripley wrote: I am sure Marc knows that ?sub has examples of trimming trailing space and whitespace in various styles. Indeed, though leading spaces are not covered there, so thought that I would take a minute or two to provide both and the

Re: [R] Function to separate effect in AOV

2007-07-26 Thread Greg Snow
PROTECTED] On Behalf Of Ronaldo Reis Junior Sent: Monday, July 23, 2007 4:05 PM To: R-Help Subject: [R] Function to separate effect in AOV Hi, I have a dummy question. Suppose that I have two explanatory variable, T1 (A, B) and T2 (C, D) and one response variable. attach(dados

[R] Function polr and discrete ordinal scale

2007-07-25 Thread Lassalle Géraldine
Dear all, To modelize the abundance of fish (4 classes) with a set of environmental variables, I used the polr and predict.polr functions. I would like to know how to bring the cumulated probabilities back to a discrete ordinal scale. For the moment I used the predict.polr function with the

[R] function optimization: reducing the computing time

2007-07-24 Thread Matthieu Dubois
Dear useRs, I have written a function that implements a Bayesian method to compare a patient's score on two tasks with that of a small control group, as described in Crawford, J. and Garthwaite, P. (2007). Comparison of a single case to a control or normative sample in neuropsychology:

Re: [R] function optimization: reducing the computing time

2007-07-24 Thread Prof Brian Ripley
You need to make use of the profiling methods described in 'Writing R Exensions'. My machine is about 4x faster than yours: I get Each sample represents 0.02 seconds. Total run time: 62.08041 seconds. Total seconds: time spent in function and callees. Self seconds: time spent in

[R] Function to separate effect in AOV

2007-07-23 Thread Ronaldo Reis Junior
Hi, I have a dummy question. Suppose that I have two explanatory variable, T1 (A, B) and T2 (C, D) and one response variable. attach(dados) tapply(Y,list(T1,T2),mean) CD A 2.20 10.2 B 2.22 20.26667 In this case, A and B inside C have no difference, but have

[R] Calling R function in C

2007-07-09 Thread Deb Midya
Hi R Users! Thanks in advance. I am using R-2.5.1 on Windows XP and I have installed all necessary tools such as perl and tools.exe. I am trying to use sample(1:100, 3, rep=F) in C. How can I use this R function in C? Once again thank you very much for your time

Re: [R] Function call within a function.

2007-06-29 Thread John Kane
--- Stephen Tucker [EMAIL PROTECTED] wrote: Dear John, Perhaps I am mistaken in what you are trying to accomplish but it seems like what is required is that you call lstfun() outside of ukn(). [and remove the call to lstfun() in ukn()]. nts - lstfun(myfile, aa, bb) results - ukn(dd1,

Re: [R] Function call within a function.

2007-06-29 Thread John Kane
, nts$cda) ### modified how called. - Original Message - From: John Kane [EMAIL PROTECTED] To: R R-help r-help@stat.math.ethz.ch Sent: Thursday, June 28, 2007 12:03 PM Subject: [R] Function call within a function. I am trying to call a funtion within another function and I

Re: [R] Function call within a function.

2007-06-29 Thread John Kane
PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Kane Sent: Thursday, June 28, 2007 12:04 PM To: R R-help Subject: [R] Function call within a function. I am trying to call a funtion within another function and I clearly am misunderstanding what I should do. Below

Re: [R] Function call within a function.

2007-06-29 Thread John Kane
-help@stat.math.ethz.ch Sent: Thursday, June 28, 2007 12:03 PM Subject: [R] Function call within a function. I am trying to call a funtion within another function and I clearly am misunderstanding what I should do. Below is a simple example. I know lstfun works on its own but I cannot

Re: [R] Function call within a function.

2007-06-29 Thread Jason Barnhart
[SNIP] This has been very helpful though I still do not understand why one must call nts$cda using the eval(parse()) command. Is it because nts is created within the ukn environment? You don't *have* to use the eval(parse()). This works just as well: mysum - nts$cda. However, it

[R] R function command on a list

2007-06-28 Thread G E
Hello R: I am working with a self-defined function and I wish to subject a list (t) to this function. My list is a list of tables: $rs7609589 2/2 2/4 4/4 2/2 2/4 4/4 89 188 87 89 188 87 $rs3909907 1/1 1/4 4/4 94 178 92 $rs12748004 0/0 1/3 3/3 37 150 177 $rs6695928 2/2 2/4 4/4 35

Re: [R] R function command on a list

2007-06-28 Thread Henrique Dallazuanna
Try whit rownames. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O On 28/06/07, G E [EMAIL PROTECTED] wrote: Hello R: I am working with a self-defined function and I wish to subject a list (t) to this function. My list is a list of tables: $rs7609589 2/2 2/4

Re: [R] R function command on a list

2007-06-28 Thread Georg Ehret
Thank you Henrique, rownames also gives me the header of the table, but not the name of the list-element... Any other idea? Wishing you a good day, Georg. ** Georg Ehret Johns Hopkins University Baltimore On 6/28/07, Henrique Dallazuanna [EMAIL PROTECTED] wrote: Try whit rownames.

[R] Function call within a function.

2007-06-28 Thread John Kane
I am trying to call a funtion within another function and I clearly am misunderstanding what I should do. Below is a simple example. I know lstfun works on its own but I cannot seem to figure out how to get it to work within ukn. Basically I need to create the variable nts. I have probably missed

Re: [R] R function command on a list

2007-06-28 Thread Henrique Dallazuanna
Perhaps, you can get the name of list element whit: unlist(lapply(list_name, rownames)) -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O On 28/06/07, Georg Ehret [EMAIL PROTECTED] wrote: Thank you Henrique, rownames also gives me the header of the table, but not

Re: [R] Function call within a function.

2007-06-28 Thread Nordlund, Dan (DSHS/RDA)
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Kane Sent: Thursday, June 28, 2007 12:04 PM To: R R-help Subject: [R] Function call within a function. I am trying to call a funtion within another function and I clearly am misunderstanding

Re: [R] Function call within a function.

2007-06-28 Thread Stephen Tucker
Dear John, Perhaps I am mistaken in what you are trying to accomplish but it seems like what is required is that you call lstfun() outside of ukn(). [and remove the call to lstfun() in ukn()]. nts - lstfun(myfile, aa, bb) results - ukn(dd1, a, b, nts$cda) Alternatively, you can eliminate the

Re: [R] Function call within a function.

2007-06-28 Thread Jason Barnhart
HERE mysum - eval(parse(text=nam1)) #mysum - nam1[,3]*5 return(mysum) } results - ukn(dd1, a, b, nts$cda) ### modified how called. - Original Message - From: John Kane [EMAIL PROTECTED] To: R R-help r-help@stat.math.ethz.ch Sent: Thursday, June 28, 2007 12:03 PM Subject: [R] Function

[R] Function -return value

2007-06-19 Thread livia
Hi, I am trying to write a function with the following codes and I would like it to return the values for alpha beta para parab seperately. Then I would like to use this funstion for variable with factor a and b. But the result turns out to be a matrix with element like Numeric,2 ... I guess

Re: [R] Function -return value

2007-06-19 Thread Christophe Pallier
You wChange the function 'parameter' sapply(split(variable,list(a,b)),parameter) On 6/19/07, livia [EMAIL PROTECTED] wrote: Hi, I am trying to write a function with the following codes and I would like it to return the values for alpha beta para parab seperately. Then I would like to use

Re: [R] Function -return value

2007-06-19 Thread Christophe Pallier
First, to return several values from your function 'parameter', you can use a list: parameter - function (...) { ... list(alpha=alpha,beta=beta,para=para,parab=parab) } Then, you may use: sapply(split(variable,list(a,b)), parameter) (tapply also works but return a matrix of lists)

[R] Function for misclassification rate/type I,II error??

2007-06-16 Thread Tirthadeep
HI Is there any function in R that tells us error rate(misclassification rate) for logistic regression type classification? i also want to know the function to determine type I and type II error. I have found a link where misclass and confusion are used. But I dont know the package name.

[R] function with xyplot

2007-06-14 Thread Diego Gruber
Hi, I'm a new user trying to switch from SAS, so sorry for the beginner's question: Suppose I have a dataframe DF that contains variables X,Y,Z. I am trying to write a function like this: myplot - function(varname){xyplot(varname ~ Y, group = Z, data = DF)}. The problem is then how to enter X

Re: [R] function with xyplot

2007-06-14 Thread John Kane
You need to reference the data.frame or append it. myplot(DF$X) should work or append(DF) myplot(X) --- Diego Gruber [EMAIL PROTECTED] wrote: Hi, I'm a new user trying to switch from SAS, so sorry for the beginner's question: Suppose I have a dataframe DF that contains variables X,Y,Z.

Re: [R] function with xyplot

2007-06-14 Thread Diego Gruber
Thanks a lot for your suggestions. Referencing the dataset solved the problem. I had actually tried it before but since I was also subsetting the datset within the function (something I didn't mention in my question) the objects were not of the same length and that caused me trouble. Your comment

[R] Function tsmooth

2007-05-29 Thread JIZ JIZ
Hi, Assume that we may model the Nottingham temperature data (nottem) or Sunspot data (sunspot) set by a nonparametric autoregressive model of the form Yt = m(Yt-1) + et. Using the kernel estimation method, produce the resulting plots. We may use the fucntion

Re: [R] Function to Sort and test AIC for mixed model lme?

2007-05-24 Thread Dieter Menne
Ken Nussear knussear at mac.com writes: I'm running a series of mixed models using lme, and I wonder if there is a way to sort them by AIC prior to testing using anova (lme1,lme2,lme3,lme7) other than by hand. You can try something like the following. However, also consider using

[R] Function to convert categorical variable in numerical

2007-05-24 Thread J.Andrés Martínez
Hello everybody, I am a new R user. At current moment I need to do a Principal Components Analysis with a table who contain mixed variables (categorical and numerical). There is some function available in R for transform these variables? For example: I need transform the categorical variable X

Re: [R] Function to convert categorical variable in numerical

2007-05-24 Thread Prof Brian Ripley
?model.matrix ?contr.treatment Whether this makes sense for PCA is another matter: princomp() contains a test to stop this happening automatically with a formula argument. One problem is the result depends on just how you do the transformation. On Thu, 24 May 2007, J.Andrés Martínez wrote:

Re: [R] Function to convert categorical variable in numerical

2007-05-24 Thread Mark Difford
Hi J. Andres, You are probably better off using the ade4 package, which has two functions that will do exactly what you want, i.e. a PCA using mixed quantitative and categorical variables: ## You will need to download ade4 first library(ade4) ?dudi.hillsmith ?dudi.mix Regards, Mark Difford.

Re: [R] Function to convert categorical variable in numerical

2007-05-24 Thread J.Andrés Martínez
Hello again, I got it with dudi.mix included in ade4 library that Mark told. Thank you very much to all! J. Andres On 5/24/07, Mark Difford [EMAIL PROTECTED] wrote: Hi J. Andres, You are probably better off using the ade4 package, which has two functions that will do exactly what you

Re: [R] Function to Sort and test AIC for mixed model lme?

2007-05-24 Thread Ken Nussear
Ken Nussear knussear at mac.com writes: I'm running a series of mixed models using lme, and I wonder if there is a way to sort them by AIC prior to testing using anova (lme1,lme2,lme3,lme7) other than by hand. You can try something like the following. However, also consider

Re: [R] Function to Sort and test AIC for mixed model lme?

2007-05-24 Thread Douglas Bates
On 5/24/07, Ken Nussear [EMAIL PROTECTED] wrote: Ken Nussear knussear at mac.com writes: I'm running a series of mixed models using lme, and I wonder if there is a way to sort them by AIC prior to testing using anova (lme1,lme2,lme3,lme7) other than by hand. You can try

Re: [R] Function to Sort and test AIC for mixed model lme?

2007-05-24 Thread Ken Nussear
On May 24, 2007, at 2:12 PM, Douglas Bates wrote: On 5/24/07, Ken Nussear [EMAIL PROTECTED] wrote: Ken Nussear knussear at mac.com writes: I'm running a series of mixed models using lme, and I wonder if there is a way to sort them by AIC prior to testing using anova

[R] Function to Sort and test AIC for mixed model lme?

2007-05-23 Thread Ken Nussear
Hi List I'm running a series of mixed models using lme, and I wonder if there is a way to sort them by AIC prior to testing using anova (lme1,lme2,lme3,lme7) other than by hand. My current output looks like this. anova

[R] Running R function as a Batch process

2007-05-16 Thread d. sarthi maheshwari
Hi, I am struggling with using R CMD BATCH command. Kindly suggest solution to the following problem. I have a function named CinC with accept two input parameters. This can be shown as: CinC - function(start, end) where start and end both are character strings. Please suggest me how can I

Re: [R] Running R function as a Batch process

2007-05-16 Thread Vladimir Eremeev
) CinC(command.args[1],command.args[2]) -- View this message in context: http://www.nabble.com/Running-R-function-as-a-Batch-process-tf3764048.html#a10640433 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing

Re: [R] Running R function as a Batch process

2007-05-16 Thread Hanke, Alex
:\logout.txt Regards Alex -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of d. sarthi maheshwari Sent: May 16, 2007 8:29 AM To: r-help@stat.math.ethz.ch Subject: [R] Running R function as a Batch process Hi, I am struggling with using R CMD BATCH command

[R] function name collision

2007-05-14 Thread Bobby Prill
I am using the graph package, which has a function called union() that acts on graph objects. There is also a {base} function called union(). How do I explicitly specify union {graph} instead of the default union {base} ? union(g1, g2) evokes the wrong union(), which produces an error.

[R] function similar to get that works for both an object, and elements of an object?

2007-05-12 Thread new ruser
#Is there a single function similar to get that works for both an object, and elements of an object ? #(I want the function to be able to return objects, and/or the deeper elements of an object.) #(i.e. elements of a dataframe and/or list)? #e.g. tempdf = data.frame(a=c(4,5,6) ,

Re: [R] function similar to get that works for both an object, and elements of an object?

2007-05-12 Thread Gabor Grothendieck
Try: get('tempdf')$a get('templist')$x On 5/12/07, new ruser [EMAIL PROTECTED] wrote: #Is there a single function similar to get that works for both an object, and elements of an object ? #(I want the function to be able to return objects, and/or the deeper elements of an object.)

[R] Function knn.dist from knnflex library

2007-04-10 Thread jmoreira
Hello, I am feeling that this question can have a very simple answer, but I can't find it. I need to use the function knn.dist from knnflex library. Whatever I try, I get the error: Error in as.vector.dist(x, character) : unused argument(s) (character) First example: a-NULL

Re: [R] Function knn.dist from knnflex library

2007-04-10 Thread Prof Brian Ripley
On Wed, 11 Apr 2007, [EMAIL PROTECTED] wrote: Hello, I am feeling that this question can have a very simple answer, but I can't find it. I need to use the function knn.dist from knnflex library. Whatever I try, I get the error: Error in as.vector.dist(x, character) : unused argument(s)

[R] Any R function for self-controlled case series method /effect absorption?

2007-03-20 Thread Jari Haukka
Hello, Has anyone written R functions for applying self-controlled case series methods (http://statistics.open.ac.uk/sccs/). In fact only thing needed is to modify glm function to allow absorption of effect. Eg. in Poisson model individual effect is used as factor, but it is considered as

Re: [R] Any R function for self-controlled case series method /effect absorption?

2007-03-20 Thread vito muggeo
Dear Jari The problem is to build the dataset to apply the conditional logit model. However, as far as I know, no R function exists. BTW if you are dealing with time series of pollution and health, the following two papers might be of interest of you: It appears that the time series approach

Re: [R] Any R function for self-controlled case series method /effect

2007-03-20 Thread Jari Haukka
, as far as I know, no R function exists. BTW if you are dealing with time series of pollution and health, the following two papers might be of interest of you: It appears that the time series approach could be preferred. Heather J. Whitaker, Mounia N. Hocine, C. Paddy Farrington On case

[R] transform R function

2007-03-07 Thread lamack lamack
Dear all, Why the transform function does not accept two statistics functions? a = data.frame(matrix(rnorm(20),ncol=2)) transform(a,M.1=mean(X1),M.2=mean(X2)) # does not works #while: transform(a,M.1=mean(X1),M2=log(abs(X2))) #works Best regards JL

Re: [R] transform R function

2007-03-07 Thread Peter Dalgaard
lamack lamack wrote: Dear all, Why the transform function does not accept two statistics functions? a = data.frame(matrix(rnorm(20),ncol=2)) transform(a,M.1=mean(X1),M.2=mean(X2)) # does not works #while: transform(a,M.1=mean(X1),M2=log(abs(X2))) #works It's a variation of this

Re: [R] function with Multiple Output

2007-03-05 Thread Levent TERLEMEZ
With help of list(), function can return ala of the results. my.fun=function(vector, index){ a=fun.a(vector, index) b=fun.b(vector, index) return(list(a,b)) } Example: R : Copyright 2005, The R Foundation for Statistical Computing Version 2.2.1 (2005-12-20 r36812) ISBN

[R] function doesnt return/create object

2007-03-03 Thread Matthias Bannert
hello, i have written a function to extract certain lines from a matrix. the result is a matrix with 6 cols, named dynamically according to the functions arguments. the problem is now, that i'm not able to return the resultmatrix for further use. the object is not being created. example

Re: [R] function doesnt return/create object

2007-03-03 Thread jim holtman
Instead of trying to create object back in the global environment (which is not really recommended from a function), return the answer in a list that you can then access it as you want. Here is an example: getans - function(x){ + # create the name that you want in the list + .name -

Re: [R] function with Multiple Output

2007-03-02 Thread jim holtman
my.fun=function(vector, index){ a=fun.a(vector, index) b=fun.b(vector, index) return(list(a=a, b=b)) } On 3/1/07, Claudio Isella [EMAIL PROTECTED] wrote: Dear R user, I have a simple question for you: I have created a global function that evoke other subsidiary functions. when

[R] function with Multiple Output

2007-03-01 Thread Claudio Isella
Dear R user, I have a simple question for you: I have created a global function that evoke other subsidiary functions. when I run the global function I want to store the outcomes of the of each subsidiary function into a variables. an examples my.fun=function(vector, index){ a=fun.a(vector,

[R] Function to do multiple named lookups faster?

2007-02-27 Thread David Reiss
Hi, I apologize if this topic has been discussed - I could not figure out a good search phrase for this question. I have a named vector x, with multiple (duplicate) names, and I would like to obtain a (shorter) vector with non-duplicate names in which the values are the means of the values of the

Re: [R] Function to do multiple named lookups faster?

2007-02-27 Thread jim holtman
try this: x - 1:30 names(x) - sample(LETTERS[1:5], 30, TRUE) x B B C E B E E D D A B A D B D C D E B D E B D A B B A B E B 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 x - 1:30 names(x) - sample(LETTERS[1:5], 30,

Re: [R] Function to assign quantiles?

2007-02-16 Thread Talbot Katz
PROTECTED] CC: [EMAIL PROTECTED], r-help@stat.math.ethz.ch, Talbot Katz [EMAIL PROTECTED] Subject: Re: [R] Function to assign quantiles? Date: Fri, 16 Feb 2007 19:51:49 +1300 On 2/16/07, Frank E Harrell Jr [EMAIL PROTECTED] wrote: Marc Schwartz wrote: On Thu, 2007-02-15 at 17:50 -0500, Talbot Katz

[R] Function to assign quantiles?

2007-02-15 Thread Talbot Katz
Hi. If I call the quantiles function as follows: qvec = quantiles(dvals,probs=seq(0,1,0.1)) the results will return a vector something like the following example: 0%10%20%30% 40% 50%60%70% 80% 90% 100% 56.0 137.3 238.4 317.9 495.8

Re: [R] Function to assign quantiles?

2007-02-15 Thread Marc Schwartz
On Thu, 2007-02-15 at 17:50 -0500, Talbot Katz wrote: Hi. If I call the quantiles function as follows: qvec = quantiles(dvals,probs=seq(0,1,0.1)) the results will return a vector something like the following example: 0%10%20%30% 40% 50%60%70% 80%

Re: [R] Function to assign quantiles?

2007-02-15 Thread Frank E Harrell Jr
Marc Schwartz wrote: On Thu, 2007-02-15 at 17:50 -0500, Talbot Katz wrote: Hi. If I call the quantiles function as follows: qvec = quantiles(dvals,probs=seq(0,1,0.1)) the results will return a vector something like the following example: 0%10%20%30% 40% 50%

Re: [R] Function to assign quantiles?

2007-02-15 Thread hadley wickham
On 2/16/07, Frank E Harrell Jr [EMAIL PROTECTED] wrote: Marc Schwartz wrote: On Thu, 2007-02-15 at 17:50 -0500, Talbot Katz wrote: Hi. If I call the quantiles function as follows: qvec = quantiles(dvals,probs=seq(0,1,0.1)) the results will return a vector something like the

[R] Calling R function from C++ when C++ was not invoced by R, or Calling R from PL/SQL

2007-01-23 Thread Mucha
of this system called it directly from the DB (PostgreSQL) in form of PL/R, I haven't found Oracle to have this capability. So I'm thinking that the solution might be to make a short C++ wrapper for the R function. Looking at the documentation I was only able to run R functions in C++ if the C++ function

[R] Using JRI Calling R function from Java

2007-01-07 Thread freezemanx
Hey guys. I have Installed and running JRI from Java and it works. Using : java -cp jri.jar; MainApp.java The problem is How do I calling R function that need R library I have tried these with my Java program : x = re.eval(glm( y ~ x1 + x2, family = poisson

Re: [R] Function to fit a STARIMA model

2006-12-15 Thread Roger Bivand
On Thu, 14 Dec 2006, Rajesh Krishnan wrote: Hi all, I was wondering if there is a function available in any of the R add-on packages that could be used to fit a STARIMA (Phillip E. Pfeifer and Stuart Jay Deutsch. (1980). A STARIMA Model-Building Procedure with Application to Description

[R] Function to fit a STARIMA model

2006-12-14 Thread Rajesh Krishnan
Hi all, I was wondering if there is a function available in any of the R add-on packages that could be used to fit a STARIMA (Phillip E. Pfeifer and Stuart Jay Deutsch. (1980). A STARIMA Model-Building Procedure with Application to Description and Regional Forecasting, Transactions of the

Re: [R] function

2006-11-09 Thread Douglas Bates
On 11/9/06, Bill Hunsicker [EMAIL PROTECTED] wrote: I am trying to create a function that i pass a data set to and have the function return some calculations based on data. Allow me to illustrate: myfunc - function(lst,mn,sd){ lst - sort(lst) mn - mean(lst) sd - sqrt(var(lst))

Re: [R] function

2006-11-09 Thread Marc Schwartz
On Thu, 2006-11-09 at 12:58 -0500, Bill Hunsicker wrote: R-help, I am trying to create a function that i pass a data set to and have the function return some calculations based on data. Allow me to illustrate: myfunc - function(lst,mn,sd){ lst - sort(lst) mn - mean(lst)

Re: [R] function

2006-11-09 Thread Marc Schwartz
On Thu, 2006-11-09 at 12:15 -0600, Marc Schwartz wrote: On Thu, 2006-11-09 at 12:58 -0500, Bill Hunsicker wrote: R-help, I am trying to create a function that i pass a data set to and have the function return some calculations based on data. Allow me to illustrate: myfunc -

[R] function to normalize vectors?

2006-10-26 Thread Daniel Elliott
Hello all. I can find no function to compute norms (even the basic two-norm) of a vector in the online help (within the GUI) or the downloadable documentation. Thanks. - dan elliott [[alternative HTML version deleted]] __

[R] Function that operates on functions: it's ok, but the display isn't

2006-10-10 Thread Alberto Monteiro
The following code works fine: # g is the function that returns the square of a number g - function(y) y^2 # f1 is a function that takes one function # as argument, and returns another function f1 - function(f) function(x) f(x+1) - f(x) # h(x) is g(x+1) - g(x) or 2x + 1 h - f1(g) # h(1) = 3 #

Re: [R] Function that operates on functions: it's ok, but the display isn't

2006-10-10 Thread Duncan Murdoch
On 10/10/2006 3:53 PM, Alberto Monteiro wrote: The following code works fine: # g is the function that returns the square of a number g - function(y) y^2 # f1 is a function that takes one function # as argument, and returns another function f1 - function(f) function(x) f(x+1) - f(x) #

Re: [R] Function that operates on functions: it's ok, but the display isn't

2006-10-10 Thread Deepayan Sarkar
On 10/10/06, Alberto Monteiro [EMAIL PROTECTED] wrote: The following code works fine: # g is the function that returns the square of a number g - function(y) y^2 # f1 is a function that takes one function # as argument, and returns another function f1 - function(f) function(x) f(x+1) -

Re: [R] Function that operates on functions: it's ok, but the display isn't

2006-10-10 Thread Alberto Vieira Ferreira Monteiro
Deepayan Sarkar wrote: # f1 is a function that takes one function # as argument, and returns another function f1 - function(f) function(x) f(x+1) - f(x) # h(x) is g(x+1) - g(x) or 2x + 1 h - f1(g) h function(x) f(x+1)-f(x) environment: 0264BE84 Presumably, 'f' takes the value 'g' in

[R] function used to smooth the scatter plot and generate a density map

2006-10-09 Thread hong
Dear R-helpers, I want to smooth a scatter plot (or 2d histogram) to generate the density map using a squared Euclidean kernel function, with each data point contributing a density of 1/(r*r + k) to each cell on the heatmap, where r*r was the squared Euclidean distance between the coordinates of

[R] R function to compute kappa statistics for two vector

2006-10-02 Thread Philip He
Dear R-user, Did anybody know how to calculate the kappa statistics of two vectors for the agreement? for example: a-c(0,1,0,0,1,0) b-c(0,1,1,0,0,1) I know the percent of agreement is 3/6, but how to get the kappa? [[alternative HTML version deleted]]

Re: [R] R function to compute kappa statistics for two vector

2006-10-02 Thread Bruno L. Giordano
: [R] R function to compute kappa statistics for two vector Dear R-user, Did anybody know how to calculate the kappa statistics of two vectors for the agreement? for example: a-c(0,1,0,0,1,0) b-c(0,1,1,0,0,1) I know the percent of agreement is 3/6, but how to get the kappa? [[alternative

Re: [R] R function to compute kappa statistics for two vector

2006-10-02 Thread Peter Dalgaard
Philip He [EMAIL PROTECTED] writes: Dear R-user, Did anybody know how to calculate the kappa statistics of two vectors for the agreement? for example: a-c(0,1,0,0,1,0) b-c(0,1,1,0,0,1) I know the percent of agreement is 3/6, but how to get the kappa? Multiple packages appear to

[R] function changes argument

2006-09-11 Thread Moeltner, Andreas
Dear R-list, the following function f changes L. I thought, assignments within functions are only local? f-function(LL) { for (ll in LL) { ll$txt-changed in f } } l-list(txt=original value) L-list(l) L[[1]]$txt f(L) L[[1]]$txt gives (using R 2.3.1): ... L[[1]]$txt [1] original value

Re: [R] function changes argument

2006-09-11 Thread Duncan Murdoch
On 9/11/2006 4:49 AM, Moeltner, Andreas wrote: Dear R-list, the following function f changes L. I thought, assignments within functions are only local? That looks like a bug, still present in R-patched and R-devel. (I haven't got the latest pre-release built yet today, but I expect it's

[R] function which gives the hessian matrix of the log-likelihood of a nonlinear mixed model?

2006-08-30 Thread Olive Yang
Hi, Can anyone tell me which function in R gives the hessian matrix of the log-likelihood of a nonlinear mixed model? fdHess is for scarlar function only. Thanks in advance! Hongmei [[alternative HTML version deleted]] __

  1   2   3   4   >