
I've a dataframe with a column that gives me a value in type time (e.g. 08:00:00). What I am trying to do is:
in case of my value is None I replace with current time.
For that I am trying with this:
...

I have a database as a dataframe named 'data' which constitutes 500 objects and 2 variables.
in fact
dim(data)
returns
[1] 500 2
and
str(data)
returns
'data.frame': 500 obs. of 2 ...

I have two data.frames, dA (HERE) and dB (HERE). They are exactly the same EXCEPT that dB has one completely empty column and multiple empty rows.
dA < read.csv("https://raw.githubusercontent.com/...

I need to create a variable which is similar to var1 if var2 is missing, similar to var2 if var1 is empty, the mean of var1 and var 2 if the two are not missing ((var1+var2)/2) and finally NA if both ...

I want to remove all columns that are all NA. I have two solutions as shown below, but they both use looping structures under the hood.
I was wondering if there is a faster solution that does NOT ...

So I'm trying to remove rows that have missing data in some columns, but not those that have missing data in all columns.
using rowSums alongside !is.na() gave me 1000's of rows of NA at the bottom ...

I have two vectors, say A and B
A < c(1, 2, 3, 4, 5)
B < c(6, NA, 8, 9, NA)
I would like to exclude elements in A corresponding to the elements of B which comprise NAs.
So, I am in need of ...

I have a data frame with categorical and numeric variables. I try to onehot transform the categories, while the numerics should stay unchanged.
It took me some time to reproduce the issue that I get ...

I am trying to group the rows of a matrix by their unique placement of NA values within each columns.
For example with the following matrix:
1, 2, NA, 3 NA
2, 5, NA, 4, 5
3, 2, 1, 0, 7
5, 3, NA, 9, ...

I am trying to unite 5 columns into one new column using the Unite function. However, all rows contain lots of NA values, creating variables that look like
MotherNANANANA
NANAFatherMotherNA
...

Here my dataset is pd and i have split it into training and testing data as pd_train1 and pd_train2
sku national_inv lead_time in_transit_qty forecast_3_month forecast_6_month
1 3921548 ...

I am trying to replace numbers with N/A in R.
Why does this work  primaryage<na_if(PrimaryAge, 0)  but the two below do not?
primaryage<na_if(PrimaryAge, 96)
primaryage<na_if(...

I'm currently working with FBI crime data that takes all city crime data within each state and provides statistics for it. I am trying to figure out a way to copy each state string (which is only ...

I want to replace wherever value is greater than 8 to NA using only "Apply" function in a matrix of 1 to 20
m < matrix(c(1:10, 11:20), nrow = 5, ncol = 4)
I have tried apply(m, 1:2, function(x) ...

I have this situation:
ID date Weight
1 20141202 23
1 20141002 25
2 20141103 27
2 20140903 45
3 20140711 56
3 NA 34
4 ...

I have a similar problem to Q: Connecting across missing values with geom_line, but found the answers provided only connect the lines when there is one missing value only. If there are 2+ consecutive ...

I have code which looks like:
mat1 < matrix(1, nrow = 1, ncol = 2)
mat1[1,1] < NA
colnames(mat1) < c(NA, 'Name1')
mat2 < mat1
mylist < list(mat1, mat2)
mylist < lapply(...

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,...

I have a data frame containing columns with integers, characters, and numerics. The actual data set is much larger than the example given below, but what is below is a passable and much smaller ...

I'm not very familiar with the Renvironment so far and I'm struggling with the following..:
df < tibble(x= c(1.12, 4.12,4.64, NA, NA, 0.72),
y= c(8.92, 14.9, 3.2, NA, NA, NA))
I'd ...

getting a strange #N/A error excel/vlookup. I have a database connection with sql query returning a lot of rows ~40k. I have a field with two data values separated with a comma. I am breaking these up ...

Given a simple df:
library(naniar)
library(tidyverse)
df < tibble(a = c(1,NA,2,3,NA,4,5))
Please explain me why I get first NA to be 0.623 and second 0.504 after running:
df %>% bind_shadow(...

I was trying to plot a heatmap however in my matrix i have a bunch of NAs. I don't want to throw away the whole rows so i am looking for a solution here.
The first error is NA/NaN/Inf in foreign ...

I am cleaning a database, of which one column contains purely numbers with thousand seperators ",". I used sub() to wipe out the ",", and then i use as.numeric() to transfer the column into numbers, ...

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 ...

I want to calculate the sum of credits a person achieved for a course, based on the person's age and grade when the course was taken. For 14yearolds, I want to sum the credits for 8th grade courses, ...

I am having problems with hd.eigen in Rfast. It gives extremely close results to eigen with most data, but sometimes hd.eign returns an empty $vector, NAs, or other undesirable results.
For example:
...

I tried to switch my data using "as.numeric", "as.factor", etc etc
This is for the latest version in R, and I've been trying to solve by searching on some website but I can't find the solution.
Take ...

I have a data table that looks like this:
DT<data.table(day=c(1,2,3,4,5,6,7,8),Consumption=c(5,9,10,2,NA,NA,NA,NA),id=c(1,2,3,1,1,2,2,1))
day Consumption id
1: 1 5 1
2: 2 ...

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 ...

I'm running a large number of metaanalyses with metafor. To get an overview of the results, I wanted to put together vectors containing the main estimates (to combine them in a dataframe later on). ...

How can I remove NAs in my dataset after ungrouping them in a character vector?
this is the data set :
Mno drugs
100173 9
100173 3
100173 NA
100173 NA
100463 18
100463 18
100463 1
...

I'm so glad I found the sjlabelled package to set NA labels with data (comparable to Stata). My missings are coded as negative numbers. The behaviour of print_tagged_na is to only display one digit of ...

I'm running multinom() on a dataset with 4 different types of predictors (y ~ x1, x2, x3, x4).
Some records have only one predictor, with the other 3 as NA. Some have 2, some 3, and some all 4. All ...

I recognize that this question could be a duplicate.
I have a list of matrices and for each matrix, I want to identify whether or not there is an NA present in the first column. I want to identify ...

I have the following DataFrame:
df < data.frame(
"DateValue" = c("20160701", "20160702", "20160703", "20160704", "20160705", "20160706","20160707"),
"Age1" = c(rep(NA, 2), seq(...

I am trying to add annual company data to monthly ones. Since the annual data is reported at specific months and not always updated every 12 months, I need the annual values to match the month in the ...

I have a Dataframe where most columns have 10866 nonnull values, except a couple of columns with fewer. The column with the least number of nonnull values is "keywords" (9373). So when I drop the NA...

I am assessing sensitivity/specificity in my data using package epi r.
There are missing values but when I make the table and then run the analysis the n includes all cases (should be 452 not 545), ...

I have been using the following code to remove variables with too many NA's:
DT < DT[,colMeans(is.na(DT)) <= 0.1]
However, on a data.table this gives:
library(data.table)
set.seed(1)
DT <...

When I run random forest on dataset LLL
rfm < randomForest(ONEorZERO~., data = LLL)
The code produces the following "Error in na.fail.default"
Even thou I take out the nulls (na.omit) and am ...

First of all I am a starter with R, so maybe I am just stupid not seeing the problem...
The data consists of stock returns and some of the stocks did not exist at the time of evaluation but will at a ...

I have a csv file where in one of the column i need to fill NA values on the basis of data which is available above in same column.For example lets say if lets say column data is like this chrome,NA,...

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'. The ...

I'd like to create a column that contains the "last" nonNA date value from a series of columns:
type<c("a","b","c","d")
date1<c("20190101","20190101",NA,NA)
date2<c("20180301",NA,...

I have a data frame that includes three columns that have numerical data. I would like to exclude cases where all three columns contain NA values, but not exclude columns where zero, one, or two of ...

I have a dataframe that contains values and NAs in columns. The dataframe looks like:
A B C D
1 NA NA NA
NA 2 3 NA
NA 4 NA NA
5 NA NA 6
I'm ...

I have a data frame with the string <NA> in a character column. If I apply kable to this data frame, that string does not appear.
In fact, it has nothing to do with data frame as following ...

I'm trying to use an if statement to conditionally recode my NAs as 0s. The if statement has two conditions and is followed by a bracketed replace_na argument. I've played with it quite a bit and it ...

I would like to gapfill NA values for each group by sampling non NA values from the same group.
This is the closest to what I'd like to achieve using !is.na() Ignoring values or NAs in the sample ...