Re: [R] cut{base}: is it a bug?

2018-09-24 Thread David L Carlson
- David L Carlson Department of Anthropology Texas A&M University College Station, TX 77843-4352 From: Jose Claudio Faria Sent: Monday, September 24, 2018 2:01 PM To: David L Carlson Cc: Jeff Newmiller ; r-help@r-project.org Subject: Re: [R] cut{base}:

Re: [R] cut{base}: is it a bug?

2018-09-24 Thread David Winsemius
;> Department of Anthropology >> Texas A&M University >> College Station, TX 77843-4352 >> >> -Original Message- >> From: Jeff Newmiller >> Sent: Monday, September 24, 2018 10:41 AM >> To: r-help@r-project.org; David L Carlson ; Jose >>

Re: [R] cut{base}: is it a bug?

2018-09-24 Thread Jose Claudio Faria
ty > College Station, TX 77843-4352 > > -Original Message- > From: Jeff Newmiller > Sent: Monday, September 24, 2018 10:41 AM > To: r-help@r-project.org; David L Carlson ; Jose > Claudio Faria ; r-help@r-project.org > Subject: Re: [R] cut{base}: is it a bug? > > &

Re: [R] cut{base}: is it a bug?

2018-09-24 Thread David L Carlson
t.org; David L Carlson ; Jose Claudio Faria ; r-help@r-project.org Subject: Re: [R] cut{base}: is it a bug? "Subtracting a bit" only fixes the problem for the test data... it introduces a bias in any continuous data you happen to throw at it. However, if you have data with known r

Re: [R] cut{base}: is it a bug?

2018-09-24 Thread Jeff Newmiller
,1.59)6 >[1.59,1.79)6 >[1.79,1.99)5 >[1.99,2.19]6 > > >David L Carlson >Department of Anthropology >Texas A&M University >College Station, TX 77843-4352 > > >-Original Message- >From: R-help On B

Re: [R] cut{base}: is it a bug?

2018-09-24 Thread David L Carlson
[1.79,1.99)5 [1.99,2.19]6 David L Carlson Department of Anthropology Texas A&M University College Station, TX 77843-4352 -Original Message- From: R-help On Behalf Of Jose Claudio Faria Sent: Monday, September 24, 2018 9:32 AM To: r-help@r-project.or

[R] cut{base}: is it a bug?

2018-09-24 Thread Jose Claudio Faria
Dears members, Is the below a bug of the cut {base} function? dat <- c( 0.6, 0.6, 0.6, 0.7, 0.7, 0.7, 0.7, 0.7, #(8) 0.8, 0.8, 0.8, 0.9, 0.9, 0.9, 0.9,#(7) 1.0, 1.0, 1.0, 1.0, 1.1, 1.1, 1.1,#(7) 1.2, 1.2, 1.2, 1.2, 1.3, 1.3, 1.3,#(7) 1.4, 1.4, 1.4, 1.5, 1.5, 1.5,

Re: [R] Cut Dates into bins

2016-06-08 Thread Jim Lemon
Week",1:52,sep=" ")) Jim On Wed, Jun 8, 2016 at 12:44 PM, TJUN KIAT TEO wrote: > > It does not seem to work for me. I will show you exactly my data format > > SMA$TIME_DATE > > "28/9/2014" "17/6/2014" "19/9/2014" "17/1/2015

Re: [R] Cut Dates into bins

2016-06-07 Thread TJUN KIAT TEO
"2014-06-16" "2014-06-16" "2014-06-17" "2014-06-23" What I would like to do is the cut the first set of dates into the second set of dates > From: drjimle...@gmail.com > Date: Fri, 3 Jun 2016 18:59:11 +1000 > Subject: Re: [R] Cut Dates into b

Re: [R] Cut Dates into bins

2016-06-03 Thread PIKAL Petr
fiddle with as.numeric and what do you mean by bin dates. Regards Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of TJUN KIAT > TEO > Sent: Friday, June 3, 2016 10:01 AM > To: r-help@r-project.org > Subject: [R] Cut Dates into bins

Re: [R] Cut Dates into bins

2016-06-03 Thread Jim Lemon
Hi Tjun Kiat, This seems to work: daily_date<-as.Date(paste("2000-01",1:28,sep="-"),"%Y-%m-%d") weekly_date<-as.Date(paste(c(1,8,15,22,28),"01/2000",sep="/"), "%d/%m/%Y") cut(daily_date,breaks=weekly_date,include.lowest=TRUE, labels=paste("Week",1:4)) Jim On Fri, Jun 3, 2016 at 6:00 PM, TJUN

[R] cut-off point to separate overlapping distributions

2016-02-14 Thread Luigi Marongiu
dear all, I have a set of data that can be defined as bimodal; would be possible to define a cut-off to split it? my mathematical/statistical knowledge is limited, my apologies, thus i am not sure what kind of area this problem belongs to; at the moment I can fit -- thanks to previous help from the

Re: [R] cut - strange NA as output

2015-10-06 Thread Hermann Norpois
Thanks this was very helpful. @Olivier Crouzet: Yes, round (x) would do the job but it was a principal confusion ... 2015-10-06 21:57 GMT+02:00 Marc Schwartz : > > > On Oct 6, 2015, at 2:20 PM, Hermann Norpois wrote: > > > > Hello, > > > > why do I get NA for the following: > > > > cut (x, seq

Re: [R] cut - strange NA as output

2015-10-06 Thread Olivier Crouzet
Hi, On Tue, 6 Oct 2015 21:20:13 +0200 Hermann Norpois wrote: > Hello, > > why do I get NA for the following: > > cut (x, seq (0, max(x), by=1), label=FALSE) > [1] 1322 1175 1155 1149 1295 1173 1289 1197 NA 1129 The NA comes from your max value and it's due to your seq(0, max(x), by = 1) cr

Re: [R] cut - strange NA as output

2015-10-06 Thread Marc Schwartz
> On Oct 6, 2015, at 2:20 PM, Hermann Norpois wrote: > > Hello, > > why do I get NA for the following: > > cut (x, seq (0, max(x), by=1), label=FALSE) > [1] 1322 1175 1155 1149 1295 1173 1289 1197 NA 1129 > > dput (x) > c(1321.55376901374, 1174.35657200935, 1154.02042504008, 1148.6098192594

Re: [R] cut - strange NA as output

2015-10-06 Thread William Dunlap
Because > tail(seq(0, max(x), by=1)) [1] 1350 1351 1352 1353 1354 1355 > tail(seq(0, ceiling(max(x)), by=1)) [1] 1351 1352 1353 1354 1355 1356 and max(x)=1355.88836502166 is beyond the range of the former. Bill Dunlap TIBCO Software wdunlap tibco.com On Tue, Oct 6, 2015 at 12:20 PM, Herm

[R] cut - strange NA as output

2015-10-06 Thread Hermann Norpois
Hello, why do I get NA for the following: cut (x, seq (0, max(x), by=1), label=FALSE) [1] 1322 1175 1155 1149 1295 1173 1289 1197 NA 1129 dput (x) c(1321.55376901374, 1174.35657200935, 1154.02042504008, 1148.60981925942, 1294.6166388941, 1172.45806806869, 1288.31933914639, 1196.26080041462, 1

Re: [R] cut variable within a loop

2015-08-23 Thread Janka VANSCHOENWINKEL
0, 0, 0, 0, 0, 0, 0, 0, > > > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > > > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), RO = c(0, > > > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > > > 0, 0, 0, 0, 0, 0, 0, 0, 0

Re: [R] cut variable within a loop

2015-08-16 Thread David Winsemius
64175415, 34.4827562570572, 7.95454531908035, > > 75, 0, 0, 0, 0, 0, 0, 5.26393800973892, 0, 0, 0, 0, 0, 0, 0, > > 0, 0, 74.6153831481934, 84.6153914928436, 0, 5.09554147720337, > > 0, 0, 0, 21.0884347558022, 18.4549376368523, 6.1224490404129, > > 25.373136997222

Re: [R] cut variable within a loop

2015-08-16 Thread Janka VANSCHOENWINKEL
224490404129, > > 25.3731369972229, 2.12765969336033, 0, 84.3988716602325, 0, 0, > > 0, 100), awc_class = c(106.228088378906, 78.2306137084961, > 80.9311141967773, > > 32.4921531677246, 54.8475151062012, 80.6665878295898, 116.331588745117, > > 54.84751510620

Re: [R] cut variable within a loop

2015-08-14 Thread David Winsemius
2812, 453.118286132812, > 95.2380981445312, 63), se025 = c(163.529998779297, 2.70000004768372, > 157, 5.5, 6.3019073486, 36.024577637, 86, 5.0990463257, > 6.4009536743, 6, 8.6980926514, 4, 6.3019073486, 5.8019073486, > 8.8019073486, 2, 118.809997558594,

Re: [R] cut variable within a loop

2015-08-14 Thread Janka Vanschoenwinkel
"2", "3", "4", "5", "6", "7", "8", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "2

Re: [R] cut variable within a loop

2015-08-14 Thread Janka Vanschoenwinkel
Hi Thierry and Petr, I really appreciate the comments you already gave. Thank you very much for that. Below you can find a link to the data and the code. Hopefully this helps in spotting the error. I still think the issue is that the cut2 function only accepts numbers, and not an "i" that refers

Re: [R] cut variable within a loop

2015-08-14 Thread PIKAL Petr
day, August 14, 2015 10:16 AM > To: Michael Dewey > Cc: r-help@r-project.org > Subject: Re: [R] cut variable within a loop > > Hey Michael, > > Sorry for the late reply! > > Thanks for your comment, but for the cut2 command, this is not the > case. If I enter for insta

Re: [R] cut variable within a loop

2015-08-14 Thread Janka Vanschoenwinkel
Hey Michael, Sorry for the late reply! Thanks for your comment, but for the cut2 command, this is not the case. If I enter for instance Alldata$irri=cut2(irrigation,3) Then I get 2 intervals from 0-3 and from 3-100. Janka 2015-08-11 17:25 GMT+02:00 Michael Dewey : > Dear Janka > If you suppl

Re: [R] cut variable within a loop

2015-08-11 Thread Michael Dewey
Dear Janka If you supply a single number to the breaks parameter of cut I think it is the number of intervals. On 11/08/2015 13:57, Janka Vanschoenwinkel wrote: Hi Thierry! Thanks for your answer. I tried this, but I get this error: "Error in cut.default(x, k2) : invalid number of intervals"

Re: [R] cut variable within a loop

2015-08-11 Thread Janka Vanschoenwinkel
Hi Thierry! Thanks for your answer. I tried this, but I get this error: "Error in cut.default(x, k2) : invalid number of intervals" Which is strange because I am not specifying intervals, but the number at where the sample has to be cut? Greetings from Belgium! :-) 2015-08-11 14:52 GMT+02:00 T

Re: [R] cut variable within a loop

2015-08-11 Thread Thierry Onkelinx
You'll need to send a reproducible example of the code. We can't run the code that you send. Hence it is hard to help you. See e.g. http://adv-r.had.co.nz/Reproducibility.html ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kw

Re: [R] cut variable within a loop

2015-08-11 Thread Thierry Onkelinx
Dear Janka, You loop goes for 0 to 100. It should probably go from 1:99 Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Kliniekstraat 25 1070 Anderlecht Belg

[R] cut variable within a loop

2015-08-11 Thread Janka Vanschoenwinkel
Dear list members, I have a loop where I want to do several calculations for different samples and save the results for each sample. These samples are for each loop different. I want to use the "i" in the loop to cut the samples. So for instance: - In loop 1 (i=1), I have a sample from 0-1 an

Re: [R] Cut breaks in descending order

2015-04-03 Thread David Winsemius
On Apr 3, 2015, at 5:09 AM, Wing Keong Lew wrote: > Hi, > > Is it a requirement to provide the break intervals of the cut function in > ascending order? Apparently not. I get teh sam splits even with random permutations. It is apparently a "requirement" to make sure you labels match the sorte

[R] Cut breaks in descending order

2015-04-03 Thread Wing Keong Lew
Hi, Is it a requirement to provide the break intervals of the cut function in ascending order? The help documentation for cut didn't specify this but the labels returned are reversed if I indicate the break intervals in a descending order. Here is an example tbl<-data.frame(x=c(0:10)) tbl$asce

Re: [R] cut into groups of equal nr of elements...

2013-07-20 Thread Wet Bell Diver
Witold, Here's one way: Vec <- rnorm(30) Vec.cut <- cut(Vec, breaks=c(quantile(Vec, probs = seq(0, 1, by = 0.20))), labels=c("0-20","20-40","40-60","60-80","80-100"), include.lowest=TRUE) table(Vec.cut) or determine the breaks automatically: cut.size <- function(x, size) { cut.prob <

Re: [R] cut into groups of equal nr of elements...

2013-07-18 Thread Wet Bell Diver
Here's one way: Vec <- rnorm(30) Vec.cut <- cut(Vec, breaks=c(quantile(Vec, probs = seq(0, 1, by = 0.20))), labels=c("0-20","20-40","40-60","60-80","80-100"), include.lowest=TRUE) table(Vec.cut) or determine the breaks automatically: cut.size <- function(x, size) { cut.prob <- size/leng

Re: [R] cut into groups of equal nr of elements...

2013-07-18 Thread Marc Schwartz
Greg, Good catch. My recollection was that the vector would be broken up into 'breaks' groups of equal size, however it is range(x) that is split into 'breaks' intervals, each of which is equal width. Thanks, Marc On Jul 18, 2013, at 10:55 AM, Greg Snow <538...@gmail.com> wrote: > Marc, >

Re: [R] cut into groups of equal nr of elements...

2013-07-18 Thread Wensui Liu
my fault. qcut() is a python function in pandas ;-) what i meant is cut2() in hmisc. sorry for messing up. On Jul 18, 2013 11:51 AM, "Greg Snow" <538...@gmail.com> wrote: > Wensui, > > ?qcut on my machine gives an error and ??qcut does not find anything in > the installed packages. Which packa

Re: [R] cut into groups of equal nr of elements...

2013-07-18 Thread Greg Snow
Marc, Your method works fine when the data is perfectly uniform, but try it with "Vec <- rnorm(30)" and you will see that there are more observations in the middle groups and fewer in the tail groups. Something like quantile needs to be used to find the unequally spaced breaks that will give equa

Re: [R] cut into groups of equal nr of elements...

2013-07-18 Thread Greg Snow
Wensui, ?qcut on my machine gives an error and ??qcut does not find anything in the installed packages. Which package is qcut in? On Wed, Jul 17, 2013 at 4:43 PM, Wensui Liu wrote: > ?qcut > On Jul 17, 2013 5:45 PM, "Witold E Wolski" wrote: > > > I would like to "cut" a vector into groups o

Re: [R] cut into groups of equal nr of elements...

2013-07-17 Thread Marc Schwartz
On Jul 17, 2013, at 4:43 PM, Witold E Wolski wrote: > I would like to "cut" a vector into groups of equal nr of elements. > looking for a function on the lines of cut but where I can specify > the size of the groups instead of the nr of groups. In addition to the other options, if the 'breaks'

Re: [R] cut into groups of equal nr of elements...

2013-07-17 Thread Wensui Liu
?qcut On Jul 17, 2013 5:45 PM, "Witold E Wolski" wrote: > I would like to "cut" a vector into groups of equal nr of elements. > looking for a function on the lines of cut but where I can specify > the size of the groups instead of the nr of groups. > > > > > -- > Witold Eryk Wolski > > __

Re: [R] cut into groups of equal nr of elements...

2013-07-17 Thread arun
:04 PM Subject: Re: [R] cut into groups of equal nr of elements... HI, Not sure whether this is what you wanted.  vec1<- 1:7  fun1<- function(x,nr) {((x-1)%/%nr)+1}  fun1(vec1,2) #[1] 1 1 2 2 3 3 4  fun1(vec1,3) #[1] 1 1 1 2 2 2 3 split(vec1,fun1(vec1,2)) A.K. - Original Messag

Re: [R] cut into groups of equal nr of elements...

2013-07-17 Thread arun
nesday, July 17, 2013 5:43 PM Subject: [R] cut into groups of equal nr of elements... I would like to "cut" a vector into groups of equal nr of elements. looking for a function on the lines of cut but where I can specify the size of the groups instead of the nr of groups. -- Wi

Re: [R] cut into groups of equal nr of elements...

2013-07-17 Thread Greg Snow
You could use the quantile function to choose the cut points and pass that to cut. Or you could sort the vector and just take the first n elements as the 1st group, etc. On Wed, Jul 17, 2013 at 3:43 PM, Witold E Wolski wrote: > I would like to "cut" a vector into groups of equal nr of elements

[R] cut into groups of equal nr of elements...

2013-07-17 Thread Witold E Wolski
I would like to "cut" a vector into groups of equal nr of elements. looking for a function on the lines of cut but where I can specify the size of the groups instead of the nr of groups. -- Witold Eryk Wolski __ R-help@r-project.org mailing list http

Re: [R] cut a vector in equal parts

2013-02-27 Thread Patrick Burns
There is a discussion of the ways to do this task (which can be trickier than it seems) at: http://www.portfolioprobe.com/2012/12/24/miles-of-iles/ Pat On 26/02/2013 17:39, Martin Batholdy wrote: Hi, I would like to cut a vector of values in parts. Each part should have an equal number of el

Re: [R] cut a vector in equal parts

2013-02-26 Thread David L Carlson
ollege Station, TX 77843-4352 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Rui Barradas > Sent: Tuesday, February 26, 2013 1:59 PM > To: Martin Batholdy > Cc: r-help@r-project.org > Subject: Re: [R] cut

Re: [R] cut a vector in equal parts

2013-02-26 Thread Rui Barradas
Hello, Try the following. x <- rnorm(500)^2 split(x, cut(x, quantile(x, probs = seq(0, 1, by = 0.2 Hope this helps, Rui Barradas Em 26-02-2013 17:39, Martin Batholdy escreveu: Hi, I would like to cut a vector of values in parts. Each part should have an equal number of elements. for e

Re: [R] cut a vector in equal parts

2013-02-26 Thread jim holtman
?sort ?cut On Tue, Feb 26, 2013 at 12:39 PM, Martin Batholdy wrote: > Hi, > > I would like to cut a vector of values in parts. > Each part should have an equal number of elements. > > for example: > > x <- (rnorm(500)^2) > > now I want 5 vectors each with 100 elements. > The first vector should i

[R] cut a vector in equal parts

2013-02-26 Thread Martin Batholdy
Hi, I would like to cut a vector of values in parts. Each part should have an equal number of elements. for example: x <- (rnorm(500)^2) now I want 5 vectors each with 100 elements. The first vector should include the 100 lowest values of x and so on (so that the fifth vector contains the 100 h

Re: [R] cut ()

2013-01-01 Thread Neal H. Walfield
At Tue, 1 Jan 2013 02:00:14 +, Muhuri, Pradip (SAMHSA/CBHSQ) wrote: > Although David's solution (putting the right parenthesis, which I had missed) > has resolved the issue, I would like to try yours as well. > > Could you please clarify the six elements: c(-1e-8, 0, 0, 0, 0, 1e8)? It's a v

Re: [R] cut ()

2012-12-31 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
From: Neal H. Walfield [n...@walfield.org] Sent: Monday, December 31, 2012 5:42 PM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: R help Subject: Re: [R] cut () At Mon, 31 Dec 2012 22:25:25 +, Muhuri, Pradip (SAMHSA/CBHSQ) wrote: > The issue is that, for Utah, I am getting an instead of (42,48.7

Re: [R] cut ()

2012-12-31 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
help' Subject: RE: [R] cut () A misplaced right parenthesis caused the problem: p1_st_data$ob_mrj_cat <- cut (p1_st_data$obt_mrj_p, quantile (p1_st_data$obt_mrj_p, (0:5/5), include.lowest=TRUE)) Should be p1_st_data$ob_mrj_cat <- cut (p1_st_data$obt_mrj_p, quantile (p1_st_data$o

Re: [R] cut ()

2012-12-31 Thread David L Carlson
radip (SAMHSA/CBHSQ) > Sent: Monday, December 31, 2012 4:25 PM > To: R help > Subject: [R] cut () > > Hello List, > > > My goal is to create a 5 category variable (p1_st_data$ob_mrj_cat), > based on the p1_st_data$obt_mrj_p variable, using the following code

Re: [R] cut ()

2012-12-31 Thread Neal H. Walfield
At Mon, 31 Dec 2012 22:25:25 +, Muhuri, Pradip (SAMHSA/CBHSQ) wrote: > The issue is that, for Utah, I am getting an instead of (42,48.7] in the > ob_mrj_cat column. The problem is likely due to comparisons of floating point numbers. Try moving your lower and upper bounds out a tiny bit. Whe

[R] cut ()

2012-12-31 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello List, My goal is to create a 5 category variable (p1_st_data$ob_mrj_cat), based on the p1_st_data$obt_mrj_p variable, using the following code for 50 States and District of Columbia (N=51). p1_st_data$ob_mrj_cat <- cut (p1_st_data$obt_mrj_p, quantile (p1_st_data$obt_mrj_p, (0:5/5), incl

Re: [R] cut point in ROC

2012-10-25 Thread Bhupendrasinh Thakre
Please use dput while supplying data. Best Regards, Bhupendrasinh Thakre Sent from my iPhone On Oct 25, 2012, at 5:31 AM, Soheila Khodakarim wrote: > var1 > > var2 > > var3 > > var4 > > var5 > > var6 > > var7 > > var8 > > var9 > > var10 > > gold > > 2 > > 3 > > 1 > > 2 > > 4 >

[R] cut point in ROC

2012-10-25 Thread Soheila Khodakarim
var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 gold 2 3 1 2 4 0 1 4 4 3 2 2 4 2 4 3 4 2 4 4 4 2 3 3 0 0 4 1 0 2 4 4 2 1 4 0 3 2 0 0 2 4 4 2 3 4 0 2 2 0 0 0 3 4 2 2 2 3 2 2 0 0 0 2 4 2 2 4 1 1 2 0 0 3 3 3 2 3

Re: [R] cut data into sevral group and assign calculated values individually

2011-10-19 Thread Petr PIKAL
x 0 0 > > Thank you very much! > > Regards, > Yan > > -Original Message- > From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] > Sent: Tuesday, October 18, 2011 5:23 AM > To: Li, Yan > Cc: r-help@r-project.org > Subject: Re: [

Re: [R] cut data into sevral group and assign calculated values individually

2011-10-18 Thread Li, Yan
1 x 0 0 Thank you very much! Regards, Yan -Original Message- From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Sent: Tuesday, October 18, 2011 5:23 AM To: Li, Yan Cc: r-help@r-project.org Subject: Re: [R] cut data into sevral group and ass

Re: [R] cut data into sevral group and assign calculated values individually

2011-10-18 Thread Uwe Ligges
On 17.10.2011 20:53, Li, Yan wrote: Hi All, I have some data from which I set four points to be breaks. Based on these points, I cut the dataset into four groups and assign a number to it: <=331.04 assign 0 331.04<=476.07 assign data-331.04/(476.07-331.04) 476.07<=608.66 assign 1 608.66<=

[R] cut data into sevral group and assign calculated values individually

2011-10-17 Thread Li, Yan
Hi All, I have some data from which I set four points to be breaks. Based on these points, I cut the dataset into four groups and assign a number to it: <=331.04 assign 0 >331.04 <=476.07 assign data-331.04/(476.07-331.04) >476.07<=608.66 assign 1 >608.66 <=791.5 assign 791.5- data/(791.5-608.

Re: [R] cut & histogram

2011-04-20 Thread Jim Lemon
On 04/20/2011 12:32 AM, Santosh wrote: Dear Rxperts, Below is a small sample of values (cut short due to space considerations while posting).. I was wondering if it is possible to construct boundaries (or intervals) based on the distribution of points. Is it anything similar to boundary detecti

Re: [R] cut & histogram

2011-04-19 Thread David Winsemius
On Apr 19, 2011, at 10:32 AM, Santosh wrote: Dear Rxperts, Below is a small sample of values (cut short due to space considerations while posting).. I was wondering if it is possible to construct boundaries (or intervals) based on the distribution of points. Is it anything similar to b

[R] cut & histogram

2011-04-19 Thread Santosh
Dear Rxperts, Below is a small sample of values (cut short due to space considerations while posting).. I was wondering if it is possible to construct boundaries (or intervals) based on the distribution of points. Is it anything similar to boundary detection of distributions? x1 <- c(0.00,0.25,0.

[R] Cut off end of string [and some chemotherapy staff]

2011-03-12 Thread Denis Kazakiewicz
У Срд, 09/03/2011 у 23:29 -0800, Dennis Murphy піша: > Hi: > > Here's one approach, although I imagine there are more efficient ways. > > # A function to strip spaces and return the first three non-blank elements > of a string > keyset <- function(x) substr(gsub(' ', '', x)[1], 1, 3) Hello to ev

Re: [R] Cut including the 0 value as separate bin

2010-10-26 Thread Henrique Dallazuanna
Try this: cut(DF$A, c(-Inf, 0, 4, 8, 12, 14, 16, 20)) On Tue, Oct 26, 2010 at 7:01 PM, LCOG1 wrote: > > Hi everyone, > > I have been using R too long to have to ask this but here i am. How do i > create a separate bin for the 0 value? So for: > > #Create data frame > DF<-data.frame(A=0:20)

[R] Cut including the 0 value as separate bin

2010-10-26 Thread LCOG1
Hi everyone, I have been using R too long to have to ask this but here i am. How do i create a separate bin for the 0 value? So for: #Create data frame DF<-data.frame(A=0:20) #Create label vector labs<-1:6 #Create buckets and label DF$Cut<-cut(DF$A,c(0,4,8,12,14,16,20),labels=labs,include.l

Re: [R] Cut a within elements by length, not value, of vectors

2010-07-15 Thread Benjamin Caldwell
Thanks all! That did it. On Thu, Jul 15, 2010 at 11:07 AM, Nikhil Kaza wrote: > Building on Erik's solution and because it would easier to do date > arithmetic.. > > d1 <- as.character(date) > d1 <- ifelse(nchar(d1)<4, paste(0,d1,sep=""),d1) > d2 <- as.Date(date, "%m%d") > > > On Jul 15, 2010, a

Re: [R] Cut a within elements by length, not value, of vectors

2010-07-15 Thread Nikhil Kaza
Building on Erik's solution and because it would easier to do date arithmetic.. d1 <- as.character(date) d1 <- ifelse(nchar(d1)<4, paste(0,d1,sep=""),d1) d2 <- as.Date(date, "%m%d") On Jul 15, 2010, at 1:21 PM, btc1 wrote: Hello, I have a vector, "dates", as a series of 3 digit elements,

Re: [R] Cut a within elements by length, not value, of vectors

2010-07-15 Thread Henrique Dallazuanna
Try this: gsub("^(.)", "\\1/", dates) On Thu, Jul 15, 2010 at 2:21 PM, btc1 wrote: > > Hello, I have a vector, "dates", as a series of 3 digit elements, i.e. > > date > [1] 528 528 528 528 528 528 528 528 528 528 528 528 708 708 708 708 708 > 708 > [19] 708 708 708 708 529 529 529 529 529 5

Re: [R] Cut a within elements by length, not value, of vectors

2010-07-15 Thread Wu Gong
gsub("(.*)(.{2})","\\1/\\2",dates) - A R learner. -- View this message in context: http://r.789695.n4.nabble.com/Cut-a-within-elements-by-length-not-value-of-vectors-tp2290440p2290471.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] Cut a within elements by length, not value, of vectors

2010-07-15 Thread Erik Iverson
btc1 wrote: Hello, I have a vector, "dates", as a series of 3 digit elements, i.e. > date [1] 528 528 528 528 528 528 528 528 528 528 528 528 708 708 708 708 708 708 [19] 708 708 708 708 529 529 529 529 529 529 529 529 529 529 529 529 529 529 [37] 529 624 I need to convert them into julian

Re: [R] Cut a within elements by length, not value, of vectors

2010-07-15 Thread Martyn Byng
uot; "12/08" "4/23" "15/06" "3/21" Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of btc1 Sent: 15 July 2010 18:22 To: r-help@r-project.org Subject: [R] Cut a within elements by length,

[R] Cut a within elements by length, not value, of vectors

2010-07-15 Thread btc1
Hello, I have a vector, "dates", as a series of 3 digit elements, i.e. > date [1] 528 528 528 528 528 528 528 528 528 528 528 528 708 708 708 708 708 708 [19] 708 708 708 708 529 529 529 529 529 529 529 529 529 529 529 529 529 529 [37] 529 624 I need to convert them into julian, but have to i

[R] cut edge from surface using persp()

2010-06-09 Thread marlene marchena
Hi R users! Is it possible to cut the edges from a surface graph without to cut the axes using persp function? I am using the following code: op <- par(bg = "white") persp(phi1, phi2, z,main="Bullwhip generated with AR(2) demand when L=1", xlab ="phi1" , ylab ="phi2", zlab ="Bullwhip", t

Re: [R] cut out single lines out of matrix

2010-03-17 Thread Petr PIKAL
Hi I am a bit curious why one shall do such a twisted construction. Accessing list is basically the same as accessing corresponding matrix row, you only need to remember drop=FALSE option. Regards Petr r-help-boun...@r-project.org napsal dne 17.03.2010 00:58:54: > Here is a way of creating a

Re: [R] cut out single lines out of matrix

2010-03-16 Thread jim holtman
Here is a way of creating a list of the matrices: > x <- matrix(1:(12*30), nrow=30) > # create a list of single row matrices > x.l <- lapply(seq(nrow(x)), function(a) x[a,, drop=FALSE]) > > x.l [[1]] [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,]1 31 61 91 121

[R] cut out single lines out of matrix

2010-03-16 Thread Schmidt Martin
Hey dear users I'm trying to kind of split my matrix which looks as follows: dim(out) [1] 30 12 What I finally want is each line as it's own matrix which I can handle then separately. Like, say: out1<- [1,] out2<-[2,] .. Would you do that with a for() loop or does exist an other approp

[R] Cut-aways with contour3d

2010-03-15 Thread Waichler, Scott R
Luke, Thanks for your previous advice on using misc3d; I've been able to get a good start with it. Most of my colleagues use Tecplot for graphing and are wondering if I can make "cut-aways" using R. An example is attached. The idea is show a 3D isosurface of one property together with a 2D c

Re: [R] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread David Winsemius
On Dec 1, 2009, at 3:28 PM, Gabor Grothendieck wrote: > Try this: > > > library(gsubfn) > > strapply(testvec, "[-+.0-9]+", as.numeric, simplify = ~ > colMeans(cbind(...))) > [1] -5.8500 -2.9800 -2.8160 -2.7120 -2.6325 -2.5680 Very, nice. Also tried on some other valid ("200,2") and invalid )

Re: [R] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread Gabor Grothendieck
Try this: > library(gsubfn) > strapply(testvec, "[-+.0-9]+", as.numeric, simplify = ~ colMeans(cbind(...))) [1] -5.8500 -2.9800 -2.8160 -2.7120 -2.6325 -2.5680 On Tue, Dec 1, 2009 at 3:14 PM, David Winsemius wrote: > I'm sitting here chuckling. Your solution is just so "pure". > > I would offer

Re: [R] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread David Winsemius
I'm sitting here chuckling. Your solution is just so "pure". I would offer an enhancement. When I tested with my cuts that had "-" before the digits, you solution dropped them, so my suggestion for the pattern would be: "[-[:digit:].]+" I will admit that I thought it might fail with posit

Re: [R] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread Henrique Dallazuanna
Perhaps this shoul work too: sapply(strsplit(gsub("^\\W|\\W$", "", testvec), ","), function(x)sum(as.numeric(x))/2) On Tue, Dec 1, 2009 at 5:41 PM, David Winsemius wrote: > Starting with the head of a 499 element matrix whose column names are now > the labels trom a cut() operation, I needed to

Re: [R] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread Gabor Grothendieck
You also might want to look at demo("gsubfn-cut") On Tue, Dec 1, 2009 at 2:41 PM, David Winsemius wrote: > Starting with the head of a 499 element matrix whose column names are now > the labels trom a cut() operation, I needed to get to a vector of midpoints > to serve as the basis for plotting

[R] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread David Winsemius
Starting with the head of a 499 element matrix whose column names are now the labels trom a cut() operation, I needed to get to a vector of midpoints to serve as the basis for plotting a calibration curve ( exp(linear predictor) vs. : > dput(head(dimnames(mtcal)[2][[1]])) # was starting po

Re: [R] cut and re-factor data

2009-09-22 Thread johannes rara
Try e.g. function recode from package car. 2009/9/22 Chris Hane : > Hello R-users, > I have a data frame with a factor of ages in 5 year increments, and various > count data for each age group. I only have this summary information in R at > the moment. > > I want to create a new factor that aggreg

[R] cut and re-factor data

2009-09-22 Thread Chris Hane
Hello R-users, I have a data frame with a factor of ages in 5 year increments, and various count data for each age group. I only have this summary information in R at the moment. I want to create a new factor that aggregates the age factors if the existing factors have insufficient counts. Then I

Re: [R] cut with floating point, a bug?

2009-06-19 Thread Duncan Murdoch
Shawn Rutledge wrote: With floating point numbers I'm seeing 'cut' putting values in the wrong bands. An example below places 0.3 in (0.3,0.6] i.e. 0.3 > 0.3. x = 1:5*.1 x [1] 0.1 0.2 0.3 0.4 0.5 cut(x, br=c(0,.3,.6)) [1] (0,0.3] (0,0.3] (0.3,0.6] (0.3,0.6] (0.3,0.6] Leve

[R] cut with floating point, a bug?

2009-06-18 Thread Shawn Rutledge
With floating point numbers I'm seeing 'cut' putting values in the wrong bands. An example below places 0.3 in (0.3,0.6] i.e. 0.3 > 0.3. > x = 1:5*.1 > x [1] 0.1 0.2 0.3 0.4 0.5 > cut(x, br=c(0,.3,.6)) [1] (0,0.3] (0,0.3] (0.3,0.6] (0.3,0.6] (0.3,0.6] Levels: (0,0.3] (0.3,0.6] I'm sure this i

Re: [R] cut with intervals open on the right?

2007-10-19 Thread Pedro de Barros
Thanks for the quick and nice reply. I must apologise twice: 1-I should have reported I am using R 2.5.1 on Windows; 2- It was a spelling error on my part (rigth instead of right). Pedro At 11:27 2007/10/19, you wrote: >Works for me with current R-2.6.0 (but you haven't told us about >your R ver

Re: [R] cut with intervals open on the right?

2007-10-19 Thread Uwe Ligges
Works for me with current R-2.6.0 (but you haven't told us about your R version!): > cut(1:5, 1:5) [1] (1,2] (2,3] (3,4] (4,5] Levels: (1,2] (2,3] (3,4] (4,5] > cut(1:5, 1:5, right=FALSE) [1] [1,2) [2,3) [3,4) [4,5) Levels: [1,2) [2,3) [3,4) [4,5) Uwe Ligges Pedro de Barros wrote: > Dear

[R] cut with intervals open on the right?

2007-10-19 Thread Pedro de Barros
Dear All, I am trying to use cut() to produce intervals open on the right, but it seems to ignore the argument right=F, contrary to what is indicated on the help for cut. Can anyone help? Thanks, Pedro __ R-help@r-project.org mailing list https://st