R studio IDE related Query

In excel I have column name as "data_ver" , it has numbers 1 to 100

I have to put them into slots for example a should be from 1 to 10, similarly b should be from 11 to 20

how to put that excel in R and out put should be a = 1 to 10, b = 11 to 20

How to do that.

Hi, welcome!

I think you are a little bit confused about RStudio, IDE stands for Integrated Development Environment and your questions is not about the IDE, is about how to import data from excel and categorize a continuous variable using the R programming language.

Also, the best way for asking a question here, is with a minimal REPRoducible EXample (reprex), since it seems like you are new to R, I'm going to try to make one for you this time.

I think this is similar to what you want to do, so we can start from here

library(openxlsx)
library(dplyr)

# You could read your file with something like this
# df <- read.xlsx("path/to/your_file.xlsx", sheet = 1)

# Made up data to simulate yours since I don't have access to your actual file
df <- data.frame(data_ver = 1:100)

df %>% 
    mutate(slots = cut(data_ver,
                       breaks = c(1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100),
                       labels = letters[1:10]))
#>     data_ver slots
#> 1          1  <NA>
#> 2          2     a
#> 3          3     a
#> 4          4     a
#> 5          5     a
#> 6          6     a
#> 7          7     a
#> 8          8     a
#> 9          9     a
#> 10        10     a
#> 11        11     b
#> 12        12     b
#> 13        13     b
#> 14        14     b
#> 15        15     b
#> 16        16     b
#> 17        17     b
#> 18        18     b
#> 19        19     b
#> 20        20     b
#> 21        21     c
#> 22        22     c
#> 23        23     c
#> 24        24     c
#> 25        25     c
#> 26        26     c
#> 27        27     c
#> 28        28     c
#> 29        29     c
#> 30        30     c
#> 31        31     d
#> 32        32     d
#> 33        33     d
#> 34        34     d
#> 35        35     d
#> 36        36     d
#> 37        37     d
#> 38        38     d
#> 39        39     d
#> 40        40     d
#> 41        41     e
#> 42        42     e
#> 43        43     e
#> 44        44     e
#> 45        45     e
#> 46        46     e
#> 47        47     e
#> 48        48     e
#> 49        49     e
#> 50        50     e
#> 51        51     f
#> 52        52     f
#> 53        53     f
#> 54        54     f
#> 55        55     f
#> 56        56     f
#> 57        57     f
#> 58        58     f
#> 59        59     f
#> 60        60     f
#> 61        61     g
#> 62        62     g
#> 63        63     g
#> 64        64     g
#> 65        65     g
#> 66        66     g
#> 67        67     g
#> 68        68     g
#> 69        69     g
#> 70        70     g
#> 71        71     h
#> 72        72     h
#> 73        73     h
#> 74        74     h
#> 75        75     h
#> 76        76     h
#> 77        77     h
#> 78        78     h
#> 79        79     h
#> 80        80     h
#> 81        81     i
#> 82        82     i
#> 83        83     i
#> 84        84     i
#> 85        85     i
#> 86        86     i
#> 87        87     i
#> 88        88     i
#> 89        89     i
#> 90        90     i
#> 91        91     j
#> 92        92     j
#> 93        93     j
#> 94        94     j
#> 95        95     j
#> 96        96     j
#> 97        97     j
#> 98        98     j
#> 99        99     j
#> 100      100     j

Created on 2019-06-11 by the reprex package (v0.3.0)

1 Like

Hi andresrcs,

First of all thank you very much for assisting me. Yes, I am new to R and I am in learning phase.

I was not able to describe my question correctly which you understood correctly.

I really appreciate it.

Whenever I have some doubt or issue I will take your help.

Thank you very much once again for your help.

Regards
Nikhil