Bert Gunter
2022-Jan-17 15:34 UTC
[R] How to convert category (or range/group) into continuous ?
IMO, this is a bad idea. You are asking how to fabricate information that isn't there. You lost the information when you created the categories. Why can you not just go back to your original data? Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Sun, Jan 16, 2022 at 11:06 PM Marna Wagley <marna.wagley at gmail.com> wrote:> Hi R users, > I first categorized the continuous data into groups (ranges or category) > but now I would like to change the category into a continuous data and > plot it. For example I have attached the data in which you can see two > columns named "group" and "value". The group column contains a range > (group, for example ), I am wondering how I can change the category data > (for example: "0,0.01]" )into continuous data with a 0.1 interval. > Thank you for your suggestions. > > daT<-structure(list(group = c("(0,0.01]", "(0.01,0.025]", "(0.025,0.05]", > "(0.05,0.075]", "(0.075,0.1]", "(0.1,0.2]", "(0.2,0.3]", "(0.3,0.4]", > "(0.4,0.5]", "(0.5,0.6]", "(0.6,0.7]", "(0.7,0.8]", "(0.8,0.9]", > "(0.9,1]", "(1,1.1]", "(1.1,1.5]", "(1.5,2]", "(2,2.5]"), VALUE = c(1, > 1, 1, 1, 1, 1, 0.944444444, 0.916666667, 0.888888889, 0.857777778, > 0.826666667, 0.66, 0.439090909, 0.328636364, 0.273409091, 0.245795455, > 0.218181818, 0.084848485)), class = "data.frame", row.names = c(NA, > -18L)) > thanks, > MW > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Stephen H. Dawson, DSL
2022-Jan-17 15:36 UTC
[R] How to convert category (or range/group) into continuous ?
Thank you, Bert. You beat me to the reply. I concur, original source is best. Too much at risk otherwise, IMO. *Stephen Dawson, DSL* /Executive Strategy Consultant/ Business & Technology +1 (865) 804-3454 http://www.shdawson.com <http://www.shdawson.com> On 1/17/22 10:34 AM, Bert Gunter wrote:> IMO, this is a bad idea. You are asking how to fabricate information that > isn't there. You lost the information when you created the categories. Why > can you not just go back to your original data? > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along and > sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > On Sun, Jan 16, 2022 at 11:06 PM Marna Wagley <marna.wagley at gmail.com> > wrote: > >> Hi R users, >> I first categorized the continuous data into groups (ranges or category) >> but now I would like to change the category into a continuous data and >> plot it. For example I have attached the data in which you can see two >> columns named "group" and "value". The group column contains a range >> (group, for example ), I am wondering how I can change the category data >> (for example: "0,0.01]" )into continuous data with a 0.1 interval. >> Thank you for your suggestions. >> >> daT<-structure(list(group = c("(0,0.01]", "(0.01,0.025]", "(0.025,0.05]", >> "(0.05,0.075]", "(0.075,0.1]", "(0.1,0.2]", "(0.2,0.3]", "(0.3,0.4]", >> "(0.4,0.5]", "(0.5,0.6]", "(0.6,0.7]", "(0.7,0.8]", "(0.8,0.9]", >> "(0.9,1]", "(1,1.1]", "(1.1,1.5]", "(1.5,2]", "(2,2.5]"), VALUE = c(1, >> 1, 1, 1, 1, 1, 0.944444444, 0.916666667, 0.888888889, 0.857777778, >> 0.826666667, 0.66, 0.439090909, 0.328636364, 0.273409091, 0.245795455, >> 0.218181818, 0.084848485)), class = "data.frame", row.names = c(NA, >> -18L)) >> thanks, >> MW >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
peter dalgaard
2022-Jan-17 18:35 UTC
[R] How to convert category (or range/group) into continuous ?
Depends on what was meant. If you just want the interval midpoints for plotting, you can do something like endp <- c(0,.01, .025, .05, ... 2.5) # some manual assembly required here mid <- (head(endp, -1) + tail(endp, -1))/2 groupmid <- mid[group] plot(groupmid, VALUE) -pd> On 17 Jan 2022, at 16:34 , Bert Gunter <bgunter.4567 at gmail.com> wrote: > > IMO, this is a bad idea. You are asking how to fabricate information that > isn't there. You lost the information when you created the categories. Why > can you not just go back to your original data? > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along and > sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > On Sun, Jan 16, 2022 at 11:06 PM Marna Wagley <marna.wagley at gmail.com> > wrote: > >> Hi R users, >> I first categorized the continuous data into groups (ranges or category) >> but now I would like to change the category into a continuous data and >> plot it. For example I have attached the data in which you can see two >> columns named "group" and "value". The group column contains a range >> (group, for example ), I am wondering how I can change the category data >> (for example: "0,0.01]" )into continuous data with a 0.1 interval. >> Thank you for your suggestions. >> >> daT<-structure(list(group = c("(0,0.01]", "(0.01,0.025]", "(0.025,0.05]", >> "(0.05,0.075]", "(0.075,0.1]", "(0.1,0.2]", "(0.2,0.3]", "(0.3,0.4]", >> "(0.4,0.5]", "(0.5,0.6]", "(0.6,0.7]", "(0.7,0.8]", "(0.8,0.9]", >> "(0.9,1]", "(1,1.1]", "(1.1,1.5]", "(1.5,2]", "(2,2.5]"), VALUE = c(1, >> 1, 1, 1, 1, 1, 0.944444444, 0.916666667, 0.888888889, 0.857777778, >> 0.826666667, 0.66, 0.439090909, 0.328636364, 0.273409091, 0.245795455, >> 0.218181818, 0.084848485)), class = "data.frame", row.names = c(NA, >> -18L)) >> thanks, >> MW >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com