How to delete negative data in the R programming language. More details: https://statisticsglobe.com/remove-ne...
R code of this video:
vec <- c(1, 5, - 3, 2, 2, - 5, 7) # Create example vector
vec # Print example vector
vec_new <- vec[vec >= 0] # Remove negative vector elements
vec_new # Print updated vector
data <- data.frame(x1 = - 2:4, # Create example data frame
x2 = 5:- 1,
x3 = 1:7)
data # Print example data frame
data_new1 <- data # Duplicate data frame
data_new1[data_new1 < 0] <- NA # Replace negative values by NA
data_new1 # Print updated data frame
data_new2 <- na.omit(data_new1) # Remove rows with NA values
data_new2 # Print updated data frame
Follow me on Social Media:
Facebook – Statistics Globe Page: / statisticsglobecom
Facebook – R Programming Group for Discussions & Questions: / statisticsglobe
Facebook – Python Programming Group for Discussions & Questions: / statisticsglobepython
LinkedIn – Statistics Globe Page: / statisticsglobe
LinkedIn – R Programming Group for Discussions & Questions: / 12555223
LinkedIn – Python Programming Group for Discussions & Questions: / 12673534
Twitter: / joachimschork
Music by bensound.com
Watch video Remove Negative Values from Vector & Data Frame (2 Examples) | Delete Elements or Rows | na.omit() online without registration, duration hours minute second in high quality. This video was added by user Statistics Globe 10 September 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 1,417 once and liked it 14 people.