na Questions
3
Solved
I'm working in R and have a dataframe, dd_2006, with numeric vectors. When I first imported the data, I needed to remove $'s, decimal points, and some blank spaces from 3 of my variables: SumOfCost...
5
Solved
I would like to replace NA values with zeros via mutate_if in dplyr. The syntax below:
set.seed(1)
mtcars[sample(1:dim(mtcars)[1], 5),
sample(1:dim(mtcars)[2], 5)] <- NA
require(dplyr)
mtcars...
2
Solved
Two questions related to boxplot:
What are the options for na.action? The documentation doesn't list them.
How would I go about answering these types of question in the future?
4
I am new to R. I want to fill in an empty matrix with the results of my for loop using cbind. My question is, how can I eliminate the NAs in the first column of my matrix. I include my code below: ...
2
Solved
I would like to do a last observation carried forward for a variable, but only up to 2 observations. That is, for gaps of data of 3 or more NA, I would only carry the last observation forward for t...
1
Can someone please answer in layman terms how indexing (subsetting) with NA works. Even though there are some answers from google, I would like to understand it better in simple terms.
When indexi...
3
Solved
1
When I load my data file in tab delimited format in R, I got this error message:
Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, : line 3 did not have 5 elements
Her...
Plectron asked 7/8, 2018 at 2:40
2
Solved
Ok, here is yet another missing value filling question.
I am looking for a way to fill NAs based on both the previous and next existent values in a column. Standard filling in a single direction i...
1
Solved
R seems to support an efficient NA value in floating point arrays. How does it represent it internally?
My (perhaps flawed) understanding is that modern CPUs can carry out floating point calculati...
Macaque asked 4/8, 2018 at 10:54
1
Solved
I have two datasets. Both are xts objects.
> dput(head(all_data[,2:3]))
structure(c(0.00108166576527857, 0.00324149108589955, 0, 0, 0.00484652665589658,
0.00267952840300101, 0.0060698027314...
2
Solved
When estimating the mean with a vector of all NA's we get an NaN if na.rm = TRUE. Why is this, is this flawed logic or is there something I'm missing? Surely it would make more sense to use NA than...
2
I'm looking to multiply two matrices together in R, one of which may contain randomly placed NA values (i.e., there's no reason they will be all in a row or column), but I still want an output like...
Gentlewoman asked 14/5, 2013 at 4:23
4
Solved
I have a data frame like this:
> head(df1)
iso year var1 var2 var3
1 XXX 2005 165 29 2151
2 XXX 2006 160 21 2139
3 XXX 2007 NA NA NA
4 XXX 2008 184 9 3640
5 XXX 2009 NA NA NA
6 YYY 2005 206 461...
3
In R, when using lm(), if I set na.action = na.pass inside the call to lm(), then in the summary table there is an NA for any coefficient that cannot be estimated (because of missing cells in this ...
4
I have a list of lists, which may contain NA values.
How can I remove the lists that are full of NA values, keeping in mind that if there are non-NA values on the list these values and the NA valu...
4
vector1 = c(1,2,3,NA)
condition1 = (vector1 == 2)
vector1[condition1]
vector1[condition1==TRUE]
In the above code, the condition1 is "FALSE TRUE FALSE NA",
and the 3rd and the 4th lines both giv...
Oriflamme asked 18/4, 2018 at 2:30
5
Solved
Does anybody know how to aggregate by NA in R.
If you take the example below
a <- matrix(1,5,2)
a[1:2,2] <- NA
a[3:5,2] <- 2
aggregate(a[,1], by=list(a[,2]), sum)
The output is:
Group...
3
Solved
I am trying to replace missing values (NA) in a vector. NA between two equal number is replaced by that number. NA between two different values, should stay NA. For example, given vector "a", I wan...
Westward asked 6/4, 2018 at 15:28
1
Solved
This question has a partial answer here but the question is too specific and I'm not able to apply it to my own problem.
I would like to skip a potentially heavy computation of the NA group when u...
Stratocracy asked 19/3, 2018 at 15:35
3
Solved
# have
> aDT <- data.table(colA = c(1,1,1,1,2,2,2,2,3,3,3,3), colB = c(4,NA,NA,1,4,3,NA,NA,4,NA,2,NA))
> aDT
colA colB
1: 1 4
2: 1 NA
3: 1 NA
4: 1 1
5: 2 4
6: 2 3
7: 2 NA
8: 2 NA
...
Geoponic asked 20/2, 2018 at 22:55
3
Solved
1
Solved
I'm finding the minimum date within a group. Many times, the group includes only missing dates (in which case I'd prefer something like NA to be assigned).
The NAs appear to be assigned corr...
3
Solved
I have a data frame containing entries; It appears that these values are not treated as NA since is.na returns FALSE. I would like to convert these values to NA but could not find the way.
3
Solved
I want to find all the names of columns with NA or missing data and store these column names in a vector.
# create matrix
a <- c(1,2,3,4,5,NA,7,8,9,10,NA,12,13,14,NA,16,17,18,19,20)
cnames <...
© 2022 - 2024 — McMap. All rights reserved.