na Questions
7
Solved
I have a data frame containing (in random places) a character value (say "foo") that I want to replace with a NA.
What's the best way to do so across the whole data frame?
2
Solved
I have a factor that I'm using as a lookup table.
condLookup = c(hotdog = "ketchup", ham = "mustard", popcorn = "salt", coffee = "cream")
This works as expe...
2
Solved
I have the following data.frame:
x <- data.frame(A = c("Y", "Y", "Z", NA),
B = c(NA, TRUE, FALSE, TRUE),
C = c(TRUE, TRUE, NA, FALSE))
And I need to compute the following table with xtabs:
...
3
Solved
I have a big data.frame called "mat" of 49952 obs. of 7597 variables and I'm trying to replace NAs with zeros. Here is and example how my data.frame looks like:
A B C E F D Q Z . . .
1 1 1 0 NA N...
1
Solved
I'm using kaggle's pokemon data to practice KNN imputation via preProcess(), but when I did I encountered this following message after the predict() step. I am wondering if I use the incorrect data...
4
Solved
Quick question. I read my csv file into the variable data. It has a column label var, which has numerical values.
When I run the command
sd(data$var)
I get
[1] NA
instead of my standard d...
Frieze asked 21/4, 2011 at 4:28
7
I've been encountering what I think is a bug. It's not a big deal, but I'm curious if anyone else has seen this. Unfortunately, my data is confidential, so I have to make up an example, and it's no...
4
My data looks like this:
https://i.sstatic.net/zXk8a.jpg
I want to change the values NA to another value for each column.
For example in the column that contains NA, Single and Dual, I want to ch...
6
Solved
I want to replace <NA> values in a factors column with a valid value. But I can not find a way. This example is only for demonstration. The original data comes from a foreign csv file I have ...
2
Solved
How can I pass an NA value from Rcpp to R in a 64 bit vector?
My first approach would be:
// [[Rcpp::export]]
Rcpp::NumericVector foo() {
Rcpp::NumericVector res(2);
int64_t val = 12345678901...
5
Solved
I have a df as follows which has 20 people across 5 households. Some people within the household have missing data for whether they have a med_card or not. I want to give these people the same valu...
4
Solved
Here is my toy dataset
df <- tribble(
~x, ~y, ~z,
7, NA, 4,
8, 2, NA,
NA, NA, NA,
NA, 4, 6)
I want to get a dataframe with a number of NAs for each variable only between the first and th...
Mada asked 12/2, 2020 at 13:28
3
Solved
I have used the same method for replacing NA's with blanks or other characters but for some reason this one is not working. I want to replace the NA's on my dataframe to blanks (columns year and An...
4
Solved
This line:
which(!is.na(c(NA,NA,NA))) == 0
produces logical(0)
While this line
if(which(!is.na(c(NA,NA,NA))) == 0){print('TRUE')}
generates:
Error in if (which(!is.na(c(NA, NA, NA))) == 0)...
Robber asked 5/2, 2018 at 15:42
5
Solved
Suppose you have a dataframe with 9 columns. You want to remove cases which have all NAs in columns 5:9. It's not at all relevant if there are NAs in columns 1:4.
So far I have found functions tha...
3
Solved
I have some data that I am looking at in R. One particular column, titled "Height", contains a few rows of NA.
I am looking to subset my data-frame so that all Heights above a certain value are e...
6
Solved
edit
The question was originally asked for data.table. A solution with any package would be interesting.
I am a little stuck with a particular variation of a more general problem. I have panel d...
Responsive asked 8/12, 2014 at 23:13
3
Solved
I need to delete rows containing NA, but only if they are leading(trailing) i.e. before(after) any data appears for a variable. This is very similar to:
How to find (not replace) leading NAs, gap...
Unionism asked 26/10, 2019 at 10:52
10
Solved
I have some columns in R and for each row there will only ever be a value in one of them, the rest will be NA's. I want to combine these into one column with the non-NA value. Does anyone know of a...
4
Solved
I have a sample dataset which looks something similar to the one below:
d= data.frame(a = c(1,5,56,4,9),
b = c(0,0,NA,0,NA),
c = c(98,67,NA,3,7),
d = c(0,0,0,0,0),
e = c(NA,NA,NA,NA,NA))
...
5
Solved
I have some vectors in the following format
v1 <- c(NA,NA,NA,10,10,10,10)
v2 <- c(NA,NA, 3, 3, 3,NA,NA)
v3 <- c( 5, 5, NA,NA,NA,NA,NA)
For each vector I want to calculate how many le...
3
Solved
This question is related to a post with a similar title (replace NA in an R vector with adjacent values). I would like to scan a column in a data frame and replace NA's with the value in the adjace...
Attitude asked 26/3, 2013 at 5:18
4
Solved
I have a dataset that looks like this:
before = data.frame(diag1 = c(1,NA, 1, NA, NA, 1), diag2 = c(NA, NA, NA, 2, NA, NA), diag3 = c(3, NA, NA, NA, 3, 3), diag4 = c(4, 4, NA, NA, 4, NA))
diag1...
4
Solved
I'm trying to write a function that turns empty strings into NA. A summary of one of my column looks like this:
a b
12 210 468
I'd like to change the 12 empty values to NA. I also have a few...
Libidinous asked 2/11, 2016 at 11:38
2
While trying to convert a column of characters (strings of numbers, e.g "0.1234") into numeric, using as.numeric, some of the values are returned NA with the warning 'NAs introduced by coercion'. T...
© 2022 - 2024 — McMap. All rights reserved.