Às 00:22 de 25/10/2023, Sorkin, John escreveu:
Colleagues,
I have written an R function (see fully annotated code below), with which I
want to process a dataframe within levels of the variable StepType. My program
works, it processes the data within levels of StepType, but the usual headers
t
Dear John,
Printing inside the function is problematic. Your function itself does
NOT print the labels.
Just as a clarification:
F = factor(rep(1:2, 2))
by(data.frame(V = 1:4, F = F), F, function(x) { print(x); return(NULL); } )
# V F
# 1 1 1
# 3 3 1
# V F
# 2 2 2
# 4 4 2
# F: 1 <- this i
Colleagues,
I have written an R function (see fully annotated code below), with which I
want to process a dataframe within levels of the variable StepType. My program
works, it processes the data within levels of StepType, but the usual headers
that separate the output by levels of StepType are
Hello,
These two gives the same results:
aggregate(values ~ sex + status, mydata, sum)
# sex status values
#1 0 0 224
#2 1 0 5227
#3 0 1 11
#4 1 1 552
by(mydata$values, list(mydata$sex, mydata$status), sum)
#: 0
#: 0
#[1] 224
#-
On 2020-07-24 01:48 +0200, Rasmus Liland wrote:
> aggregate(x=list("values"=mydata$values),
> by=list("sex"=mydata$sex,
> "status"=mydata$status),
> FUN=sum)
>
> yields
>
> sex status values
> 1 0 0224
>
On 2020-07-23 18:54 -0400, Duncan Murdoch wrote:
> On 23/07/2020 6:15 p.m., Sorkin, John wrote:
> > Colleagues,
> > The by function in the R program below is not giving me the sums
> > I expect to see, viz.,
> > 382+170=552
> > 4730+170=4900
> > 5+6=11
> > 199+25=224
> > ###
On 23/07/2020 6:15 p.m., Sorkin, John wrote:
Colleagues,
The by function in the R program below is not giving me the sums
I expect to see, viz.,
382+170=552
4730+170=4900
5+6=11
199+25=224
###
#full R program:
mydata <- data.frame(covid=c(0,0,0,
by() chooses **data frame** subsets -- sum() is acting on these frames,
adding up everything in them.
Try this instead:
> by(mydata,list(mydata$sex,mydata$status),function(x)sum(x$values))
: 0
: 0
[1] 224
---
: 1
: 0
[1] 5227
Colleagues,
The by function in the R program below is not giving me the sums
I expect to see, viz.,
382+170=552
4730+170=4900
5+6=11
199+25=224
###
#full R program:
mydata <- data.frame(covid=c(0,0,0,0,1,1,1,1),
sex=(rep(c(1,1,0,0),2)),
status=rep(
chr "by"
You maybe should consult ?aggregate.
Cheers.
Petr
-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of ???
Sent: Thursday, April 20, 2017 2:17 AM
To: r-help
Subject: [R] by function error
hi, I practice R programing by the step in &
hi, I practice R programing by the step in <>;
when i test by function, i get error like these;
call for help!
dstats <- function(x){c(mean=mean(x), sd=sd(x))}
> by(mtcars[,c('mpg', 'hp')], mtcars$am, dstats)
Show Traceback
Rerun with Debug
Error in is.data.frame(x) :
(list) object canno
10 24 43
6B H 13 17 28
-
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 O
Good day,
Yes, exactly. I found that aggregate is another alternative which doesn't
require a package dependency, although the column formatting is less suitable,
always prepending x.
aggregate(warpbreaks[, 1], warpbreaks[, 2:3], function(breaks) c(Min =
min(breaks), Med = median(breaks), Max
Do you want something like the following?
> library(dplyr, quietly=TRUE, warn.conflicts=FALSE)
> warpbreaks %>% group_by(wool, tension) %>% summarize(Min=min(breaks),
> Median=median(breaks), Max=max(breaks))
Source: local data frame [6 x 5]
Groups: wool
wool tension Min Median Max
1A
Good day,
How is it possible to get a data.frame of factor levels used for obtaining each
element of the result of the by function ? For example,
result <- by(warpbreaks[, 1], warpbreaks[, -1], summary)
> result
wool: A
tension: L
Min. 1st Qu. MedianMean 3rd Qu.Max.
25.00 26.0
0 m 255 60
A.K.
- Original Message -
From: "Ray DiGiacomo, Jr."
To: R Help
Cc:
Sent: Friday, January 4, 2013 12:00 AM
Subject: [R] "By" function Frame Conversion (with Multiple Indices)
Hello,
I have the following dataset. Please note that ther
On Jan 3, 2013, at 9:00 PM, Ray DiGiacomo, Jr. wrote:
Hello,
I have the following dataset. Please note that there are missing
values on
records 4 and 5:
id,age,weight,height,gender
1,22,180,72,m
2,13,100,67,f
3,5,40,40,f
4,6,42,,f
5,12,98,66,
6,50,255,60,m
I'm using the "By" function lik
Hello,
I have the following dataset. Please note that there are missing values on
records 4 and 5:
id,age,weight,height,gender
1,22,180,72,m
2,13,100,67,f
3,5,40,40,f
4,6,42,,f
5,12,98,66,
6,50,255,60,m
I'm using the "By" function like this:
list1 <- by(dataset[c("weight", "height")],
Liviu,
Thanks for your attention and help!
Sorry for attached csv file, I didn't read R-Help Posting guide
careful. Another R-helper thaught me use de dput() function, and this
output are in email's end.
Your correction in my code works pretty well!! Now I can understand a
little more how the R
Hello
On Fri, Apr 8, 2011 at 12:38 AM, Raoni Rodrigues
wrote:
> Hello all!
>
> I have a data frame with nine variables and 293 cases. (attached goes
> the csv file).
>
The CSV didn't get through so it's difficult to replicate your
example. Please post the output of:
str(cpue)
> I need to calcul
Hello all!
I have a data frame with nine variables and 293 cases. (attached goes
the csv file).
I need to calculate a index using the sum of one variable (N) divided
by the length of other variable (Fisherman), but for each day (Date).
I tried to use that codes:
by (cpue, cpue$Date, function (x
sage
> news:77eb52c6dd32ba4d87471dcd70c8d7000243c...@na-pa-vbe03.na.tibco.com...
>> -Original Message-
>> From: r-help-boun...@r-project.org
>> [mailto:r-help-boun...@r-project.org] On Behalf Of L.A.
>> Sent: Saturday, December 12, 2009 12:39 PM
>> To: r-help@
You asked how to 'create confidence intervals around the median'. Since
intervals was plural and you asked within the context of 'by' LEAID then
that made sense and I guessed you meant 'confidence interval around the
median ratio of each group'. I already assumed you had posted a small subset
o
Thanks, but that produces what I think is an estimated interval.
I really want to use the above formula. I just can't figure out how to
get it to run by the LEAID.
It does require 9 observations to produce an interval, but I was showing a
sample.
Thanks again.
L.A.
Matthew Dowle-3 wrote:
>
>
Maybe this (with enough data for a CI) ? :
> Dataset = data.table(Dataset)
> Dataset[,as.list(wilcox.test(ratio,conf.int=TRUE)$conf.int),by="LEAID"]
LEAID V1 V2
[1,] 6307 0.720 0.92
[2,] 8300 0.5678462 0.83
Warning messages:
1: In switch(alternative, two.sided
Well, I'm back again.
Thanks for all the help. Besides working, it's helping me begin to
understand how these functions work.
I still have trouble reading or following the process of a function, which
brings my next question:
Dataset:
LEAID ratio
3 6307 0.720
1 6307 0.7623810
-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of L.A.
> Sent: Saturday, December 12, 2009 12:39 PM
> To: r-help@r-project.org
> Subject: Re: [R] by function ??
>
>
>
> Thanks for all the help, They all worked, But I'm stuck again.
> I've
On Dec 12, 2009, at 3:38 PM, L.A. wrote:
Thanks for all the help, They all worked, But I'm stuck again.
I've tried searching, but I not sure how to word my search as
nothing came
up.
Here is my new hurdle, my data has 7 abservations and my results
have 2
answers:
Here is my data
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of L.A.
> Sent: Saturday, December 12, 2009 12:39 PM
> To: r-help@r-project.org
> Subject: Re: [R] by function ??
>
>
>
> Thanks for all the help,
Thanks for all the help, They all worked, But I'm stuck again.
I've tried searching, but I not sure how to word my search as nothing came
up.
Here is my new hurdle, my data has 7 abservations and my results have 2
answers:
Here is my data
LEAID ratio
3 6307 0.720
1 6307
other
situations.
Michael
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of Ista Zahn
> Sent: Mittwoch, 9. Dezember 2009 02:54
> To: L.A.
> Cc: r-help@r-project.org
> Subject: Re: [R] by function ??
&
Hi,
I think you want
by(TestData[ , "RATIO"], LEAID, median)
-Ista
On Tue, Dec 8, 2009 at 8:36 PM, L.A. wrote:
>
> I'm just learning and this is probably very simple, but I'm stuck.
> I'm trying to understand the by().
> This works.
> by(TestData, LEAID, summary)
>
> But, This doesn't.
>
> by
I'm just learning and this is probably very simple, but I'm stuck.
I'm trying to understand the by().
This works.
by(TestData, LEAID, summary)
But, This doesn't.
by(TestData, LEAID, median(RATIO))
ERROR: could not find function "FUN"
HELP!
Thanks,
LA
--
View this message in context:
http
I have a longitudinal data set in long format and I want to run
individual regressions. I do this by using the by() function as
follows:
temp <- by(tolerance.pp, tolerance.pp$id, function(x)
summary(lm(tolerance ~ time, data=x)))
This works fine. Coefficients for the first two subjects ar
Please give minimal reproducible examples.
The data and a test driver were missing.
See last line to every message to r-help.
The problem is discussed here:
http://tolstoy.newcastle.edu.au/R/help/06/08/32017.html
On Mon, Feb 25, 2008 at 10:05 AM, vincent chouraki <[EMAIL PROTECTED]> wrote:
> Dear
Dear R users,
I'm trying to save the results of separate logistic regression analyses of a
dataset according to a categorical factor. For that, I first used a "by"
function such as following :
temp <- by( data, data$categorical.factor , function(x) summary( glm( formula =
data$var1 ~ data$var
36 matches
Mail list logo