[R] add to vector without duplicatation

2008-08-28 Thread Yuan Jian
Hi,   I try to add items to a vector, but when the it has existed, the item should be skipped. does anyone know how to do it a simple way?     Yu [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

Re: [R] add to vector without duplicatation

2008-08-28 Thread Nicky Chorley
2008/8/28 Yuan Jian [EMAIL PROTECTED]: Hi, I try to add items to a vector, but when the it has existed, the item should be skipped. does anyone know how to do it a simple way? You might be able to use unique(). Regards, Nicky Chorley __

[R] sample consecutive integers efficiently

2008-08-28 Thread Chris Oldmeadow
Hi all, I have some rough code to sample consecutive integers with length according to a vector of lengths #sample space (representing positions) pos-c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20) #sample lengths lengths-c(2,3,2) From these two vectors I need a vector of sampled

[R] Renaming objects

2008-08-28 Thread Williams, Robin
Hi, Is there any quick and easy way to rename a number of objects, without having to rename each one individually and then remove the old one? And if so, is there anything I can do to adjust the associated comments accordingly? Thanks for any help, Robin Williams Met Office summer intern -

Re: [R] Upgrading R means I lose my packages

2008-08-28 Thread ONKELINX, Thierry
On a windows machine you get the same problem. Useless one uses tha same trick as Rolf suggested: don't install the packages in the default directory and set R_LIBS to that directory. Then all you need to do after an upgrade is to set R_LIBS in the new version and run update.package(checkBuilt =

Re: [R] Updating a list.

2008-08-28 Thread ONKELINX, Thierry
Kevin, Notice the subtle difference between Hadley's and your code: Hadley m2008$DayOfYear - factor(m2008$DayOfYear, levels = 1:365) Kevin m2007$DayOfYear - factor(m2008$DayOfYear, levels = 1:365) Your are using the m2007 object instead of the suggested m2008 object! HTH, Thierry

Re: [R] ggplot2: problem with large fonts and overlapping labels

2008-08-28 Thread ONKELINX, Thierry
Dear Paul, How are you generating (saving) your plots? I tend to play with the pointsize argument of the graphical device, something in conjunction with the size argument in ggplot2 (size of points and lines). Working like that I get plots with nicely propotioned labels without overlaps. HTH,

[R] Odp: I need to change from character to numeric?

2008-08-28 Thread Petr PIKAL
Hi [EMAIL PROTECTED] napsal dne 28.08.2008 02:55:34: Hi, I am reading numeric data as below but the problem is the object ndata1 and nd1 have characters instead of numeric values. I want to keep it as numeric. Why the type has changed from numeric to character and how to avoid this

Re: [R] coding rules

2008-08-28 Thread Gavin Simpson
On Wed, 2008-08-27 at 09:48 -0300, Henrique Dallazuanna wrote: See http://www1.maths.lth.se/help/R/RCC/ The R Internals manual that is shipped with R also has a section on coding standards: http://cran.r-project.org/doc/manuals/R-ints.html#R-coding-standards though this is quite short and

[R] drop unused levels in sqldf

2008-08-28 Thread glaporta
Hi, sqldf is a fantastic package, but when the SELECT procedure runs unused levels remain in the output. I tried with the drop function, but without success. Do you have any suggestions? Thanx, Gianandrea data(iris) require(sqldf) base-sqldf(select * from iris where Species 'setosa') str(base)

Re: [R] How to learn R language?

2008-08-28 Thread Tomas Lanczos
Bert Gunter wrote: -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robert Baer Sent: Wednesday, August 27, 2008 3:42 PM To: r-help@r-project.org Subject: Re: [R] How to learn R language? but I doubt you'll ever be done learning because the project

Re: [R] convert princomp output to equation for plane?

2008-08-28 Thread Mark Difford
Hi Bill, Since x, y,and z all have measurement errors attached, the proper way to do the fit is with principal components analysis, and to use the first component (called loadings in princomp output). The easiest way for you to do this is to use the pcr [principal component regression]

Re: [R] Fw: How to learn R language?

2008-08-28 Thread Graham Smith
While agreeing with how good the texts that have been suggested are, the questions to me (language + systematic) suggests Braun and Murdoch A first course in statistical programming or/and Chambers Software for data analysis: programming with R These would seem to take you through developing

Re: [R] drop unused levels in sqldf

2008-08-28 Thread David Hajage
If you want to suppress the unused level of Species, you can use factor() : table(base$Species) table(factor(base$Species)) 2008/8/28 glaporta [EMAIL PROTECTED] Hi, sqldf is a fantastic package, but when the SELECT procedure runs unused levels remain in the output. I tried with the drop

[R] error in packet 1

2008-08-28 Thread Giovanni Tarquinio
Hello, I'm Giovanni from ROMA.. I can't find a solution for the error: error using packet 1 the y field is not specified and it has not a default value (this is my traslation from italian language) The code is: pc-qqmath(~valori, distribution=function(p) qweibull(p,beta,alpha),

[R] Linear model with one known coordinate

2008-08-28 Thread abaresic
Dear All, I have a question which seems trivial, but I reached a dead end. I have a set of points (measurements) and I used lm() to obtain their linear regression model. From the biological background this line must pass through a point (100,0). Our dataset is not optimal and it shows a slight

[R] A simple analysis of Bayesian Robustness with R

2008-08-28 Thread Davide Crapis
I have to make a simulation testing the Bayesian Robustness of a normal linear model and comparing the regression results obtained using two different g-priors. I tried with the function blinreg() in the LearnBayes package from J.Albert but it doesn't help me because it uses a standard flat

Re: [R] ggplot2: problem with large fonts and overlapping labels

2008-08-28 Thread Paul Emberson
Hi Thierry, Thanks for your reply. I use the pdf graphics device. I did not know about the pointsize option so I will take a look. Here is an example of what I might do. pdf(onefile=FALSE, width=10, height=7) ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() + theme_bw

Re: [R] ggplot2: problem with large fonts and overlapping labels

2008-08-28 Thread Paul Emberson
Dear Thierry, The pointsize option works perfectly for me. Thanks, Paul ONKELINX, Thierry wrote: Dear Paul, How are you generating (saving) your plots? I tend to play with the pointsize argument of the graphical device, something in conjunction with the size argument in ggplot2 (size of

[R] Singularity?

2008-08-28 Thread Williams, Robin
Hi all, When using lm to model a response with 8 explanatory variables, one of the variables is not defined due to singularities. I have checked the csv file from which the data come, there are no na's in the dataset, etc. What should I be looking for in this variable to correct the problem?

[R] R graph with values incorporated

2008-08-28 Thread Prasanth
Dear All: Greetings! By the way, is it possible to have a graph (say line graph) that shows values as well (say y-axis values within the graph)? One could do it in excel. I am just wondering whether it is possible with R! Thanks in advance, Prasanth VP, Global Manager - Biometrics,

Re: [R] Quantitative risk analysis with R

2008-08-28 Thread Tobias Verbeke
Dear Graham, Recently a course with this title, from Vose consulting, was announced on the list. Does anyone know of any books/websites/downloadable tutorials etc that cover the same ground. There is an R package QRMlib on CRAN http://cran.r-project.org/web/packages/QRMlib/index.html that

Re: [R] coloured letters in a text

2008-08-28 Thread Fränzi Korner
Hi does somebody know how to plot single letters in a text in different colours? example 1: I would like to add the word ABC to a figure. Thereby each letter should have a different colour. text(x,y,ABC, col=c(1,2,3)) # this does not work example 2: I would like to add the name of a

Re: [R] Renaming objects

2008-08-28 Thread stephen sefick
names, colnames, rownames - list of names I think it depends on what you are renaming? Stephen On Thu, Aug 28, 2008 at 4:03 AM, Williams, Robin [EMAIL PROTECTED] wrote: Hi, Is there any quick and easy way to rename a number of objects, without having to rename each one individually and then

Re: [R] Singularity?

2008-08-28 Thread Ted Harding
On 28-Aug-08 11:04:47, Wi lliams, Robin wrote: Hi all, When using lm to model a response with 8 explanatory variables, one of the variables is not defined due to singularities. I have checked the csv file from which the data come, there are no na's in the dataset, etc. What should I be

Re: [R] A Tip: lm, glm, and retained cases

2008-08-28 Thread Prof Brian Ripley
In R-devel na.action(GLM) will work as the extractor. The problem with attr(GLM$model, na.action) is that the 'model' component is optional, and with model.frame(ModelObject) that if the 'model' component has been omitted it will try to recreate the model frame from the currently visible

Re: [R] Quantitative risk analysis with R

2008-08-28 Thread Graham Smith
Tobias, Thanks I will give this a look, it seems the focus is on credit risk (where I am more interested in environmental risks) but it should still be useful. Graham 2008/8/28 Tobias Verbeke [EMAIL PROTECTED]: Dear Graham, Recently a course with this title, from Vose consulting, was

Re: [R] coloured letters in a text

2008-08-28 Thread Barry Rowlingson
2008/8/28 Fränzi Korner [EMAIL PROTECTED]: example 1: I would like to add the word ABC to a figure. Thereby each letter should have a different colour. text(x,y,ABC, col=c(1,2,3)) # this does not work kludge alert! How about: text(x,y,ABC,col=3) text(x,y,AB,col=2) text(x,y,A,col=1)

[R] [R-pkgs] New package: ``denstrip'' for compactly illustrating distributions

2008-08-28 Thread Chris Jackson
Dear R users, I'd like to announce a new package on CRAN called ``denstrip''. It implements ``density strips'' and other graphical methods for illustrating and comparing distributions in a compact fashion. Posterior distributions of parameters are often summarised using point and line drawings

Re: [R] averaging pairs of columns in a dataframe

2008-08-28 Thread Gasper Cankar
somehow robust method for dataframe df would be newdf - (df[,seq(1,66,2)]+df[,seq(2,66,2)])/2 Gasper -Original Message- From: JonD [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 27, 2008 3:47 PM To: r-help@r-project.org Subject: [R] averaging pairs of columns in a dataframe

[R] Plots spanning columns

2008-08-28 Thread Jose Luis Aznarte M.
Hi! I want to plot three graphs (residuals, ACF and PACF of a model). Ideally I would use a c(2,2) disposition where the residuals plot would start at position 1,1 and span to position 1,2. Then I would plot the ACF in position 2,1 and the PACF in position 2,2. Maybe is clearer like this:

Re: [R] coloured letters in a text

2008-08-28 Thread Gabor Grothendieck
See ?strwidth, e.g. plot(1) text(1.1, 1.1, A) text(1.1 + strwidth(A), 1.1, B, col = 2) text(1.1 + strwidth(AB), 1.1, C, col = 3) On Thu, Aug 28, 2008 at 7:33 AM, Fränzi Korner [EMAIL PROTECTED] wrote: Hi does somebody know how to plot single letters in a text in different colours? example

Re: [R] Plots spanning columns

2008-08-28 Thread Henrique Dallazuanna
Try this: l - layout(matrix(c(1, 2, 1, 3), 2)) layout.show(l) On Thu, Aug 28, 2008 at 9:40 AM, Jose Luis Aznarte M. [EMAIL PROTECTED] wrote: Hi! I want to plot three graphs (residuals, ACF and PACF of a model). Ideally I would use a c(2,2) disposition where the residuals plot would start

Re: [R] Updating a list.

2008-08-28 Thread rkevinburton
That would be one source of error. Thank you. Kevin ONKELINX wrote: Kevin, Notice the subtle difference between Hadley's and your code: Hadley m2008$DayOfYear - factor(m2008$DayOfYear, levels = 1:365) Kevin m2007$DayOfYear - factor(m2008$DayOfYear, levels = 1:365) Your are

Re: [R] Potential Error/Bug?: addition of NULL during arithmetic

2008-08-28 Thread Prof Brian Ripley
On Tue, 26 Aug 2008, Eric DeWitt wrote: I encountered an error that does not make sense to me given my reading of the documentation and does not appear to be referenced in the list archives or online. The error occurred when a function received a NULL value rather than a numeric value as a

Re: [R] R graph with values incorporated

2008-08-28 Thread Rubén Roa-Ureta
Prasanth wrote: Dear All: Greetings! By the way, is it possible to have a graph (say line graph) that shows values as well (say y-axis values within the graph)? One could do it in excel. I am just wondering whether it is possible with R! x - rnorm(100,2,3) y - rnorm(100,2,3)

Re: [R] Upgrading R means I lose my packages

2008-08-28 Thread Michael Friendly
James Milks wrote: The title says it all. Does anyone know of a way to save your packages when you upgrade to a new version of R? This may seem petty, but I'm accumulating enough packages that having to download and install each of them anew every time I install a new version of R is rather

Re: [R] coloured letters in a text

2008-08-28 Thread Prof Brian Ripley
On Thu, 28 Aug 2008, Barry Rowlingson wrote: 2008/8/28 Fränzi Korner [EMAIL PROTECTED]: example 1: I would like to add the word ABC to a figure. Thereby each letter should have a different colour. text(x,y,ABC, col=c(1,2,3)) # this does not work kludge alert! How about:

Re: [R] Plots spanning columns

2008-08-28 Thread Richard M. Heiberger
library(HH) example(tsacfplots) ?tsacfplots __ 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,

Re: [R] Plots spanning columns

2008-08-28 Thread David Scott
On Thu, 28 Aug 2008, Jose Luis Aznarte M. wrote: Hi! I want to plot three graphs (residuals, ACF and PACF of a model). Ideally I would use a c(2,2) disposition where the residuals plot would start at position 1,1 and span to position 1,2. Then I would plot the ACF in position 2,1 and the

Re: [R] Upgrading R means I lose my packages

2008-08-28 Thread Prof Brian Ripley
On Thu, 28 Aug 2008, Michael Friendly wrote: James Milks wrote: The title says it all. Does anyone know of a way to save your packages when you upgrade to a new version of R? This may seem petty, but I'm accumulating enough packages that having to download and install each of them anew

Re: [R] Integrate a 1-variable function with 1 parameter (Jose L.Romero)

2008-08-28 Thread Ravi Varadhan
Hi, The answer can be obtained in closed form using the pgamma function, which is closely related to the incomplete gamma function, as follows: integrand - function (t, x) { exp(-2*t)*(2*t)^x/(10*factorial(x)) } upper - 10 x - 0:44 ans1 - sapply(x, function(x) integrate(integrand,

Re: [R] Renaming objects

2008-08-28 Thread Gavin Simpson
On Thu, 2008-08-28 at 07:39 -0400, stephen sefick wrote: names, colnames, rownames - list of names I think it depends on what you are renaming? Those alter the dimnames of objects that have them, not the names of the objects themselves. I think a short answer to the question is no. There is a

[R] Help with shading a polygon below a segment of a curve (normal distribution)

2008-08-28 Thread Bertolt Meyer
Dear R users, I still feel new to R so please apologize if I am doing something stupid here. My use of the polygon() function produces a result that I cannot comprehend: In a plot, I would like to shade the area below a normal distribution. However, I do not want the entire area to be shaded,

Re: [R] GeoR model.control - defining covariates at prediction locations

2008-08-28 Thread imicola
Thanks, I've managed to make some progress, but seem to be getting some strange results from my kriging, which I think much have something to do with a problem with my prediction points. I have my geodata object (called nicola), my prediction points (predpoints, imported from a csv containing

Re: [R] Help with shading a polygon below a segment of a curve (normal distribution)

2008-08-28 Thread Peter Dalgaard
Bertolt Meyer wrote: Dear R users, I still feel new to R so please apologize if I am doing something stupid here. My use of the polygon() function produces a result that I cannot comprehend: In a plot, I would like to shade the area below a normal distribution. However, I do not want the

Re: [R] juxtaposed and stacked bars in one barplot?

2008-08-28 Thread Stefan Uhmann
hadley wickham schrieb: Hi Stefan, Could you be a bit more explicit? Do you have an example dataset that you are trying to visualise? Right, thanks for pointing out the obvious. So here's my code: library(gplots) quarter - as.factor(sample(c(Q1, Q2, Q3, Q4), 100, replace =

Re: [R] Help with shading a polygon below a segment of a curve (normaldistribution)

2008-08-28 Thread Richard M. Heiberger
library(HH) normal.and.t.dist() There are many related examples in example(normal.and.t.dist) __ 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

Re: [R] Help with shading a polygon below a segment of a curve (normaldistribution)

2008-08-28 Thread Derek Ogle
Bertolt, The points you send to polygon() do not fully enclose the area you desire. Try adding one more point as such xt - c(x[(length(x)-cutpoint):length(x)],linepos) yt - c(y[(length(y)-cutpoint):length(y)],0) polygon(xt, yt, density = 10 ) -Original Message- From: [EMAIL

Re: [R] Upgrading R means I lose my packages

2008-08-28 Thread Don MacQueen
Speaking for myself, I think it's easier to just create a script and put it somewhere easy to remember. For example my.pkgs - c('pkg1', 'pkg2') ## and so on for my preferred packages install.packages(my.pkgs, dependencies=TRUE) Then after each upgrade just source the script. You will

Re: [R] Help with shading a polygon below a segment of a curve (normal distribution)

2008-08-28 Thread Greg Snow
The power.examp function in the TeachingDemos package (among others) may already do what you want. Even if it does not, it does shade the area under a curve, you can look at the source for the function as an example of where to start. Hope this helps, -- Gregory (Greg) L. Snow Ph.D.

Re: [R] Upgrading R means I lose my packages

2008-08-28 Thread Robert A LaBudde
At 04:12 AM 8/28/2008, ONKELINX, Thierry wrote: On a windows machine you get the same problem. Useless one uses tha same trick as Rolf suggested: don't install the packages in the default directory and set R_LIBS to that directory. Then all you need to do after an upgrade is to set R_LIBS in

Re: [R] RCurl: authentication when posting forms

2008-08-28 Thread Duncan Temple Lang
Hi Valerie Valerie Obenchain wrote: Hi, Has anyone successfully used RCurl for posting data to a password-protected site? Yes. I just set up a sample form to test with and the following all work # Perl script (and HTML form for testing in the browser) taken from #

[R] Read a file

2008-08-28 Thread Dani Valverde
Hello, I have a text file with this structure: # File created = Thursday, August 28, 2008 3:33:02 PM GMT # Data set = 373 2 1 C:\Bruker\TOPSPIN GABRMN # Spectral Region: # LEFT = 4.5 ppm. RIGHT = 0.5 ppm. # # SIZE = 13111 ( = number of points) # # In the following ordering is from the 'left'

[R] Tidying up code - Warning message: deparse may be incomplete

2008-08-28 Thread Marie Pierre Sylvestre
Dear R users, I am currently writing a R package and to do so I am following the guidelines in manual 'Writing R extensions'. In Section 3.1, it is suggested to tidy up the code using a file containing the following: options(keep.source = FALSE) source(myfuns..R) dump(ls(all = TRUE), file =

Re: [R] juxtaposed and stacked bars in one barplot?

2008-08-28 Thread hadley wickham
On Thu, Aug 28, 2008 at 9:31 AM, Stefan Uhmann [EMAIL PROTECTED] wrote: hadley wickham schrieb: Hi Stefan, Could you be a bit more explicit? Do you have an example dataset that you are trying to visualise? Right, thanks for pointing out the obvious. So here's my code:

Re: [R] Tidying up code - Warning message: deparse may be incomplete

2008-08-28 Thread Duncan Murdoch
On 28/08/2008 10:46 AM, Marie Pierre Sylvestre wrote: Dear R users, I am currently writing a R package and to do so I am following the guidelines in manual 'Writing R extensions'. In Section 3.1, it is suggested to tidy up the code using a file containing the following: options(keep.source =

Re: [R] Read a file

2008-08-28 Thread jim holtman
Is this what you want to do: x - scan('clipboard', what=, sep=\n) Read 18 items x [1] # File created = Thursday, August 28, 2008 3:33:02 PM GMT [2] # Data set = 373 2 1 C:\\Bruker\\TOPSPIN GABRMN [3] # Spectral Region: [4] # LEFT = 4.5 ppm. RIGHT = 0.5 ppm. [5] # [6] # SIZE = 13111 (

Re: [R] Read a file

2008-08-28 Thread Henrique Dallazuanna
Try this: x - readLines('clipboard') newx - as.numeric(x[setdiff(seq(length(x)), grep(^#, x))]) comment(newx) - grep(^#, x, value = TRUE) newx comment(newx) On Thu, Aug 28, 2008 at 12:41 PM, Dani Valverde [EMAIL PROTECTED]wrote: Hello, I have a text file with this structure: # File created

Re: [R] Maintaining repeated ID numbers when transposing with reshape

2008-08-28 Thread Adaikalavan Ramasamy
Not the prettiest code but it returns what you want. Might be slow for large dataframes. df - data.frame( ID=c(1,1,1,1,2,2), TEST=c(A,A,B,C,B,B), RESULT=c(17,12,15,12,8,9) ) big.out - list(NULL) for( uID in unique(df$ID) ){ m - df[ df$ID == uID, ,

Re: [R] Cluster

2008-08-28 Thread Adaikalavan Ramasamy
Try reading help(hclust) and help(matplot) and run the examples given in the documentation. If that doesn't work, try posting again with a simple reproducible example. Regards, Adai Marco Chiapello wrote: Hi all, I'm trying to do a cluster analysis,but I don't know if it's possible in the

[R] variance covariance matrix in GLM

2008-08-28 Thread markleeds
this is for the person who asked me about prediction confidence intervals in a GLM because I lost your email. Below follows a simple example in CAR and the variance covariance of the beta coefficients is in the summary. So, I think, given that output, it should be pretty straightforward to do

Re: [R] Linear model with one known coordinate

2008-08-28 Thread Philipp Pagel
I have a set of points (measurements) and I used lm() to obtain their linear regression model. From the biological background this line must pass through a point (100,0). Our dataset is not optimal and it shows a slight deviation from that coordinate. How can I add the restraint to the model,

Re: [R] Notice

2008-08-28 Thread stephen sefick
WHAT is this in reguard too? On Thu, Aug 28, 2008 at 12:56 PM, Ajay ohri [EMAIL PROTECTED] wrote: For the record, I* * ** *am not and have never been an employee of World Programming Ltd and that the postings and views expressed in these communities and forums have been motivated by my

Re: [R] svymeans question

2008-08-28 Thread Thomas Lumley
Other people have explained that the issue is missing data. I just wanted to note that the reason for using only the complete cases on all variables is that svymeans() computes the covariance matrix of all the means, and this can't really be done sensibly when the means are based on

Re: [R] sample consecutive integers efficiently

2008-08-28 Thread Charles C. Berry
On Thu, 28 Aug 2008, Chris Oldmeadow wrote: Hi all, I have some rough code to sample consecutive integers with length according to a vector of lengths #sample space (representing positions) pos-c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20) #sample lengths lengths-c(2,3,2) From

[R] Function not returning a vector?

2008-08-28 Thread rkevinburton
Why does: (shape/scale) * (1:365/scale)^(shape - 1) return a vector of numbers but calling a function hasard(1:365,shape,scale) defined like: hazard - function(x,shape,scale) { return (shape/scale) * (x/scale)^(shape - 1) } Only return a single value? It is like x becomes a single value

Re: [R] Survey Design / Rake questions

2008-08-28 Thread Thomas Lumley
On Mon, 25 Aug 2008, Farley, Robert wrote: I see a number of things that bother me. 1) str(ByEBNum$StnTraveld) says int [1:12] 1 2 3 4 5 6 7 8 9 10 ... Even though StnTraveld - c(as.factor(1:12)) You don't want the c() a-as.factor(1:12) str(a) Factor w/ 12 levels 1,2,3,4,..: 1 2

Re: [R] Function not returning a vector?

2008-08-28 Thread Jeff Laake
Try hazard - function(x,shape,scale) { return ((shape/scale) * (x/scale)^(shape - 1)) } hazard(1:365,1,1) --jeff [EMAIL PROTECTED] wrote: Why does: (shape/scale) * (1:365/scale)^(shape - 1) return a vector of numbers but calling a function hasard(1:365,shape,scale) defined like: hazard

Re: [R] Function not returning a vector?

2008-08-28 Thread Barry Rowlingson
2008/8/28 [EMAIL PROTECTED]: hazard - function(x,shape,scale) { return (shape/scale) * (x/scale)^(shape - 1) } Only return a single value? It is like x becomes a single value passed as an argument. It's evaluating return(shape/scale) and returning that! Add some extra parentheses:

Re: [R] Function not returning a vector?

2008-08-28 Thread Peter Dalgaard
[EMAIL PROTECTED] wrote: Why does: (shape/scale) * (1:365/scale)^(shape - 1) return a vector of numbers but calling a function hasard(1:365,shape,scale) defined like: hazard - function(x,shape,scale) { return (shape/scale) * (x/scale)^(shape - 1) } Only return a single value? It is like

Re: [R] Function not returning a vector?

2008-08-28 Thread Mark Lyman
rkevinburton at charter.net writes: Why does: (shape/scale) * (1:365/scale)^(shape - 1) return a vector of numbers but calling a function hasard(1:365,shape,scale) defined like: hazard - function(x,shape,scale) { return (shape/scale) * (x/scale)^(shape - 1) } Only

Re: [R] Function not returning a vector?

2008-08-28 Thread Achim Zeileis
On Thu, 28 Aug 2008, [EMAIL PROTECTED] wrote: Why does: (shape/scale) * (1:365/scale)^(shape - 1) return a vector of numbers but calling a function hasard(1:365,shape,scale) defined like: hazard - function(x,shape,scale) { return (shape/scale) * (x/scale)^(shape - 1)

Re: [R] Function not returning a vector?

2008-08-28 Thread Nordlund, Dan (DSHS/RDA)
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Thursday, August 28, 2008 11:36 AM To: r-help@r-project.org Subject: [R] Function not returning a vector? Why does: (shape/scale) * (1:365/scale)^(shape - 1) return a

[R] Spider Graph

2008-08-28 Thread Van Patten, Isaac T
Is there an R function to generate a radar or spider graph from a table - e.g.radar(table(x)) or some such? == Isaac T. Van Patten, Ph.D. Professor Department of Criminal Justice Box 6934, Radford University Radford, VA 24142

Re: [R] Spider Graph

2008-08-28 Thread Sarah Goslee
help.search(radar) and help.search(spider) would both get you right to stars() Sarah On Thu, Aug 28, 2008 at 3:00 PM, Van Patten, Isaac T [EMAIL PROTECTED] wrote: Is there an R function to generate a radar or spider graph from a table - e.g.radar(table(x)) or some such? -- Sarah Goslee

Re: [R] Notice

2008-08-28 Thread Henrik Bengtsson
On Thu, Aug 28, 2008 at 10:42 AM, stephen sefick [EMAIL PROTECTED] wrote: WHAT is this in reguard too? It seems to be a message from another universe (SAS something) - maybe a wormhole? Are we not alone? /H On Thu, Aug 28, 2008 at 12:56 PM, Ajay ohri [EMAIL PROTECTED] wrote: For the

[R] hex2RGB back to hex not the same?

2008-08-28 Thread Aaron Mackey
Witness this oddity (to me): rainbow_hcl(10)[1] [1] #E18E9E d - attributes(hex2RGB(rainbow_hcl(10)))$coords[1,] rgb(d[1], d[2], d[3]) [1] #C54D5F What happened? FYI, this came up as I'm trying to reuse the RGB values I get from rainbow_hcl in a call to rgb() where I can also set alpha

Re: [R] error in packet 1

2008-08-28 Thread Deepayan Sarkar
On Thu, Aug 28, 2008 at 3:07 AM, Giovanni Tarquinio [EMAIL PROTECTED] wrote: Hello, I'm Giovanni from ROMA.. I can't find a solution for the error: error using packet 1 the y field is not specified and it has not a default value (this is my traslation from italian language) The code is:

[R] drop.unused.levels for two factors {lattice}

2008-08-28 Thread Dylan Beaudette
Hi, Is there any way to suppress plotting of panels that don't actually contain any information? I have tried using 'drop.unused.levels=TRUE', but there doesn't seem to be any effect. Here is an example: library(lattice) # some fake data: d - data.frame(x=runif(20), x.class=rep(letters[1:5],

[R] Interaction between aggregate() and length()

2008-08-28 Thread Seeliger . Curt
Folks, I've been running into an odd situation that occurs when I use length() function with aggregate(), but not with either one separately. Together, the results looks correct but is given an unexpected name. 'if (stringsAsFactors) factor(x) else x' instead of just 'x'. # Numbers work ok

Re: [R] hex2RGB back to hex not the same?

2008-08-28 Thread Deepayan Sarkar
On Thu, Aug 28, 2008 at 1:07 PM, Aaron Mackey [EMAIL PROTECTED] wrote: Witness this oddity (to me): rainbow_hcl(10)[1] [1] #E18E9E d - attributes(hex2RGB(rainbow_hcl(10)))$coords[1,] rgb(d[1], d[2], d[3]) [1] #C54D5F What happened? FYI, this came up as I'm trying to reuse the RGB values

[R] USING TOBIT OR WHAT ALTERNATIVE WHEN DATA ARE PANEL AND HETEROSKEDASTIC AND PROBABLY AUTOCORRELATED?

2008-08-28 Thread Adrienne Kandel
Please, I seek expertise and advice, possibly leads to R packages or stats literature. My data: measurements of economic variables for each county of California over 37 years. My dependent variable is square feet of office floor space permitted to be added in a county. Independent variables

Re: [R] drop.unused.levels for two factors {lattice}

2008-08-28 Thread Deepayan Sarkar
On Thu, Aug 28, 2008 at 1:21 PM, Dylan Beaudette [EMAIL PROTECTED] wrote: Hi, Is there any way to suppress plotting of panels that don't actually contain any information? I have tried using 'drop.unused.levels=TRUE', but there doesn't seem to be any effect. Here is an example:

Re: [R] Interaction between aggregate() and length()

2008-08-28 Thread Henrique Dallazuanna
One option is use this: aggregate(list(t=tt$t), list(idx=tt$idx), length) On Thu, Aug 28, 2008 at 4:36 PM, [EMAIL PROTECTED] wrote: Folks, I've been running into an odd situation that occurs when I use length() function with aggregate(), but not with either one separately. Together, the

Re: [R] drop.unused.levels for two factors {lattice}

2008-08-28 Thread Dylan Beaudette
On Thursday 28 August 2008, Deepayan Sarkar wrote: On Thu, Aug 28, 2008 at 1:21 PM, Dylan Beaudette [EMAIL PROTECTED] wrote: Hi, Is there any way to suppress plotting of panels that don't actually contain any information? I have tried using 'drop.unused.levels=TRUE', but there doesn't

Re: [R] Interaction between aggregate() and length()

2008-08-28 Thread Seeliger . Curt
That's a great work around, as I can eliminate renaming the results column from 'x' to whatever. Thanks for the quick tip, Henrique. On the other hand, I'm still stumped as to why aggregate() would name an output column as 'if (stringsAsFactors) factor(x) else x'. That sort of behaviour

Re: [R] RCurl: authentication when posting forms

2008-08-28 Thread Valerie Obenchain
Duncan, Thank you for the examples. I had tried all of these different options for authentication but had no luck. I was getting a 100 continue and then a 401 unauthorized response. This morning the owners of the server I was trying to access discovered a bug with their api when using

[R] Adjusting for initial status (intercept) in lme growth models

2008-08-28 Thread D Chaws
Hi everyone, I have a quick and probably easy question about lme for this list. Say, for instance you want to model growth in pituitary distance as a function of age in the Orthodont dataset. fm1 = lme(distance ~ I(age-8), random = ~ 1 + I(age-8) | Subject, data = Orthodont) You notice that

[R] abline of an lm fit not correct

2008-08-28 Thread stephen sefick
mac osx 10.5.4 R 2.7.1 I have fit a model d-lm(y~x) with an R^2 of 0.963 but when I issue the command abline(d) the line is below where it ought to be. Looks like the right slope, but not the right intercept. thanks -- Stephen Sefick Research Scientist Southeastern Natural Sciences Academy

Re: [R] abline of an lm fit not correct

2008-08-28 Thread stephen sefick
sorry idiotic question- you have to make sure you are using the right things before you start ploting On Thu, Aug 28, 2008 at 7:54 PM, stephen sefick [EMAIL PROTECTED] wrote: mac osx 10.5.4 R 2.7.1 I have fit a model d-lm(y~x) with an R^2 of 0.963 but when I issue the command abline(d)

Re: [R] sample consecutive integers efficiently

2008-08-28 Thread Chris Oldmeadow
Charles C. Berry wrote: On Thu, 28 Aug 2008, Chris Oldmeadow wrote: Hi all, I have some rough code to sample consecutive integers with length according to a vector of lengths #sample space (representing positions) pos-c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20) #sample lengths

Re: [R] RCurl: authentication when posting forms

2008-08-28 Thread Duncan Temple Lang
Valerie Obenchain wrote: Duncan, Thank you for the examples. I had tried all of these different options for authentication but had no luck. I was getting a 100 continue and then a 401 unauthorized response. This morning the owners of the server I was trying to access discovered a bug

[R] Newbie: Examples on functions callling a library etc.

2008-08-28 Thread Eduardo M. A. M.Mendes
Hello R is pretty new to me. I need to write a function that returns three matrices of different dimensions. In addition, I need to call a function from a contributed package with the function. I have browsed several manuals and docs but the examples on them are either very simple or

Re: [R] Survey Design / Rake questions

2008-08-28 Thread Farley, Robert
I'm feeling like I just don't get it. My attempt at rake now fails with: Error in postStratify.survey.design(design, strata[[i]], population.margins[[i]], : Stratifying variables don't match The factors in the data frame looks fine. Should I have the same structure in the design?

[R] lost attrubute:names

2008-08-28 Thread Yuan Jian
Hi, when I pick out one element from a matrix, the attribute name is kept, but when more than one elements are extracted, the attribute name lost;   a-matrix(c(1,2,3,11,12,13,45,56,76),ncol=3,dimnames=list(c(),c(c1,c2,c3))) k-a[a[,c3]50,c3] kk-a[a[,c3]60,c3] attributes(k) NULL attributes(kk)

Re: [R] lost attrubute:names

2008-08-28 Thread Charles C. Berry
On Thu, 28 Aug 2008, Yuan Jian wrote: Hi, when I pick out one element from a matrix, the attribute name is kept, but when more than one elements are extracted, the attribute name lost; To what attribute 'name' do you refer? I only see 'dim' and 'dimnames' attributes: attributes(a) $dim

Re: [R] Newbie: Examples on functions callling a library etc.

2008-08-28 Thread Ben Bolker
Eduardo M. A. M.Mendes emammendes at gmail.com writes: R is pretty new to me. I need to write a function that returns three matrices of different dimensions. In addition, I need to call a function from a contributed package with the function. I have browsed several manuals and docs but the

Re: [R] Newbie: Examples on functions callling a library etc.

2008-08-28 Thread Steven McKinney
Hi Ed, Here's a simple example showing your needs: myfun - function(n1, n2, n3) { mat1 - matrix(rep(1), nrow = n1, ncol = 3) mat2 - matrix(rep(2), nrow = n2, ncol = 4) mat3 - matrix(rep(3), nrow = n3, ncol = 5) require(survival) ## make sure the package you need is loaded mypkgfun

[R] extract variance components

2008-08-28 Thread huang min
HI, I would like to extract the variance components estimation in lme function like a.fit-lme(distance~age, data=aaa, random=~day/subject) There should be three variances \sigma_day, \sigma_{day %in% subject } and \sigma_e. I can extract the \sigma_e using something like a.fit$var. However, I

  1   2   >