Da: Gabor Grothendieck
Inviato: lunedì 7 agosto 2023 20:30
A: Stefano Sofia
Cc: r-help@R-project.org
Oggetto: Re: [R] group consecutive dates in a row
It is best to use Date, rather than POSIXct, class if there are no times.
Use the cumsum expression
It is best to use Date, rather than POSIXct, class if there are no times.
Use the cumsum expression shown to group the dates and then summarize
each group.
We assume that the dates are already sorted in ascending order.
library(dplyr)
mydf <- data.frame(date = as.Date(c("2012-02-05",
Here is another way to obtain the day differences that is the argument
of rle() . It is perhaps more reliable in that it uses methods for
class POSIXct rather than depending on the underlying class structure
and conversion via as.numeric. In theory, the methods won't change or
any changes will be
rle(as.numeric(diff(mydf$data_POSIX))) should get you started, I think?
On 2023-08-07 12:41 p.m., Stefano Sofia wrote:
Dear R users,
I have a data frame with a single column of POSIXct elements, like
mydf <- data.frame(data_POSIX=as.POSIXct(c("2012-02-05", "2012-02-06", "2012-02-07",
Dear R users,
I have a data frame with a single column of POSIXct elements, like
mydf <- data.frame(data_POSIX=as.POSIXct(c("2012-02-05", "2012-02-06",
"2012-02-07", "2012-02-13", "2012-02-21"), format = "%Y-%m-%d", tz="Etc/GMT-1"))
I need to transform it in a two-columns data frame where I
Hi everyone,
I have the following dataframe:
structure(list(Department = c("A", "A", "A", "A", "A", "A", "A",
"A", "B", "B", "B", "B", "B", "B", "B", "B"), Class = c(1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), Value = c(0L,
100L, 800L, 800L, 0L,
Hello, Elahe,
you were, of course, supposed to insert my suggested
code-snippet into you code and test it therein ...
Regards -- Gerrit
-
Dr. Gerrit Eichner Mathematical Institute, Room 212
Hello Gerit
mutate(MinValue = min(Value[Value != 0]) ) or mutate(MinValue =
sort(unique(Value))[2]) only mutates one value which is 100, it doesnt mutate
minimum Value != 0 per group by element
On Tuesday, May 11, 2021, 01:26:49 PM GMT+2, Gerrit Eichner
wrote:
Homework?
Try
Hello,
This can be done by getting the min of Value[Value != 0].
In the code that follows I have named the expected output df2 and
assigned the result to df3 and df4.
library(dplyr)
df3 <- df %>%
group_by(Department,Class) %>%
mutate(flag = Value != 0,
MinValue = min(Value[flag]) )
Homework?
Try maybe
mutate(MinValue = min(Value[Value != 0]) )
or
mutate(MinValue = sort(unique(Value))[2])
Hth -- Gerrit
-
Dr. Gerrit Eichner Mathematical Institute, Room 212
Hi all,
I have the following data frame
dput(df)
structure(list(Department = c("A", "A", "A", "A", "A", "A", "A",
"A", "B", "B", "B", "B", "B", "B", "B", "B"), Class = c(1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), Value = c(0L,
100L, 800L, 800L, 0L, 300L, 1200L,
Hi carol,
You could use the "I" function, which will just return what you pass to it.
Jim
On Thu, Mar 10, 2016 at 12:28 AM, carol white via R-help
wrote:
> What should be FUN in aggregate as no function like mean, sum etc will be
> applied
> Carol
>
> On Wednesday,
On Wed, Mar 9, 2016 at 8:28 AM, carol white wrote:
> What should be FUN in aggregate as no function like mean, sum etc will be
> applied
I have no idea, since you haven't told us what you want the results to
look like.
> Carol
>
>
> On Wednesday, March 9, 2016 1:59 PM, Sarah
gt; From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of carol
> white via R-help
> Sent: Wednesday, March 09, 2016 2:28 PM
> To: Sarah Goslee
> Cc: R-help Help
> Subject: Re: [R] group by rows
>
> What should be FUN in aggregate as no function like
> How is it possible to group rows of a matrix or a data frame by the same
> values
> of the first column?
If you mean _group_ as in SQL GROUP BY, use aggregate() with a count or summary
statistic.
If you mean _sort_, just to get similar values close together, use order()
For example, to
What should be FUN in aggregate as no function like mean, sum etc will be
applied
Carol
On Wednesday, March 9, 2016 1:59 PM, Sarah Goslee
wrote:
Possibly aggregate(), but you posted in HTML so your data were mangled.
Please use dput(), post in plain text, and
Possibly aggregate(), but you posted in HTML so your data were mangled.
Please use dput(), post in plain text, and try to explain more clearly
what you want the result to look like.
Sarah
On Wed, Mar 9, 2016 at 7:09 AM, carol white via R-help
wrote:
> How is it possible
How is it possible to group rows of a matrix or a data frame by the same values
of the first column?
1 14331 453452 653 3762 45
1 1433,453452 45, 653 376
Thanks
Carol
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
Hello,
I work with the kruskla function of the agricolae package to conduct
Kurskal-Wallis tests.
The kurskal function has the argument "group"=T/F.
If group=T, the output of the kruskal test assigns a "significance letter" to
each mean of each tested treatment (means with the same letter are
Dear group,
kindly, I have the following data frame
structure(c(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2,
3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1.5, 2, 1, 0, 2, 2, 1.5,
0, 0, 1, 1, 2, 0, 1, 2), .Dim = c(15L, 3L), .Dimnames = list(
NULL, c("i", "Measure_id", "value")))
it has 3
??
Row 4 has i = 2 and Measure_id =4 and therefore has value divided by
the max of all values with that i and Measure_id, which is 1. Row 7
has i =2 and Measure_id =2, and so is divided by the max value in all
rows with those values of i and Measure_id, which is 2. etc. So either
you do not
many thanks for replying,
yes I am kindly accept my pardon, I mistaken the rows from each other many
thanks I will read them.
Ragia
> Date: Sat, 7 Nov 2015 07:48:36 -0800
> Subject: Re: [R] group by function
> From: bgunter.4...@gmail.com
&
Dear R experts,
Having an ordinal response (3 levels) and factors in the predictors set,
I would like to fit Proportional Odds Group Lasso.
I found several packages that fit the group lasso:
grplasso, grpreg, gglasso and ordPens.
However, they vary penalty and implementation in several ways,
yes thanks, that's correct!
here a slight variation inspired by your solution: a cartesian product
restricted to non duplicated records to get the logical vector i to be
used in the next natural join
i-!duplicated(merge(df1$id,df1$item, by=NULL))
merge(df1[i,],df2)
thanks
Il 08/05/2014
given this bare bone example:
df1 - data.frame(id=rep(1:3,each=2), item=c(rep(A,2), rep(B,2),
rep(C,2)))
df2 - data.frame(id=c(1,2,3), who=c(tizio,caio,sempronio))
I need to group the first dataframe df1 by id and then merge with
the second dataframe df2 (again by id)
so far I've manged to
Hello,
There are some alternatives without using sqldf or another package.
1.
tmp2 - aggregate(item ~ id, data = df1, FUN = unique)
Then merge() like you've done.
2.
tmp3 - merge(df1, df2)
tmp3[!duplicated(tmp3), ]
Hope this helps,
Rui Barradas
Em 08-05-2014 10:44, Massimo Bressan
Hi,
May be this helps:
merge(unique(df1),df2)
A.K.
On Thursday, May 8, 2014 5:46 AM, Massimo Bressan mbres...@arpa.veneto.it
wrote:
given this bare bone example:
df1 - data.frame(id=rep(1:3,each=2), item=c(rep(A,2), rep(B,2),
rep(C,2)))
df2 - data.frame(id=c(1,2,3),
yes, thank you for all your replies, they worked out correctly indeed...
...but because of my fault, by then working on my real data I fully
realised that I should have mentioned something that is changing (quite
a lot, in fact) the terms of the problem...
please would you consider the
Hi,
May be:
indx - !duplicated(as.character(interaction(df1[,-3])))
merge(df1[indx,],df2)
A.K.
On Thursday, May 8, 2014 12:34 PM, Massimo Bressan mbres...@arpa.veneto.it
wrote:
yes, thank you for all your replies, they worked out correctly indeed...
...but because of my fault, by then
holtman [jholt...@gmail.com]
Inviato: mercoledì 2 ottobre 2013 17.29
A: Stefano Sofia
Cc: r-help@r-project.org
Oggetto: Re: [R] Group all the consecutive days
try this:
rain - read.table(text = 'year month day rainfall landslide
+ 3 2007 6 6 1.6 0
+ 4 2007 6 7 1.8 0
+ 6 2007 6 12 4.6 0
+ 8 2007 7 5
Dear R-users,
I have a data frame where in each row there is the daily rainfall cumulative;
missing days mean that in that days rainfall has been zero.
I need to group all the consecutive days in a single row and store in the field
rainfall the sum of these consecutive days.
Is there a reasonable
try this:
rain - read.table(text = 'year month day rainfall landslide
+ 3 2007 6 6 1.6 0
+ 4 2007 6 7 1.8 0
+ 6 2007 6 12 4.6 0
+ 8 2007 7 5 6.6 0
+ 9 2007 7 10 3 0
+ 10 2007 7 11 1.2 0
+ 11 2007 8 3 6.4 0
+ 12 2007 8 10 2.8 0
+ 14 2007 9 4 5.4 0
+ 15 2007 9 5 1 0
+ 16 2007 9 10 2.8 0
+ 17 2007
: [R] Group all the consecutive days
Dear R-users,
I have a data frame where in each row there is the daily rainfall cumulative;
missing days mean that in that days rainfall has been zero.
I need to group all the consecutive days in a single row and store in the field
rainfall the sum
Hi
I'm trying to manipulate a data frame (that has about 10 million rows) rows
by grouping it with multiple columns. For example, say the data set looks
like:
Area
Sex
Year
y
Bob
F
2011
1
Bob
F
2011
2
Bob
F
2012
3
Bob
M
2012
3
Bob
M
2012
2
Fred
F
2011
1
michael.l...@hotmail.com
To: r-help@r-project.org
Cc:
Sent: Saturday, August 3, 2013 8:11 PM
Subject: [R] Group by a data frame with multiple columns
Hi
I'm trying to manipulate a data frame (that has about 10 million rows) rows
by grouping it with multiple columns. For example, say the data set
Of Jeff Newmiller
Sent: Wednesday, May 22, 2013 5:27 PM
To: Ye Lin; R help
Subject: Re: [R] group data based on row value
dat$group - cut( dat$Var, breaks=c(-Inf,0.1, 0.6,Inf))
levels(dat$group) - LETTERS[1:3]
---
Jeff Newmiller
hey, I want to divide my data into three groups based on the value in one
column with group name.
dat:
Var
0
0.2
0.5
1
4
6
I tried:
dat - cbind(dat, group=cut(dat$Var, breaks=c(0.1,0.6)))
But it doesnt work, I want to group those 0.1 as group A, 0.1-0.6 as group
B, 0.6 as group C
Thanks for
Hi,
Try:
dat- read.table(text=
Var
0
0.2
0.5
1
4
6
,sep=,header=TRUE)
res1-within(dat,group-factor(findInterval(Var,c(-Inf,0.1,0.6),rightmost.closed=TRUE),labels=LETTERS[1:3]))
res1
# Var group
#1 0.0 A
#2 0.2 B
#3 0.5 B
#4 1.0 C
#5 4.0 C
#6 6.0 C
#or
dat$group - cut( dat$Var, breaks=c(-Inf,0.1, 0.6,Inf))
levels(dat$group) - LETTERS[1:3]
---
Jeff NewmillerThe . . Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.
What if more generally that the group name doest have anything to do with
the ID, eg. for ID=AL1 and AL2, I want to name the group as Key1, how can
I approach that?
Thanks,
On Thu, Apr 11, 2013 at 11:54 AM, Rui Barradas ruipbarra...@sapo.pt wrote:
Hello,
Try the following.
dat -
1 Key1
#2 AL2 2 Key1
#3 CA1 3 Key2
#4 CA4 4 Key2
A.K.
- Original Message -
From: Ye Lin ye...@lbl.gov
To: Rui Barradas ruipbarra...@sapo.pt
Cc: R help r-help@r-project.org
Sent: Monday, April 15, 2013 11:50 AM
Subject: Re: [R] group data
What if more generally
Hey,
I have a dataset and I want to identify the records by groups for further
use in ggplot.
Here is a sample data:
ID Value
AL1 1
AL2 2
CA1 3
CA4 4
I want to identify all the records that in the same state (AL1 AND A2),
group them as AL, and do the same for CA1 and CA4. How can I have
Hello,
Try the following.
dat - read.table(text =
ID Value
AL1 1
AL2 2
CA1 3
CA4 4
, header = TRUE, stringsAsFactors = FALSE)
dat$State - substr(dat$ID, 1, 2)
Note that this dependes on having State being defined by the first two
characters of ID.
Hope this helps,
Rui Barradas
Thanks!
But What if I have a very large data with 1000+rows, anyway to identify all
AL1 and AL2 under ID and mark them as AL under new column State?
Thanks.
On Thu, Apr 11, 2013 at 11:54 AM, Rui Barradas ruipbarra...@sapo.pt wrote:
Hello,
Try the following.
dat - read.table(text =
ID
Hi,
dat1- read.table(text=
ID Value
AL1 1
AL2 2
CA1 3
CA4 4
,sep=,header=TRUE,stringsAsFactors=FALSE)
dat2- dat1
dat1$State-gsub(\\d+,,dat1$ID)
dat1
# ID Value State
#1 AL1 1 AL
#2 AL2 2 AL
#3 CA1 3 CA
#4 CA4 4 CA
#or
library(stringr)
I think I just misinterpret~Thanks for your help~
On Thu, Apr 11, 2013 at 11:54 AM, Rui Barradas ruipbarra...@sapo.pt wrote:
Hello,
Try the following.
dat - read.table(text =
ID Value
AL1 1
AL2 2
CA1 3
CA4 4
, header = TRUE, stringsAsFactors = FALSE)
dat$State -
Hello all!
I have a problem to group my data (years) in 10 years classes. For example
for year
year decade
1598 1590-1600
1599 1590-1600
1600 1590-1600
1601 1600-1610
---
my is like this
[1] 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611
1612
[16] 1613 1614 1615
brs - seq(1590,2000,by=10)
lbs - paste(brs[-length(brs)],brs[-1],sep=-)
y - cut(x,breaks=brs,labels=lbs) # Where x is your data vector.
grpd - data.frame(year=x,decade=y)
head(grpd)
yeardecade
1 1598 1590-1600
2 1599 1590-1600
3 1600 1590-1600
4 1601 1600-1610
5 1602 1600-1610
6 1603
-1600
#2 1599 1590-1600
#3 1600 1590-1600
#4 1601 1600-1610
#5 1602 1600-1610
A.K.
- Original Message -
From: catalin roibu catalinro...@gmail.com
To: r-help@r-project.org
Cc:
Sent: Sunday, April 7, 2013 3:47 AM
Subject: [R] group data in classes
Hello all!
I have a problem to group my data
On 04.01.2013 17:10, catalin roibu wrote:
Dear R users,
I want to group the d values in classes. If I use this script I have a
problem.
classes - function(x, n){
s - seq(0, ceiling(max(x)), by = n)
factor(n*findInterval(x, s), levels = s)
}
z-sapply(tapply(t$d,t$plot,function(x)
Dear R users,
I want to group the d values in classes. If I use this script I have a
problem.
classes - function(x, n){
s - seq(0, ceiling(max(x)), by = n)
factor(n*findInterval(x, s), levels = s)
}
z-sapply(tapply(t$d,t$plot,function(x) classes(t$d, 4)),table)
z-cbind(z)
Thank you!
Initial
Dear R users,
I want to group numerical values in classes with different size and count
the values for each classes.
My data is in this forma:
d 15 12,5 30,4 20,5 80,4 100,5 8,2 40,5 33 21 11
And I want the group them in classes with 4 (5,etc) cm size like this:
class d 16 16
Hello,
Try the following.
classes - function(x, n){
n*findInterval(x, seq(0, ceiling(max(x)), by = n))
}
c4 - classes(d, 4)
table(c4)
sum(table(c4))
Happy new year,
Rui Barradas
Em 31-12-2012 10:13, catalin roibu escreveu:
Dear R users,
I want to group numerical values in classes with
At Mon, 31 Dec 2012 12:13:43 +0200,
catalin roibu wrote:
Dear R users,
I want to group numerical values in classes with different size and count
the values for each classes.
My data is in this forma:
d 15 12,5 30,4 20,5 80,4 100,5 8,2 40,5 33 21 11
And I want the group them
Hi there,
I have a task of two group samples' comparison for ordinal variable, the
possible values are from 0 to 4 with many many ties for about 60 samples
totally. I am wondering which wilcox test like a regular wilcox.test in R
or the version wilcox_test in package coin can do this job or not;
Hi there,
I have a task of two group samples' comparison for ordinal variable, the
possible values are from 0 to 3 with many many ties for about 60 samples
totally. I am wondering if wilcox test is a proper one and which wilcox
test like a regular wilcox.test in R or the version wilcox_test in
Hello,
I can get the median for each factor, but I'd like another column to go
with each factor. The nm column is a long name for the lvls column. So
unique work except for the order can get messed up.
Example:
x =
aggregate(val~lvls+nm,data=x,FUN='median')
On Tue, Feb 28, 2012 at 4:43 PM, Ben quant ccqu...@gmail.com wrote:
Hello,
I can get the median for each factor, but I'd like another column to go
with each factor. The nm column is a long name for the lvls column. So
unique work except for the
Excellent! I wonder why I haven't seen aggregate before.
Thanks!
ben
On Tue, Feb 28, 2012 at 4:51 PM, ilai ke...@math.montana.edu wrote:
aggregate(val~lvls+nm,data=x,FUN='median')
On Tue, Feb 28, 2012 at 4:43 PM, Ben quant ccqu...@gmail.com wrote:
Hello,
I can get the median for
Dear R-experts,
I am struggling with the following problem, and I am looking for advice
from more experienced R-users: I have a data frame with 2 identifying
variables (comn and mi), and an output variable (x). comn is a variable for
a company and mi is a variable for a month.
comn-c(abc, abc,
@r-project.org
Sent: Sunday, December 4, 2011 12:32 PM
Subject: [R] Group several variables and apply a function to the group
Dear R-experts,
I am struggling with the following problem, and I am looking for advice
from more experienced R-users: I have a data frame with 2 identifying
variables (comn
://www.fws.gov/redbluff/rbdd_jsmp.aspx
*From:* Aurélien PHILIPPOT aurelien.philip...@gmail.com
*To:* R-help@r-project.org
*Sent:* Sunday, December 4, 2011 12:32 PM
*Subject:* [R] Group several variables and apply a function to the group
Dear R-experts,
I am struggling with the following
Aurélien PHILIPPOT wrote
Dear R-experts,
I am struggling with the following problem, and I am looking for advice
from more experienced R-users: I have a data frame with 2 identifying
variables (comn and mi), and an output variable (x). comn is a variable
for
a company and mi is a variable
: Aurélien PHILIPPOT aurelien.philip...@gmail.com
Subject: [R] Group several variables and apply a function to the group
To: R-help@r-project.org
Received: Sunday, December 4, 2011, 3:32 PM
Dear R-experts,
I am struggling with the following problem, and I am
looking for advice
from more
Using the reshape2 package
library(reshape2)
x1 - melt(df, id=c(comn, mi))
dcast(x1, comn + mi ~ variable, sd)
--- On Sun, 12/4/11, Aurélien PHILIPPOT aurelien.philip...@gmail.com wrote:
From: Aurélien PHILIPPOT aurelien.philip...@gmail.com
Subject: [R] Group several variables
I have been searching the web for an answer on whether there is a package for
group-based trajectory modeling in R. Something along the lines of what PROC
TRAJ (http://www.andrew.cmu.edu/user/bjones/index.htm) accomplishes in SAS.
Does anyone have any experience working with a package that
Hello,
the more general thing I'd like to learn here is how to compute Function of
Data on the basis of grouping determiend by n variables.
In terms of the reason why I am interested in this, I need to compute the
average of my data based on the value of the month and day across years. I
have
Actually to get exactly what I want I need to add
no.dimnames(AvgDemand )
where
no.dimnames - function(a) {
## Remove all dimension names from an array for compact printing.
d - list()
l - 0
for(i in dim(a)) {
d[[l - l + 1]] - rep(, i)
}
Dear UseRs,
I built varying coefficient models (in mgcv) for two groups separately, with
one explanatory and one moderator variable (see the example below).
# ---
# Example:
# --
# generate moderator variable (can the same for both groups)
modvar - c(1:1000)
# generate group1
Hello,
I would like to create a group variable that is based on the values of three
variables:
For example,
dat - data.frame(A=c(1,1,1,1,1,2,2,2,2,2),
B=c(1,1,1,5,5,5,9,9,9,9),
C=c(1,1,1,1,1,2,2,7,7,7))
dat
A B C
1 1 1 1
2 1 1 1
3 1 1 1
4 1
Hi,
There are probably much better ways, but try this
transform(dat, group = as.numeric(factor(paste(A,B,C, sep=
HTH,
baptiste
On 31 May 2011 09:47, Mendolia, Franco fmendo...@mcw.edu wrote:
Hello,
I would like to create a group variable that is based on the values of three
On Mon, 30 May 2011 16:47:45 -0500,
Mendolia, Franco fmendo...@mcw.edu wrote:
Hello, I would like to create a group variable that is based on the
values of three variables:
For example,
dat - data.frame(A=c(1,1,1,1,1,2,2,2,2,2),
B=c(1,1,1,5,5,5,9,9,9,9),
Hi Jim,
I think i sorted it out how to read and write each vector separately. Thanks
a lot. It was exactly what i wanted to do.
best,
salih
On Sat, May 21, 2011 at 11:41 PM, jim holtman jholt...@gmail.com wrote:
Is this what you are after:
x = c(1 ,2 ,4 ,7 ,9 ,10 ,15)
# partition if the
Hi everyone,
i am trying to group close numbers in a vector.
For example i have a vector x = [1 2 4 7 9 10 15].
I want the code to pick 1 2 4 (max difference between successive numbers is
2) and assign them to variable a, then pick 7 9 10 and assign them to b and
15 to c. But since i do not know
Hi everyone,
i am trying to group close numbers in a vector.
For example i have a vector x = [1 2 4 7 9 10 15].
I want the code to pick 1 2 4 (max difference between successive numbers
is
2) and assign them to variable a, then pick 7 9 10 and assign them to b
and
15 to c. But since i do not
Hi Robert,
thanks for your reply. is there a way to store them in separate vectors?
and when i try it with a different example i got different result. For
example if x = [1 2 8 9]
i want the result to be x1 = [1 2] and x2 = [8 9].
thanks
On Sat, May 21, 2011 at 7:16 PM, Robert Baer rb...@atsu.edu
Is this what you are after:
x = c(1 ,2 ,4 ,7 ,9 ,10 ,15)
# partition if the difference is 2)
breaks - cumsum(c(0, diff(x) 2))
# partition into different lists
split(x, breaks)
$`0`
[1] 1 2 4
$`1`
[1] 7 9 10
$`2`
[1] 15
On Sat, May 21, 2011 at 6:03 PM, Salih Tuna saliht...@gmail.com
Yes this is exactly what i want, thanks Jim.
One last question, (i am sure this is a very simple question but i am still
learning) how can i write the output to a txt file seperately?
vector 1 to one file and vector 2 to another and etc?
thanks
salih
On Sat, May 21, 2011 at 11:41 PM, jim
Hi
I have four groups
y1=c(1.214,1.180,1.199)
y2=c(1.614,1.710,1.867,1.479)
y3=c(1.361,1.270,1.375,1.299)
y4=c(1.459,1.335)
Is there a function that can give me the length for each, like the made up
example below?
function(length(y1:y2)
[1] 3 4 4 2
[[alternative HTML version
require(plyr)
laply(list(y1, y2, y3, y4), length)
Scott
On Thursday, May 12, 2011 at 11:50 AM, Asan Ramzan wrote:
Hi
I have four groups
y1=c(1.214,1.180,1.199)
y2=c(1.614,1.710,1.867,1.479)
y3=c(1.361,1.270,1.375,1.299)
y4=c(1.459,1.335)
Is there a function that can give me the length
: Thursday, May 12, 2011 12:50 PM
To: r-help@r-project.org
Subject: [R] group length
Hi
I have four groups
y1=c(1.214,1.180,1.199)
y2=c(1.614,1.710,1.867,1.479)
y3=c(1.361,1.270,1.375,1.299)
y4=c(1.459,1.335)
Is there a function that can give me the length for each, like the made up
example
On Thu, May 12, 2011 at 10:00 AM, Ledon, Alain alain.le...@ally.com wrote:
sapply...
y1=c(1.214,1.180,1.199)
y2=c(1.614,1.710,1.867,1.479)
y3=c(1.361,1.270,1.375,1.299)
y4=c(1.459,1.335)
sapply(list(y1,y2,y3,y4), length)
[1] 3 4 4 2
Or, if you don't want to name each object individually:
Hello, I've been searching on the web for a few hours and seem to be stuck on
this. The code pasted below generates a histogram of subject responses in four
different conditions in an experiment. This version of the graph is one I'm
using for internal consistency checking, so I've set it up
Hi:
The problem with your panel.text() code is that y = Count is either 0 or 1,
so the labels never get off the ground, so to speak. Since groups =
StimCount, you don't need to specify StimCount in panel.text(); the groups
argument does that for you. The essential issue, AFAICT, is to coordinate
Hi all,
i have a little problem, and i think it is really simple to solve, but i
dont know exactly how to.
here is the challange:
i have a data.frame with n colum, i have to group 2 of them and calculate
the mean value of the 3. one. so far so good, that was easy - i used
aggregate function to
Hi,
I think ave() might do what you want:
df - data.frame(a=rep(c(this,that),5), b1=rnorm(10), b2=rnorm(10))
ave(df[,2], df[,1], FUN=mean)
For all columns, you could do that:
d - lapply(df[,2:3], FUN=function(x)ave(x,df[,1],FUN=mean))
df2 - cbind(df, d)
HTH,
Ivan
Le 2/25/2011 12:11, zem a
Date: Thu, 24 Feb 2011 13:28:18 -0800
From: dannyb...@gmail.com
To: r-help@r-project.org
Subject: Re: [R] Group rows by common ID and plot?
does this do what you want?
library(lattice)
df-data.frame(x=1:100,y=1.0/(1:100),f=floor((1:100
Hi Ivan,
thanks for your replay!
but the problem is there that the dataframe has 2 rows and ca. 2000
groups, but i dont have the column with the groupnames, because the groups
are depending on 2 onother columns ...
any other idea or i didnt understand waht are you posted ... :(
--
View
I imagine you want the ggplot2 package.
something like:
ggplot(dataframe, aes(x = yourxvar, y = youryvar)) +
geom_point() +
facet_wrap(~ ProbeSet.ID)
Or facet_grid(), either of which makes a different panel for each unique level
of ProbeSet.ID
see gggplot help here:
10x i solved it ... mein problem was that i had 2 column by them i have to
group, i just pasted the values together so that at the end i have one
column to group and then was easy ...
here is the script that i used:
http://tolstoy.newcastle.edu.au/R/help/06/07/30184.html
Ivan thanks for the help
Yeah, you are right
i want to post an short example what i want to do .. and in the meantime i
solved the problem ...
but here is:
i have something like this dataframe:
c1-c(1,2,3,2,2,3,1,2,2,2)
c2-c(5,6,7,7,5,7,5,7,6,6)
c3-rnorm(10)
x-cbind(c1,c2,c3)
x
c1 c2 c3
[1,] 1 5
Ok, now I think I've understood, but I'm not sure since I think that my
ave() solution does work. Although, I though you have several numerical
variables and 1 factor; it is the opposite but it is still possible:
c3_mean - ave(x[,3], list(x[,1],x[,2]), FUN=mean) #note that values
are
On Feb 25, 2011, at 10:14 AM, zem wrote:
Yeah, you are right
i want to post an short example what i want to do .. and in the
meantime i
solved the problem ...
but here is:
i have something like this dataframe:
c1-c(1,2,3,2,2,3,1,2,2,2)
c2-c(5,6,7,7,5,7,5,7,6,6)
c3-rnorm(10)
Hi:
Here's another way:
c1-c(1,2,3,2,2,3,1,2,2,2)
c2-c(5,6,7,7,5,7,5,7,6,6)
c3-rnorm(10)
x - data.frame(c1 = factor(c1), c2 = factor(c2), c3)
x - transform(x, mean = ave(c3, c1, c2, FUN = mean))
Yet another with function ddply() in package plyr:
ddply(x, .(c1, c2), transform, mean = mean(c3))
Thanks Mike - this doesn't quite do it, but I think that you've hit of the
right method.
I am just trying to use 'plot' initially - I don't care so much about the
arrangement in the file.
plot(df$y,group=df$f) outputs the Y column in the appropriate plot. What I
would like to do is have 10 Y
So to simplify this a bit:
Using dataframe:
name x1 x2 x3 x4 x5 x6 x7 x8
1 fred 2 3 4 6 7 8 9 12
2 fred 4 5 6 8 9 10 11 14
3 fred 6 7 8 10 11 12 13 16
4 fred 8 9 10 12 13 14 15 18
5 james 10 11 12 14 15 16 17 20
6 james 12 13 14 16 17 18 19 22
7 james 14 15 16 18
hi guys,
many many thanks for all the solutions! :-D they are working great!
i have another little question:
i would like to save these groups in a new column with serial number like
the solution from David, but wit integer values: 1,2,3...
i do this allready but with my 1. solution and there
ok, i have it - match()
10x all again! :)
--
View this message in context:
http://r.789695.n4.nabble.com/group-by-in-data-frame-tp3324240p3325269.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
In terms of a reproducible example:
ProbeSet.ID.F ProbeSet.ID Feature.ID Gene.Symbol X0030V120810.4
X0143V120110.4 X0258V111710.4 X0283V111710.4 X0430V120710.4 X0472V111610.4
X0520V111610.4 X0546V113010.4 X0578V111810.4 X0624V111810.4
7896741_479302 7896741 479302 OR4F17
Suspect that this is easier than I realize, but taking some figuring out
currently. Any help would be appreciated.
I have a data frame (testhm) with many rows such as:
ProbeSet.ID.F ProbeSet.ID Feature.ID G.S X0030V120810.14 X0143V120110.14
X0258V111710.14 X0283V111710.14 X0430V120710.14
1 - 100 of 172 matches
Mail list logo