You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
266 B
R
17 lines
266 B
R
5 years ago
|
> sum(2,7,5)
|
||
|
[1] 14
|
||
|
|
||
|
> x
|
||
|
[1] 2 NA 3 1 4
|
||
|
|
||
|
> sum(x) # if any element is NA or NaN, result is NA or NaN
|
||
|
[1] NA
|
||
|
|
||
|
> sum(x, na.rm=TRUE) # this way we can ignore NA and NaN values
|
||
|
[1] 10
|
||
|
|
||
|
> mean(x, na.rm=TRUE)
|
||
|
[1] 2.5
|
||
|
|
||
|
> prod(x, na.rm=TRUE)
|
||
|
[1] 24
|