Questions tagged [na.rm]
48 questions
0
votes
1 answer
svydesign function with missing data
I am working with secondary data within the survey package in R. I have defined the weight, strata, and cluster using the svydesign function.
mydesign <- svydesign(id=~C17SCPSU, weights=~C1_7SC0,strata=~C17SCSTR,
nest=TRUE,…

Debbie Hahs-Vaughn
- 15
- 3
0
votes
1 answer
How do you remove NAs?
penguins %>%
select(bill_length_mm) %>%
filter(!is.na(bill_length_mm)) %>%
mean(as.numeric(bill_length_mm), na.rm=TRUE)
Error message: argument is not numeric or logical: returning NA[1] NA
Examining the dataset after filtering shows…

Robert Cline
- 37
- 1
- 7
0
votes
1 answer
Issue with na.rm = TRUE when combining multiple character columns using Unite from dplyr
When trying to combine multiple character columns using unite from dplyr, the na.rm = TRUE option does not remove NA.
Step by step:
Original dataset has 5 columns word1:word5 Image of the original data
Looking to combine word1:word5 in a single…

nsmd
- 1
- 1
0
votes
1 answer
How to I overcome Dividing by Zero Error in R
Hi, Stack community! I came across this error working today. I am not sure exactly how to work around it. I read to use a na.rm in my mutate, and I tried it, but it didn't work. I could be completely wrong.…

72o
- 43
- 9
0
votes
1 answer
mean of vector with at least n (>1) non-missing values, R
I want to calculate the mean of a vector with missing values only if at least a number of values exist. So for example if only one (or less than five) value(s) are non-missing, I want to return NA, but if I have at least two (or more than five)…

MrMax
- 393
- 1
- 2
- 10
0
votes
1 answer
How do I perform operations on variables omitting missing values
I'm sure this question will seem a little bit basic for many but here is my problem:
I want to create a new variable which is an equation of other variables in RStudio:
D$satisfaction.conditions <- (D$imp.distance * D$sat.distance
…

wikninja
- 3
- 1
0
votes
0 answers
List of data frames - problems with na.rm
I am a newish R user and have a basic question about na.rm
I have a long list of dataframes, from which I am trying to calculate column means. I have the following code to do this -
results <- lapply(list_of_data_frames,
function(x)…

Ollie Perkins
- 333
- 1
- 12
0
votes
1 answer
R custom function to apply to all variables in a dataframe
I am trying to create a custom function that would, applied within a loop, give me a table with all the informations I need for all the variables of my table. My function is based on dplyr functions and base.
myfun <- function(x, y) summarise(x,…

GaryDe
- 492
- 1
- 5
- 17
0
votes
1 answer
Ignore NA while using mapply
I have the following dataset:
longitude latitude
NA NA
NA NA
NA NA
NA NA
-73.77384042 40.64582098
NA NA
NA NA
NA NA
NA NA
NA NA
I am using the below code for converting the lat & long to get the location using the below…

GoRion
- 23
- 4
0
votes
3 answers
na.rm for other values in R
I have a data frame
df=data.frame(a=1:5,b=c(1,3,4,-999999,4))
and want to calculate the average of it, but want to exlcude the outlier, -9999 in this case
Is there a command similar to
na.rm
so I can go
apply(df,1,function(x) mean(if x>-100 & x…

frank
- 3,036
- 7
- 33
- 65
0
votes
0 answers
Applying multiple functions using the sapply function to columns of data frame
I have a simple and a small data set for which I wish to apply a set of functions to each column or variable of the data frame using the sapply function. Below is the code from R Blogs
multi.sapply <- function(...) {
arglist <-…

user3571389
- 335
- 1
- 5
- 10
0
votes
0 answers
Warning with missing data when making a plot (R) - but am using na.rm=TRUE
I was trying to change the whiskers (upper &lower limits) of boxplots and was directed to boxplotperc() in the StatDA package. The data I'm using has missing values and works fine when using the regular boxplot()
However when I used the function…

Ameno
- 21
- 6
-1
votes
1 answer
Where to place NA.RM=TRUE in an equation?
I am doing the following:
branques_Idescat_EU <- indexIPI_branques_EU_wide %>%
mutate(alimentació = round(C10*(C10/(C10+C11+C12)) + C11*(C11/(C10+C11+C12)) + C12*(C12/(C10+C11+C12)), 1),
tèxtil = round(C13*(C13/(C13+C14+C15)) +…

Maria
- 173
- 7
-1
votes
1 answer
na.rm is not found in R
I am trying to use na.rm but it looks like it is not in R at all. I was using it in the past just now it does not seem to be there at all. I tried using the help() function and the ??na.rm both showed not results. How could this suddenly happen? and…

H B
- 1
- 4
-1
votes
1 answer
How to find the mean of a continuous variable for each categorical variable?
I am trying to calculate the average duration of UFO sighting (continuous) for each categorical shape that it is related with. Essentially, what is the average sighting length for each UFO shape?
I tried:
a <- aggregate(duration..seconds. ~…

Mikayla Baer
- 49
- 6