[R] Using different function (parameters) with apply

2013-04-17 Thread Sachinthaka Abeywardana
Hi All, I have the following problem (read the commented bit below): a<-matrix(1:9,nrow=3) a [,1] [,2] [,3] [1,]147 [2,]258 [3,]369 div<-1:3 apply(a,2,function(x)x/div) ##want to divide each column by div- instead each row is divided## [,1] [,

Re: [R] t-statistic for independent samples

2013-04-17 Thread Thomas Lumley
I just looked more carefully at your code. You are computing the unequal-variance (Welch) version of the t-test, so that's why there isn't a problem. Compare it with the equal-variance t-test, using the pooled variance estimate, which does have a problem, as below -thomas tstat4 <- function

[R] Memory usage reported by gc() differs from 'top'

2013-04-17 Thread Christian Brechbühler
In help(gc) I read, "...the primary purpose of calling 'gc' is for the report on memory usage". What memory usage does gc() report? And more importantly, which memory uses does it NOT report? Because I see one answer from gc(): used (Mb) gc trigger (Mb) max used (Mb) Ncells 148759

Re: [R] Understanding why a GAM can't suppress an intercept

2013-04-17 Thread Andrew Crane-Droesch
Simon, Many thanks as always for your help. I see and appreciate the example that you cited, but I'm having a hard time generalizing it to a multivariate case. A bit about my context -- my dataset is response ratios; the log of a treatment over a control. One of my explanatory variables is t

Re: [R] t-statistic for independent samples

2013-04-17 Thread David Arnold
OK,although the variance ratio was already 2.25 to 1, tried sigma1=10, sigma2=25, which makes the ratios of the variances 6.25 to 1. Still no change. See: http://msemac.redwoods.edu/~darnold/math15/R/chapter11/DistributionForTwoIndependentSamplesPartII.html D. -- View this message in context

Re: [R] t-statistic for independent samples

2013-04-17 Thread Jay Kerns
Dear David, On Wed, Apr 17, 2013 at 6:24 PM, David Arnold wrote: > Hi, [snip] > > D. Before posting to StackExchange, check out the Wikipedia entry for "Behrens-Fisher problem". Cheers, Jay -- G. Jay Kerns, Ph.D. Youngstown State University http://people.ysu.edu/~gkerns/ _

Re: [R] t-statistic for independent samples

2013-04-17 Thread Kevin E. Thorpe
On 04/17/2013 06:24 PM, David Arnold wrote: Hi, Typical things you read when new to stats are cautions about using a t-statistic when comparing independent samples. You are steered toward a pooled test or welch's approximation of the degrees of freedom in order to make the distribution a t-dist

[R] t-statistic for independent samples

2013-04-17 Thread David Arnold
Hi, Typical things you read when new to stats are cautions about using a t-statistic when comparing independent samples. You are steered toward a pooled test or welch's approximation of the degrees of freedom in order to make the distribution a t-distribution. However, most texts give no informati

[R] Multi-core processing in glmulti

2013-04-17 Thread M.-O. Adams
Dear list, I am trying to do an automated model selection of a glmm (function glmer; package: lme4) containing a large number of predictors. As far as i understand, glmulti is able to devide the process into chuncks and proceed by parallel processing on on multiple cores. Unfortunately this does n

[R] Full Information Maximum Likelihood estimation method for multivariate sample selection problem

2013-04-17 Thread Champak Ishram
Dear R experts/ users Full Information Maximum Likelihood (FIML) estimation approach is considered robust over Seemingly Unrelated Regression (SUR) approach for analysing data of multivariate sample selection problem. The zero cases in my dependent variables are resulted from three sources: Irreve

Re: [R] Best way to calculate averages of Blocks in an matrix?

2013-04-17 Thread arun
 tapply(t(data.matrix(sim_sub)),rep( rep(1:4, each=5), each=10),mean)    #  1  2  3  4 #0.0086 0.0074 0.0082 0.0108 unlist(lapply(split(sim_sub,((seq_len(nrow(sim_sub))-1)%/%5)+1),function(x) mean(unlist(x #    1  2  3  4 #0.0086 0.0074 0.0082 0.0108 A.K.

Re: [R] Best way to calculate averages of Blocks in an matrix?

2013-04-17 Thread David Winsemius
On Apr 17, 2013, at 9:54 AM, Keith S Weintraub wrote: > Folks, > I recently was given a simulated data set like the following subset: > > sim_sub<-structure(list(V11 = c(0.01, 0, 0, 0.01, 0, 0.01, 0, 0, 0, 0, > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), V12 = c(0, 0, 0, 0.01, 0.03, 0, > 0, 0, 0, 0, 0, 0.

Re: [R] use of names() within lapply()

2013-04-17 Thread Duncan Murdoch
On 17/04/2013 11:33 AM, Ivan Alves wrote: Dear Duncan and A.K. Many thanks for your super quick help. The modified lapply did the trick, mapply died with a error "Error in dots[[2L]][[1L]] : object of type 'builtin' is not subsettable". That's due to a typo: I should have said mapply(plot,

Re: [R] Unsubscribe please

2013-04-17 Thread David Winsemius
On Apr 16, 2013, at 11:02 PM, Pascal Oettli wrote: > Hello, > > Don't reply only to me. > > 1) Filter the unwanted mails, There is also an option to get Rhelp postings in digest-format. -- David. > 2) It takes few days to unsubscribe you. > > Regards, > Pascal > > > On 04/17/2013 02:59 P

[R] simulation\bootstrap of list factors

2013-04-17 Thread Berg, Tobias van den
Dear R experts, I am trying to simulate a list containing data matrices. Unfortunately, I don't manage to get it to work. A small example: n=5 nbootstrap=2 subsets<-list() for (i in 1:n){ subsets[[i]] <- rnorm(5, mean=80, sd=1) for (j in 1:nbootstrap){ test<-list()

Re: [R] proper way to handle obsolete function names

2013-04-17 Thread Peter Langfelder
On Wed, Apr 17, 2013 at 10:36 AM, R. Michael Weylandt > > It sounds like you want .Deprecate > > ?.Deprecate > Perhaps you meant Deprecated? ?Deprecated Best, Peter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PL

Re: [R] mgcv: how select significant predictor vars when using gam(...select=TRUE) using automatic optimization

2013-04-17 Thread Simon Wood
Jan, What mgcv version are you using, please? (Older versions have a poor p-value approximation when select=TRUE, but of course it's possible that you've managed to break the newer approximation as well) The 'select=TRUE' option adds a penalty to each smooth, to allow it to be penalized out

Re: [R] proper way to handle obsolete function names

2013-04-17 Thread R. Michael Weylandt
On Apr 17, 2013, at 10:17 AM, Jannis wrote: > Dear R community, > > > what would be the proper R way to handle obsolete function names? I have > created several packages with functions and sometimes would like to change > the name of a function but would like to create a mechanism that othe

Re: [R] Merge

2013-04-17 Thread arun
No, you don't have to use four dots. Please check these links for further details: http://stackoverflow.com/questions/5890576/usage-of-three-dots-or-dot-dot-dot-in-functions http://cran.r-project.org/doc/manuals/R-lang.pdf A.K. From: Janesh Devkota To: arun

Re: [R] Merge

2013-04-17 Thread Janesh Devkota
Hello Arun, Thank you so much for the prompt reply. I have one simple question here. DOes three dots (...) in the reduce function means we are applying for three dataframes here ? So, if we were to combine four would that dots be four dots ? Thanks. On Wed, Apr 17, 2013 at 12:16 PM, arun wrote

[R] mgcv: how select significant predictor vars when using gam(...select=TRUE) using automatic optimization

2013-04-17 Thread Jan Holstein
I have 11 possible predictor variables and use them to model quite a few target variables. In search for a consistent manner and possibly non-manual manner to identify the significant predictor vars out of the eleven I thought the option "select=T" might do. Example: (here only 4 pedictors) firs

Re: [R] Merge

2013-04-17 Thread arun
HI Janesh, YOu can use: library(plyr) ?join_all() #From the help page:  dfs <- list(    a = data.frame(x = 1:10, a = runif(10)),    b = data.frame(x = 1:10, b = runif(10)),    c = data.frame(x = 1:10, c = runif(10)) ) join_all(dfs) join_all(dfs, "x")  join_all(dfs,

Re: [R] Mancova with R

2013-04-17 Thread peter dalgaard
On Apr 17, 2013, at 16:47 , Rémi Lesmerises wrote: > Dear all, > > I'm trying to compare two sets of variables, the first set is composed > exclusively of numerical variables and the second regroups factors and > numerical variables. I can't use a Manova because of this inclusion of > numeric

Re: [R] Best way to calculate averages of Blocks in an matrix?

2013-04-17 Thread Rui Barradas
Hello, Try the following. blocks <- rep(1:(1 + nrow(sim_sub) %/% 5), each = 5)[seq_len(nrow(sim_sub))] aggregate(sim_sub, list(blocks), FUN = mean) Hope this helps, Rui Barradas Em 17-04-2013 18:04, arun escreveu: do.call(rbind,lapply(split(sim_sub,((seq_len(nrow(sim_sub))-1)%/% 5)+1),col

Re: [R] Best way to calculate averages of Blocks in an matrix?

2013-04-17 Thread arun
Also, do.call(rbind,lapply(split(sim_sub,rep(1:(1+nrow(sim_sub)/5),each=5)[seq_len(nrow(sim_sub))]),colMeans)) #    V11   V12   V13   V14   V15  V16   V17   V18   V19   V20 #1 0.004 0.008 0.002 0.008 0.004 0.01 0.004 0.014 0.022 0.010 #2 0.002 0.000 0.002 0.006 0.006 0.01 0.018 0.006 0.010 0.014 #3

Re: [R] Merge

2013-04-17 Thread Janesh Devkota
Hi, I have a quick question here. Lets say he has three data frames and he needs to combine those three data frame using merge. Can we simply use merge to join three data frames ? I remember I had some problem using merge for more than two dataframes. Thanks. On Wed, Apr 17, 2013 at 1:05 AM, Far

Re: [R] Best way to calculate averages of Blocks in an matrix?

2013-04-17 Thread arun
do.call(rbind,lapply(split(sim_sub,((seq_len(nrow(sim_sub))-1)%/% 5)+1),colMeans))   #  V11   V12   V13   V14   V15  V16   V17   V18   V19   V20 #1 0.004 0.008 0.002 0.008 0.004 0.01 0.004 0.014 0.022 0.010 #2 0.002 0.000 0.002 0.006 0.006 0.01 0.018 0.006 0.010 0.014 #3 0.000 0.004 0.002 0.012 0.

Re: [R] use of names() within lapply()

2013-04-17 Thread arun
Dear Ivan, No problem. If you want it in a single plot: matplot(do.call(cbind,g),ylab="value",pch=1:2,main="Some plot",col=c("red","orange"),type="o")   legend("topleft",inset=.01,lty=c(1,1),title="Plot",col=c("red","orange"),names(g),horiz=TRUE) A.K. From: Iv

[R] Best way to calculate averages of Blocks in an matrix?

2013-04-17 Thread Keith S Weintraub
Folks, I recently was given a simulated data set like the following subset: sim_sub<-structure(list(V11 = c(0.01, 0, 0, 0.01, 0, 0.01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), V12 = c(0, 0, 0, 0.01, 0.03, 0, 0, 0, 0, 0, 0, 0.01, 0, 0.01, 0, 0, 0, 0, 0, 0.04), V13 = c(0, 0, 0, 0.01, 0, 0, 0,

Re: [R] odfWeave: Some questions about potential formatting options

2013-04-17 Thread Milan Bouchet-Valat
Le mardi 16 avril 2013 à 10:15 -0700, Paul Miller a écrit : > Hi Milan and Max, > > Thanks to each of you for your reply to my post. Thus far, I've > managed to find answers to some of the questions I asked initially. > > I am now able to control the justification of the leftmost column in > my t

Re: [R] Regularized Regressions

2013-04-17 Thread Christos Giannoulis
Hi Levi, Thank you very much for your reply and concern. There was a package till 2011...or even 2012...entitled "Generalized Path Seeking" Regression in "R" which was using a combination of all of these methods...as a way to regularize regression. However, I presently can't find it. Thus, I was

Re: [R] Anova unbalanced

2013-04-17 Thread Jose Iparraguirre
Dear Claudia, Your question has been posed on many previous occasions. The (short) answer has always been the same: have a look at the Anova function in the car package but before doing that, get a copy of John Fox's "Applied Regression Analysis and Generalized Linear Models" book. Best, José

Re: [R] Mancova with R

2013-04-17 Thread John Fox
Dear Remi, On Wed, 17 Apr 2013 08:23:07 -0700 (PDT) Rémi Lesmerises wrote: > Dear John, > > Thanks for your comments! But when I tried your suggestion, the output was as > the following: > > >  Response Dist_arbre : >             Df     Sum Sq    Mean Sq F value    Pr(>F)     > Poids        

Re: [R] use of names() within lapply()

2013-04-17 Thread Ivan Alves
Dear Duncan and A.K. Many thanks for your super quick help. The modified lapply did the trick, mapply died with a error "Error in dots[[2L]][[1L]] : object of type 'builtin' is not subsettable". Kind regards, Ivan On 17 Apr 2013, at 17:12, Duncan Murdoch wrote: > On 17/04/2013 11:04 AM, Ivan Al

Re: [R] Mancova with R

2013-04-17 Thread Rémi Lesmerises
Dear John, Thanks for your comments! But when I tried your suggestion, the output was as the following:  Response Dist_arbre :             Df     Sum Sq    Mean Sq F value    Pr(>F)     Poids        1 0.00010398 0.00010398  6.2910 0.0364733 *   Age          1 0.520

Re: [R] how to change the date into an interval of date?

2013-04-17 Thread arun
Hi. No problem. cc:ing to Rhelp. A.K. From: GUANGUAN LUO Sent: Wednesday, April 17, 2013 10:25 AM Subject: Re: how to change the date into an interval of date? Thank you so much . That is exactly the things i want. GG Hi, >Try this: >library(mondate) >

[R] proper way to handle obsolete function names

2013-04-17 Thread Jannis
Dear R community, what would be the proper R way to handle obsolete function names? I have created several packages with functions and sometimes would like to change the name of a function but would like to create a mechanism that other scripts of functions using the old name still work. C

Re: [R] use of names() within lapply()

2013-04-17 Thread arun
Hi, Try: set.seed(25) g<- list(sample(1:40,20,replace=TRUE),sample(40:60,20,replace=TRUE)) names(g)<- c("2009-10-07","2012-02-29") pdf("Trialnew.pdf")  lapply(seq_along(g),function(i) plot(g[[i]],main=names(g)[i])) dev.off() A.K. - Original Message - From: Ivan Alves To: "R-help@r-proj

Re: [R] use of names() within lapply()

2013-04-17 Thread Duncan Murdoch
On 17/04/2013 11:04 AM, Ivan Alves wrote: Dear all, List g has 2 elements > names(g) [1] "2009-10-07" "2012-02-29" and the list plot lapply(g, plot, main=names(g)) results in equal plot titles with both list names, whereas distinct titles names(g[1]) and names(g[2]) are sought. Clearly, lap

Re: [R] Mancova with R

2013-04-17 Thread John Fox
Dear Remi, Take a look at the Anova() function in the car package. In your case, you could use Anova(lm(as.matrix(Y) ~ x + z)) or, for more detail, summary(Anova(lm(as.matrix(Y) ~ x + z))) I hope this helps, John John Fox Sen. William McMas

[R] use of names() within lapply()

2013-04-17 Thread Ivan Alves
Dear all, List g has 2 elements > names(g) [1] "2009-10-07" "2012-02-29" and the list plot lapply(g, plot, main=names(g)) results in equal plot titles with both list names, whereas distinct titles names(g[1]) and names(g[2]) are sought. Clearly, lapply is passing 'g' in stead of consecutivel

[R] spatial graph and its boundary

2013-04-17 Thread Ondřej Mikula
Dear r-helpers, I have a graph created using the library 'spatgraphs'. library(spatstat) library(spatgraphs) xy <- rbind(c(28.39, -16.27), c(30.62, -20.13), c(32.25, -28.7), c(22.43, -27.22), c(27.5, -21.17), c(31.22, -24.52), c(17.93, -26.92), c(18.72, -17.95), c(24.15, -17.82), c(29.23, -22.85))

Re: [R] plot 2 y axis

2013-04-17 Thread John Kane
Exel is hardly the epitome of good graphing. There are a couple of ways to do what you want and Jim has shown you one , but ... What about using two panels to present the data as in opar <- par(mfrow = c(2, 1)) plot(dat1$Date, dat1$Weight, col = "red", xlab = "", ylab = "Weight") plot(dat1$Da

[R] Mancova with R

2013-04-17 Thread Rémi Lesmerises
Dear all, I'm trying to compare two sets of variables, the first set is composed exclusively of numerical variables and the second regroups factors and numerical variables. I can't use a Manova because of this inclusion of numerical variables in the second set. The solution should be to perform

Re: [R] Overlay two stat_ecdf() plots

2013-04-17 Thread PIKAL Petr
Hi Your files have only one column, so melted data is virtualy the same. When I read them as test1 and test2 i can do plot(ecdf(test1$Down)) plot(ecdf(test2$Up), add=T, col=2) Or using previously ustated ggplot2 package test<-rbind(melt(test1),melt(test2)) p<-ggplot(test, aes(x=value, colour

Re: [R] Error: could not find function "invlogit" and "bayesglm"

2013-04-17 Thread Berend Hasselman
On 17-04-2013, at 10:08, "S'dumo Masango" wrote: > I have installed the arm package and its dependents (e.g MATRIX, etc), but > cannot use the functions "invlogit" and "bayesglm" because it gives me the > error message "Error: could not find function "invlogit" or Error: could not > find functio

Re: [R] Error: could not find function "invlogit" and "bayesglm"

2013-04-17 Thread Jorge I Velez
Hi Carrington, You also need the boot package (see http://stat.ethz.ch/R-manual/R-patched/library/boot/html/inv.logit.html ) As for the other function, please load the arm package, e.g., require(arm) require(boot) and then you will be able to use the functions mentioned below. HTH, Jorge.- O

Re: [R] Error: could not find function "invlogit" and "bayesglm"

2013-04-17 Thread John Kane
Have you loaded it? library(arm) John Kane Kingston ON Canada > -Original Message- > From: masan...@uniswa.sz > Sent: Wed, 17 Apr 2013 10:08:39 +0200 > To: r-help@r-project.org > Subject: [R] Error: could not find function "invlogit" and "bayesglm" > > I have installed the arm package

[R] Pathological case for the function 'brunch' of CAPER?

2013-04-17 Thread Xavier Prudent
Dear R-enthusiats, While using the regression fonction 'brunch' of CAPER (with R v2.15.4), in a simple case (binary variable Yes/No vs. a continuous variable) I ended with an unexplained error: Error in if (any(stRes > robust)) { : missing value where TRUE/FALSE needed I simplified my code

[R] Anova unbalanced

2013-04-17 Thread paladini
Hello everybody, I have got a data set with about 400 companies. Each company has a score for its enviroment comportment between 0 and 100. These companies belong to about 15 different countries. I have e.g. 70 companies from UK and 5 from Luxembourg,- so the data set is pretty unbalanced and

Re: [R] Creating a vector with repeating dates

2013-04-17 Thread Katherine Gobin
Dear Sir, Thanks a lot for your valuable suggestions and help. Regards Katherine --- On Wed, 17/4/13, Jim Lemon wrote: From: Jim Lemon Subject: Re: [R] Creating a vector with repeating dates To: "Katherine Gobin" Cc: r-help@r-project.org Date: Wednesday, 17 April, 2013, 10:35 AM On 04/17

[R] Error: could not find function "invlogit" and "bayesglm"

2013-04-17 Thread S'dumo Masango
I have installed the arm package and its dependents (e.g MATRIX, etc), but cannot use the functions "invlogit" and "bayesglm" because it gives me the error message "Error: could not find function "invlogit" or Error: could not find function "invlogit". What could be the problem. Regards Car

[R] Bug in VGAM z value and coefficient ?

2013-04-17 Thread Olivier Merle
Dear, When i multiply the y of a regression by 10, I would expect that the coefficient would be multiply by 10 and the z value to stay constant. Here some reproducible code to support the case. *Ex 1* library(mvtnorm) library(VGAM) set.seed(1) x=rmvnorm(1000,sigma=matrix(c(1,0.75,0.75,1),2,2)) s

Re: [R] how to change the date into an interval of date?

2013-04-17 Thread arun
Hi, Try this: library(mondate) mutate(evt_c.1,t=ave(round(as.numeric(mondate(paste(evt_c.1[,2],"-01",sep="",patient_id,FUN=function(x) c(0,cumsum(diff(x)  #  patient_id responsed_at t #1   1   2010-5 0 #2   1   2010-7 2 #3   1   2010-8 3 #4   1  

Re: [R] odfWeave: Some questions about potential formatting options

2013-04-17 Thread Max Kuhn
Paul, #1: I've never tried but you might be able to escape the required tags in your text (e.g. in html you could write out the in your text). #3: Which output? Is this in text? #2: I may be possible and maybe easy to implement. So if you want to dig into it, have at it. For me, I'm completely

Re: [R] Regularized Regressions

2013-04-17 Thread Levi Waldron
Perhaps I am wrong, but I think there are only a few packages supporting Elastic Net, and none of them also perform Best Subsets. On Wed, Apr 17, 2013 at 8:46 AM, Christos Giannoulis wrote: > Merhaba, Hello to you too Mehmet (Yasu ki sena) > > Thank you for your email and especially for sharing

[R] Package VIF

2013-04-17 Thread Jaap van Wyk
Hi Could you perhaps possibly help me. I would like to use the package VIF but cannot get results I attach the .csv file and my R code. What do I have to do ? Any help is greatly appreciated. library(VIF) coal <- read.csv("e:/freekvif/cqa1.csv",header=TRUE) y <- as.numeric(coal$AI) x <-

Re: [R] how to change the date into an interval of date?

2013-04-17 Thread arun
Hi, I hope this is what you are looking for: library(plyr)   mutate(evt_c.1,t=ave(as.numeric(gsub(".*\\-","",responsed_at)),patient_id,gsub("-.*","",responsed_at),FUN=function(x) c(0,cumsum(diff(x) #   patient_id responsed_at t #1   1   2010-5 0 #2   1   2010-7 2 #3

Re: [R] Problem with DateVisit-gives wrong year?

2013-04-17 Thread Pancho Mulongeni
Thank you, I see this was due to me using %y instead of %Y, See ?strptime -Original Message- From: arun [mailto:smartpink...@yahoo.com] Sent: 17 April 2013 12:31 To: Pancho Mulongeni Cc: R help Subject: Re: [R] Problem with DateVisit-gives wrong year? HI, test.date<- rep(c("14/05/2012","

Re: [R] the joy of spreadsheets (off-topic)

2013-04-17 Thread Gabor Grothendieck
On Tue, Apr 16, 2013 at 1:25 PM, Sarah Goslee wrote: > Given that we occasionally run into problems with comparing Excel > results to R results, and other spreadsheet-induced errors, I thought > this might be of interest. > > http://www.nextnewdeal.net/rortybomb/researchers-finally-replicated-rein

Re: [R] On matrix calculation

2013-04-17 Thread Berend Hasselman
On 17-04-2013, at 14:39, Christofer Bogaso wrote: > Hello again, > > Let say I have a matrix: > > Mat <- matrix(1:12, 4, 3) > > And a vector: > > Vec <- 5:8 > > Now I want to do following: > > Each element of row-i in 'Mat' will be divided by i-th element of Vec > > Is there any direct wa

Re: [R] how to change the date into an interval of date?

2013-04-17 Thread arun
Hi, Try: evt_c.1<- read.table(text=" patient_id   responsed_at 1    2010-5 1    2010-7 1    2010-8 1    2010-9 2    2010-5 2    2010-6 2    2010-7 ",sep="",header=TRUE,stringsAsFactors=FALSE)  lst1<-split(evt_c.1,evt_c.1$patient_id)  res<-do.

Re: [R] On matrix calculation

2013-04-17 Thread arun
Hi, Try: sweep(Mat,1,Vec,"/")  #     [,1] [,2] [,3] #[1,] 0.200    1 1.80 #[2,] 0.333    1 1.67 #[3,] 0.4285714    1 1.571429 #[4,] 0.500    1 1.50 do.call(rbind,lapply(seq_len(nrow(Mat)),function(i) Mat[i,]/Vec[i])) #  [,1] [,2] [,3] #[1,] 0.200   

Re: [R] Regularized Regressions

2013-04-17 Thread Christos Giannoulis
Merhaba, Hello to you too Mehmet (Yasu ki sena) Thank you for your email and especially for sharing this package. I appreciate it. However, my feeling is that this package does not have the third component of Best Subsets (pls correct me if I am wrong). It uses only a combination of Ridge and Las

[R] On matrix calculation

2013-04-17 Thread Christofer Bogaso
Hello again, Let say I have a matrix: Mat <- matrix(1:12, 4, 3) And a vector: Vec <- 5:8 Now I want to do following: Each element of row-i in 'Mat' will be divided by i-th element of Vec Is there any direct way to doing that? Thanks for your help ___

Re: [R] remove higher order interaction terms

2013-04-17 Thread Liviu Andronic
On Wed, Apr 17, 2013 at 2:33 PM, Marc Schwartz wrote: > If you only want up to say second order interactions: > >> summary(lm(mpg ~ (cyl + disp + hp + drat) ^ 2, data = mtcars)) > This is what I was looking for. Thank you so much. > This is covered in ?formula > Indeed. I tried to parse ?formula

Re: [R] compate tow different data frame

2013-04-17 Thread arun
Hi, dat1<- read.table(text=" V1    V2 A  1 B  2 C  1 D  3 ",sep="",header=TRUE,stringsAsFactors=FALSE) dat2<- read.table(text=" V3    V2 AAA   1 BBB   2 CCC   3 ",sep="",header=TRUE,stringsAsFactors=FALSE) library(plyr) join(dat1,dat2,by="V2",type="full") #  V1 V2 

Re: [R] remove higher order interaction terms

2013-04-17 Thread Marc Schwartz
On Apr 17, 2013, at 7:23 AM, Liviu Andronic wrote: > Dear all, > Consider the model below: > >> x <- lm(mpg ~ cyl * disp * hp * drat, mtcars) >> summary(x) > > Call: > lm(formula = mpg ~ cyl * disp * hp * drat, data = mtcars) > > Residuals: >Min 1Q Median 3Q Max > -3.5725 -

[R] remove higher order interaction terms

2013-04-17 Thread Liviu Andronic
Dear all, Consider the model below: > x <- lm(mpg ~ cyl * disp * hp * drat, mtcars) > summary(x) Call: lm(formula = mpg ~ cyl * disp * hp * drat, data = mtcars) Residuals: Min 1Q Median 3Q Max -3.5725 -0.6603 0.0108 1.1017 2.6956 Coefficients: Estimate S

Re: [R] the joy of spreadsheets (off-topic)

2013-04-17 Thread Kevin Wright
On Tue, Apr 16, 2013 at 4:33 PM, Jim Lemon wrote: > On 04/17/2013 03:25 AM, Sarah Goslee wrote: The final point does relate to Excel and any application that hides what is > going on to the casual observer. I will treasure this URL to give to anyone > who chastises my moaning when I have to perf

Re: [R] Transformation of a variable in a dataframe

2013-04-17 Thread arun
Hi, You may also try: dfab<-data.frame(A,B) library(plyr)  dfcd<-subset(mutate(dfab,C=A*2,D=B*3),select=-c(A,B)) #or  dfcd1<-subset(within(dfab,{D<-B*3;C<-A*2}),select=-c(A,B)) dfcd$C #[1] 2 4 6  dfcd$D #[1] 12 18 21 A.K. - Original Message - From: jpm miao To: r-help Cc: Sent: Wedn

Re: [R] Problem with DateVisit-gives wrong year?

2013-04-17 Thread arun
HI, test.date<- rep(c("14/05/2012","01/10/2012","28/09/2012"),each=6)  as.Date(test.date,"%d/%m/%Y") # [1] "2012-05-14" "2012-05-14" "2012-05-14" "2012-05-14" "2012-05-14"  #[6] "2012-05-14" "2012-10-01" "2012-10-01" "2012-10-01" "2012-10-01" #[11] "2012-10-01" "2012-10-01" "2012-09-28" "2012-09-28

Re: [R] Problem with DateVisit-gives wrong year?

2013-04-17 Thread Jim Lemon
On 04/17/2013 09:18 PM, Pancho Mulongeni wrote: Hi I have the following factor of dates that I want to converted to Date class so I can extract the month test.date [1] 14/05/2012 14/05/2012 14/05/2012 14/05/2012 14/05/2012 14/05/2012 [7] 14/05/2012 14/05/2012 14/05/2012 14/05/2012 201 Leve

[R] Regularized Regressions

2013-04-17 Thread Christos Giannoulis
Hi all, I would greatly appreciate if someone was so kind and share with us a package or method that uses a regularized regression approach that balances a regression model performance and model complexity. That said I would be most grateful is there is an R-package that combines Ridge (sum of sq

[R] Problem with DateVisit-gives wrong year?

2013-04-17 Thread Pancho Mulongeni
Hi I have the following factor of dates that I want to converted to Date class so I can extract the month > test.date [1] 14/05/2012 14/05/2012 14/05/2012 14/05/2012 14/05/2012 14/05/2012 [7] 14/05/2012 14/05/2012 14/05/2012 14/05/2012 201 Levels: 01/10/2012 01/11/2012 01/12/2012 02/07/2012 ...

Re: [R] Spatial Ananlysis: zero.policy=TRUE doesn't work for no neighbour regions??

2013-04-17 Thread Roger Bivand
Molo uni-hohenheim.de> writes: > ... > *As there are some regions without neighbours in my data I use the following > code to create the Weights Matrix:* > > > W_Matrix<- nb2listw(location_nbq, style="W", zero.policy=TRUE) > >W_Matrix > > *And get this Output:* > ... > /("Error in print.listw

Re: [R] I don't understand the 'order' function

2013-04-17 Thread peter dalgaard
On Apr 17, 2013, at 10:41 , Patrick Burns wrote: > There is a blog post about this: > > http://www.portfolioprobe.com/2012/07/26/r-inferno-ism-order-is-not-rank/ > > And proof that it is possible to confuse them > even when you know the difference. It usually helps to remember that x[order(x)]

Re: [R] Creating a vector with repeating dates

2013-04-17 Thread Jim Lemon
On 04/17/2013 07:11 PM, Katherine Gobin wrote: Dear R forum I have a data.frame df = data.frame(dates = c("4/15/2013", "4/14/2013", "4/13/2013", "4/12/2013"), values = c(47, 38, 56, 92)) I need to to create a vector by repeating the dates as "Current_date", 4/15/2013, 4/14/2013, 4/13/2013, 4

Re: [R] Creating a vector with repeating dates

2013-04-17 Thread andrija djurovic
Hi. Here are some examples that can maybe help you: a <- "Current date" b <- Sys.Date()-1:5 a b class(a) class(b) c(a,b) mode(b) as.numeric(b) class(c(a,b)) c(a, as.character(b)) class(c(a,b)) class(c(a,as.character(b))) Hope this helps. On Wed, Apr 17, 2013 at 11:21 AM, Katherine Gobin wr

Re: [R] Creating a vector with repeating dates

2013-04-17 Thread Rui Barradas
Hello, Try the following. rep(c("Current_date", as.character(df$dates)), 3) Hope this helps, Rui Barradas Em 17-04-2013 10:11, Katherine Gobin escreveu: Dear R forum I have a data.frame df = data.frame(dates = c("4/15/2013", "4/14/2013", "4/13/2013", "4/12/2013"), values = c(47, 38, 56,

Re: [R] Creating a vector with repeating dates

2013-04-17 Thread Katherine Gobin
Dear Andrija Djurovic, Thanks for the suggestion. Ia m aware of "rep". However, here I need to repeat not only dates, but a string "Current_date". Thus, I need to create a vector ( to be included in some other data.frame) with the name say "dt" which will contain dt Current_date 4/15/2013 4/

Re: [R] Understanding why a GAM can't suppress an intercept

2013-04-17 Thread Simon Wood
hi Andrew. gam does suppress the intercept, it's just that this doesn't force the smooth through the intercept in the way that you would like. Basically for the parameteric component of the model '-1' behaves exactly like it does in 'lm' (it's using the same code). The smooths are 'added on' t

Re: [R] Creating a vector with repeating dates

2013-04-17 Thread andrija djurovic
?rep On Wed, Apr 17, 2013 at 11:11 AM, Katherine Gobin wrote: > Dear R forum > > I have a data.frame > > df = data.frame(dates = c("4/15/2013", "4/14/2013", "4/13/2013", > "4/12/2013"), values = c(47, 38, 56, 92)) > > I need to to create a vector by repeating the dates as > > "Current_date", 4/

[R] Creating a vector with repeating dates

2013-04-17 Thread Katherine Gobin
Dear R forum I have a data.frame df = data.frame(dates = c("4/15/2013", "4/14/2013", "4/13/2013", "4/12/2013"), values = c(47, 38, 56, 92)) I need to to create a vector by repeating the dates as "Current_date", 4/15/2013, 4/14/2013, 4/13/2013, 4/12/2013,  "Current_date", 4/15/2013, 4/14/2013

Re: [R] the joy of spreadsheets (off-topic)

2013-04-17 Thread peter dalgaard
On Apr 17, 2013, at 10:16 , Shane Carey wrote: > Can you resend this link please? > Psst: https://stat.ethz.ch/pipermail/r-help/2013-April/351669.html -- Peter Dalgaard, Professor Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)381

Re: [R] I don't understand the 'order' function

2013-04-17 Thread Patrick Burns
There is a blog post about this: http://www.portfolioprobe.com/2012/07/26/r-inferno-ism-order-is-not-rank/ And proof that it is possible to confuse them even when you know the difference. Pat On 16/04/2013 19:10, Julio Sergio wrote: Julio Sergio gmail.com> writes: I thought I've understoo

Re: [R] the joy of spreadsheets (off-topic)

2013-04-17 Thread Shane Carey
Can you resend this link please? Thanks On Tue, Apr 16, 2013 at 10:33 PM, Jim Lemon wrote: > On 04/17/2013 03:25 AM, Sarah Goslee wrote: > >> ... >> Ouch. >> >> (Note: I know nothing about the site, the author of the article, or >> the study in question. I was pointed to it by someone else. Bu

Re: [R] Merge

2013-04-17 Thread Farnoosh
Thanks a lot:) Sent from my iPad On Apr 16, 2013, at 10:15 PM, arun wrote: > Hi Farnoosh, > YOu can use either ?merge() or ?join() > DataA<- read.table(text=" > ID v1 > 1 10 > 2 1 > 3 22 > 4 15 > 5 3 > 6 6 > 7 8 > ",sep="",header=TRUE) > > DataB<- read.