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...
Beverleybeverlie asked 11/7, 2013 at 15:52

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...
Obsolescent asked 5/2, 2017 at 12:31

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?
Googolplex asked 5/4, 2011 at 19:52

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: ...
Dashboard asked 5/2, 2014 at 18:40

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...
Pires asked 13/9, 2018 at 13:47

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...
Causeway asked 28/8, 2018 at 14:43

3

Solved

If I have a data frame as follows: data.frame( cola = c(3,NA,NA), colb = c(1,NA,NA), colc = c(NA,6,NA), cold = c(NA,7,NA), cole = c(NA,3,NA), colf = c(NA,NA,9), colg = c(NA,NA,8) ) How c...
Phore asked 5/8, 2018 at 19:54

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...
Absolve asked 6/8, 2018 at 9:9

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...
Cheese asked 26/7, 2018 at 20:56

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...
Rime asked 24/7, 2018 at 16:50

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...
Vinita asked 13/7, 2018 at 18:46

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 ...
Courtnay asked 7/6, 2012 at 14:55

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...
Coarctate asked 18/5, 2018 at 4:22

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...
Reinert asked 25/8, 2015 at 21:10

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

Here is my example mydf<-data.frame('col_1' = c('A','A','B','B'), 'col_2' = c(100,NA, 90,30)) I would like to group by col_1 and count non-NA elements in col_2 I would like to do it with ...
Discommode asked 31/5, 2017 at 17:0

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...
Prothalamium asked 26/1, 2018 at 22:56

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.
Asthenosphere asked 6/10, 2014 at 16:46

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 &lt...
rna
Osmund asked 4/12, 2013 at 0:21

© 2022 - 2024 — McMap. All rights reserved.