0

I have the data that has numeric variable A. I want to make groups for A to have something like B.

data <- structure(list(A = c(0, 0, 0, 0, 1, 2, 9, 15, 30, 100, 0.2, 0.003, 
95, 18), B = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 4L, 10L, 1L, 1L, 
10L, 2L)), class = "data.frame", row.names = c(NA, -14L))
mustafa
  • 203
  • 1
  • 8

1 Answers1

2

Are you trying to create B from A? it looks like you want something like

data$A %/% 10
[1]  0  0  0  0  0  0  0  1  3 10  0  0  9  1

or

(data$A %/% 10)+1 
[1]  1  1  1  1  1  1  1  2  4 11  1  1 10  2
Daniel O
  • 4,258
  • 6
  • 20