0
There is a problem in the import, your data is not in numerical.
Setting the example:
data <- data.frame(x1 = 1:10, x2 = 11:20)
Example of non-numerical data:
data$x1 <- as.factor(data$x1)
mean.default(data$x1[8:9])
Warning message:
In mean.default(data$x3) : argument is not numeric or logical: returning NA
You can check this by the str command():
str(data)
'data.frame': 10 obs. of 2 variables:
$ x1: Factor w/ 10 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9 10
$ x2: int 11 12 13 14 15 16 17 18 19 20
Data storage correction if factor:
data$x1 <- as.numeric(levels(data$x1))
mean.default(data$x3[8:9])
[1] 8.5
Try to put the sample you separated into a variable and average it
– Gustavo Fragoso
Welcome to the Portuguese stack overflow. To facilitate our help, it is recommended to follow the good response guide as shown here.
– Willian Vieira
Unfortunately, your question cannot be reproduced by anyone who tries to answer it. Please, take a look at this link and see how to ask a reproducible question in R, so that people who want to help you can do this in the best possible way.
– Marcus Nunes
Use the command
dput()
with the data you want to take the average and post in your question, it would be much easier!– Flavio Silva