logo
down
shadow

Delete NA data ,but with certain condition in R


Delete NA data ,but with certain condition in R

Content Index :

Delete NA data ,but with certain condition in R
Tag : r , By : afds
Date : January 12 2021, 07:00 PM

This might help you Let's see example data , So maybe you are looking for
nad[!is.na(nad$x1) & is.na(nad$x2) | rowSums(!is.na(nad)) == ncol(nad), ]

#  x1 x2 x3 x4 x5 x6
#1  1 NA NA NA NA NA
#2  2  2  1  2  3  4
#4  4 NA NA NA NA NA

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How to delete data from list with check condition


Tag : chash , By : Igor Carron
Date : March 29 2020, 07:55 AM
it should still fix some issue You can use List.RemoveAll:
List<boko_data_json> thedata = Newtonsoft.Json.JsonConvert.DeserializeObject<List<boko_data_json>>(json);
theData.RemoveAll(n => n.status == "0");

How to delete duplicate data with a condition


Tag : mysql , By : sgmichelsen
Date : March 29 2020, 07:55 AM
wish helps you Try this delete statement, it works as described in rules and gave correct output for your examples:
SQLFiddle
delete from tbl_test t 
  where t.sta in ('F', 'R') and exists ( 
      select 1 from tbl_test b 
        where b.ser_no = t.ser_no 
          and (sta='L' or (sta<>'L' and b.id<t.id)) )

data.table: delete row following those matching specified condition?


Tag : r , By : user165781
Date : March 29 2020, 07:55 AM
will be helpful for those in need I'll write in data.table because I prefer the syntax; the translation to base is straightforward.
library(xts)  #Needed to get the following "xts" "zoo" object
data1 <- structure(c(6.32, 6.27, 6.3, 6.3, 6.26, 6.24, 6.36, 6.36, 6.3, 
6.36, 6.28, 6.5, 6.21, 6.22, 6.3, 6.23, 6.2, 6.24, 6.22, 6.3, 
6.3, 6.23, 6.24, 6.44, 329400, 126500, 0, 126600, 54000, 61000, 
6.22, 6.3, 6.3, 6.23, 6.24, 6.44), .Dim = c(6L, 6L), .Dimnames = list(
    NULL, c("open", "high", "low", "close", "volume", "adj.")), index = structure(c(1387756800, 
1387843200, 1387929600, 1388016000, 1388102400, 1388361600), tzone = "UTC", tclass = "Date"), .indexCLASS = "Date", tclass = "Date", .indexTZ = "UTC", tzone = "UTC", class = c("xts", 
"zoo"))

library(data.table)
#setDT fails on "xts" "zoo" object. We need as.data.table
#setDT(data1) #convert to native 'data.table' class _by reference_

data1 <- as.data.table(data1)
data1[if (!length(rows <- -c(idx <- which(volume == 0), (if (volume[.N] == 0) idx[-length(idx)] else idx) + 1L))) TRUE else rows]
data1[if (!length(rows <- -c(idx <- which(volume == 0), idx + 1L))) TRUE else rows]

Tag : postgresql , By : kiirpi
Date : March 29 2020, 07:55 AM
I hope this helps . , why not just dblink and format?..
t=# create table so43 (i int);
CREATE TABLE
t=# insert into so43 select 1;
INSERT 0 1
t=# select * from dblink('dbname = t',format('delete from so43 where i <= %s',1)) as row(result text);
  result
----------
 DELETE 1
(1 row)

I want to delete data on condition.if data is available in another table as a foreign key then donot delete this


Tag : php , By : kraszie
Date : March 29 2020, 07:55 AM
seems to work fine i have 3 tables, 1 is for bloggers, blogger id is save in the campaign table as a foreign key and also save in the categories tables as a foreign key which is the junction table actually. , you need change in delete function just like this
 function delete($id){
    $result = $this->db->query("SELECT blogger_id FROM tbl_campaign_detail WHERE blogger_id = $id")->row();
    if(!$result){
           $this->db->query("DELETE FROM tbl_bloggers_cat  WHERE blogger_id  = $id AND Cat_id > 2000");
           if($this->db->affected_rows() > 0){
                 return true;
            }
    }
    return false;
}
Related Posts Related QUESTIONS :
  • How to find the given value from the range of values?
  • Solution on R group by issue _ multiple combination
  • Transform multiple columns with a function that uses different arguments per column
  • How can I parse a string with the format "1/16/2019 1:24:51" into a POSIXct or other date variable?
  • How to plot a box plot in R for outlier detection for a huge number of rows?
  • How to change column name according to another dataframe in R?
  • `sjPlot::tab_df()`--how to set the number of decimal places?
  • time average for specific time range in r
  • joining dataframes by closest time and another key in r
  • How to create nested for loop for a certain range
  • New category based on sequence of date ranges
  • how to extract formula from coxph model summary in R?
  • add row based on variable condition in R
  • Generating the sequence 111122222333334
  • Unable to use has_goog_key() in R
  • how to multiply each row with a scaler in corresponding column?
  • R is not recognizing levels of a factor as the same. Is there a way to do this?
  • Calculating mean of replicate experiment result values in a column based on multiple columns using R
  • Best method to extract the first instance of a string between specified keywords using data.table
  • ignore optional combination of alphanumeric characters in str_extract
  • Why tracemem shows two copies when modification occurs inside function body?
  • Can't use mppm on multitype point patterns
  • How to move selected matrix rows to top of matrix based on a selection vector of row names
  • Combining expressions with a common operator
  • Passing string through multiple filters for matching
  • Convert two columns in R to rows of unique occurrence
  • How to create a dataframe using a function based on user-input?
  • How to access the visited vertices in a given shortest path using R igraph
  • Differences in Unicode character output with print()
  • Extracting Function or Objects from a String and then Piping Them with Magrittr/Dplyr
  • renderUI not evaluated until it is rendered
  • Find the maximum absolute value by row in an R data frame
  • Extracting data from irregular lists using purrr:map()
  • transforming data based on range of column in r
  • Identify and subset rows with some similar information
  • converting character from mongolite to timestamp in R
  • Create list from two vectors with every combo of each
  • Error in running a spread because of unique 'key combinations'; combining rows of data
  • visualize numerical strings as a matrixed heatmap
  • how to make a blocked matrix?
  • How to summarize with two functions using with dplyr
  • Dataframe is no longer the same after being saved to Excel and read back in
  • Create duplicate rows using based on availability of data
  • Keep empty groups when grouping with data.table in R
  • Grouping of Event Time Data based on multiple, iterative conditions
  • Formatting Numbers in Flextable for Specific Columns
  • How to store results from for-loop into a dataframe
  • How to select the values in my dataframe which has logical operator "<" (less than), divide them by two, an
  • Rowwise extract data between two strings
  • Convert a string separate by . and +
  • stacking function for values in R
  • dplyr coerces characters to factors
  • How do I use spread and group_by on a single row dataset
  • Replacing values in one matrix with values from another
  • Aggregate data and exclude duplicates in one column
  • Perform an R data.table binary search with OR select
  • How can I include a function in the Standard Deviation parameter of pnorm
  • How to get a tidy excel output of P values from R
  • Rotate boxplot legend (R, ggplot2)
  • dplyr::n() returns “Error: Error: n() should only be called in a data context ”
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com