in Education by
How to replace the values of NA with zeros in some column and data frame I have? Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
You can also use norm package as it has a lot of nice features for the missing data analysis and there’s no need to use apply . For Reference check the following example: > m <- matrix(sample(c(NA, 1:2), 100, replace = TRUE), 2) > d <- as.data.frame(m) V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 1 4 3 NA 3 7 6 6 10 6 5 2 9 8 9 5 10 NA 2 1 7 2 > d[is.na(d)] <- 0 > d V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 1 4 3 0 3 7 6 6 10 6 5 2 9 8 9 5 10 0 2 1 7 2 Comment for doubts. Cheers.

Related questions

0 votes
    How to replace the values of NA with zeros in some column and data frame I have? Select the correct ... Questions, Core Hadoop MCQ,core Hadoop interview questions for experienced...
asked Oct 30, 2021 in Education by JackTerrance
0 votes
    I work on Mac OSX and want to install a RJSONIO package in my R, I am a beginner currently and I have no ... someone explain it to me? Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    I want to supply some command-line parameters from a R script I have. And it runs on windows. I just want it ... help me with it? Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    I want to remove some questions from data frame, I know how to delete them individually using df$x...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    How can I sort a data.frame by multiple columns. E.x. I would like to sort the column q(descending) by column f (ascending) dd...
asked Jan 20, 2022 in Education by JackTerrance
0 votes
    Can someone tell me a function which can return a specified no. of rows picked randomly without any replacement from a DataFrame in R? Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    I have a dataframe as below itm Date Amount 67 420 2012-09-30 00:00:00 65211 68 421 2012-09-09 00 ... solutions would be appreciated. Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    Is there any shortcut method to find an index of an element in a vector, I have an element Q with me ... someone answer this doubt? Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    How to write a trycatch code to sort out an error in web downloading. url...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    Can someone please tell me some tips to make a great minimal reproducible r example? And How can I paste data ... should I include? Select the correct answer from above options...
asked Jan 20, 2022 in Education by JackTerrance
0 votes
    I have file called q.r and it has chmod of 755, how can I run it using a command-line? sayHello...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    What does startup profiles of R professionals include, I have no customization in R and I want to add some. ... highlight my syntax. Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    I want to set some global variables inside a function, how can I do that? Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    Can someone please tell me a quick way to convert a nested list of data whose length is 100 and each item is a list of ... 100 rows and 10 columns? I am attaching a sample data: 5...
asked Jan 20, 2022 in Education by JackTerrance
0 votes
    I have a dataframe: > myvec name order_no 1 Nehal 12 2 sejal 14 3 sejal 16 4 shyam 11 5 Nehal 12 6 Sejal 16 ... Sejal 3 Shyam 1 Ram 1 Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
...