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.
 500 2
'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
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?
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 2014-12-02 23
1 2014-10-02 25
2 2014-11-03 27
2 2014-09-03 45
3 2014-07-11 56
3 NA 34
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 R-environment 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))
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:
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 14-year-olds, 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.
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.
I have a data table that looks like this:
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))
I'm running a large number of meta-analyses 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 :
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("2016-07-01", "2016-07-02", "2016-07-03", "2016-07-04", "2016-07-05", "2016-07-06","2016-07-07"),
"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 non-null values, except a couple of columns with fewer. The column with the least number of non-null 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:
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" non-NA date value from a series of columns:
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 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 ...