Re: [R] For Loop Error

2012-01-29 Thread Rui Barradas
Hello, Every time the loop blows up, I get back this error: Error in table.combos[i, ] - table(combos) : number of items to replace is not a multiple of replacement length This is because not all colors are present in that one sample that breaks the code. There is no apparent

[R] Please help, a question about the R function arima, thanks a lot!

2012-01-29 Thread blackkettle
Dear everyone, I have met a problem when using the R function arima. The following is the coding. www - http://www.massey.ac.nz/~pscowper/ts/pounds_nz.dat; x - read.table(www, header = T) x.ts - ts(x, st = 1991, fr = 4) x.ma - arima(x.ts, order = c(0, 0, 1)) x.ma acf(x.ma$res[-1]) I was

Re: [R] For Loop Error

2012-01-29 Thread Petr Savicky
On Sat, Jan 28, 2012 at 10:25:47AM -0800, Melrose2012 wrote: Hi Again, I am writing a 'for loop' to create a matrix of randomly sampled colors. I've written this loop in matlab and it works fine. I then tried to do it in R and apparently there is something wrong with my syntax b/c every

Re: [R] Why does the order of terms in a formula translate into different models/ model matrices?

2012-01-29 Thread peter dalgaard
On Jan 29, 2012, at 02:42 , Ben Bolker wrote: (quoting removed to make Gmane happy) AFAICS, this is a bug. I think so too, although I haven't got my head around it yet. Chuck, are you willing to post a summary of this to r-devel for discussion ... and/or post a bug report? You

[R] Help joincount.test

2012-01-29 Thread CD
Hello, I'm trying to analyse the spatial organization of different fields planted with different varieties (each field has only one variety), but I have problems trying to understand the results of the test I did. To do this, I created different neighbourhood matrix. For example, for the first

[R] r-help; weibull parameter estimate

2012-01-29 Thread Christopher Kelvin
Hello, If i write a function as below using log of weibull distribution i do not get the required results in estimating the parameters what do i do, please a/b * (t/b)^a-1 * exp(-t/b)^a n=500 x-rweibull(n,2,2) z-function(p) {(-n*log(p[1])+n*log(p[2])-

[R] question on model.matrix

2012-01-29 Thread Daniel Negusse
I am new to this group - joined today. I am in because i have an assignment to do using R = microarray analysis using affy (bioconductor). while reading some tutorials, i came across this and i am stuck. i want to understand it and would appreciate if anyone can tell me. design -

Re: [R] r-help; weibull parameter estimate

2012-01-29 Thread peter dalgaard
On Jan 29, 2012, at 12:17 , Christopher Kelvin wrote: Hello, If i write a function as below using log of weibull distribution i do not get the required results in estimating the parameters what do i do, please Presumably find and fix the error in your likelihood function! z2 -

Re: [R] Error from Brugs 'r for windows gui front-end has stopped working''

2012-01-29 Thread Jin Minming
Thanks. I guess it may be due to the software conflict in my computers as there are the same software packages which have been installed in these two laptops. Anyway, I can still use my desktop with Windows XP system. Jim --- On Sat, 28/1/12, Uwe Ligges lig...@statistik.tu-dortmund.de

Re: [R] wireframe_box_axis

2012-01-29 Thread David Winsemius
On Jan 28, 2012, at 6:44 PM, h...@komarac.biologija.unios.hr wrote: Thank you very much for help. But would you be kind to show me on this simple example how to obtain x, y and z axis. Namely, it is not problem to avoid box with par.box = list(col=transparent) but to keep axis?

Re: [R] package does not have a NAMESPACE

2012-01-29 Thread Uwe Ligges
On 27.01.2012 19:51, Ondřej Mikula wrote: Dear r-helpers, I have a trouble with a package downloaded from sourceforge.net (namely the package 'kopls'). I installed it from the local zip file with the expected result utils:::menuInstallLocal() package ‘kopls’ successfully unpacked and MD5

[R] r-help; weibull distribution

2012-01-29 Thread Christopher Kelvin
 Please, Help me, How do I generate data from the weibull distribution if the data contain both failure and interval censored, For example, I want to generate n=100, shape=2 and scale =4 with 30% interval censored.  What about right censoring Thank you  [[alternative HTML version

Re: [R] Need very fast application of 'diff' - ideas?

2012-01-29 Thread R. Michael Weylandt
Have you not followed your own thread? Dirk is Mr. Rcpp himself and he gives an implementation that gives you 25x improvement here as well as tips for getting even more out of it: http://tolstoy.newcastle.edu.au/R/e17/help/12/01/2471.html Michael On Sat, Jan 28, 2012 at 12:28 PM, Kevin Ummel

[R] Data Structure to Code

2012-01-29 Thread Ajay Askoolum
Given: data(AirPassengers) I get a ts data structure AirPassengers in the workspace. How can I generate the code that can create that structure? That is, given an example of a data structure, is there a way to generate the code that can greate that structure? Alternatively, is there a

Re: [R] Data Structure to Code

2012-01-29 Thread R. Michael Weylandt
dput() Michael On Sun, Jan 29, 2012 at 10:56 AM, Ajay Askoolum aa2e...@yahoo.co.uk wrote: Given: data(AirPassengers) I get a ts data structure AirPassengers in the workspace. How can I generate the code that can create that structure? That is, given an example of a data structure, is

Re: [R] Data Structure to Code

2012-01-29 Thread Florent D.
see dump() or dput(). On Sun, Jan 29, 2012 at 10:56 AM, Ajay Askoolum aa2e...@yahoo.co.uk wrote: Given: data(AirPassengers) I get a ts data structure AirPassengers in the workspace. How can I generate the code that can create that structure? That is, given an example of a data structure,

Re: [R] r-help; weibull distribution

2012-01-29 Thread David Winsemius
On Jan 29, 2012, at 7:38 AM, Christopher Kelvin wrote: Please, Help me, How do I generate data from the weibull distribution if the data contain both failure and interval censored, For example, I want to generate n=100, shape=2 and scale =4 with 30% interval censored. What about right

Re: [R] Need very fast application of 'diff' - ideas?

2012-01-29 Thread Kevin Ummel
Sorry, guys. I'm not active on the listserve, so my last post was held by the moderator until after Dirk's solution was posted. Excellent stuff. thanks, kevin On Jan 29, 2012, at 8:37 AM, R. Michael Weylandt wrote: Have you not followed your own thread? Dirk is Mr. Rcpp himself and he gives

Re: [R] Data Structure to Code

2012-01-29 Thread Ajay Askoolum
Thank you. I need some clarification. dput(AirPassengers) gives: structure(c(112, 118, 132, 129, 121, 135, 148, 148, 136, 119, 104, 118, 115, 126, 141, 135, 125, 149, 170, 170, 158, 133, 114, 140, 145, 150, 178, 163, 172, 178, 199, 199, 184, 162, 146, 166, 171, 180, 193, 181, 183, 218, 230,

Re: [R] Need very fast application of 'diff' - ideas?

2012-01-29 Thread R. Michael Weylandt
Sorry about that -- Gmail threaded things by arrival in my mailbox, not by timestamp (surprisingly) Rcpp really is one of the coolest new things in the R ecosystem -- hope it works well for you. M On Sun, Jan 29, 2012 at 11:12 AM, Kevin Ummel kevinum...@gmail.com wrote: Sorry, guys. I'm not

Re: [R] Data Structure to Code

2012-01-29 Thread R. Michael Weylandt
You said something about extracting January to June -- that's not so possible with the default ts (best I understand it): ts() only allows regular time-series so you can't go jan to jun at 1 month intervals and then jump to jan again (6 months). If you want irregular time series, check out the zoo

[R] Drawing sample

2012-01-29 Thread Ron Michael
Dear all, here I need to draw all possible samples of size 2, from a population, which is characterized by c(1,4,56, 3). Sampling will be done with replacement. Is there any direct R function to faciliate this darwing?   Thanks for your help __

Re: [R] Data Structure to Code

2012-01-29 Thread David Winsemius
On Jan 29, 2012, at 11:36 AM, Ajay Askoolum wrote: Thank you. I need some clarification. dput(AirPassengers) gives: structure(c(112, 118, 132, 129, 121, 135, 148, 148, 136, 119, 104, 118, 115, 126, 141, 135, 125, 149, 170, 170, 158, 133, 114, 140, 145, 150, 178, 163, 172, 178, 199, 199,

Re: [R] Drawing sample

2012-01-29 Thread David Winsemius
On Jan 29, 2012, at 11:21 AM, Ron Michael wrote: Dear all, here I need to draw all possible samples of size 2, from a population, which is characterized by c(1,4,56, 3). combn(c(1,4,56, 3), 2) # an enumeration of possible tuples [,1] [,2] [,3] [,4] [,5] [,6] [1,]1114

[R] How do I turn NA's to zeroes when a combination lacks one element?

2012-01-29 Thread C_Crown
Hi all, I am very new to R. I am taking a course and am trying to complete my first assignment. For the assignment I have to get the program to generate different color combinations possible for a sample size of 55 with the probabilities of each color being chosen as: .24, .24, .16, .20, .13,

[R] ColorBrewer question

2012-01-29 Thread Mario Giesel
Hello, R friends,   I'm trying to change colors of my horizontal bars so that they show a sequence. I chose the ColorBrewer palette Blues. However the resulting plot doesn't show any changes to the default. I tried several places of + scale_colour_brewer(type=seq, pal = Blues) with no effect.

Re: [R] Need very fast application of 'diff' - ideas?

2012-01-29 Thread Martin Morgan
On 01/29/2012 08:12 AM, Kevin Ummel wrote: Sorry, guys. I'm not active on the listserve, so my last post was held by the moderator until after Dirk's solution was posted. Excellent stuff. Is 'diff' really the bottleneck in your calculations? I would have said diff was in the class of 'fast'

Re: [R] Drawing sample

2012-01-29 Thread Jorge I Velez
Take a look at ?sample HTH, Jorge.- On Sun, Jan 29, 2012 at 11:21 AM, Ron Michael wrote: Dear all, here I need to draw all possible samples of size 2, from a population, which is characterized by c(1,4,56, 3). Sampling will be done with replacement. Is there any direct R function to

Re: [R] Data Structure to Code

2012-01-29 Thread Gabor Grothendieck
On Sun, Jan 29, 2012 at 11:36 AM, Ajay Askoolum aa2e...@yahoo.co.uk wrote: Thank you. I need some clarification. dput(AirPassengers) gives: structure(c(112, 118, 132, 129, 121, 135, 148, 148, 136, 119, 104, 118, 115, 126, 141, 135, 125, 149, 170, 170, 158, 133, 114, 140, 145, 150, 178,

Re: [R] Horizontal stacked 100% bars with ggplot2

2012-01-29 Thread Mario Giesel
Thanks, Carlos,    your solution looks nice, however, there are 4 bars instead of 2 i.e. bars are not stacked. Meanwhile I got a solution for that task. So thanks for sharing your version of it!   Good luck,  Mario Von: Carlos Ortega c...@qualityexcellence.es

[R] question about ... questions/ code

2012-01-29 Thread Nicole Marie Ford
Hello, I have a dataset which I am calling RB09. I am trying to match the questions in the code book with variable codes. It is not very intuitive. example: names(RB09) [1] ea1eaf1 eaf1a eaf2 eaf2_7 [6] eaf3 eafimpun eafunpun evimpmar evfutpro

Re: [R] How do I turn NA's to zeroes when a combination lacks one element?

2012-01-29 Thread Berend Hasselman
On 29-01-2012, at 18:18, C_Crown wrote: Hi all, I am very new to R. I am taking a course and am trying to complete my first assignment. For the assignment I have to get the program to generate different color combinations possible for a sample size of 55 with the probabilities of each

Re: [R] Help joincount.test

2012-01-29 Thread Roger Bivand
CD camille.dezecache at gmail.com writes: Hello, I'm trying to analyse the spatial organization of different fields planted with different varieties (each field has only one variety), but I have problems trying to understand the results of the test I did. Can somebody help me

Re: [R] How do I turn NA's to zeroes when a combination lacks one element?

2012-01-29 Thread Mitchell Maltenfort
?ifelse Type that in and you'll be in good shape. On 1/29/12, C_Crown ccr...@life.bio.sunysb.edu wrote: Hi all, I am very new to R. I am taking a course and am trying to complete my first assignment. For the assignment I have to get the program to generate different color combinations

Re: [R] How do I turn NA's to zeroes when a combination lacks one element?

2012-01-29 Thread C_Crown
Thank you so very much for your help. That worked perfectly. Yes, it's homework, but hopefully what I'm learning with the homework I'll be able to apply to my own research in the future, so I'd really like to learn the program. And by the by, the someone was a classmate. Thanks again! Crystal

[R] How I assign the result of a plot to a variable?

2012-01-29 Thread Ajay Askoolum
I can write a plot to a files of a given format using this: x-sample(c(1:100),10) bmp(c:/mygraph.bmp) plot(x) dev.off() and then show the image file in another application. This application can also display the image from the stream of numbers that define the image. How I can get the plot as a

Re: [R] How I assign the result of a plot to a variable?

2012-01-29 Thread baptiste auguie
Try this, plot(1:10) img - grid::grid.cap() # grid.raster(img) stream - col2rgb(img) write.table(stream, file=dam.txt, row.names = FALSE, col.names = FALSE) (you'll have to restore the dimensions of the matrix once you've read the rgb values for each pixel) HTH, baptiste On 30

Re: [R] formula error inside function

2012-01-29 Thread Hugh Morgan
Hi, I have what I suppose is the same problem as this. I am using the linear mixed model function lme, and this does not seems to take the attribute model=TRUE at the end of the function. Is there a more general way of solving this problem? Is my description of the problem below correct

Re: [R] percentage from density()

2012-01-29 Thread William Dunlap
If v is your original data, v - c(-20, rep(0,98), 20) why not use mean( -20 v v 2) as your estimate of the probability that v is in (-20,2)? Estimating a density is like taking the derivative of a smooth of the empirical distribution function, so why not eliminate the middleman instead

[R] apply lm() to each row of a matrix

2012-01-29 Thread Martin Batholdy
Hi, I would like to fit lm-models to a matrix with 'samples' of a dependent variable (each row represents one sample of the dependent variable). The independent variable is a vector that stays the same: y - c(1:10) x - matrix(rnorm(5*10,0,1), 5, 10) now I would like to avoid looping over

Re: [R] apply lm() to each row of a matrix

2012-01-29 Thread R. Michael Weylandt
If it's a simple one variable OLS regression and you only need regression coefficients, you'll probably get best performance by hard-coding the closed form solutions. apply() might help a little (since it's a very good loop) but ultimately you'll be best served by deciding exactly what you want

Re: [R] apply lm() to each row of a matrix

2012-01-29 Thread Bert Gunter
Reread ?lm and note that the lhs can be a matrix. I believe this is exactly what you want. -- Bert On Sun, Jan 29, 2012 at 2:05 PM, Martin Batholdy batho...@googlemail.com wrote: Hi, I would like to fit lm-models to a matrix with 'samples' of a dependent variable (each row represents one

Re: [R] question about ... questions/ code

2012-01-29 Thread R. Michael Weylandt
Perhaps I'm misunderstanding you, but it doesn't sound like this is much of an R question at all: what is the code book? If it's an actual (dead tree) book, I don't think there's much you can do in R to automate identifications; if it's an online API, you *might* be able to rig a matching

Re: [R] ColorBrewer question

2012-01-29 Thread R. Michael Weylandt
I believe you need to use the scale_fill_brewer since fill is the color of the bars while color is the outside of the bars in ggplot2-speak: E.g., with built-in data (it's polite to provide yours so that your minimal working example is working): data(diamonds) ggplot(diamonds, aes(clarity)) +

Re: [R] Calculate a function repeatedly over sections of a ts object

2012-01-29 Thread R. Michael Weylandt
It's customary to keep the list cc'd. I can't run your code without the data, but it does seem to me that your problem is in the FUN argument, as you guess. You have: FUN=function(z) SDF(adezoo,method=lag window, window=taper(type=parzen,n.sample=n.d,cutoff=(2*sqrt(n.d))), npad=2*n.d) But this

Re: [R] Calculate a function repeatedly over sections of a ts object

2012-01-29 Thread R. Michael Weylandt
Sorry, that last line should read: FUN=function(z){ lz - length(z) SDF(z,method=lag window, window=taper(type=parzen,n.sample=lz,cutoff= 2*sqrt(lz)), npad=2*lz) } On Sun, Jan 29, 2012 at 11:29 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: It's customary to keep the list cc'd.

Re: [R] question about ... questions/ code

2012-01-29 Thread R. Michael Weylandt
It's standard form to cc the list so that replies and experience get pooled. This sounds like a problem with your data set to be honest. Can you post a link to it? If it's not publicly available, there's probably nothing that we (having no access to it) can do to help interpret. If you know the