0

I have a dataframe "data" like following:

data

  Names   value1   value2  value3
  TNHJ    -3.22    -0.11   1.88
  JKIN    -6.90    -4.23   0.98
  EFGT     7.56    -8.90   9.34

From this data frame "data" based on the column "value1" I want to extract only negative information into a new dataframe.

Result:

  Names   value1   value2  value3
  TNHJ    -3.22    -0.11   1.88
  JKIN    -6.90    -4.23   0.98

I tried like following but it didn't work.

within(data, value1[value1<0])
beginner
  • 1,059
  • 8
  • 23

1 Answers1

2

dplyr library filter is your helper:

library(dplyr)
new_df <- data %>% filter(value1 <0)
cephalopod
  • 1,826
  • 22
  • 31