How ‘breaks’ and ‘ cut’ works in R?

0 votes
How ‘breaks’ and ‘ cut’ works in R?
Oct 14 in Data Analytics by ch
• 3,290 points
21 views

1 answer to this question.

0 votes

@ch,

Cut divides the range of x into intervals and codes the values in x according to which interval they fall. breaks indicate the number of levels or intervals required to categorize the values.

Example:

> c = c(1:50)
> cut(c,breaks = 3)
 [1] (0.951,17.3] (0.951,17.3] (0.951,17.3] (0.951,17.3] (0.951,17.3] (0.951,17.3] (0.951,17.3] (0.951,17.3]
 [9] (0.951,17.3] (0.951,17.3] (0.951,17.3] (0.951,17.3] (0.951,17.3] (0.951,17.3] (0.951,17.3] (0.951,17.3]
[17] (0.951,17.3] (17.3,33.7]  (17.3,33.7]  (17.3,33.7]  (17.3,33.7]  (17.3,33.7]  (17.3,33.7]  (17.3,33.7] 
[25] (17.3,33.7]  (17.3,33.7]  (17.3,33.7]  (17.3,33.7]  (17.3,33.7]  (17.3,33.7]  (17.3,33.7]  (17.3,33.7] 
[33] (17.3,33.7]  (33.7,50]    (33.7,50]    (33.7,50]    (33.7,50]    (33.7,50]    (33.7,50]    (33.7,50]   
[41] (33.7,50]    (33.7,50]    (33.7,50]    (33.7,50]    (33.7,50]    (33.7,50]    (33.7,50]    (33.7,50]   
[49] (33.7,50]    (33.7,50]   
Levels: (0.951,17.3] (17.3,33.7] (33.7,50]
answered Oct 14 by rohan

Related Questions In Data Analytics

0 votes
1 answer

How can we trim leading and trailing whitespaces in R?

trimws {base} //Remove Leading/Trailing Whitespace Removes leading and/or ...READ MORE

answered Apr 18, 2018 in Data Analytics by zombie
• 3,690 points
567 views
0 votes
1 answer

How to filter a data frame with dplyr and tidy evaluation in R?

Requires the use of map_df to run each model, ...READ MORE

answered May 16, 2018 in Data Analytics by DataKing99
• 8,130 points
139 views
0 votes
1 answer

How to forecast season and trend of data using STL and ARIMA in R?

You can use the forecast.stl function for the ...READ MORE

answered May 18, 2018 in Data Analytics by DataKing99
• 8,130 points
591 views
0 votes
1 answer

How to calculate group mean and assign it to new data in R

You can use something like this: df$grp.mean.values <- ...READ MORE

answered Jun 27, 2018 in Data Analytics by darklord
• 6,170 points
58 views
0 votes
1 answer

By using dpylr package sum of multiple columns

Basically here we are making an equation ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
116 views
0 votes
1 answer

How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
161 views
0 votes
1 answer

In a dpylr pipline how to use sample and seq?

For avoiding rowwise(), I prefer to use ...READ MORE

answered Apr 6, 2018 in Data Analytics by DeepCoder786
• 1,720 points
87 views
0 votes
1 answer

How to create a list of Data frames?

Basically all we have to do is ...READ MORE

answered Apr 9, 2018 in Data Analytics by DeepCoder786
• 1,720 points
105 views
0 votes
1 answer

How to convert a continuous variable to discrete variable and vice versa in R?

Discretize function convert a continuous variable into ...READ MORE

answered Nov 4 in Data Analytics by rajeev
69 views
0 votes
1 answer

In R programming language, how do I export data in .txt?

See this image for ways to export ...READ MORE

answered Oct 11 in Data Analytics by ashwini
22 views