Re: [R] mean() produces NA on double column [FIXED]

2021-11-04 Thread Rich Shepard
On Thu, 4 Nov 2021, Rui Barradas wrote: Maybe which(is.na(pdx_stage$ft)) Have you tried na.rm = TRUE? mean(pdx_stage$ft, na.rm = TRUE) Rui, I just scrolled through the data file. Yes, there are severeal NAs when the equipment was down and I hadn't put na.rm = TRUE in the read_csv() import co

Re: [R] mean() produces NA on double column

2021-11-04 Thread Rui Barradas
Hello, Maybe which(is.na(pdx_stage$ft)) Have you tried na.rm = TRUE? mean(pdx_stage$ft, na.rm = TRUE) Hope this helps, Rui Barradas Às 18:34 de 04/11/21, Rich Shepard escreveu: I'm not seeing what's different about this tibble so that mean() returns NA on a column of doubles: head(pdx

Re: [R] Mean absolute error from data matrix

2021-06-23 Thread PIKAL Petr
Hi. First, please do not post in HTML. It usually scrambles any posted code. Second, as you did not post any code or data your message was not scrambled but I wonder what are columns and what are rows and what do you actually calculates. From Suppose the ist column of the > second matrix is S

Re: [R] Mean of a row of a data frame

2018-03-20 Thread Richard M. Heiberger
rowMeans is designed for speed. It also has as.matrix inside it. On Tue, Mar 20, 2018 at 10:40 PM, Boris Steipe wrote: > R > rowMeans(roop) > [1] 1.67 5.33 3.00 > R > mean(as.numeric(roop[1,])) > [1] 1.67 > > > :-) > > > > >> On Mar 20, 2018, at 10:18 PM, Sorkin, John wrote: >>

Re: [R] Mean of a row of a data frame

2018-03-20 Thread Richard M. Heiberger
> mean(list(1,4,0)) [1] NA Warning message: In mean.default(list(1, 4, 0)) : argument is not numeric or logical: returning NA > mean(unlist(roop[1,])) [1] 1.67 > apply(roop, 1, mean) [1] 1.67 5.33 3.00 data.frame is a list with some matrix characteristics. The list characteristic

Re: [R] Mean of a row of a data frame

2018-03-20 Thread Boris Steipe
R > rowMeans(roop) [1] 1.67 5.33 3.00 R > mean(as.numeric(roop[1,])) [1] 1.67 :-) > On Mar 20, 2018, at 10:18 PM, Sorkin, John wrote: > > I am trying to get the mean of a row of a data frame. My code follows: > > > roop <- data.frame(x=c(1,2,3),y=c(4,5,2),z=c(0,9,4)) > roo

Re: [R] mean of a column in a list of data frames

2017-02-05 Thread Rui Barradas
Hello, Try instead the following. aList<- numeric(3) for(i in 1:3){ aList[i] <- mean(ownersList[[i]]$grossIncome) } aList Hope this helps, Rui Barradas Em 05-02-2017 12:01, Brandon Payne escreveu: I have a list of data frames, ownersList <- list(exp2004owners,exp2005owners,

Re: [R] mean of a column in a list of data frames

2017-02-05 Thread Duncan Murdoch
On 05/02/2017 7:01 AM, Brandon Payne wrote: I have a list of data frames, ownersList <- list(exp2004owners,exp2005owners, exp2006owners,exp2007owners, exp2008owners,exp2009owners, exp2010owners,exp2011owners, exp2012

Re: [R] mean for every quartile

2016-05-16 Thread David L Carlson
ect.org] On Behalf Of ch.elahe via R-help Sent: Monday, May 16, 2016 8:46 AM To: Michael Dewey; ulrik.ster...@gmail.com Cc: R-help Mailing List Subject: Re: [R] mean for every quartile Thnaks for your reply, By using tapply I get this result: tapply(df$BR, findInterval(df$BR, quant

Re: [R] mean for every quartile

2016-05-16 Thread ch.elahe via R-help
Thnaks for your reply, By using tapply I get this result: tapply(df$BR, findInterval(df$BR, quantile(df$BR)), mean) 1 3 4 5 256 320 384 512 But I think this is not true,cause I have to get 5 means but here I get four numbers! On Monday, May 16, 2016 6:29 AM, Michael

Re: [R] mean for every quartile

2016-05-16 Thread Ulrik Stervbo
Hi Elahe, you can create a matrix of ranges and loop over each row: m <- c(384, 384, 384, 384, 512, 384, 384, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 384, 384, 384, 320, 320, 320, 320, 384, 384, 256, 320, 320, 320, 384, 320, 320, 320, 384, 384, 320, 320, 320, 320, 320, 320, 320, 320, 32

Re: [R] mean for every quartile

2016-05-16 Thread Michael Dewey
Dear Elahe In line On 16/05/2016 13:31, ch.elahe via R-help wrote: Hi all, I have a column in my df and I want to get quartiles for this column and then calculate mean for each and every quartile, here is my column: The quartiles are strictly speaking the boundaries but if you really meant

Re: [R] Mean of hexadecimal numbers

2016-04-16 Thread Atte Tenkanen
Hm..., Should these two versions produce the same solution? Unfortunately and shame to confess, I don't know much about the colors in R: myColors <- c("#FF7C00","#00BF40","#00") Colors=rgb2hsv(col2rgb(myColors)) apply(Colors,1,mean) h s v 0.2122974 1.000 0.9163

Re: [R] Mean of hexadecimal numbers

2016-04-16 Thread Atte Tenkanen
Thanks to William and Bert! Atte 16.4.2016, 18.56, William Dunlap kirjoitti: > Since these are color strings, you can use functions in the grDevices > package (other others) to manipulate them. E.g., you can convert them > to various color spaces and perhaps use the mean in one of those > spaces

Re: [R] Mean of hexadecimal numbers

2016-04-16 Thread Duncan Murdoch
On 16/04/2016 12:33 PM, Atte Tenkanen wrote: Hm..., Should these two versions produce the same solution? I wouldn't expect them to. Duncan Murdoch Unfortunately and shame to confess, I don't know much about the colors in R: myColors <- c("#FF7C00","#00BF40","#00") Colors=rgb2hsv(col2

Re: [R] Mean of hexadecimal numbers

2016-04-16 Thread boB Rudis
grDevices has `convertColor()` and the `colorspace` has other functions that can convert from RBG to Lab space. You should convert the RGB colors to Lab and average them that way (or us other functions to convert to HSL or HSV). It all depends on what you are trying to accomplish with the "average"

Re: [R] Mean of hexadecimal numbers

2016-04-16 Thread Duncan Murdoch
On 16/04/2016 8:47 AM, Atte Tenkanen wrote: Hi, How would you calculate the "mean colour" of several colours, for example c("#FF7C00","#00BF40","#00")? Bert answered your subject line question. Your text is asking something else: if those are colours, you don't want to treat each of th

Re: [R] Mean of hexadecimal numbers

2016-04-16 Thread William Dunlap via R-help
Since these are color strings, you can use functions in the grDevices package (other others) to manipulate them. E.g., you can convert them to various color spaces and perhaps use the mean in one of those spaces as your 'average color'. > myColors <- c(One="#FF7C00",Two="#00BF40",Three="#00

Re: [R] Mean of hexadecimal numbers

2016-04-16 Thread Bert Gunter
... and if you need to convert back: ?as.hexmode -- 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 Sat, Apr 16, 2016 at 8:20 AM, Bert Gunter wrote: >

Re: [R] Mean of hexadecimal numbers

2016-04-16 Thread Bert Gunter
?strtoi You'll have to remove the "#" first, e.g. via substring() -- 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 Sat, Apr 16, 2016 at 5:47 AM, Atte

Re: [R] Mean effect size in meta-analysis using Metafor

2015-12-21 Thread Viechtbauer Wolfgang (STAT)
arlijn . > Sent: Monday, December 21, 2015 14:35 > To: Michael Dewey; r-help@r-project.org > Subject: Re: [R] Mean effect size in meta-analysis using Metafor > > Dear Michael, > > Thanks for your reaction. The estimates in the example in the link are > not exactly identic

Re: [R] Mean effect size in meta-analysis using Metafor

2015-12-21 Thread Carlijn .
50.093 0.506 ** DBD 0.114 0.084 1.354 0.178 -0.053 0.281 ADHD0.087 0.104 0.8360.405 -0.119 0.293 > Subject: Re: [R] Mean effect size in meta-analysis using Metafor > To: wibbelt...@hotmail.com; r-help@r-project.org > From: li

Re: [R] Mean effect size in meta-analysis using Metafor

2015-12-12 Thread Michael Dewey
Dear Carlijn I wonder whether http://www.metafor-project.org/doku.php/tips:comp_two_independent_estimates answers your question? If you had given us an example of your fitting procedure we might know for sure. On 12/12/2015 15:35, Carlijn . wrote: Hi all, I have a question about doing

Re: [R] Mean effect size in meta-analysis using Metafor

2015-12-12 Thread Bert Gunter
**If** I understand correctly, this is because of correlation in effects due to non-independence between males and females in the data. As this is primarily a statistical, not an R programming, issue, I suggest you post on a statistics list like stats.stackexchange.com. Better yet, talk with a loca

Re: [R] Mean error message missing

2015-06-08 Thread Christian Brandstätter
Thank you very much, I didn't know that. On 08/06/2015 6:04 AM, Christian Brandstätter wrote: Thank you for the explanation. But if you take for instance plot.default(), being another generic function, it would not work like that: plot(1,2,3,4), only plot(1,2) is accepted. From R-help (Usag

Re: [R] Mean error message missing

2015-06-08 Thread Duncan Murdoch
On 08/06/2015 6:04 AM, Christian Brandstätter wrote: > Thank you for the explanation. > But if you take for instance plot.default(), being another generic > function, it would not work like that: > plot(1,2,3,4), only plot(1,2) is accepted. > > > From R-help (Usage): > ## Default S3 method: > m

Re: [R] Mean error message missing

2015-06-08 Thread Christian Brandstätter
Thank you for the explanation. But if you take for instance plot.default(), being another generic function, it would not work like that: plot(1,2,3,4), only plot(1,2) is accepted. From R-help (Usage): ## Default S3 method: mean(x, trim = 0, na.rm = FALSE, ...) What is puzzling, is that apparen

Re: [R] Mean error message missing

2015-06-08 Thread Achim Zeileis
On Mon, 8 Jun 2015, Christian Brandstätter wrote: Dear list, I found an odd behavior of the mean function; it is allowed to do something that you probably shouldn't: If you calculate mean() of a sequence of numbers (without declaring them as vector), mean() then just computes mean() of the fi

Re: [R] Mean rain per rain day

2015-05-13 Thread Jim Lemon
Hi Frederic, It looks like you have a number of daily rainfall values and you want to get the mean rainfall on days where there was some rain. What you probably want is: daily_rainfall<-rpois(50,2) mean(daily_rainfall[daily_rainfall>0]) You may have to add na.rm=TRUE if there are NAs in your data

Re: [R] Mean of dates

2015-04-27 Thread Jue Lin-Ye
On 24 April 2015 at 13:47, Jue Lin-Ye wrote: > > > On 24 April 2015 at 12:59, Achim Zeileis wrote: > >> >> >> On Fri, 24 Apr 2015, Jue Lin-Ye wrote: >> >> Dear fellow R-help members, >>> >>> If my data is >>> >>> MM DD HH >>> 2015 04 24 01 >>> 2015 04 24 02 >>> 2015 04 24 06 >>> >>> Where

Re: [R] Mean of dates

2015-04-24 Thread Jue Lin-Ye
On 24 April 2015 at 12:59, Achim Zeileis wrote: > > > On Fri, 24 Apr 2015, Jue Lin-Ye wrote: > > Dear fellow R-help members, >> >> If my data is >> >> MM DD HH >> 2015 04 24 01 >> 2015 04 24 02 >> 2015 04 24 06 >> >> Where >> >> : year >> MM:month >> DD:day >> HH: hour >> >> How could I

Re: [R] Mean of dates

2015-04-24 Thread Achim Zeileis
On Fri, 24 Apr 2015, Jue Lin-Ye wrote: Dear fellow R-help members, If my data is MM DD HH 2015 04 24 01 2015 04 24 02 2015 04 24 06 Where : year MM:month DD:day HH: hour How could I calculate the mean of the ISOdatetime(,MM,DD,HH,0,0) of these? With the mean() method? On my

Re: [R] mean calculation

2015-01-26 Thread arun
Hi Juvin, The error "dim(X) must have a positive length" usually shows when you are passing a vector to "apply", ie. apply(1:5,2,mean) #Error in apply(1:5, 2, mean) : dim(X) must have a positive length Also, if your dataset originally has "1206" columns, it is not clear why you n

Re: [R] Mean of colMeans

2014-05-22 Thread arun
ment. > Please refer to www.vestas.com/legal/notice > If you have received this e-mail in error please contact the sender. > > >> -Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] >> On Behalf Of Sarah Goslee >

Re: [R] Mean of colMeans

2014-05-21 Thread Boris Steipe
. > > >> -Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] >> On Behalf Of Sarah Goslee >> Sent: 21. maj 2014 21:11 >> To: Kate Ignatius; r-help >> Subject: Re: [R] Mean of colMeans >> >&g

Re: [R] Mean of colMeans

2014-05-21 Thread Igor Sosa Mayor
Kate Ignatius writes: > Hi All, > > I've successfully gotten out the colMeans for 60 columns using: > > col <- colMeans(x, na.rm = TRUE, dims = 1) > > My next question is: is there a way of getting a mean of all the > column means (ie a mean of a mean)? maybe mean(x) ? -- :: Igor Sosa Mayor

Re: [R] Mean of colMeans

2014-05-21 Thread Frede Aakmann Tøgersen
to:r-help-boun...@r-project.org] > On Behalf Of Sarah Goslee > Sent: 21. maj 2014 21:11 > To: Kate Ignatius; r-help > Subject: Re: [R] Mean of colMeans > > That would be because col is a function in base R, and thus a poor > choice of names for user objects. Nonetheless, it wor

Re: [R] Mean of colMeans

2014-05-21 Thread Kate Ignatius
Thanks for the explanation. And tip... this was a quick a dirty code so didn't really think about naming something that is already a function in R. Data was generic - just a bunch of columns with numbers so didn't bother including that as I know that wasn't the problem. Same goes with replying -

Re: [R] Mean of colMeans

2014-05-21 Thread Sarah Goslee
That would be because col is a function in base R, and thus a poor choice of names for user objects. Nonetheless, it worked when I ran it, but you didn't provide reproducible example so who knows. R> set.seed(1) R> x <- data.frame(matrix(runif(150), ncol=10)) R> # col is a function, so not a good

Re: [R] Mean not working in function

2014-04-16 Thread arun
Hi, Try: set.seed(48) dat1 <- data.frame(matrix(sample(c(NA, 1:20), 4 * 20, replace = TRUE), ncol = 4), fac1 = sample(LETTERS, 20, replace = TRUE)) mysummary <- function(dataf) { indx <- sapply(dataf, is.numeric) for (name in names(dataf)[indx]) { cat("Variable name: ", name, ": Mean=", mean(da

Re: [R] mean calculations from a dframe column

2014-04-14 Thread andre.zacha...@gmail.com
hello, yes I will try colmeans, I thought it will not get rid of th NA's But thank you for the advice! Andre 2014-04-14 13:25 GMT+01:00 David McPearson [via R] < ml-node+s789695n4688731...@n4.nabble.com>: > On Sun, 13 Apr 2014 05:01:40 -0700 (PDT) "[hidden > email]

Re: [R] mean calculations from a dframe column

2014-04-14 Thread David McPearson
On Sun, 13 Apr 2014 05:01:40 -0700 (PDT) "andre.zacha...@gmail.com" wrote > Thank you very much!! > .. .. > *De :* arun kirshna [via R] > *Envoyé :* 13 avril 2014 11:23 > *À :* andre.zacha...@gmail.com > *Objet :* Re: mean calculations from a dframe column > > Hi André, > > Your codes wer

Re: [R] mean calculations from a dframe column

2014-04-13 Thread andre.zacha...@gmail.com
Thank you very much!! You saved me a lot of time now! When you look for the key for hours Many thank again André *De :* arun kirshna [via R] *Envoyé :* 13 avril 2014 11:23 *À :* andre.zacha...@gmail.com *Objet :* Re: mean calculations from a dframe column Hi André, Your codes we

Re: [R] mean calculations from a dframe column

2014-04-13 Thread arun
Hi André,  Your codes were missing in some information. If your code looks like this: Measure <- function(a, b) { a <- as.matrix(a) b <- as.matrix(b) Mean <- apply(a, 2, mean, na.rm = TRUE) somme <- c() for (i in seq_along(b)) somme[i] <- divide(Mean, b[i]) somme <- as.data.frame(somme) return(

Re: [R] Mean not working in function

2014-04-11 Thread arun
Hi, Try: mysummary <- function(dataf){ for(name in names(dataf)){ cat ("Variable name: ", name, ": Mean=", mean(dataf[,name],na.rm=TRUE),"\n") } }  ##Using some example data: set.seed(48) dat1 <- as.data.frame(matrix(sample(c(NA,1:20),4*20,replace=TRUE),ncol=4)) mysummary(dat1) #Variable name:

Re: [R] Mean of values in different files

2014-04-11 Thread arun
Hi, Try: dir.create("final") lst1 <- split(list.files(pattern=".csv"),gsub("\\_.*","",list.files(pattern=".csv"))) lst2 <- lapply(lst1,function(x1) lapply(x1, function(x2) {lines1 <- readLines(x2); header1 <- lines1[1:2]; dat1 <- read.table(text=lines1,header=FALSE,sep=",",stringsAsFactors=FAL

Re: [R] mean help?

2014-02-12 Thread Rui Barradas
Hello, At an R prompt type ?mean ?sd ?median And read the file R-intro.pdf that comes with your installation of R. Hope this helps, Rui Barradas Em 12-02-2014 18:20, frankreynolds escreveu: Hey everyone, I need help getting the mean, standard deviation, median, etc. I'm just not sure how to

Re: [R] mean help?

2014-02-12 Thread Don McKenzie
Frank — you need to read the R tutorial that came with your installation. If you don’t have the answers to your VERY BASIC questions after that, let us know. On Feb 12, 2014, at 10:20 AM, frankreynolds wrote: > Hey everyone, I need help getting the mean, standard deviation, median, etc. > I'm

Re: [R] Mean: category wise within a data frame

2013-12-24 Thread arun
HI, May be this helps: Please use ?dput() to show the example dataset dat1 <- read.table(text="Categories  Variable Frequencies 1 0.009 1003 1 0.867 1200 1 0.567 987 1 0.765 134 1 0.445 890 2 0.007 899   2 0.768 707    2 0.789 865 2 0.544  678    2  0.987 889",sep="",

Re: [R] Mean: category wise within a data frame

2013-12-24 Thread David Carlson
Please do not use html formatting in your messages to the list. The format codes are stripped and you table becomes a single long column (see below). Only use plain text emails and use the results of dput(mydata) to insert your data into the message. As to your question. Look at the aggregate() fu

Re: [R] Mean error

2013-10-29 Thread arun
Hi, Try either: res1 <- apply(mydata[,1:2],2,mean)  res2 <- colMeans(mydata[,1:2])  identical(res1,res2) #[1] TRUE # Also if you need to find means for each group ("Ungrazed vs. "Grazed") by(mydata[,-3],mydata[,3],colMeans) #or if column names are "V1", "V2", "V3" aggregate(.~V3,mydata,mean) #or

Re: [R] mean

2013-09-04 Thread S Ellison
> -Original Message- > When I try to apply mean to a list, I get the answer : > > argument is not numeric or logical: returning NA > Example: l4 <- list(1:4) class(l4) #not numeric or logical ... mean(l4) #same error #a list is not a number, a logical (TRUE/FALSE) or a vector or arra

Re: [R] mean

2013-08-30 Thread arun
a3)) #[1] 5.285714 A.K. - Original Message - From: Albyn Jones To: agnes69 Cc: r-help@r-project.org Sent: Friday, August 30, 2013 11:59 AM Subject: Re: [R] mean It would be easier to diagnose the problem if you included an example illustrating exactly what you did.  I'll guess:

Re: [R] mean

2013-08-30 Thread Roy Mendelssohn - NOAA Federal
Use is.numeric(list) on the list to see if it is a list of numbers or if it is list of characters. If it is a list of characters (which could be the case if you read it in using read.csv or the like) and it makes sense to convert to numeric, then do something like: list<-as.numeric(list) -R

Re: [R] mean

2013-08-30 Thread Albyn Jones
It would be easier to diagnose the problem if you included an example illustrating exactly what you did. I'll guess: > a <- list(3,4,5) > mean(a) [1] NA Warning message: In mean.default(a) : argument is not numeric or logical: returning NA > mean(as.numeric(a)) [1] 4 But that's just a guess, as

Re: [R] mean

2013-08-30 Thread arun
Hi, Better would be to show a reproducible example using ?dput() and the codes you used.  Assuming that you tried something like this: lst1<- list(1:10,c(5,4,3),4:15)  mean(lst1) #[1] NA #Warning message: #In mean.default(lst1) : argument is not numeric or logical: returning NA  sapply(lst1,mean) 

Re: [R] Mean using different group for a real r beginner

2013-05-16 Thread arun
Hi, Try either: tolerance <- read.csv("http://www.ats.ucla.edu/stat/r/examples/alda/data/tolerance1.txt";)  aggregate(exposure~male,data=tolerance,mean)  # male exposure #1    0 1.246667 #2    1 1.12 #or  library(plyr)  ddply(tolerance,.(male),summarize,exposure=mean(exposure)) #  male expos

Re: [R] mean for each observation

2013-05-03 Thread arun
HI, Not sure I understand it correctly. dat1<- read.table(text=" site Year doy fish Feed swim agr_1 agr_2 agr_3 rest hide 3 2012 203 1 1 0 0 0 0 0 0 3 2012 203 1 0 1 0 0 0 0 0 3 2012 203 1 0 1 0 0 0 0 0 3 2012 203 2 0 0 0 0 0 1 0 3 2012 203 2 1 0 0 0 0 0 0 3 2012 203 2 1 0 0 0 0 0 0 4 2012 197 1 0

Re: [R] Mean calculation by two variables

2013-01-17 Thread arun
igues To: Rui Barradas Cc: r-help@r-project.org Sent: Wednesday, January 16, 2013 11:23 PM Subject: Re: [R] Mean calculation by two variables Hello Rui! Thanks a lot for your help! Sorry for make mistake with the factor's name, was inattention during data preparation for the asking

Re: [R] Mean calculation by two variables

2013-01-16 Thread Raoni Rodrigues
Hello Rui! Thanks a lot for your help! Sorry for make mistake with the factor's name, was inattention during data preparation for the asking mail. Unfortunately, it not simple mean calculation, because same individual could have more than one row, if it eat more than a food item. In example data

Re: [R] Mean calculation by two variables

2013-01-16 Thread Rui Barradas
Hello, If you want to calculate the mean weight by Specie and Food.item, you can use ?aggregate. In what follows, I've named your EXAMPLE ex and your SOLUTION sol. Note that the result is different from sol. (No exemplo não há Peixe, é Fish, e os números são outros.) aggregate(Weight ~ Specie +

Re: [R] Mean according to the combination of two factors

2013-01-11 Thread Rui Barradas
Hello, Try the following. # make up some data dat <- data.frame(values = rnorm(100), experiment = sample(10, 100, TRUE), composite = sample(17, 100, TRUE)) aggregate(values ~ experiment + composite, data = dat, FUN = mean) Hope this helps, Rui Barradas Em 11-01-2013 23:26, li li escreveu:

Re: [R] mean of each month in data

2012-12-17 Thread Rui Barradas
thankyou very much indeed once again eliza Date: Mon, 17 Dec 2012 09:32:54 -0800 From: smartpink...@yahoo.com Subject: Re: [R] mean of each month in data To: eliza_bo...@hotmail.com CC: r-help@r-project.org HI, May be this helps: dat1<-read.table("Eliza.txt",sep="",header

Re: [R] mean of each month in data

2012-12-17 Thread Rui Barradas
n, 17 Dec 2012 09:32:54 -0800 From: smartpink...@yahoo.com Subject: Re: [R] mean of each month in data To: eliza_bo...@hotmail.com CC: r-help@r-project.org HI, May be this helps: dat1<-read.table("Eliza.txt",sep="",header=TRUE,stringsAsFactors=FALSE) library(reshape2) res<-lap

Re: [R] mean of each month in data

2012-12-17 Thread eliza botto
h indeed once again eliza > Date: Mon, 17 Dec 2012 09:32:54 -0800 > From: smartpink...@yahoo.com > Subject: Re: [R] mean of each month in data > To: eliza_bo...@hotmail.com > CC: r-help@r-project.org > > HI, > > May be this helps: > dat1<-read.table("El

Re: [R] mean of each month in data

2012-12-17 Thread arun
HI, May be this helps: dat1<-read.table("Eliza.txt",sep="",header=TRUE,stringsAsFactors=FALSE) library(reshape2)  res<-lapply(split(dat1,dat1$st.),function(x) dcast(x,month~year,mean,value.var="population_in_million")) res $Sa #   month 1955 1956 1957 1958 #1  1 2.40  NaN  NaN

Re: [R] mean of each month in data

2012-12-17 Thread David L Carlson
ject.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Rui Barradas > Sent: Monday, December 17, 2012 12:06 PM > To: eliza botto > Cc: r-help@r-project.org > Subject: Re: [R] mean of each month in data > > Hello, > > Something like this? > > > dat <

Re: [R] mean of each month in data

2012-12-17 Thread Rui Barradas
Hello, Something like this? dat <- structure(list(st = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1

Re: [R] Mean-Centering Question

2012-12-09 Thread David L Carlson
t; project.org] On Behalf Of arun > Sent: Sunday, December 09, 2012 10:27 AM > To: Ray DiGiacomo, Jr. > Cc: R help > Subject: Re: [R] Mean-Centering Question > > Hi, > > You could also use: > newFunction1<-function(x) {t(t(log(x))-colMeans(log(x)))} > >  res1<-

Re: [R] Mean-Centering Question

2012-12-09 Thread arun
ements for res is data.frame and res1 is matrix.  A.K. - Original Message - From: "Ray DiGiacomo, Jr." To: R Help Cc: Sent: Saturday, December 8, 2012 11:11 PM Subject: Re: [R] Mean-Centering Question Hi David and Arun, Thanks for looking into this.  I think I have fo

Re: [R] Mean-Centering Question

2012-12-08 Thread arun
Hi, It works for me also:  by(dat1[c("Units","AveragePrice")],dat1[,1],specialFunction) #dat1[, 1]: Los Angeles  # Units AveragePrice #1  0.2136827  0.071790268 #2  2.2735148 -2.351758623 #3 -0.2083118  0.001082696 -- #or  by(cbind(Units=dat1[,3],A

Re: [R] Mean-Centering Question

2012-12-08 Thread Ray DiGiacomo, Jr.
Hi David and Arun, Thanks for looking into this. I think I have found a solution. The "by" function will run ok without errors but the values returned in the second row of the "Los Angeles" output are both incorrect. These incorrect values are shown below in red. I think my original custom fun

Re: [R] Mean-Centering Question

2012-12-08 Thread David Winsemius
On Dec 8, 2012, at 7:06 PM, Elizabeth Fuller Bettini wrote: please remove me from this list. You subscribed and only you know the password that allows you to control the subscription options. Please use the links at the bottom of every posting to Rhelp. On Sat, Dec 8, 2012 at 6:54 PM,

Re: [R] Mean-Centering Question

2012-12-08 Thread David Winsemius
On Dec 8, 2012, at 3:54 PM, Ray DiGiacomo, Jr. wrote: Hello, I'm trying to create a custom function that "mean-centers" data and can be applied across many columns. Here is an example dataset, which is similar to my dataset: dat <- read.table(text="Location,TimePeriod,Units,AveragePrice

Re: [R] Mean-Centering Question

2012-12-08 Thread Elizabeth Fuller Bettini
please remove me from this list. On Sat, Dec 8, 2012 at 6:54 PM, Ray DiGiacomo, Jr. wrote: > R-help@r-project.org [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do

Re: [R] mean and kurtosis

2012-11-09 Thread John Kane
http://www.statmethods.net/stats/descriptives.html the psych package seems to do what you wan set.seed(235) mydata <- data.frame(aa = rnorm(20), bb = rnorm(20) , cc = rnorm(20)) library(psych) describe(mydata) John Kane Kingston ON Canada > -Original Message- > From: powella...@g

Re: [R] Mean of matrices entries in list of lists

2012-11-09 Thread arun
HI, It is better to have a reproducible example to work with.  I hope this helps you. library(reshape) library(zoo) set.seed(132) list1<-lapply(1:13,function(x) lapply(1:12,function(x) data.frame(col1=sample(1:50,5,replace=TRUE),col2=sample(1:150,5,replace=TRUE names(list1)<-2000:2012 na

Re: [R] Mean Help

2012-10-31 Thread arun
f dat1  # Height EyeColor #5    156 Blue #6    177 Blue #7    179 Blue #8    170 Blue #Finally, mean(dat1[,1][dat1[,2]=="Blue"]) gives the mean of those values I mentioned above. #[1] 170.5   - Original Message - From: Hard Core To: r-help@r-project.or

Re: [R] Mean Help

2012-10-31 Thread Hard Core
Dear Michael ... You're a genius thak you very much really thank you !!! It worked!!! -- View this message in context: http://r.789695.n4.nabble.com/Mean-Help-tp4648000p4648038.html Sent from the R help mailing list archive at Nabble.com. __ R-help@

Re: [R] Mean Help

2012-10-31 Thread R. Michael Weylandt
On Wed, Oct 31, 2012 at 4:31 PM, Hard Core wrote: > Thank you but with that formula i don't understand how R can select only the > one with blue eyes > Assuming you're referring to my proposal of aggregate(height ~ eyes, DATA, mean) It's not blue eyes only: that will summarize height for each e

Re: [R] Mean Help

2012-10-31 Thread Hard Core
Thank you but with that formula i don't understand how R can select only the one with blue eyes -- View this message in context: http://r.789695.n4.nabble.com/Mean-Help-tp4648000p4648030.html Sent from the R help mailing list archive at Nabble.com. _

Re: [R] Mean Help

2012-10-31 Thread Hard Core
Thank you ... can you explain what you've done? -- View this message in context: http://r.789695.n4.nabble.com/Mean-Help-tp4648000p4648013.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat

Re: [R] Mean Help

2012-10-31 Thread Jessica Streicher
please provide a bit of the dataframe in the future using the dput() function > x<-data.frame(height=1:10, > color=sample(c("blue","green","brown"),10,replace=T)) > x height color 1 1 blue 2 2 green 3 3 blue 4 4 brown 5 5 blue 6 6 brown 7 7 green 8

Re: [R] Mean Help

2012-10-31 Thread R. Michael Weylandt
Many forms, but I'll recommend this one this time around: aggregate(height ~ eyes, DATA, mean) See ?aggregate for an explanation of what aggregate() does and ?formula for an explanation of the tilde syntax. Note that this assumes your column names are "height" and "eyes." Adjust as needed. Mich

Re: [R] mean of a value of the last 2 hours using plyr (Thank you)

2012-10-26 Thread Tagmarie
Hi dear three helpers, Thanks a lot! Your solutions worked great. Again I learned a lot. Tagmarie Am 25.10.2012 18:36, schrieb Felipe Carrillo: > Another option using plyr, > library(plyr) > myframe <- data.frame (ID=c("Ernie", "Ernie", "Ernie", "Bert", "Bert", > "Bert"), Timestamp=c("24.09.2012

Re: [R] mean of a value of the last 2 hours

2012-10-25 Thread Felipe Carrillo
Or using ddply from plyr,   library(plyr) myframe <- data.frame (ID=c("Ernie", "Ernie", "Ernie", "Bert", "Bert", "Bert"), Timestamp=c("24.09.2012 09:00", "24.09.2012 10:00", "24.09.2012 11:00"), Hunger=c(1,1,1,2,2,1) ) myframe myframestime <- as.POSIXct (strptime(as.character(myframe$Timestamp), "%

Re: [R] mean of a value of the last 2 hours

2012-10-25 Thread S Ellison
> > I want to add an additional column at the right and get in > each row a value which shows the mean of "hunger" of the last two hours. Isn't that just a moving average? if so, see http://stackoverflow.com/questions/743812/calculating-moving-average-in-r, which mentions zoo for RollingMeans,

Re: [R] mean of a value of the last 2 hours

2012-10-25 Thread Rui Barradas
Hello, Or ct <- cut(myframe2$myframestime, breaks = "2 hour") ave(myframe2$Hunger, ct) And assign the output of 'ave' to a new column. Hope this helps, Rui Barradas Em 25-10-2012 15:50, arun escreveu: Hi, May be this helps: new1<-with(myframe2,aggregate(cbind(Hunger,myframestime),by=list(

Re: [R] mean of a value of the last 2 hours

2012-10-25 Thread arun
Hi, May be this helps:  new1<-with(myframe2,aggregate(cbind(Hunger,myframestime),by=list(ID=ID), function(x) mean(tail(x,2[,1:2]  merge(myframe2,new1,by="ID",all=TRUE) # ID Hunger.x    myframestime Hunger.y #1  Bert    2 2012-09-24 09:00:00  1.5 #2  Bert    2 2012-09-24 10:

Re: [R] mean value calculation

2012-10-18 Thread arun
Hi, Are you looking for something like this? #dat1 aggregate(dat1[,2:4],by=list(dat1[,1]),FUN=mean) #  Group.1 val1 val2. val3 #1 AKT  2.2  5.00    6 #2 CKT  4.5  5.75    7 A.K. - Original Message - From: Nico Met To: R help Cc: Sent: Thursday, October 18, 2012 11:59 AM Sub

Re: [R] mean-aggregate – but use unique for factor variables

2012-09-25 Thread Bert Gunter
In the absence of data via dput() or other wise I would assume that if you made your function FUN something like: function(x) if(is.factor(x)) unique(x) else mean(x) (or maybe length(unique(x)) as first clause) you'd get what you want. No? On Tue, Sep 25, 2012 at 2:32 PM, Martin Batholdy

Re: [R] Mean calculation of groups

2012-09-25 Thread Rui Barradas
Hello, Or ?tapply. ave will return a vector with the length of the input, tapply just one value per group. ave(test$Score, test$Name, FUN = mean) # 24 values tapply(test$Score, test$Name, FUN = mean) # 3 values Hope this helps, Rui Barradas Em 25-09-2012 15:54, Bert Gunter escreveu: Nic

Re: [R] Mean calculation of groups

2012-09-25 Thread Bert Gunter
Nico: 1. Thanks for the example. 2. Please read -- or at least peruse -- the tutorial, An Introduction to R (or other tutorial that you might find on the Web, there are many) to familiarize yourself with R's features. 3. This is an example of what the apply() family of functions can do, so you m

Re: [R] Mean of matched data

2012-07-18 Thread robgriffin247
got it... another merge did the trick narrow6<-merge(narrow2,narrow5,by=c("gene","gender")) Thanks for the help Rui -- View this message in context: http://r.789695.n4.nabble.com/Mean-of-matched-data-tp4636856p4636877.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] Mean of matched data

2012-07-18 Thread robgriffin247
Thanks, in a way this has worked... with a slight modification to this: narrow3<-aggregate(narrow2$value~narrow2$gene+narrow2$gender,data=narrow2,mean) narrow4<-aggregate(narrow2$value~narrow2$gene+narrow2$gender,data=narrow2,sd) which gives a table of the 24000 gene&gender means (narro

Re: [R] Mean of matched data

2012-07-18 Thread Peter Ehlers
On 2012-07-18 04:27, Rui Barradas wrote: Helo, All problems should be easy. d <- read.table(text=" gene variable value gender line rep 1 CG1 X208.F1.30456 4.758010 Female 208 1 2 CG1 X365.F2.30478 4.915395 Female 365 2 3 CG1 X799.F2.30509 4.641636 Female 799 2 4 CG1 X306.M2.326

Re: [R] Mean of matched data

2012-07-18 Thread Rui Barradas
Helo, All problems should be easy. d <- read.table(text=" gene variable value gender line rep 1 CG1 X208.F1.30456 4.758010 Female 208 1 2 CG1 X365.F2.30478 4.915395 Female 365 2 3 CG1 X799.F2.30509 4.641636 Female 799 2 4 CG1 X306.M2.32650 4.550676 Male 306 2 5 CG1 X712.M2.3

Re: [R] Mean of simulation runs given in a table

2012-01-19 Thread Irek Szczesniak
;> Behalf Of Ireneusz >> Szczesniak >> Sent: Tuesday, January 17, 2012 2:43 PM >> To: r-help@r-project.org >> Subject: Re: [R] Mean of simulation runs given in a table >> >> Thank you, Uwe, for your help!  I have more measurements (m1, m2) and >> more par

Re: [R] Mean of simulation runs given in a table

2012-01-17 Thread William Dunlap
z > Szczesniak > Sent: Tuesday, January 17, 2012 2:43 PM > To: r-help@r-project.org > Subject: Re: [R] Mean of simulation runs given in a table > > Thank you, Uwe, for your help! I have more measurements (m1, m2) and > more parameters (par1, par2). I can calculate the means of

Re: [R] Mean of simulation runs given in a table

2012-01-17 Thread Ireneusz Szcześniak
Thank you, Uwe, for your help! I have more measurements (m1, m2) and more parameters (par1, par2). I can calculate the means of m1 and m2 this way: aggregate(cbind(m1, m2) ~ par1 + par2, dat, mean) However, I also need to calculate the standard error of the mean, and the variance for the sa

  1   2   >