dataset into two subsets

Hello,

I need your help.

I was asked to do this :

Divide your dataset into two subsets: Subset A and Subset B. Subset B
includes the “individuals” whose missing values for the variable
“Esperance_maintien” (you can use “filter”, “!is.na” or “is.na”).

I tried this but i have an empty database ...

data <- read_csv("C:/Users/ABC/Downloads/sgl-arbres-urbains-wgs84.csv")

View((data$esperance_maintien))

summary(data$esperance_maintien)

SubsestB <- subset(data, esperance_maintien == "NA")

View(SubsestA)

THANKS

Anis

Hi, can you provide a reproducible example? We don't have your dataset.

thank you for the answer,

Here is the link to the database I am currently working on

:https://static.data.gouv.fr/resources/arbres-urbains/20210218-172059/sgl-arbres-urbains-wgs84.csv

Thank you for your help :slight_smile:

Use is.na().

library(tidyverse)

data <- read_csv("https://static.data.gouv.fr/resources/arbres-urbains/20210218-172059/sgl-arbres-urbains-wgs84.csv")

data1 <- data %>% 
  filter(is.na(esperance_maintien)) # use is.na

Thank you for your help :slight_smile:

Hello sir,
I have one more request please,

How to have a dataset Subset A without subset B

In the end I want to have this :

The database includes 709 individuals: sub-base A includes 699 individuals
and sub-base B includes 10 individuals

Thanks

This:

data2 <- data %>% 
  filter(!is.na(esperance_maintien)) 

# A tibble: 699 x 57

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.