Skip to content
Prev 390669 / 398500 Next

exp / log scaled version of cut?

In plotting with ggplot the graphing function geom_histogram() can do this for you. https://www.tutorialgateway.org/r-ggplot2-histogram/#:~:text=The%20syntax%20to%20draw%20a%20ggplot%20Histogram%20in,%3D%20FALSE%2C%20show.legend%20%3D%20NA%2C%20inherit.aes%20%3D%20TRUE%29

Binning the raw data could be done using case_when() see https://www.rdocumentation.org/packages/dplyr/versions/0.7.8/topics/case_when

With case_when() you could create a new variable so that you have the original data to refer back to. You might be able to overlay a plot of the axes in the raw data and the graph in binned data. I am not sure that would make much sense, and might be a way to trick readers into making bad conclusions: plotting binned data onto a continuous axis. Might work better to plot the binned data and then change labels using commands like 
xlab(), ylab(), theme(axis_title.x=element_blank()), axis_title.x=element_text(), labs(x="my x", y="my y")

http://www.sthda.com/english/wiki/ggplot2-axis-ticks-a-guide-to-customize-tick-marks-and-labels
https://www.datanovia.com/en/blog/ggplot-axis-labels/

Depending on exactly what you want to do here.

Regards,
Tim

-----Original Message-----
From: R-help <r-help-bounces at r-project.org> On Behalf Of Uwe Ligges
Sent: Thursday, February 3, 2022 7:42 AM
To: Fredrik Karlsson <dargosch at gmail.com>; R-help <r-help at r-project.org>
Subject: Re: [R] exp / log scaled version of cut?

[External Email]
On 03.02.2022 11:06, Fredrik Karlsson wrote:
Yes, cut():

x <- runif(100, 0, 100)
cut(x, c(0, 10, 100))

Best,
Uwe Ligges

______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp&d=DwICAg&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAsRzsn7AkP-g&m=E5bX46POI6aWCVW2Sn1gYLSC19ff-eoqeKiPmpipinQEE2CU38mPX2ReGsGWTfwG&s=MsUQlOyfUie2u5p7BJAJzW-BHNtXOlFZMiq-hPxTRVQ&e=
PLEASE do read the posting guide https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html&d=DwICAg&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAsRzsn7AkP-g&m=E5bX46POI6aWCVW2Sn1gYLSC19ff-eoqeKiPmpipinQEE2CU38mPX2ReGsGWTfwG&s=q8534zhXd2FeFS4Z_Dth5YadYUs4P_9ZXjxdohleFB0&e=
and provide commented, minimal, self-contained, reproducible code.
Message-ID: <BN6PR2201MB15532150D3FABC1DADD7A94FCF289@BN6PR2201MB1553.namprd22.prod.outlook.com>
In-Reply-To: <c8773396-b593-c801-4949-67d32b7ccaef@statistik.tu-dortmund.de>