Re: [R] Matrix summary

2016-02-12 Thread Bert Gunter
Yes, but colMeans, rowMeans, pmax, pmin , etc. are *much* faster. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Fri, Feb 12, 2016 at 9:15 PM, J

Re: [R] Matrix summary

2016-02-12 Thread Jim Lemon
Hi Ashta, Surely you are aware of the "apply" family of functions that return the numbers you want: ashmat<-matrix(c(117,12,13,21,21,32,11,1,65,43,23,7,58,61,78,95 ), nrow=4,byrow=TRUE) apply(ashmat,2,mean) [1] 65.25 37.00 31.25 31.00 apply(ashmat,1,which.max) [1] 1 2 1 4 Jim On Sat, Feb 13, 2

[R] Matrix summary

2016-02-12 Thread Ashta
hi all, I have a square matrix (1000 by 1000), 1. I want calculate mean, min and max values for each column and row. 2, I want pick the coordinate value of the matrix that has the max and min value for each row and column. This an example 4 by 4 square matrix

Re: [R] why is 9 after 10?

2016-02-12 Thread peter dalgaard
It can also happen if you use colClasses, since that applies as.factor to the input column without first converting it to numeric. To wit: > read.table(text=" + 9 + 10", colClasses="factor")$V1 [1] 9 10 Levels: 10 9 -pd > On 12 Feb 2016, at 22:43 , Jim Lemon wrote: > > It depends upon what g

Re: [R] why is 9 after 10?

2016-02-12 Thread Jim Lemon
It depends upon what goes into the "data reshaping pipeline". If there is a single non-numeric value in the data read in, it will alpha sort it upon conversion to a factor: x<-factor(c(sample(6:37,1000,TRUE)," ")) z<-factor(x) levels(z) [1] " " "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "

Re: [R] Separating point symbols and line types in a legend.

2016-02-12 Thread Rolf Turner
Thanks Greg. Worked perfectly!!! cheers, Rolf On 13/02/16 09:22, Greg Snow wrote: One option is to call `legend` twice and do some manual positioning. This worked for me: plot(1:10) legend('topleft', lty=1:3, bty="n", legend=c('','','') ) legend('topleft', pch=c(20,8,1), bty="n", legend=c('

Re: [R] Why two curves and numerical integration look so different?

2016-02-12 Thread peter dalgaard
> On 12 Feb 2016, at 17:44 , C W wrote: > > On a side note, is it ok to do? > > > which(max(p_x)) > and use that instead of numerical integration to get E[X]? Now THAT makes absolutely no sense. max() is a number, so which(max()) usually returns 1. If you mean whether the mode is equal to t

Re: [R] Separating point symbols and line types in a legend.

2016-02-12 Thread Greg Snow
One option is to call `legend` twice and do some manual positioning. This worked for me: plot(1:10) legend('topleft', lty=1:3, bty="n", legend=c('','','') ) legend('topleft', pch=c(20,8,1), bty="n", legend=c('clyde','irving','melvin'), inset=c(0.1,0)) You may need to fiddle with the amount of ins

[R] lapply on list of lists

2016-02-12 Thread Stefano Sofia
Dear R list users, I have three lists of data frames, respectively temp_list, wind_list and snow_list. The elements of these three lists are temp_list$station1, temp_list$station2 and temp_list$station3 with columns date and temp; wind_list$station1, wind_list$station2 and wind_list$station3 wit

Re: [R] confirm family==binomial and link==logistic

2016-02-12 Thread Bert Gunter
Not an answer But note that your several stopifnot() statements can be combined into 1. See ?stopifnot . Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic

Re: [R] confirm family==binomial and link==logistic

2016-02-12 Thread Marc Schwartz
> On Feb 12, 2016, at 10:33 AM, Jacob Wegelin wrote: > > To check that a regression object comes from logistic regression, I employ > the following two lines: > > stopifnot(glmObject$family$family=="binomial") > > stopifnot(glmObject$family$link=="logit") > > For instance: > > t

Re: [R] Help with truncated normal distribution

2016-02-12 Thread Bert Gunter
Define "truncated." (It is often confused with "censored".) As stated, it seems to me that you already have the answer. Do you have data? -- i.e. what do you mean by "parameters" ? Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking thin

Re: [R] Why two curves and numerical integration look so different?

2016-02-12 Thread C W
On a side note, is it ok to do? > which(max(p_x)) and use that instead of numerical integration to get E[X]? I will try both and report back! Thank you expeRts On Fri, Feb 12, 2016 at 11:29 AM, C W wrote: > Hi Peter, > > Great, let me try that and get back to you on my findings in a few hours

Re: [R] Help with the Twitter Analysis

2016-02-12 Thread Boris Steipe
Since this is due to a throttle in Twitter's API, I would assume that attempts to bypass this will violate Twitter's TOS. You'll either have to purchase the data you need, or build your own in-house data set, going forward. B. On Feb 12, 2016, at 8:18 AM, SHIVI BHATIA wrote: > Dear Team, >

[R] confirm family==binomial and link==logistic

2016-02-12 Thread Jacob Wegelin
To check that a regression object comes from logistic regression, I employ the following two lines: stopifnot(glmObject$family$family=="binomial") stopifnot(glmObject$family$link=="logit") For instance: toyfunction<-function(glmObject) { stopifnot(inherits(glmObject, "

Re: [R] Why two curves and numerical integration look so different?

2016-02-12 Thread C W
Hi Peter, Great, let me try that and get back to you on my findings in a few hours! :) On Fri, Feb 12, 2016 at 11:09 AM, peter dalgaard wrote: > I don't see here FAQ 7.31 comes in either (for once!...) > > However, either the density is unnormalized and the integral is not 1, or > the integral

[R] Help with the Twitter Analysis

2016-02-12 Thread SHIVI BHATIA
Dear Team, Kindly refer to the error below while generating a Twitter Analysis for my firm: # Warning message: # In doRppAPICall("search/tweets", n, params = params, retryOnRateLimit = retryOnRateLimit, : As I checked on forums such as StackOverflow and other r related literature it

[R] Help with truncated normal distribution

2016-02-12 Thread Pamela Foggia
Hello, Do you know how to obtain the parameters of a theoretical normal distribution knowing the parameters of the same truncated normal distribution? Is there in R any function that can do it? Thanks in advance [[alternative HTML version deleted]] ___

Re: [R] Why two curves and numerical integration look so different?

2016-02-12 Thread peter dalgaard
I don't see here FAQ 7.31 comes in either (for once!...) However, either the density is unnormalized and the integral is not 1, or the integral is 1 and it is normalized. The one in the picture clearly does not integrate to one. You can fit a rectangle of size 0.1 by 1e191 under the curve so th

Re: [R] Why two curves and numerical integration look so different?

2016-02-12 Thread C W
Hi Bert, Yay fantasyland! In all seriousness, You are referring to this? https://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f In particular, you mean this: .Machine$double.eps ^ 0.5? Thanks! On Fri, Feb 12, 2016 at 10:53 AM, Bert Gunter wrote: >

Re: [R] Why two curves and numerical integration look so different?

2016-02-12 Thread Bert Gunter
You are working in fantasyland. Your density is nonsense. Please see FAQ 7.31 for links to computer precision of numeric calculations. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in

Re: [R] why is 9 after 10?

2016-02-12 Thread Fox, John
Dear Federico, > -Original Message- > From: Federico Calboli [mailto:federico.calb...@helsinki.fi] > Sent: February 12, 2016 10:27 AM > To: Fox, John > Cc: R Help > Subject: Re: [R] why is 9 after 10? > > Dear John, > > that is fortunatey not the case, I just managed to figure out that

Re: [R] Why two curves and numerical integration look so different?

2016-02-12 Thread C W
Hi David, This is the Gaussian looking distribution I am trying to integrate. https://drive.google.com/file/d/0B2xN0-A6iTB4NThIZ2tYdGxHc00/view?usp=sharing Notice the unnormalized density goes up as high as 2.5*101^191. I tried to create small intervals like > seq(0.5, 1.3, by = 10^(-8)) but th

Re: [R] why is 9 after 10?

2016-02-12 Thread Federico Calboli
Dear John, that is fortunatey not the case, I just managed to figure out that the problem was that in the data reshaping pipeline the numeric column was transformed into a factor. Many thanks for your time. BW F > On 12 Feb 2016, at 17:22, Fox, John wrote: > > Dear Federico, > > Might m

Re: [R] why is 9 after 10?

2016-02-12 Thread Fox, John
Dear Federico, Might my.data[, 2] contain character data, which therefore would be sorted in this manner? For example: > x <- sample(6:37, 1000, replace=TRUE) > table(x) x 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 29 30 35 29 41 33 27 21 38

[R] why is 9 after 10?

2016-02-12 Thread Federico Calboli
Hi All, I have some data, one of the columns is a bunch of numbers from 6 to 41. table(my.data[,2]) returns 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 1761 1782 1897 1749 1907 1797 1734 1810 1913

Re: [R] MonteCarlo sampling on profile log likelihood - package extRemes

2016-02-12 Thread Jue Lin-Ye
> > ​​ > Date: Wed, 10 Feb 2016 15:19:21 + > From: Lila Collet > To: r-help@R-project.org > Subject: [R] MonteCarlo sampling on profile log likelihood - package > extRemes > > > Hi > > > I am using the package extRemes to assess 100-year return period > runoffs with the GEV and GP dist