[R] how to introduce missing data for complete data

2013-11-10 Thread dila radi
Hi, Im new R users. In my research I use rainfall data and Im interested in estimating missing data. I would like to use Normal Ratio Method to estimate missing data. My problem is, how do I introduce missing data randomly within my complete set of data? Stn ID Year Mth Day Amount 4860

Re: [R] decode and annotate

2013-11-10 Thread Jeff Newmiller
This is not a homework assistance forum. You really need to use the resources provided by your educational institution for that. Please read the Posting Guide, and note for future reference that HTML email distorts your R code so it is not appropriate on this list. As regards your question, you

[R] decode and annotate

2013-11-10 Thread Agony
Dear all, Could anyone help me annotate and decode the below codes? Many thanks in advance. Best, coverage.col <- rep(0, length(mean)) coverage.col[coverage=="a"] <-  rainbow(50)[30] coverage.col[coverage=="b"] <-  rainbow(50)[15] coverage.col[coverage=="c"] <- rainbow(50)[8] coverage.col[cove

Re: [R] Colour Legend text, in a print color2D.matplot

2013-11-10 Thread Alaios
Thanks! It worked. Regards Alex On Monday, November 11, 2013 12:02 AM, Jim Lemon wrote: On 11/11/2013 04:57 AM, Alaios wrote: > Hi all, > > I am plotting very nice looking mattrices with  plotrin... > > so far so good, I would like though to ask you if it would be possible to add > at t

Re: [R] Tables Package Ampersand Quoting

2013-11-10 Thread Duncan Murdoch
On 13-11-10 1:16 PM, Jeff Newmiller wrote: There seems to be some inappropriate quoting in the tabular function from the tables package. Consider this example: This turned out to be different than I thought at first. It was simply that I mis-used the latexTranslate function from the Hmisc pac

Re: [R] Tables Package Ampersand Quoting

2013-11-10 Thread Duncan Murdoch
On 13-11-10 1:16 PM, Jeff Newmiller wrote:> There seems to be some inappropriate quoting in the tabular function from > the tables package. Consider this example: > > library(tables) > sampledf <- data.frame( Manufacturer=c(rep("Joe & Co.",6) > ,rep("\\tabu

[R] Nadaraya-Watson kernel estimation 2

2013-11-10 Thread Ms khulood aljehani
Hello I've written previously about my problem with the Nadaraya-Watson kernel estimator this is a copy of my message --- Hello i want to compute the Nadaraya-Watson kernel estim

Re: [R] Colour Legend text, in a print color2D.matplot

2013-11-10 Thread Jim Lemon
On 11/11/2013 04:57 AM, Alaios wrote: Hi all, I am plotting very nice looking mattrices with plotrin... so far so good, I would like though to ask you if it would be possible to add at the bottom of the color.legend (this lovely color bar that maps colors to numbers). Would that be possible

Re: [R] Custom Numeric type in R

2013-11-10 Thread Duncan Murdoch
On 13-11-10 4:52 PM, Rui Barradas wrote: Hello, Try the following. > class(NA) [1] "logical" This doesn't actually prove anything, since there are multiple different objects that display as NA. For example: > 1+NA [1] NA > class(1+NA) [1] "numeric" See ?"NA" for other ways to represent

Re: [R] Custom Numeric type in R

2013-11-10 Thread Rui Barradas
Hello, Try the following. > class(NA) [1] "logical" > class(NaN) [1] "numeric" > class(Inf) [1] "numeric" So my guess is that what the op wants is not possible. And that to declare a new class shouldn't solve the problem. Rui Barradas Em 10-11-2013 21:07, Bert Gunter escreveu: Charles: T

Re: [R] Using Unicode inside R's expression() command

2013-11-10 Thread David Winsemius
On Nov 9, 2013, at 11:01 AM, Sverre Stausland wrote: > I'm using 'expression()' in R plots in order to get italicized text. > But it appears as if I cannot use Unicode symbols inside 'expression' > outside of ASCII characters. Is there some way I can work around this? > My goal is to get the 'fi'

Re: [R] Custom Numeric type in R

2013-11-10 Thread Bert Gunter
Charles: That was my initial thought, too. But then I wondered whether what was meant was to use "TBD" as an alternative kind of numeric value that would be part of numeric vectors, lists, etc. in the same way that NA or Inf is. It is not clear to me that a new object class provides a way to do t

Re: [R] Custom Numeric type in R

2013-11-10 Thread Charles Berry
Christofer Bogaso gmail.com> writes: > > Hi again, > > In R, there are various numerics like, NA, Inf, or simple integers etc. > However I want to include one custom type: "TBD", which R should treat as > numeric, not character. > > That "TBD" should have same property like Inf, however except

Re: [R] S4; Setter function is not chaning slot value as expected

2013-11-10 Thread daniel schnaider
It is excellent. thanks! On Sun, Nov 10, 2013 at 12:49 PM, Martin Morgan wrote: > On 11/09/2013 11:31 PM, Hadley Wickham wrote: > >> Modelling a mutable entity, i.e. an account, is really a perfect >> example of when to use reference classes. You might find the examples >> on http://adv-r.had.

[R] Mark each group centroid in a linear discriminant analysis plot

2013-11-10 Thread ashz
Hi, How can I calculate and mark each group centroid in a linear discriminant analysis plot (using ggplot2)? Script: ## originate from http://r.789695.n4.nabble.com/LDA-and-confidence-ellipse-td4671308.html require(MASS) require(ggplot2) iris.lda<-lda(Species ~ Sepal.Length + Sepal.Width + Peta

[R] Set system font in R package Cairo in Mac OS X

2013-11-10 Thread Sverre Stausland
Because of the issue raised in https://stat.ethz.ch/pipermail/r-help/2013-November/362896.html, I am switching to R on Mac OS X (10.6.8) to create some plots. Using CairoPDF(), however, the commands I use in Windows (7) to select my fonts don't have any effect on Mac OS X, where the output .pdf fil

[R] Plotrix: Add text below the color- legend.

2013-11-10 Thread Alaios
Hi all, I am plotting very nice and sexy images with plotrix :) so far so good, I would like though to ask you if it would be possible to add at the bottom of the color.legend (this lovely color bar that maps colors to numbers). Would that be possible to do that? I would like to thank you in adv

Re: [R] S4; Setter function is not chaning slot value as expected

2013-11-10 Thread daniel schnaider
Thanks Martin. It worked well. Two new questions related to the same subject. 1) Why create this semantic of a final argument name specifically names value? 2) Regarding performance. When CustomerID(ac) <- "54321" runs, does it only change the slot from whatever it was to 54321, or it really creat

Re: [R] union of list objects if objects intersect

2013-11-10 Thread Hermann Norpois
I guess I found a solution though it is not very elegant. Hermann snp.block <- function (huz) { for (i in names (huz)) { chain1 <- huz[[i]] for (k in names (huz)) { chain2 <- huz[[k]]

[R] Earth (MARS) package with categorical predictors

2013-11-10 Thread Chris Wilkinson
It appears to be legitimate to include multi-level categorical and continuous variables in defining the model for earth (e.g. y ~ cat + cont1 + cont2) but is it also then possible use categoricals in the predict method using the earth result? Chris _

Re: [R] union of list objects if objects intersect

2013-11-10 Thread Hermann Norpois
My purpose is to create chains of list objects if elements of the object overlap. If there is no overlap the object remains as it is. My plan is to identify snps that are in ld. The letters in each list object represent snps that are in ld in respect to the first snp (or letter). The first snp (or

Re: [R] Cross Tabulation

2013-11-10 Thread David Carlson
The simplest would be to create a variable combining region and district: > data$region_district <- with(data, paste(region, district)) > prop.table(xtabs(~region_district+response, data), 1) response region_district no yes A d 0.5 0.5 A e 0.0 1.0

[R] Tables Package Ampersand Quoting

2013-11-10 Thread Jeff Newmiller
There seems to be some inappropriate quoting in the tabular function from the tables package. Consider this example: library(tables) sampledf <- data.frame( Manufacturer=c(rep("Joe & Co.",6) ,rep("\\tabular, Inc.",4)) , Tool=rep(c("Shov

[R] Colour Legend text, in a print color2D.matplot

2013-11-10 Thread Alaios
Hi all, I am plotting very nice looking mattrices with  plotrin... so far so good, I would like though to ask you if it would be possible to add at the bottom of the color.legend (this lovely color bar that maps colors to numbers). Would that be possible to do that? I would like to thank you i

Re: [R] union of list objects if objects intersect

2013-11-10 Thread Bert Gunter
I'll leave it to others to muddle through your code. It appears to refer to an earlier post that you did not include. Note also that you still have not specified what you want to get from your example ja list. Doing so might help you get a useful response, which mine clearly is not. Cheers, Bert

Re: [R] union of list objects if objects intersect

2013-11-10 Thread Bert Gunter
Your specification is a unclear (to me anyway): What do you want to return if the intersection is empty? What if intersect(ja[[i]], ja[[i+1]]) is empty for all i? What if length(intersect( ja[[i]], ja[[i+1]] )) ==0 but intersect(ja[[i]],ja[[i+2]]) is nonempty? Your example isn't -- you did not sp

Re: [R] S4; Setter function is not chaning slot value as expected

2013-11-10 Thread Martin Morgan
On 11/09/2013 11:31 PM, Hadley Wickham wrote: Modelling a mutable entity, i.e. an account, is really a perfect example of when to use reference classes. You might find the examples on http://adv-r.had.co.nz/OO-essentials.html give you a better feel for the strengths and weaknesses of R's differe

Re: [R] S4; Setter function is not chaning slot value as expected

2013-11-10 Thread Martin Morgan
On 11/10/2013 03:54 AM, daniel schnaider wrote: Thanks Martin. It worked well. Two new questions related to the same subject. 1) Why create this semantic of a final argument name specifically names value? I do not know. It is a requirement of replacement methods in R in general, not just S4 m

Re: [R] Cross Tabulation

2013-11-10 Thread Peter Maclean
#Would like to create a cross-table (Region, district, response) and #(Region, district, cost. The flat table function does not look so good region <- c("A","A","A","A","B","B", "B", "B", "C","C", "C", "C") district <- c("d","d","e","e","f","f", "g", "g", "h","h", "i", "j") response <- c("ye

Re: [R] finding a min against an id in a column

2013-11-10 Thread arun
Hi, Try:  df <- data.frame(ID=c("ID1","ID1","ID2","ID3","ID1","ID2"), date=c("Mar03","Mar01","Mar05","Mar02","Mar02","Mar01"),stringsAsFactors=FALSE)  #as.Date(paste0(1,df[,2]),"%d%b%y") #assuming that year represents the digits #as.Date(paste0(2001,df[,2]),"%Y%b%d")# if the digits represent day

Re: [R] making chains from pairs

2013-11-10 Thread arun
Hi, May be this helps.  But, the conditions are not very clear. lst1 <- lapply(split(test,test$V1),function(x) unique(as.vector(t(x indx <- unlist(lapply(lst1,function(x) which(names(lst1) %in% x))) lst2 <- split(gsub("\\d+","",names(indx)),indx) indx1 <- duplicated(lapply(lst2,`[`,1))|!(dup