Re: [R] how do I name data frames and files according to the index of a for loop?

2009-10-08 Thread Dieter Menne
Ken Ervin wrote: for (i in 1:2858) { ... write.table(Data_frame_name,file=~/file/goes/here.csv, append = FALSE, sep = \t,row.names = FALSE, col.names = c(Calc_1, Calc_2, Calc_3),qmethod = double) } use something like filename = paste(~/file/myfile,i,.csv,sep=)

Re: [R] Colouring a grid segment

2009-10-08 Thread Jim Lemon
On 10/08/2009 01:15 PM, darrenh65 wrote: Hi, I am attempting to create a polar chart (using plotrix polar.plt) and I need to colour a segment of the grid to indicate an area of interest, say from 90-120 degrees, for arguments sake. Is this possible? I can colour the whole grid by passing the

Re: [R] [R-SIG-Finance] Evaluating/comparing dynamic linear model

2009-10-08 Thread Erb Philipp (erbp)
What kind of filter are you using? Since your models are expressed in state space form I suggest that you fit your models by maximizing the log likelihood function of the Kalman filter output (see e.g. FKF-package). Using the obtained log likelihood values you might perform a likelihood ratio

[R] predict.lm() out-of-sample predictions - problem with data classes

2009-10-08 Thread Gero Schwenk
Hello! I'm still working on my problem, which also occurs with the predict.lm() function. - Providing newdata, which is a data.frame with all variables being numeric, as str() shows, R tells me the following: ar1.xpred.test.pred - predict(ar1.xpred.fitted, regdata.test, se.fit = FALSE)

Re: [R] re peat(?) measurement ANOVA or (general? mixed?) linear model?

2009-10-08 Thread Dieter Menne
Wolfgang Waser wrote: I subjected each of about 50 critters (about 10 each in 5 distinct populations) to 4 consecutive treatments (exposure to increasing concentrations), with one measurement per treatment and individual. ... Since I'm dealing with 'paired' data, and also with a

[R] statistics and R package for election results

2009-10-08 Thread Damjan Krstajic
Dear all, Is there any R package which would help in analysing election results between two elections? Does anybody know any good papers which are related to this field? I am a statistician and my main research area so far has been regression and classification modelling. The analysis of two

Re: [R] statistics and R package for election results

2009-10-08 Thread Bill.Venables
What are you trying to find out from your analysis and what techniques do you have in mind for doing it? It might be as well to sort out this first (and tell us if you have) rather than look round for a package first and then decide on what you want to do in the analysis. Having said all

Re: [R] Why do I have the following error message?

2009-10-08 Thread Uwe Ligges
LinZhongjun wrote: Dear R-help lists: Hello! I ran WinBUGS under R using the function bugs. But I kept having the following error message: Error in FUN(X[[3L]], ...) : .C(..): 'type' must be real for this format Why did I have the error message?What's the problem?How to get rid of the

Re: [R] To hell with OpenSuse, ditch it and go to Ubuntu

2009-10-08 Thread xavier . chardon
Whatever your final choice is, I think you should really try to use the distribution's package management system. I don't use the distributions you cited so I can't give you precise hints, but I'm sure you can easily find tutorials on how to install/remove software. It will make things a lot

[R] acf for a univariate time series in a data frame

2009-10-08 Thread CJ Rubio
hi everyone! i want to check the autocorrelation function for a univariate time series (streamflow) in a data frame as below: DF - read.table(D:/file path) DF year jan feb mar apr .. dec 1966 0.504 0.406 0.740 0.241 0.429 1967 0.683 0.529

Re: [R] acf for a univariate time series in a data frame

2009-10-08 Thread CJ Rubio
*additional: the lags i am expecting is in months.. since i am trying to predict monthly streamflow. thanks again -- View this message in context: http://www.nabble.com/acf-for-a-univariate-time-series-in-a-data-frame-tp25799751p25799784.html Sent from the R help mailing list archive at

[R] I can not install DAAG package . help

2009-10-08 Thread Yanyuan Zhu
I use R on my Ubuntu 9.04 laptop, which was installed by aptitude install way Now i'm learning a book of R which needs MASS and DAAG installed. So i followed the instructions: install.packages(MASS) library(MASS) MASS works fine. But DAAG doesn't. Anyone who could help would be appreciated a

Re: [R] Plotting 1 covariate, 3 factors

2009-10-08 Thread Paul Chatfield
Cheers guys that's helpful. Doug, you're right, my code for ff should have been for (i in 1:length(y)) {if (f1[i]==after f3[i]==1) ff[i]-1, after else if(f1[i]==after f3[i]==2) ff[i]-2, after else if(f1[i]==before f3[i]==1) ff[i]-1, before else if(f1[i]==before f3[i]==2) ff[i]-2, before}

Re: [R] Plotting 1 covariate, 3 factors

2009-10-08 Thread Deepayan Sarkar
On Thu, Oct 8, 2009 at 1:57 AM, Paul Chatfield p.s.chatfi...@rdg.ac.uk wrote: Cheers guys that's helpful.  Doug, you're right, my code for ff should have been for (i in 1:length(y)) {if (f1[i]==after f3[i]==1) ff[i]-1, after else if(f1[i]==after f3[i]==2) ff[i]-2, after else

[R] Slope between two points

2009-10-08 Thread FMH
Dear All, Let  499 piece-wise lines were buit up by 500 pair of observations, via R code below. x - 1:500 y - rnorm(500) plot(x, y, type = 'b') I was trying to compute all the slopes for the  lines which were connected between two adjacent points. For instance, slopes of lines between first

Re: [R] Plotting 1 covariate, 3 factors

2009-10-08 Thread Paul Chatfield
That's solved it. Superb! All you probably need is to make f2 a factor (e.g., y ~ factor(f2) | f1). Otherwise dotplot() doesn't know which one to treat as categorical. -Deepayan -- View this message in context:

Re: [R] Slope between two points

2009-10-08 Thread baptiste auguie
Hi, Like this perhaps? slope = diff(y) / diff(x) str(slope) num [1:499] 1.5068 -1.8406 2.1745 0.0676 -2.6088 ... HTH, baptiste 2009/10/8 FMH kagba2...@yahoo.com: Dear All, Let  499 piece-wise lines were buit up by 500 pair of observations, via R code below. x - 1:500 y - rnorm(500)

[R] distr package

2009-10-08 Thread msigdel
Dear all when I try to install distr, the following error appears, I am using R in windows. can u suggest me? Error in normalizePath(path) : path[1]=C:\Program Files\R\R-2.9.1\library/distr: The system cannot find the file specified -- This message was sent on behalf of msig...@yahoo.com

Re: [R] how do I name data frames and files according to the index of a for loop?

2009-10-08 Thread jim holtman
Do you really need to keep all 2858 dataframes around, or are you just using them to create the object to write out? If you really have to keep that many, I would suggest that you use a list since you will really polute your workspace with that many objects from the standpoint if you ever wanted

Re: [R] foreach loop - rejection method

2009-10-08 Thread jim holtman
Your function is referencing 'cand2' but where is it defined? There are other objects referenced in the function that do not appear to be passed in as parameters. Are they defined globally? What do you think the following statement in your function is doing:

Re: [R] Need a vectorized way to avoid two nested FOR loops

2009-10-08 Thread jim holtman
Here is one way of doing it: n - 20 set.seed(2) # create test dataframe x - as.data.frame(matrix(sample(1:2,n*6, TRUE), nrow=n)) x V1 V2 V3 V4 V5 V6 1 1 2 2 2 1 1 2 2 1 1 2 2 1 3 2 2 1 2 1 2 4 1 1 1 1 1 2 5 2 1 2 2 1 1 6 2 1 2 1 2 2 7 1 1 2 1

Re: [R] foreach loop - rejection method

2009-10-08 Thread joris meys
First, you should define your function as : test - function(cand2,phi,lambda, whatever-arguments-you-want-to-use-further){... insert code here ...} All variables you use inside a function only exist within that function. Your parameters/arguments is the interface between the function and the

Re: [R] I can not install DAAG package . help

2009-10-08 Thread joris meys
Quite a strange error. The function installed.packages should be in the utils package. Try ?installed.packages and see if you get a help file. If it doesn't find that function, there is a problem with your R installation. It might be something went wrong with downloading the package itself. DAAG

Re: [R] Need a vectorized way to avoid two nested FOR loops

2009-10-08 Thread jim holtman
I answered the wrong question. Here is the code to find all the matches for each row: n - 20 set.seed(2) # create test dataframe x - as.data.frame(matrix(sample(1:2,n*6, TRUE), nrow=n)) x x.col - c(1,3,5) # match against all the other rows x.match1 - apply(x[, x.col], 1, function(a){ .mat -

Re: [R] Second y-axis --- alternative to par(new=

2009-10-08 Thread jim holtman
What you need to do is to specify that you don't want labels on the second plot: ## (2) Does plot points where (x-axis) they should be xlim - range(x1) plot(x1, y1, type=l, xlim=xlim) par(new=TRUE) plot(x2, y2, type=p, xlim=xlim, xlab='', ylab='', axes=FALSE) axis(4) On Wed, Oct 7, 2009 at 4:29

Re: [R] I can not install DAAG package . help

2009-10-08 Thread David Winsemius
On Oct 8, 2009, at 4:27 AM, Yanyuan Zhu wrote: I use R on my Ubuntu 9.04 laptop, which was installed by aptitude install way The is an R-SIG-Debian which is going to have more people with knowledge of your particular OS. Now i'm learning a book of R which needs MASS and DAAG

[R] Determine restricted variable in SVAR and SVEC?

2009-10-08 Thread Arif Chandra
How to determine restricted variable in SVAR and SVEC? There are some values which set to be zero and others set to be NA.. How to determine values that set to be 0? Thanks Regards, Arif

[R] sm.regression - RGL display without data points?

2009-10-08 Thread Giulio Di Giovanni
Hi, I'm using the sm.regression function from the package sm. Everything works fine, but I'd like to have the the RGL display only with the smoothed surface and without the data points displayed. Is there an option to do it? I can reduce their size, using size parameter, but I haven't

[R] plotting a set of discrete distributions

2009-10-08 Thread Michael Friendly
I have the following data set, representing the the estimated number of some event (est), when the actual number was 3, 4, ..., 15. The numbers in the cells are the observed *frequencies* of each combination of (actual, estimated), so each column (a3 -- a15) gives a single discrete frequency

Re: [R] Need a vectorized way to avoid two nested FOR loops

2009-10-08 Thread Dimitris Rizopoulos
Another approach is: n - 20 set.seed(2) x - as.data.frame(matrix(sample(1:2, n*6, TRUE), nrow = n)) x.col - c(1, 3, 5) values - do.call(paste, c(x[x.col], sep = \r)) out - lapply(seq_along(ind), function (i) { ind - which(values == values[i]) ind[!ind %in% i] }) out Best, Dimitris

[R] xyplot#strips like ggplot?

2009-10-08 Thread Christian Ritter
Dear all, I want to split the strips in xyplot and push them into the margins ... Tried to find this in common documentation (such as Deepayan's book) on lattice ... but so far without success ... Here is the situation: xyplot(Speed~Count|Lane*Day,...) where Speed and Count are numeric, Lane

[R] intersection of 2 density curves

2009-10-08 Thread Monica Pisica
Hi, I would like to find out the coordinates of the intersection points of 2 density curves. I did a search but i didn't get any significant results. I really hope some of you have some ideas. here it is an example: set.seed(123) x1 - rnorm(100, 1, 1) x2 - rnorm(100, 0, 1) d1 - density(x1)

[R] Plot with CART results

2009-10-08 Thread Sunny
Hi all, I am a beginar user of R and try to do some CART analysis with it. With rpart we can get several terminals and draw it in the TREE plot. Now I am trying to draw a plot like this: x-axis is each terminal's value, and y-axis is those observe values. Does anyone has idea what gramma should

Re: [R] xyplot#strips like ggplot?

2009-10-08 Thread baptiste auguie
Hi, Try the useOuterStrips function in the latticeExtra package. HTH, baptiste 2009/10/8 Christian Ritter crit...@ridaco.be: Dear all, I want to split the strips in xyplot and push them into the margins ... Tried to find this in common documentation (such as Deepayan's book) on lattice

Re: [R] Evaluating/comparing dynamic linear model

2009-10-08 Thread Giovanni Petris
The standard asymptotic theory of likelihood ratio tests assumes that you are testing a submodel, which is not the case here. Moreover, even when testing submodels, there are other assumptions that often are not met in the case of DLMs - the typical example being hypothesised values on the

[R] variogram

2009-10-08 Thread JRE
Hello everybody, I want to run the following R-code, but it does'nt work. res.vgm = variogram(ertrag ~ rep, # !!! + loc = ~ xpos + ypos, # !!! + width = start.range / 10, + data = d) Error in vector(double, length) : element 2 is

Re: [R] distr package

2009-10-08 Thread David Winsemius
On Oct 8, 2009, at 4:33 AM, msig...@yahoo.com wrote: Dear all when I try to install distr, the following error appears, I am using R in windows. can u suggest me? I'm not a Windows user, but the obvious questions would be How?. What commands or method? and Which? (version of Windows

Re: [R] intersection of 2 density curves

2009-10-08 Thread Monica Pisica
fb7c7e870910080701o1683a41q7d4295d97af8c...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Hi=2C =20 Thanks so much for your answer. It works beautifully for my example and of = course i will test it on thereal data as

Re: [R] plotting a set of discrete distributions

2009-10-08 Thread Gabor Grothendieck
Try this (possibly after scaling the rows or columns to 1): library(gplots) with(as.data.frame.table(as.matrix(jevons[-1])), balloonplot(Var1, Var2, Freq)) On Thu, Oct 8, 2009 at 9:24 AM, Michael Friendly frien...@yorku.ca wrote: I have the following data set, representing the the estimated

Re: [R] intersection of 2 density curves

2009-10-08 Thread Rainer M Krug
On Thu, Oct 8, 2009 at 4:26 PM, Monica Pisica pisican...@hotmail.comwrote: fb7c7e870910080701o1683a41q7d4295d97af8c...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Hi=2C =20 Thanks so much for your answer. It

[R] distributed computing

2009-10-08 Thread wesley mathew
Dear All, I am a researcher, working at the Department of Software Engineering at University of Minho, Portugal. I am working on in the area of Distributed data mining and attempting to develop distributed data mining system in “R” Environment. I have an enquiry. Suppose I have 3 different nodes

Re: [R] intersection of 2 density curves

2009-10-08 Thread David Winsemius
It should also be remembered that there will often be multiple intersections of such density estimates. I hope this is not being done in support of a data-driven discretization of two group comparisons. Such practices are to be eschewed (as they are even worse than obfuscation). -- David

Re: [R] distributed computing

2009-10-08 Thread Steve Lianoglou
Hi, On Oct 8, 2009, at 11:06 AM, wesley mathew wrote: Dear All, I am a researcher, working at the Department of Software Engineering at University of Minho, Portugal. I am working on in the area of Distributed data mining and attempting to develop distributed data mining system in „R‰

Re: [R] intersection of 2 density curves

2009-10-08 Thread Monica Pisica
57d3c6e9-402b-4991-a53b-71e25af78...@comcast.net Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 No worries there =3B-)) But thanks for the reminder all the same! =20 Monica CC:

[R] How to use multiple time series in R?

2009-10-08 Thread FMH
Dear All, I have temperature series for 10 different sea levels, where there are 3000 observations for each level. I am planning to use multiple time series modelling on these series, with/ without correlation structure for the residuals. Is there any package that can be used to do this

Re: [R] plotting a set of discrete distributions

2009-10-08 Thread Michael Friendly
Gabor Grothendieck wrote: Try this (possibly after scaling the rows or columns to 1): library(gplots) with(as.data.frame.table(as.matrix(jevons[-1])), balloonplot(Var1, Var2, Freq)) Thanks, Gabor -- That's not bad as a first cut; I can work with that. -- Michael Friendly Email:

[R] unordered multinomial logistic regression (or logit model) with repeated measures (I think)

2009-10-08 Thread drlucyasher
I am attempted to examine the temporal independence of my data set and think I need an unordered multinomial logistic regression (or logit model) with repeated measures to do so. The data in question is location of chickens. Chickens could be in any one of 5 locations when a snapshot sample was

[R] how to convert list into a vector

2009-10-08 Thread delnatan
Hi , I want to convert a my list: myList [[1]] [1] 1 2 3 4 5 [[2]] [1] 6 7 8 [[3]] [1] 9 10 11 into something like c(1,2,3,4,5,6,7,8,9,10,11) I realized that this is possible by c(do.call(cbind,myList)) But only when list[[1]] through list[[3] have equal length of vectors within them

Re: [R] how to convert list into a vector

2009-10-08 Thread David Winsemius
On Oct 8, 2009, at 11:13 AM, delnatan wrote: Hi , I want to convert a my list: myList [[1]] [1] 1 2 3 4 5 [[2]] [1] 6 7 8 [[3]] [1] 9 10 11 into something like c(1,2,3,4,5,6,7,8,9,10,11) ?unlist I realized that this is possible by c(do.call(cbind,myList)) But only when list[[1]]

[R] New Special Interest Group: R-SIG-DYNAMIC-MODELS

2009-10-08 Thread Thomas Petzoldt
Dear useRs and developeRs, In the last few months we have had an increasing number of requests about deSolve and dynamic modelling. We have also received several requests to establish a SIG of our own about such things. We think this is a good idea -- here it is!

Re: [R] How to start R in mac with the current directory as the current working directory?

2009-10-08 Thread Steve Lianoglou
Hi Peng, On Oct 8, 2009, at 11:21 AM, Peng Yu wrote: Hi, I installed R on mac (see below). When I start it from a terminal by the following command, the current working directory is always '~' no matter where my current directory is in the terminal. I'm wondering if there is a way to make the

[R] 64-bit R on mac

2009-10-08 Thread Peng Yu
Hi, My Mac OS is Leopard. I downloaded R-GUI-5496-2.9-leopard-Leopard64.dmg from http://r.research.att.com/. I run R from the image disk, but it always quit unexpectedly. What could cause the problem? Is it because that I have a 32 bit R installed already installed in the same machine. Regards,

Re: [R] 64-bit R on mac

2009-10-08 Thread Steve Lianoglou
Hi, On Oct 8, 2009, at 11:59 AM, Peng Yu wrote: Hi, My Mac OS is Leopard. I downloaded R-GUI-5496-2.9-leopard-Leopard64.dmg from http://r.research.att.com/. I run R from the image disk, but it always quit unexpectedly. What could cause the problem? Is it because that I have a 32 bit R

Re: [R] unordered multinomial logistic regression (or logit model) with repeated measures (I think)

2009-10-08 Thread Dieter Menne
drlucyasher wrote: I am attempted to examine the temporal independence of my data set and think I need an unordered multinomial logistic regression (or logit model) with repeated measures to do so. What I have thought of so far is glm(Location~ Pen| Bird*AMPM*Time,

Re: [R] how to convert list into a vector

2009-10-08 Thread Henrique Dallazuanna
If you want do.call, you can use c indeed of cbind: do.call(c, list(1:5, 6:8, 9:11)) On Thu, Oct 8, 2009 at 12:13 PM, delnatan delna...@gmail.com wrote: Hi , I want to convert a my list: myList [[1]] [1] 1 2 3 4 5 [[2]] [1] 6 7 8 [[3]] [1] 9 10 11 into something like

Re: [R] how to convert list into a vector

2009-10-08 Thread delnatan
Ok, nevermind. all I had to do was unlist(myList). delnatan wrote: Hi , I want to convert a my list: myList [[1]] [1] 1 2 3 4 5 [[2]] [1] 6 7 8 [[3]] [1] 9 10 11 into something like c(1,2,3,4,5,6,7,8,9,10,11) I realized that this is possible by

Re: [R] Evaluating/comparing dynamic linear model

2009-10-08 Thread Erb Philipp (erbp)
Apologies for my overhasty and thus inaccurate reply. I of course assumed that model2 is a submodel of model1. But thanks to Giovanni: a closer look at your equations shows that this is only the case if at == bt (and of course same innovations/ disturbances et, etat) and xt e.g. something like

Re: [R] Need a vectorized way to avoid two nested FOR loops

2009-10-08 Thread Bert Gunter
If I understand your intent, I believe you can get what you want much faster (no interpreted loops and linear times) by looking at this slightly differently. First of all, the choice of columns is unimportant, as indexing can be used to create a data frame containing only the columns of

Re: [R] Parameters of Beta distribution

2009-10-08 Thread Albyn Jones
Maithili I find it really hard to believe that a beta distribution would be a reasonable probability model for loss data. There would have to be an upper bound on the size of losses. What is the process that generates the data. Is there any natural upper bound? Why is there a lower

Re: [R] 64-bit R on mac

2009-10-08 Thread David Winsemius
On Oct 8, 2009, at 11:59 AM, Peng Yu wrote: Hi, My Mac OS is Leopard. I downloaded R-GUI-5496-2.9-leopard-Leopard64.dmg from http://r.research.att.com/. I run R from the image disk, but it always quit unexpectedly. It is hard to say. If you were really trying to run R from the image, then

Re: [R] Parameters of Beta distribution

2009-10-08 Thread David Winsemius
On Oct 8, 2009, at 12:53 PM, Albyn Jones wrote: Maithili I find it really hard to believe that a beta distribution would be a reasonable probability model for loss data. There would have to be an upper bound on the size of losses. What is the process that generates the data. Is

[R] proto and get()

2009-10-08 Thread baptiste auguie
Dear all, In mucking around with ggplot2, I've hit the following snag, library(ggplot2) # this returns a grob, OK GeomAbline$icon() # lines[GRID.lines.9] # this returns the function icon, OK GeomAbline$icon # proto method (instantiated with ): function (.) # linesGrob(c(0, 1), c(0.2, 0.8)) #

Re: [R] Parameters of Beta distribution

2009-10-08 Thread Albyn Jones
Quoting David Winsemius dwinsem...@comcast.net: In insurance situation there is typically a cap on the covered losses and there is also typically an amount below which it would not make sense to offer a policy. So a minimum and a maximum are sensible assumptions about loss distributions

[R] Adapt function

2009-10-08 Thread Doran, Harold
I am trying to use the adapt function in the package adapt. To make sure I am using it correctly, I am trying a toy example that should yield a result of 2/3. Suppose the function is f(x,y) = x*y^2 and I want to integrate over f as Int_0^1 Int_0^2 x*y^2 dxdy Where the limits of integration for

[R] external variable by inside-function routines modifications

2009-10-08 Thread devol
Dear all, could you please advice whether it is possible somehow to modify an external (from the point of some function view) variable by some function-internal operators. For example var=1 foo-function(var){var=var+1} foo(var) var [1] 1 but the goal is to get the var equal to 2 in this

Re: [R] How to start R in mac with the current directory as the current working directory?

2009-10-08 Thread Peng Yu
On Thu, Oct 8, 2009 at 10:57 AM, Steve Lianoglou mailinglist.honey...@gmail.com wrote: Hi Peng, On Oct 8, 2009, at 11:21 AM, Peng Yu wrote: Hi, I installed R on mac (see below). When I start it from a terminal by the following command, the current working directory is always '~' no matter

Re: [R] proto and get()

2009-10-08 Thread baptiste auguie
... without answering my previous question, I have just found a fortune-hate workaround, getIcon - function(geom){ st - paste(Geom, firstUpper(geom),$icon, sep=) eval(parse(text=st)) } getIcon(abline) I'm still curious about the get() behaviour though. Best, baptiste

Re: [R] external variable by inside-function routines modifications

2009-10-08 Thread Henrique Dallazuanna
See assign, you can use '-' assignment: foo - function(var) var - var + 1 On Thu, Oct 8, 2009 at 2:14 PM, devol sund...@gmail.com wrote: Dear all,  could you please advice whether it is possible somehow to modify an external (from the point of some function view) variable by some

Re: [R] external variable by inside-function routines modifications

2009-10-08 Thread Alex Bird
Is it possible to do what you mentioned somehow outside of the function. I mean that there's some function and the only thing I can do is to point on the variable to be modified inside the function without any possibilities to modify the very function. 2009/10/8 Henrique Dallazuanna

Re: [R] external variable by inside-function routines modifications

2009-10-08 Thread baptiste auguie
Hi, with assign, foo - function(var){ assign(var, var+1, envir = .GlobalEnv) } var =1 foo(2) var # [1] 3 HTH, baptiste 2009/10/8 devol sund...@gmail.com: Dear all,  could you please advice whether it is possible somehow to modify an external (from the point of some function view)

Re: [R] Parameters of Beta distribution

2009-10-08 Thread David Winsemius
On Oct 8, 2009, at 1:13 PM, Albyn Jones wrote: Quoting David Winsemius dwinsem...@comcast.net: In insurance situation there is typically a cap on the covered losses and there is also typically an amount below which it would not make sense to offer a policy. So a minimum and a maximum are

Re: [R] How to start R in mac with the current directory as the current working directory?

2009-10-08 Thread David Winsemius
On Oct 8, 2009, at 1:14 PM, Peng Yu wrote: On Thu, Oct 8, 2009 at 10:57 AM, Steve Lianoglou mailinglist.honey...@gmail.com wrote: Hi Peng, On Oct 8, 2009, at 11:21 AM, Peng Yu wrote: Hi, I installed R on mac (see below). When I start it from a terminal by the following command, the

Re: [R] external variable by inside-function routines modifications

2009-10-08 Thread David Winsemius
On Oct 8, 2009, at 1:14 PM, devol wrote: Dear all, could you please advice whether it is possible somehow to modify an external (from the point of some function view) variable by some function-internal operators. For example var=1 foo-function(var){var=var+1} foo(var) var [1] 1 Use

Re: [R] external variable by inside-function routines modifications

2009-10-08 Thread Bert Gunter
I am uncertain what you mean. Possibly... x - 1 f - function()x-2 f() x [1] 2 HOWEVER, this is very dangerous and most unwise as it depends on scoping rules and where f is called to determine exactly which x is being assigned the value of 2. So I think you would do well to reconsider what you

Re: [R] Need a vectorized way to avoid two nested FOR loops

2009-10-08 Thread Rama Ramakrishnan
Bert, Jim, Dimitris and Joris, Thank you all very much for your prompt help and suggestions. After trying the ideas out, I have decided to go with Bert's approach since it is by far the fastest of the lot. Thanks again! Rama Ramakrishnan On Oct 8, 2009, at 12:49 PM, Bert Gunter wrote:

Re: [R] external variable by inside-function routines modifications

2009-10-08 Thread Alex Bird
Thanks all of you for your help!!! 2009/10/8 Bert Gunter gunter.ber...@gene.com: I am uncertain what you mean. Possibly... x - 1 f - function()x-2 f() x [1] 2 HOWEVER, this is very dangerous and most unwise as it depends on scoping rules and where f is called to determine exactly which

[R] lattice: passing multiple lty values to the key/legend

2009-10-08 Thread Folkes, Michael
hi all, It's not clear to me how (or if) I can pass multiple values for lty to a key in xyplot? I've tried: lines=list(lty=1:3), to no avail. Do I need to use something other than auto.key? (Deepayan, if you're out there, I have your book and must admit the answer isn't jumping out at me.)

[R] problem understanding factor levels for use lattice panel order

2009-10-08 Thread Folkes, Michael
Hello all, In order to get the desired order of panels within lattice I realized I needed to define my factor levels. I now see how to properly do it (attached code), but: 1. I don't understand why I have to use factor() on a variable that is already a factor, and why levels() alone doesn't work

Re: [R] foreach loop - rejection method

2009-10-08 Thread Steve Weston
Hi Ben, It looks like you're getting into trouble because you've converted the body of a for-loop into a function. You don't need to do that with foreach, and some of your problems will be solved by reverting to something more like your original for-loop, I suspect. However, it also looks like

Re: [R] Need a vectorized way to avoid two nested FOR loops

2009-10-08 Thread Dimitris Rizopoulos
Bert Gunter wrote: If I understand your intent, I believe you can get what you want much faster (no interpreted loops and linear times) by looking at this slightly differently. First of all, the choice of columns is unimportant, as indexing can be used to create a data frame containing only the

Re: [R] modifications of out-of-the-function variable

2009-10-08 Thread Ben Bolker
devol wrote: Dear all, could you please advice whether it is possible somehow to modify an external (from the point of some function view) variable by some function-internal operators. For example var=1 foo-function(var){var=var+1} foo(var) var [1] 1 but the goal is to get

[R] sort (all columns of) a matrix

2009-10-08 Thread Kajan Saied
Dear R-Help Team, I have been trying to sort (all columns of) a matrix: a-matrix(a-c(1,3,4,6,6,4,6,56,4,64,86,39,4,2),length(a),2) a [,1] [,2] [1,]11 [2,]33 [3,]44 [4,]66 [5,]66 [6,]44 [7,]66 [8,] 56 56 [9,]44

Re: [R] Adapt function

2009-10-08 Thread Ravi Varadhan
Harold, Try this: ff - function(x) x[1]*x[2]^2 adapt(2, lo = c(0,0), up = c(1,2), fun = ff) The answer should be 4/3, since the first variable is integrated from 0 to 1 and the second variable (second-degree) is integrated from 0 to 2. The answer is 1/3, if you do, adapt(2, lo = c(0,0),

Re: [R] sort (all columns of) a matrix

2009-10-08 Thread Don McKenzie
Untested, but a.sorted - apply(a,sort,2) ? Kajan Saied wrote: Dear R-Help Team, I have been trying to sort (all columns of) a matrix: a-matrix(a-c(1,3,4,6,6,4,6,56,4,64,86,39,4,2),length(a),2) a [,1] [,2] [1,]11 [2,]33 [3,]44 [4,]66 [5,]6

Re: [R] sort (all columns of) a matrix

2009-10-08 Thread Erik Iverson
You need to define sorted in the context of a matrix. By each row individually, by each column individually, or by column using the whole matrix, or by row using the whole matrix? -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf

Re: [R] sort (all columns of) a matrix

2009-10-08 Thread Henrique Dallazuanna
Try this: a[order(a[,1], a[,2]),] On Thu, Oct 8, 2009 at 1:50 PM, Kajan Saied kajan.sa...@gmail.com wrote: Dear R-Help Team, I have been trying to sort (all columns of) a matrix: a-matrix(a-c(1,3,4,6,6,4,6,56,4,64,86,39,4,2),length(a),2) a      [,1] [,2]  [1,]    1    1  [2,]    3    3

Re: [R] sort (all columns of) a matrix

2009-10-08 Thread Daniel Malter
I assume you want to sort the whole dataset (matrix) by ordering one column in ascending order (and order all other columns appropriately). a-matrix(a-c(1,3,4,6,6,4,6,56,4,64,86,39,4,2),length(a),2) a #sort by first column a[order(a[,1]),] #sort by second column a[order(a[,2]),] #both give

Re: [R] sort (all columns of) a matrix

2009-10-08 Thread Bert Gunter
Right. My guess is that Kajan wants: a[do.call(order,data.frame(a)),] ## this generalizes to an arbitrary number of columns ## do.call() is a very powerful and useful R feature worth learning about Yet another reason why the posting guide asks for a simple, proper, reproducible example. --

Re: [R] sort (all columns of) a matrix

2009-10-08 Thread William Dunlap
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Bert Gunter Sent: Thursday, October 08, 2009 11:41 AM To: 'Erik Iverson'; 'Kajan Saied'; r-help@r-project.org Subject: Re: [R] sort (all columns of) a matrix Right. My guess

[R] run WinBUGS under R, and kept getting the error message

2009-10-08 Thread LinZhongjun
Dear R help lists, Hello! I ran WinBUGS under R using the function bugs, but I kept getting the following error message. Error in FUN(X[[3L]], ...) : .C(..): 'type' must be real for this format I can not find the reason. I am freaking out. Could any one have a look at the model codes

Re: [R] sort (all columns of) a matrix

2009-10-08 Thread William Dunlap
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of William Dunlap Sent: Thursday, October 08, 2009 12:01 PM To: Bert Gunter; Erik Iverson; Kajan Saied; r-help@r-project.org Subject: Re: [R] sort (all columns of) a matrix ...

[R] error message - unexpected input

2009-10-08 Thread Danielle Dandreaux
I have been using R the past couple of years to run models on data we are collecting. I recently got a new computer and updated to a new version of R (2.60 - 2.90). Since the update, I cannot get my syntax to run. I have tried copying the file it is looking for into many different directories to

[R] Plot nls line on plot?

2009-10-08 Thread Douglas M. Hultstrand
Hello, I have a non-linear function (exponential) that I am trying to display the line with the data in a plot, is there a command similar to abline() for the function I created, if not what is the best way to display the fitted line. Example code below. ### Example z -

[R] histogram

2009-10-08 Thread Khanh Nguyen
Hi all, I have a question about hist() 1) t1 - hist(c(1,2,3,4,5)) t1 $breaks [1] 1 2 3 4 5 $counts [1] 2 1 1 1 why is there 2 counts for 1? And should the counts be '1 1 1 1 1' ? Is there any other function to count frequency of discrete data? Thanks. -k [[alternative HTML

Re: [R] histogram

2009-10-08 Thread Erik Iverson
For simply counting frequency of discrete data, table , xtabs, and ftable will work. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Khanh Nguyen Sent: Thursday, October 08, 2009 2:47 PM To: r-help@r-project.org Subject:

Re: [R] problem understanding factor levels for use lattice panel order

2009-10-08 Thread Rolf Turner
On 9/10/2009, at 6:52 AM, Folkes, Michael wrote: Hello all, In order to get the desired order of panels within lattice I realized I needed to define my factor levels. I now see how to properly do it (attached code), but: 1. I don't understand why I have to use factor() on a variable that

Re: [R] histogram

2009-10-08 Thread Henrique Dallazuanna
Change the breaks argument: t1 - hist(1:5, 0:5) t1$counts On Thu, Oct 8, 2009 at 4:47 PM, Khanh Nguyen kngu...@cs.umb.edu wrote: Hi all, I have a question about hist() 1) t1 - hist(c(1,2,3,4,5)) t1 $breaks [1] 1 2 3 4 5 $counts [1] 2 1 1 1 why is there 2 counts for 1? And should

Re: [R] Plot nls line on plot?

2009-10-08 Thread David Winsemius
On Oct 8, 2009, at 3:39 PM, Douglas M. Hultstrand wrote: Hello, I have a non-linear function (exponential) that I am trying to display the line with the data in a plot, is there a command similar to abline() for the function I created, if not what is the best way to display the fitted

Re: [R] histogram

2009-10-08 Thread David Winsemius
On Oct 8, 2009, at 3:47 PM, Khanh Nguyen wrote: Hi all, I have a question about hist() 1) t1 - hist(c(1,2,3,4,5)) t1 $breaks [1] 1 2 3 4 5 $counts [1] 2 1 1 1 why is there 2 counts for 1? And should the counts be '1 1 1 1 1' ? It depends on the way the bins are defined. Had you forced

Re: [R] histogram

2009-10-08 Thread Rolf Turner
On 9/10/2009, at 8:47 AM, Khanh Nguyen wrote: Hi all, I have a question about hist() 1) t1 - hist(c(1,2,3,4,5)) t1 $breaks [1] 1 2 3 4 5 $counts [1] 2 1 1 1 why is there 2 counts for 1? RTFM --- include.lowest = TRUE and right = TRUE by default. And should the counts be '1 1

  1   2   >