Re: [R] Generating numbers with time-dependent upperbound

2013-12-02 Thread arun
Hi, May be this helps: m <- 0.01  T <- 90  t <- 0:T set.seed(42) res1 <- sapply(t,function(.t) runif(1,0,m*(T-.t))) #or  set.seed(42)  res2 <- runif(91,rep(0,91),m*(rep(T,91)-t)) identical(res1,res2) #[1] TRUE A.K. Hi, I need to generate a sequence that consists of random numbers. My first i

[R] What is the easiest way to interpolate vertical values on a square section of a nearly-planar 3D surface

2013-12-02 Thread Mercutio Florid
I want to map out a mostly flat area of land, 300 meters on a side.  I want to make (x,y,z) triples where x and y vary between -150 and 150 and there is just one z value. Eventually I will try to use graphics to actually draw this, but my first problem is that I need to get 90601 values by i

Re: [R] why change days of the week from a factor to an ordered factor?

2013-12-02 Thread Bill
Duncan, Thanks. Why doesn't coloursf2 <- factor(1:8, levels = 8:1) give an ordering when you do str(coloursf2) like "8"<"7"<"6" ... Bill On Mon, Dec 2, 2013 at 6:29 PM, Duncan Mackay wrote: > Hi Bill > > eg > > > colours = 1:8 > > coloursf = factor(1:8) > > colourso = ordered(1:8) > > str(

Re: [R] why change days of the week from a factor to an ordered factor?

2013-12-02 Thread Duncan Mackay
Hi Bill eg > colours = 1:8 > coloursf = factor(1:8) > colourso = ordered(1:8) > str(coloursf) Factor w/ 8 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 > str(colourso) Ord.factor w/ 8 levels "1"<"2"<"3"<"4"<..: 1 2 3 4 5 6 7 8 coloursf2 <- factor(1:8, levels = 8:1) str(coloursf2) Duncan Dunc

Re: [R] ifelse -does it "manage the indexing"?

2013-12-02 Thread Bill
Duncan, Your solution seems so much simpler. I was reading The Art of R Programming and it says the following: g=c("M","F","F","I","M","M","F", ifelse (g == "M", 1, ifelse (g == "F", 2, 3)) [1] 1 2 2 3 1 1 2 What actually happens in that nested ifelse () ? Let’s take a careful look. First, for

Re: [R] ifelse -does it "manage the indexing"?

2013-12-02 Thread Bill
Duncan, Your solution seems so much simpler. I was reading The Art of R Programming and it says the following: g=c("M","F","F","I","M","M","F", ifelse (g == "M", 1, ifelse (g == "F", 2, 3)) [1] 1 2 2 3 1 1 2 What actually happens in that nested ifelse () ? Let’s take a careful look. First, fo

Re: [R] Setting contrasts

2013-12-02 Thread Joshua Wiley
Hi David, You attach the dataset, which creates a copy of it. You set the contrasts on the copy, but in your models, you reference the dataset explicitly. You should set the contrasts directly in the data (and for your sake and your students, would encourage not using attach() ). contrasts(Eyse

[R] Setting contrasts

2013-12-02 Thread David C. Howell
I have been having trouble understanding the difference between "contrasts(Group) <- contr.sum" and options(contrasts = c("contr.sum","contr.poly"). They both seem to say that they have done what I want, but only the latter works. The reason why the question arises is tha,t using Fox's Anova,

[R] big matrix in r

2013-12-02 Thread krys22
i have a problem with big matix, in fact, after th matrix's creation many rows ans colomuns are invisble because the big dimension of the matix could you help me to get may complete matrix, have you any fonctions or any solution to resolve this problem -- View this message in context: http://

[R] Fwd: Intepreting lm() results with factor

2013-12-02 Thread David Gwenzi
Dear all I have observations done in 4 different classes and the between classes *variance* is too high that I decided to run a model without pooling the *variance*. I used the following code first : model<-lm(y~x+factor(class)) and got the following output: Coefficients:

Re: [R] ifelse -does it "manage the indexing"?

2013-12-02 Thread William Dunlap
> It seems so inefficient. But ifelse knows nothing about the expressions given as its second and third arguments -- it only sees their values after they are evaluated. Even if it could see the expressions, it would not be able to assume that f(x[i]) is the same as f(x)[i] or things like ifels

Re: [R] ifelse -does it "manage the indexing"?

2013-12-02 Thread Bill
Hi. Thanks. Which part? I looked at the below but I don't think it clearly addresses the nested ifelse situation. ifelse {base}R DocumentationConditional Element Selection Description ifelse returns a value with the same shape as test which is filled with elements selected from either yes or no

Re: [R] ifelse -does it "manage the indexing"?

2013-12-02 Thread Duncan Murdoch
On 13-12-02 7:49 PM, Bill wrote: It seems so inefficient. I mean the whole first vector will be evaluated. Then if the second if is run the whole vector will be evaluated again. Then if the next if is run the whole vector will be evaluted again. And so on. And this could be only to test the first

Re: [R] ifelse -does it "manage the indexing"?

2013-12-02 Thread Bill
It seems so inefficient. I mean the whole first vector will be evaluated. Then if the second if is run the whole vector will be evaluated again. Then if the next if is run the whole vector will be evaluted again. And so on. And this could be only to test the first element (if it is false for each i

Re: [R] ifelse -does it "manage the indexing"?

2013-12-02 Thread Duncan Murdoch
On 13-12-02 7:33 PM, Bill wrote: ifelse ((day_of_week == "Monday"),1, ifelse ((day_of_week == "Tuesday"),2, ifelse ((day_of_week == "Wednesday"),3, ifelse ((day_of_week == "Thursday"),4, ifelse ((day_of_week == "Friday"),5, ifelse ((day_of_week == "Saturday"),6,7))) In cod

[R] ifelse -does it "manage the indexing"?

2013-12-02 Thread Bill
ifelse ((day_of_week == "Monday"),1, ifelse ((day_of_week == "Tuesday"),2, ifelse ((day_of_week == "Wednesday"),3, ifelse ((day_of_week == "Thursday"),4, ifelse ((day_of_week == "Friday"),5, ifelse ((day_of_week == "Saturday"),6,7))) In code like the above, day_of_week is a vector

Re: [R] why change days of the week from a factor to an ordered factor?

2013-12-02 Thread Bill
Thanks to all, still a bit of a mystery. It is for the graphing I guess but not sure why. I don't think there is too much sense to saying that Tuesday precedes Wednesday but there could, as some of you suggest, be circumstances where this is useful. On Mon, Dec 2, 2013 at 12:00 PM, Bert Gunter w

Re: [R] names error message

2013-12-02 Thread William Dunlap
> I ran a job to combine 2 dataframes using rbind. > I received this error message that the names were not the same > Error in match.names(clabs,names(xi)): names do not match previous names The column names of the data.frames given to rbind must all be permutations of one another. E.g., > r

Re: [R] names error message

2013-12-02 Thread Sarah Goslee
Hi Julie, On Mon, Dec 2, 2013 at 3:38 PM, Julie Royster wrote: > Hello wise R folks, > > I ran a job to combine 2 dataframes using rbind. > I received this error message that the names were not the same > > Error in match.names(clabs,names(xi)): names do not match previous names > > BUT when I en

Re: [R] How to reconvert binary matrix back to original numeric?

2013-12-02 Thread arun
Hi, I couldn't reproduce the first part. Lines1 <- readLines(textConnection("2 5 7 11 1 2 5 5 7 10 12 13"))  Max1 <- max(as.numeric(unlist(strsplit(Lines1," " t(sapply(strsplit(Lines1," "), function(x) {x1<- as.numeric(x); x2 <- numeric(Max1); x2[x1]<- 1; x2})) #or mat1<- as.matrix(rea

Re: [R] How to reconvert binary matrix back to original numeric?

2013-12-02 Thread arun
Hi, I couldn't reproduce the first part. Lines1 <- readLines(textConnection("2 5 7 11 1 2 5 5 7 10 12 13"))  Max1 <- max(as.numeric(unlist(strsplit(Lines1," " t(sapply(strsplit(Lines1," "), function(x) {x1<- as.numeric(x); x2 <- numeric(Max1); x2[x1]<- 1; x2})) #or mat1<- as.matrix(read.ta

[R] names error message

2013-12-02 Thread Julie Royster
Hello wise R folks, I ran a job to combine 2 dataframes using rbind. I received this error message that the names were not the same Error in match.names(clabs,names(xi)): names do not match previous names BUT when I entered this statement Identical (names(data1[[1]]),names(data2[[2]]) ) R res

Re: [R] interpretation of MDS plot in random forest

2013-12-02 Thread mbressan
thanks andy it's a real honour form me to get a reply by you; I'm still a bit faraway from a proper grasp of the purpose of the plot... may I ask you for a more technical (trivial) issue? is it possible to add a legend in the MDS plot? my problem is to link the color points in the chart to the fa

Re: [R] plus/minus +/- in factor; not plotmath not expression

2013-12-02 Thread David Winsemius
On Dec 2, 2013, at 1:01 PM, Duncan Murdoch wrote: > On 02/12/2013 2:22 PM, Jacob Wegelin wrote: >> I want to put the "plus or minus" symbol into a character variable, so that >> this can be turned into a factor and be displayed in the "strip" of a >> faceted ggplot2 plot. >> >> A very nice sol

Re: [R] plus/minus +/- in factor; not plotmath not expression

2013-12-02 Thread David Winsemius
On Dec 2, 2013, at 11:22 AM, Jacob Wegelin wrote: > > I want to put the "plus or minus" symbol into a character variable, so that > this can be turned into a factor and be displayed in the "strip" of a faceted > ggplot2 plot. > > A very nice solution, thanks to Professor Ripley's post of Nov

Re: [R] plus/minus +/- in factor; not plotmath not expression

2013-12-02 Thread Duncan Murdoch
On 02/12/2013 2:22 PM, Jacob Wegelin wrote: I want to put the "plus or minus" symbol into a character variable, so that this can be turned into a factor and be displayed in the "strip" of a faceted ggplot2 plot. A very nice solution, thanks to Professor Ripley's post of Nov 16, 2008; 3:13pm, v

Re: [R] legend position

2013-12-02 Thread philippe massicotte
Thank you David, it is exactly what I needed. Regards,Phil > From: dcarl...@tamu.edu > To: pmassico...@hotmail.com; r-help@r-project.org > Subject: RE: [R] legend position > Date: Mon, 2 Dec 2013 14:29:06 -0600 > > It is not straightforward unless you want the legend in the > right or the bottom

Re: [R] legend position

2013-12-02 Thread David Carlson
It is not straightforward unless you want the legend in the right or the bottom margins. To put the legend inside the plot region it is simplest to use image() to plot the raster file and then image.plot(legend.only=TRUE) to add the legend. In addition to reading the help page for plot{raster}, you

Re: [R] XLConnect readWorksheet comma decimal sign

2013-12-02 Thread David Winsemius
On Dec 2, 2013, at 1:17 AM, Knut Krueger wrote: > Am 29.11.2013 20:39, schrieb David Winsemius: >>> Thats impossible, we are used to hit the comma >> I don't know what that means. > it is common here, that the decimal sign is commy Believe me, I _do_ understand that in Europe it is common to use

Re: [R] legend position

2013-12-02 Thread philippe massicotte
Thank you, I'll try to work with lattice. Regards,Phil > Date: Mon, 2 Dec 2013 12:06:50 -0800 > From: c...@witthoft.com > To: r-help@r-project.org > Subject: Re: [R] legend position > > It occurs to me that perhaps you're referring to the 'color bar' on the right > of the plot. AFAIK you cannot

Re: [R] legend position

2013-12-02 Thread Carl Witthoft
It occurs to me that perhaps you're referring to the 'color bar' on the right of the plot. AFAIK you cannot get at that from the raster::plot method. However lattice::levelplot does allow you to manipulate or remove that colorbar. -- View this message in context: http://r.789695.n4.nabble.

Re: [R] why change days of the week from a factor to an ordered factor?

2013-12-02 Thread Bert Gunter
Did you not see Mark Leeds's post? The OP apparently did not really mean R's "ordered factors" as produced by the R ordered() constructor; rather, he meant "factors with levels ordered differently than the default", for which Rich's answer was apropos. Mine -- and now yours -- in which we wrongly

Re: [R] legend position

2013-12-02 Thread philippe massicotte
Thank you for reply. If I'm not wrong, legend(...) will works for discrete elements. I'm not sure hot to use it for a colorbar legend sur as the one in the example bellow. Phil > Date: Mon, 2 Dec 2013 11:49:19 -0800 > From: c...@witthoft.com > To: r-help@r-project.org > Subject: Re: [R] legend po

Re: [R] why change days of the week from a factor to an ordered factor?

2013-12-02 Thread Robert Baer
On 12/2/2013 9:35 AM, Bert Gunter wrote: > Not true, Rich. The point about alphabetical ordering explains why the author likely explicitly set the levels for the factor, though. As to why ordered factors, we may never know, but one possible explanation is that at some point he was going to use

Re: [R] legend position

2013-12-02 Thread Carl Witthoft
See ?legend . you can add a legend directly to an existing plot. An example: legend('topright',c('hot','cold'),lty=1,col=c('red','green'),bg='white') Now if you're trying to place the legend outside the plot area (i.e. in some other part of the window), you'll need to invoke par(xpd=TRUE) . Se

Re: [R] Question about ifelse() XXXX

2013-12-02 Thread William Dunlap
What is the value of diag(c1) - 1 ? (Or, use digits=16 when printing c1.) Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of Dan Abner > Sent: Monday, December 02, 201

[R] plus/minus +/- in factor; not plotmath not expression

2013-12-02 Thread Jacob Wegelin
I want to put the "plus or minus" symbol into a character variable, so that this can be turned into a factor and be displayed in the "strip" of a faceted ggplot2 plot. A very nice solution, thanks to Professor Ripley's post of Nov 16, 2008; 3:13pm, visible at http://r.789695.n4.nabble.com/Sym

[R] legend position

2013-12-02 Thread philippe massicotte
Hi all. I'm ploting a raster and I can't find the proper way to move the legend. For example, r = raster(system.file("external/test.grd", package="raster"))plot(r) How can I put the legend at the desired position? Thank in advance,Phil [[alternative HT

Re: [R] generate multiple probability distributions

2013-12-02 Thread Michael Friendly
On 12/2/2013 10:12 AM, Duncan Murdoch wrote: dbinom can take vector inputs for the parameters, so this would be a bit simpler: x <- seq(0,12) x <- rep(x, 4) p <- rep(c(1/6, 1/3, 1/2, 2/3), each=13) bin.df <- data.frame(x, prob = dbinom(x, 12, p), p) Thanks, Duncan What I was missing was how

Re: [R] Question about ifelse() XXXX

2013-12-02 Thread Duncan Murdoch
On 02/12/2013 2:08 PM, Dan Abner wrote: Hi all, Can anyone explain what is happening with element 4,4 of c1? ifelse() is not recongizing it as value 1: FAQ 7.31. Duncan Murdoch > c1 q1q2q3q4 q1 1.000 0.6668711 0.6948419 0.5758860 q2 0.6668711 1.

[R] Question about ifelse() XXXX

2013-12-02 Thread Dan Abner
Hi all, Can anyone explain what is happening with element 4,4 of c1? ifelse() is not recongizing it as value 1: > c1 q1q2q3q4 q1 1.000 0.6668711 0.6948419 0.5758860 q2 0.6668711 1.000 0.6040746 0.4917447 q3 0.6948419 0.6040746 1.000 0.4730732 q4 0.57

Re: [R] Days to solstice calculation

2013-12-02 Thread White, William Patrick
Thank you. I can't believe I didn't notice that. What a relief. From: David Carlson Sent: Monday, December 2, 2013 1:47 PM To: White, William Patrick; 'Pascal Oettli' Cc: 'r-help@R-project.org' Subject: RE: [R] Days to solstice calculation They are a day a

Re: [R] Days to solstice calculation

2013-12-02 Thread David Carlson
They are a day apart. Summer solstice is day 172 in both cases so the calendar dates should be one day apart and they are (June 22 in 2007 and June 21 in 2008): > strptime("2007-06-22", format="%Y-%m-%d")$yday [1] 172 > strptime("2008-06-21", format="%Y-%m-%d")$yday [1] 172 Your Daylength() funct

Re: [R] vcf, plink and other files in the /demo of a package

2013-12-02 Thread Duncan Murdoch
On 02/12/2013 11:59 AM, Federico Calboli wrote: Hi All, together with colleagues we are planning to submit a 2.0 version of a package we have on CRAN. Because the package deals with high throughput genomic data we though it would be nice to have some sort of guidance for the users. This sho

Re: [R] interpretation of MDS plot in random forest

2013-12-02 Thread Liaw, Andy
Yes, that's part of the intention anyway. One can also use them to do clustering. Best, Andy -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Massimo Bressan Sent: Monday, December 02, 2013 6:34 AM To: r-help@r-project.org Subject

Re: [R] why change days of the week from a factor to an ordered factor?

2013-12-02 Thread Richard M. Heiberger
Bert, the issue is the sort order of the levels. Time series graphs in the alphabetical sort order will be uninterpretable. I show the three sets of contrasts for factors, factors with specified levels, and ordered factors. week <- c("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","

Re: [R] why change days of the week from a factor to an ordered factor?

2013-12-02 Thread peter dalgaard
On 02 Dec 2013, at 16:35 , Bert Gunter wrote: > Not true, Rich. > >> z <-factor(letters[1:3],lev=letters[3:1]) >> sort(z) > [1] c b a > Levels: c b a > > What you say is true only for the **default** sort order. > > (Although maybe the code author didn't realize this either) The coding is ce

[R] vcf, plink and other files in the /demo of a package

2013-12-02 Thread Federico Calboli
Hi All, together with colleagues we are planning to submit a 2.0 version of a package we have on CRAN. Because the package deals with high throughput genomic data we though it would be nice to have some sort of guidance for the users. This should ideally mean a 'vignette', but as the time of

Re: [R] How do I extract Random Forest Terms and Probabilities?

2013-12-02 Thread Liaw, Andy
#2 can be done simply with predict(fmi, type="prob"). See the help page for predict.randomForest(). Best, Andy -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of arun Sent: Tuesday, November 26, 2013 6:57 PM To: R help Subject: Re:

Re: [R] Days to solstice calculation

2013-12-02 Thread White, William Patrick
Thank you for your response. I looked at the insol package and it does seem to contain a daylength function, but it would be more informative and aid in my growth as an R user to trace the source of the current problem rather than use a package as a work around. Understanding that an alternate

[R] ordered factor question

2013-12-02 Thread Mark Leeds
Hi: I asked Bert privately and he recommended posting what I asked/said to him to the list. My comment/question was that I looked at the code and didn't actually see an ordered factor being created. So my guess is that there is a confusion with the use of the term "ordered". I'm not clear on wheth

Re: [R] generate multiple probability distributions

2013-12-02 Thread David Carlson
You can use recycling to simplify things: > set.seed(42) > x <- seq(0,12) > bin.df <- as.data.frame( + rbind( cbind(x, prob=dbinom(x,12,1/6), p=1/6), +cbind(x, prob=dbinom(x,12,1/3), p=1/3), +cbind(x, prob=dbinom(x,12,1/2), p=1/2), +cbind(x, prob=dbinom(x,12

Re: [R] why change days of the week from a factor to an ordered factor?

2013-12-02 Thread Bert Gunter
Not true, Rich. > z <-factor(letters[1:3],lev=letters[3:1]) > sort(z) [1] c b a Levels: c b a What you say is true only for the **default** sort order. (Although maybe the code author didn't realize this either) -- Bert On Mon, Dec 2, 2013 at 7:24 AM, Richard M. Heiberger wrote: > If days of

Re: [R] why change days of the week from a factor to an ordered factor?

2013-12-02 Thread Richard M. Heiberger
If days of the week is not an Ordered Factor, then it will be sorted alphabetically. Fr Mo Sa Su Th Tu We Rich On Mon, Dec 2, 2013 at 6:24 AM, Bill wrote: > I am reading the code below. It acts on a csv file called dodgers.csv with > the following variables. > > >> print(str(dodgers)) # check t

Re: [R] why change days of the week from a factor to an ordered factor?

2013-12-02 Thread Bert Gunter
"BIll" : (Sorry -- Doubt that this will be helpful, but I couln't resist) "I don't understand why the author of the code decided to make the factor days_of_week into an ordered factor. Anyone know why this should be done?" A definitive answer would require either psychic abilities or asking the

Re: [R] generate multiple probability distributions

2013-12-02 Thread Duncan Murdoch
On 02/12/2013 9:47 AM, Michael Friendly wrote: I want to generate a collection of probability distributions in a data frame, with varying parameters. There must be some simpler way than what I have below (avoiding rbind and cbind), but I can't quite see it. x <- seq(0,12) bin.df <- as.data.fram

[R] generate multiple probability distributions

2013-12-02 Thread Michael Friendly
I want to generate a collection of probability distributions in a data frame, with varying parameters. There must be some simpler way than what I have below (avoiding rbind and cbind), but I can't quite see it. x <- seq(0,12) bin.df <- as.data.frame( rbind( cbind(x, prob=dbinom(x,12,1/6), p

[R] interpretation of MDS plot in random forest

2013-12-02 Thread Massimo Bressan
Given this general example: set.seed(1) data(iris) iris.rf <- randomForest(Species ~ ., iris, proximity=TRUE, keep.forest=TRUE) #varImpPlot(iris.rf) #varUsed(iris.rf) MDSplot(iris.rf, iris$Species) I’ve been reading the documentation about random forest (at best of my - poor - knowledge) b

[R] why change days of the week from a factor to an ordered factor?

2013-12-02 Thread Bill
I am reading the code below. It acts on a csv file called dodgers.csv with the following variables. > print(str(dodgers)) # check the structure of the data frame 'data.frame': 81 obs. of 12 variables: $ month : Factor w/ 7 levels "APR","AUG","JUL",..: 1 1 1 1 1 1 1 1 1 1 ... $ day

[R] Confidence interval, multiple imputation

2013-12-02 Thread Mª Teresa Martinez Soriano
Hi to everyone, I have a big data set where rows are observations and columns are variables. It contains a lot of missing values. I have used multiple imputation with library mice and I get an “exact” prediction of each missing value. Now, I would like to know the error I can commit or the confid

Re: [R] XLConnect readWorksheet comma decimal sign

2013-12-02 Thread Knut Krueger
Am 29.11.2013 20:39, schrieb David Winsemius: Thats impossible, we are used to hit the comma I don't know what that means. it is common here, that the decimal sign is commy All computer in the cip-pools are using the "comma" ( an I think 99.9% of all other computers here) Can you imagine what