[R] split dataframe to several dataframes in R

2015-02-16 Thread js . huang
Hi All,I have a dataframe called 'means' as shown below:iris1.csv <- iris iris2.csv <- iris names <- c("iris1.csv", "iris2.csv") dat <- mget(names) lst4 <- lapply(dat, function(x) apply(x[,-5], 2, mean)) # Build the new data frame means <- as.data.frame(do.call(rbind, lst4)) means$source <- names

Re: [R] compute values by condition in DF by rownames

2015-02-16 Thread JS Huang
Hi, I hope that someone can provide a better way to implement it. This is my implementation. > data X2 gbm_tcga lusc_tcga ucec_tcga_pub 1 gbm_tcga 1.0 0.14053719 -0.102847164 2 gbm_tcga 1.0 0.04413434 0.013568055 3 gbm_tcga 1.00

Re: [R] split dataframe to several dataframes in R

2015-02-16 Thread Aravind Jayaraman
Hi, I think you need not split the data.frame to get the desired result. You can work with your list lst4 itself. #Convert the vectors in the list to data.frames. lst4 <- lapply(lst4, function(x) {as.data.frame(t(iris1.csv))}) #Get the data.frames in the list to the global environment list2env(ls

Re: [R] Fitting gamma distribution

2015-02-16 Thread Rolf Turner
On 17/02/15 12:59, smart hendsome wrote: I'm very new to r-programming. I have rainfall data. I have tried to fit gamma into my data but there is error. Anyone can help me please. My rainfall data as I uploaded. When I try run the coding: library(MASS) KLT1<-read.csv('C:/Users/User/Dropbox/PhD

[R] Fitting gamma distribution

2015-02-16 Thread smart hendsome
I'm very new to r-programming. I have rainfall data. I have tried to fit gamma into my data but there is error. Anyone can help me please. My rainfall data as I uploaded. When I try run the coding: library(MASS) KLT1<-read.csv('C:/Users/User/Dropbox/PhD Materials/Coding_PhD_Thesis/Kelantan_Avera

[R] split dataframe to several dataframes in R

2015-02-16 Thread Zilefac Elvis via R-help
Hi All,I have a dataframe called 'means' as shown below:iris1.csv <- iris iris2.csv <- iris names <- c("iris1.csv", "iris2.csv") dat <- mget(names) lst4 <- lapply(dat, function(x) apply(x[,-5], 2, mean)) # Build the new data frame means <- as.data.frame(do.call(rbind, lst4)) means$source <- names(

[R] plm function & plm r.squared error

2015-02-16 Thread fay constanze
  DearGiovanni,Congratulationsfor the truly helpful plm package! Being new to R, I have a problem with the plm function for financial markets timeseries data: After having defined a large, unbalanced panel pdata.frame (https://www.dropbox.com/s/2r9t1cu9v65gobk/Database_CN_2004.csv?dl=0)and runn

[R] method of moments estimation

2015-02-16 Thread hms Dreams
Hi, I'm trying to use method of moments estimation to estimate 3 unkown paramters delta,k and alpha. so I had system of 3 non linear equations: 1) [delta^(1/alpha) *gamma (k-(1/alpha)) ]/gamma(k) = xbar 2) [delta^(2/alpha) *gamma (k-(2/alpha)) ]/gamma(k) = 1/n *sum (x^2) 3) [delta^(3/alpha)

Re: [R] list of list

2015-02-16 Thread William Dunlap
You can let lapply() do the preallocation and the looping for you with ASL <- lapply(1:5, function(j) lapply(1:5, function(i) i^j)) Bill Dunlap TIBCO Software wdunlap tibco.com On Mon, Feb 16, 2015 at 9:46 AM, Jeff Newmiller wrote: > You have two named objects when your goal is to have one

Re: [R] Comparing gam models fitted using ti()

2015-02-16 Thread Bert Gunter
I wonder if this might be better asked on a statistical list -- e.g. stats.stackexchange.com -- as this seems to involve complex statistical model comparison issues, which are normally OT here. -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Info

Re: [R] list of list

2015-02-16 Thread Troels Ring
Thanks to Jim, Peter and Jeff who all saw the solution! Best wishes Troels Den 16-02-2015 kl. 18:46 skrev Jeff Newmiller: You have two named objects when your goal is to have one that contains five others. ASL <- vector( "list", 5 ) for (j in 1:5){ ASL[[j]] <- vector( "list", 5 ) for (i

[R] Comparing gam models fitted using ti()

2015-02-16 Thread Arnaud Mosnier
Dear R-Help list, I want to compare gam models including interaction with simpler models. For interaction models, I used gam(Y~ti(X1) + ti(X2) + ti(X1,X2)) removing the interaction, the models end as Y~ti(X1) + ti(X2) How those models compare with models with the form Y ~ s(X1) + s(X2) In my cas

Re: [R] sd, mean with a frequency distribution matrix

2015-02-16 Thread JS Huang
Hi, For the second one, sqrt((sum(p[,1]^2*p[,2])-(sum(p[,1]*p[,2]))^2/sum(p[,2]))/(sum(p[,2])-1)), please refer to the following link for an example to explain how it works. http://www.lboro.ac.uk/media/wwwlboroacuk/content/mlsc/downloads/var_stand_deviat_group.pdf For the first one: sd(unli

Re: [R] P-value from Matching

2015-02-16 Thread Rob Wood
Hi Peter, That was my first port of call before I posted this thread. Unfortunately, it does not seem to explicitly state which test is used or how the p-value is calculated. Thanks, Rob. -- View this message in context: http://r.789695.n4.nabble.com/P-value-from-Matching-tp4703309p4703345.h

Re: [R] list of list

2015-02-16 Thread Jeff Newmiller
You have two named objects when your goal is to have one that contains five others. ASL <- vector( "list", 5 ) for (j in 1:5){ ASL[[j]] <- vector( "list", 5 ) for (i in 1:5) { ASL[[j]][[i]] <- i^j } } --- Jeff New

Re: [R] list of list

2015-02-16 Thread peter dalgaard
On 16 Feb 2015, at 17:43 , Troels Ring wrote: > Dear friends - this is simple I know but I can figure it out without your > help. > I have for each of 2195 instances 10 variables measured at specific times > from 6 to several hundred, so if I just take one of the instances, I can make > a lis

Re: [R] list of list

2015-02-16 Thread jim holtman
Is this what you mean: ASL <- list() for (j in 1:5){ RES <- list() for (i in 1:5) RES[[i]] <- i ^ j # create list ASL[[j]] <- RES # store 'list of list' } Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want t

Re: [R] ggplot2 shifting bars to only overlap in groups

2015-02-16 Thread Hörmetjan Yiltiz
Again, I come to think about violin plots which is more informative than the error bars. But for some reason, the violin in the *west* became way too slimmer than the *east* one, though the density plot tells me that is not necessarily the case. I am still trying to figure that out, and that would

[R] list of list

2015-02-16 Thread Troels Ring
Dear friends - this is simple I know but I can figure it out without your help. I have for each of 2195 instances 10 variables measured at specific times from 6 to several hundred, so if I just take one of the instances, I can make a list of the 10 variables together with their variable times.

Re: [R] Loop over regression results

2015-02-16 Thread Thierry Onkelinx
Or even easier is you use lmList() from the nlme package library(nlme) data(iris) regression.list <- lmList(Sepal.Width ~ Petal.Width | Species, data = iris) summary(regression.list) coef(regression.list) Best regards, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Resea

Re: [R] compute values by condition in DF by rownames

2015-02-16 Thread PIKAL Petr
I named your data frame temp > aggregate(temp[,-1], list(temp[,1]), function(x) sum(abs(x)>.2)) Group.1 gbm_tcga lusc_tcga ucec_tcga_pub 1 gbm_tcga4 1 0 2 lusc_tcga1 4 0 3 ucec_tcga_pub0 0 4 Cheer

Re: [R] Picking Best Discriminant Function Variables

2015-02-16 Thread David L Carlson
Look at the function stepclass() in package klaR. - David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of David Moskowitz Sent: S

Re: [R] Loop over regression results

2015-02-16 Thread David L Carlson
Or for the slopes and t-values: > do.call(rbind, lapply(mod, function(x) summary(x)[["coefficients"]][2,])) Estimate Std. Error t value Pr(>|t|) setosa 0.8371922 0.5049134 1.658091 1.038211e-01 versicolor 1.0536478 0.1712595 6.152348 1.41e-07 virginica 0.6314052 0.1428

[R] compute values by condition in DF by rownames

2015-02-16 Thread Karim Mezhoud
Hi All, how to compute only abs(value) > 0.2 of DF X2 gbm_tcga lusc_tcga ucec_tcga_pub gbm_tcga 1.0 0.1405371906 -0.1028471639 gbm_tcga 1.0 0.0441343447 0.0135680550 gbm_tcga 1.0 -0.2000397119 0.0389718175 gbm_tcga 1.0 0.

Re: [R] Loop over regression results

2015-02-16 Thread David L Carlson
In R you would want to combine the results into a list. This could be done when you create the regressions or afterwards. To repeat your example using a list: data(iris) taxon <- levels(iris$Species) mod <- lapply(taxon, function (x) lm(Sepal.Width ~ Petal.Width, data=iris, subset=Specie

Re: [R] ggplot2 shifting bars to only overlap in groups

2015-02-16 Thread John Kane
Lovely, a much more elegant solution. John Kane Kingston ON Canada -Original Message- From: hyil...@gmail.com Sent: Mon, 16 Feb 2015 02:30:09 +0800 To: jrkrid...@inbox.com, djmu...@gmail.com Subject: Re: [R] ggplot2 shifting bars to only overlap in groups Thanks so much, John and Denni

Re: [R] P-value from Matching

2015-02-16 Thread peter dalgaard
On 16 Feb 2015, at 00:31 , Rob Wood wrote: > Hi all, > > When using the match command from the matching package, the output reports > the treatment effect, standard error, t-statistic and a p-value. Which test > is used to generate this p-value, or how us it generated? > I would assume this

Re: [R] Selection/filtering from Data

2015-02-16 Thread John Kane
? subset. You have most of the command already written John Kane Kingston ON Canada > -Original Message- > From: pnsinh...@gmail.com > Sent: Mon, 16 Feb 2015 13:31:33 +0530 > To: r-help@r-project.org > Subject: [R] Selection/filtering from Data > > >From a dataset , I want select age >

Re: [R] How do I provide path character string to extdata content?

2015-02-16 Thread Duncan Murdoch
On 16/02/2015 6:37 AM, Ulrike Grömping wrote: > Dear helpeRs, > > I have some png files in the inst/extdata directory of a package (e.g., > man.png), and I want to provide character strings containing the paths to > these files; of course, these path strings have to depend on the individual > inst

[R] Loop over regression results

2015-02-16 Thread Ronald Kölpin
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Dear all, I have a problem when trying to present the results of several regression. Say I have run several regressions on a dataset and saved the different results (as in the mini example below). I then want to loop over the regression results in ord

Re: [R] Nonlinear integer programming (again)

2015-02-16 Thread John Kane
You may have good reason to distrust the Excel solver :) See below John Kane Kingston ON Canada > -Original Message- > From: rzw...@ets.org > Sent: Sat, 14 Feb 2015 23:53:55 + > To: r-help@r-project.org > Subject: [R] Nonlinear integer programming (again) > > Oddly, Excel's Solver

Re: [R] difference between max in summary table and max function

2015-02-16 Thread Franckx Laurent
Thanks for the clarification. The basic error on my side was that I had misunderstood the "digits" option in the summary, I had not understood that even integer numbers might end up being "rounded". Problem is solved now. -Original Message- From: Allen Bingham [mailto:aebingh...@gmail.co

Re: [R] How to get the error and error variance after HB using bayesm

2015-02-16 Thread Michael Langmaack
Hi Arnab, Actually, I don´t think so as in Bayesian Regression the estimation converges towards the prior distribution and not a point estimate like in the frequentist approach. But I’m not very sure honestly. I used a Bayesian Logit Model in R (bayesm, rhierBinLogit by Rossi) to calculate indi

[R] How do I provide path character string to extdata content?

2015-02-16 Thread Ulrike Grömping
Dear helpeRs, I have some png files in the inst/extdata directory of a package (e.g., man.png), and I want to provide character strings containing the paths to these files; of course, these path strings have to depend on the individual installation. So far, I have written a function that - if cal

Re: [R] #library(party) - Compare predicted results for ctree

2015-02-16 Thread Achim Zeileis
On Mon, 16 Feb 2015, Rodica Coderie via R-help wrote: Hello, I've created a ctree model called fit using 15 input variables for a factor predicted variable Response (YES/NO). When I run the following : table(predict(fit2), training_data$response) I get the following result: NO YES NO 4

Re: [R] Nonlinear integer programming (again)

2015-02-16 Thread Hans W Borchers
Zwick, Rebecca J ETS.ORG> writes: > Oddly, Excel's Solver will produce a solution to such problems but > (1) I don't trust it and > (2) it cannot handle a large number of constraints. > [...] > My question is whether there is an R package that can handle this problem. There are not many free in

[R] #library(party) - Compare predicted results for ctree

2015-02-16 Thread Rodica Coderie via R-help
Hello, I've created a ctree model called fit using 15 input variables for a factor predicted variable Response (YES/NO). When I run the following : table(predict(fit2), training_data$response) I get the following result: NO YES NO 48694 480 YES 0 0 It appears that the NO re

Re: [R] Selection/filtering from Data

2015-02-16 Thread Jim Lemon
Hi Parth, Assume that your dataset is in the form of a data frame, named psdf. psdf<-data.frame(age=sample(0:100,50),income=sample(8000:12000,50)) selectdf<-subset(psdf,age >= 36 & income > 1) Jim On Mon, Feb 16, 2015 at 7:01 PM, Partha Sinha wrote: > >From a dataset , I want select age >=3

Re: [R] problems with packages installation

2015-02-16 Thread Prof Brian Ripley
On 16/02/2015 07:49, PIKAL Petr wrote: Hi Jeff -Original Message- From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us] Sent: Friday, February 13, 2015 3:56 PM To: PIKAL Petr; r-help@r-project.org Cc: Richard M. Heiberger Subject: RE: [R] problems with packages installation I agree th

Re: [R] Pass additional arguments to do.call(grid.arrange, plots)

2015-02-16 Thread Rolf Turner
On 16/02/15 13:36, Bingzhang Chen wrote: Hi R users, I have a problem on how to pass an extra argument to do. call: The example codes are: # require(ggplot2) plots = lapply(1:5, function(.x) qplot(1:10,rnorm(10), main=paste("plot",.x))) require(gridE

[R] Selection/filtering from Data

2015-02-16 Thread Partha Sinha
>From a dataset , I want select age >=36 and income>1. How to do ? parth __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posti