Sorry, my typing was corrected by the computer.
When I have a NA, there should be a missing value.
So, if a group has 2 values and a NA, the two that have values, should be
replaced by the mean of the two,
the third should be NA.
The NA is the participant that dropped out.
On Tue, 17 Sept 2024 at
Hmmm... typos and thinkos ?
Maybe:
mean_narm<- function(x) {
m <- mean(x, na.rm = T)
if (is.nan (m)) NA else m
}
-- Bert
On Mon, Sep 16, 2024 at 4:40 PM CALUM POLWART wrote:
>
> Rui's solution is good.
>
> Bert's suggestion is also good!
>
> For Berts suggestion you'd make the list bit
>
Rui's solution is good.
Bert's suggestion is also good!
For Berts suggestion you'd make the list bit
list(mean = mean_narm)
But prior to that define a function:
mean_narm<- function(x) {
m <- mean(x, na.rm = T)
if (!is.Nan (m)) {
m <- NA
}
return (m)
}
Would do what you suggested in your r
Dear Francesca,
As Rolf already pointed out, please provide more comprehensible information.
As shot into the blue, excluding the NAs when calculating the mean might help:
> mean(c(3, 5, NA))
[1] NA
> mean(c(3, 5, NA), na.rm = TRUE)
[1] 4
Cheers,
Thomas
Von:
Às 15:23 de 16/09/2024, Francesca escreveu:
Sorry for posting a non understandable code. In my screen the dataset
looked correctly.
I recreated my dataset, folllowing your example:
test<-data.frame(matrix(c( 8, 8, 5 , 5 ,NA ,NA , 1, 15, 20, 5, NA, 17,
2 , 5 , 5, 2 , 5 ,NA, 5 ,10, 10, 5
Incidentally, if you intend to use these means for further analytical
purposes, you may produce irreproducible conclusions: after all, a
mean of 10 things is more *meaningful* than a mean of 2. However, that
is a discussion too far for this list. Consult your local statistical
resources if you need
It's NA *not* Na. Details matter.
Ah, but note:
> mean(c(NA,NA), na.rm = TRUE)
[1] NaN
So if that might happen, you'll have to write your own mean function,
say mymean(), to do what you want. I leave that (simple) pleasure to
you.
-- Bert
On Mon, Sep 16, 2024 at 8:05 AM Francesca wrote:
>
> Al
All' Na Is Na.
Il lun 16 set 2024, 16:29 Bert Gunter ha scritto:
> See the na.rm argument of ?mean
>
> But what happens if all values are NA?
>
> -- Bert
>
>
> On Mon, Sep 16, 2024 at 7:24 AM Francesca
> wrote:
> >
> > Sorry for posting a non understandable code. In my screen the dataset
> > l
Hi,
Thanks for the revised dataset. The R-list does not accept HTML s a safety
measure so it strips everything down to text which is what gives us the
very garbled text so you need to always send in text format.
The best way to supply sample data is using the dput() function. The
dput() funct
See the na.rm argument of ?mean
But what happens if all values are NA?
-- Bert
On Mon, Sep 16, 2024 at 7:24 AM Francesca wrote:
>
> Sorry for posting a non understandable code. In my screen the dataset
> looked correctly.
>
>
> I recreated my dataset, folllowing your example:
>
> test<-data.fr
Sorry for posting a non understandable code. In my screen the dataset
looked correctly.
I recreated my dataset, folllowing your example:
test<-data.frame(matrix(c( 8, 8, 5 , 5 ,NA ,NA , 1, 15, 20, 5, NA, 17,
2 , 5 , 5, 2 , 5 ,NA, 5 ,10, 10, 5 ,12, NA),
c( 18, 5,
Às 08:28 de 16/09/2024, Francesca escreveu:
Dear Contributors,
I hope someone has found a similar issue.
I have this data set,
cp1
cp2
role
groupid
1
10
13
4
5
2
5
10
3
1
3
7
7
4
6
4
10
4
2
7
5
5
8
3
2
6
8
7
4
4
7
8
8
4
7
8
10
15
3
3
9
15
10
2
2
10
5
5
2
4
11
20
20
2
5
12
9
11
3
6
13
10
13
4
On Mon, 16 Sep 2024 09:28:14 +0200
Francesca wrote:
> Dear Contributors,
> I hope someone has found a similar issue.
I hope *not*! 😊️
> I have this data set,
You may have, but we haven't. The data you provided have an
incomprehensible (to me at least) structure. Please use dput()
to include
Dear Contributors,
I hope someone has found a similar issue.
I have this data set,
cp1
cp2
role
groupid
1
10
13
4
5
2
5
10
3
1
3
7
7
4
6
4
10
4
2
7
5
5
8
3
2
6
8
7
4
4
7
8
8
4
7
8
10
15
3
3
9
15
10
2
2
10
5
5
2
4
11
20
20
2
5
12
9
11
3
6
13
10
13
4
3
14
12
6
4
2
15
7
4
4
1
16
10
0
3
7
17
20
15
14 matches
Mail list logo