Re: [R] exporting tables from an access database using parallel foreach

2015-11-21 Thread Rainer Hurling
Am 22.11.15 um 02:38 schrieb John McKown: > On Sat, Nov 21, 2015 at 11:55 AM, Vivek Sutradhara > wrote: > >> Hi John and Jeff, >> Thanks a lot for your help. I agree that row numbers are not a standard >> feature in SQL. What I am looking for is some kind of a hack. After all, >> the sqlFetch com

Re: [R] summarize_ (NSE) in combination with quantile not working

2015-11-21 Thread David Winsemius
> On Nov 21, 2015, at 3:33 PM, Tobias Byland wrote: > > Hi everyone, > > I am stumbling over the following issue when using the NSE (non-standard > evaluation) of the summarise function in dpylr (as described here: > https://cran.r-project.org/web/packages/dplyr/vignettes/nse.html): > > mtca

Re: [R] summarize_ (NSE) in combination with quantile not working

2015-11-21 Thread Jeff Newmiller
Please post using plain text. The following works. mutate %>% summarise_( ~quantile( mpg, 0.1 ) ) Read the vignette on nse that comes with dplyr, or Google the error message. On November 21, 2015 3:33:16 PM PST, Tobias Byland wrote: >Hi everyone, > >I am stumbling over the following issue wh

[R] summarize_ (NSE) in combination with quantile not working

2015-11-21 Thread Tobias Byland
Hi everyone, I am stumbling over the following issue when using the NSE (non-standard evaluation) of the summarise function in dpylr (as described here: https://cran.r-project.org/web/packages/dplyr/vignettes/nse.html): mtcars %>% summarise(min(mpg)) # summarize and min mtcars %>% summar

Re: [R] exporting tables from an access database using parallel foreach

2015-11-21 Thread John McKown
On Sat, Nov 21, 2015 at 11:55 AM, Vivek Sutradhara wrote: > Hi John and Jeff, > Thanks a lot for your help. I agree that row numbers are not a standard > feature in SQL. What I am looking for is some kind of a hack. After all, > the sqlFetch command is able to return a specific number of rows. An

Re: [R] Conditional Random selection

2015-11-21 Thread Ashta
Thank you ! I was also able to do it this way, too! hc <- ddply(tab1, .(time), summarize, S1 = length(unique(S1))) On Sat, Nov 21, 2015 at 3:40 PM, wrote: > Hello, > > Is that a real doubt? Like Bert said, you should spend some time with an R > tutorial. All you need is to know how to form a

Re: [R] Conditional Random selection

2015-11-21 Thread ruipbarradas
Hello, Is that a real doubt? Like Bert said, you should spend some time with an R tutorial. All you need is to know how to form a data.frame. tmp <- tapply(tab1$S1, tab1$time, function(x) length(unique(x))) data.frame(time = names(tmp), S1 = tmp) Rui Barradas   Citando Ashta : > Hi  Rui , >

Re: [R] Conditional Random selection

2015-11-21 Thread Ashta
Hi Rui , I tried that one before I send out my original message. it gave me only this, tapply(tab$S1, tab$time, function(x) length(unique(x))) 1 2 3 2 1 3 I am expecting an output of like this time S1 12 21 33 On Sat, Nov 21, 2015 at 2:38 PM, wrote: > Hello,

Re: [R] Conditional Random selection

2015-11-21 Thread ruipbarradas
Hello, Try tapply(tab$S1, tab$time, function(x) length(unique(x))) Hope this helps, Rui Barradas   Citando Ashta : > Hi  Bert  and all, > I have related question.  In each  time period there were different > locations where the samples were collected (S1).   I  want count  the > number of uni

Re: [R] Conditional Random selection

2015-11-21 Thread Bert Gunter
Time to do your own homework by working through an R tutorial or two. There are many on the web -- or see the Intro to R tutorial that ships with R. ?tapply ?unique is one of many answers to your query. Cheers, Bert Bert Gunter "Data is not information. Information is not knowledge. And knowled

Re: [R] Conditional Random selection

2015-11-21 Thread Ashta
Hi Bert and all, I have related question. In each time period there were different locations where the samples were collected (S1). I want count the number of unique locations (S1) for each unique time period . So in time 1 the samples were collected from two locations and time 2 only from

Re: [R] Conditional Random selection

2015-11-21 Thread Ashta
Thank you Bert! What I want is at least 500 samples based on random sampling of time period. This allows samples collected at the same time period are included together. Your script is doing what I wanted to do!! Many thanks On Sat, Nov 21, 2015 at 1:15 PM, Bert Gunter wrote: > David's "

Re: [R] Conditional Random selection

2015-11-21 Thread Bert Gunter
David's "solution" is incorrect. It can also fail to give you times with a total of 500 items to sample from in the time periods. It is not entirely clear what you want. The solution below gives you a random sample of time periods in which X1>0 and the total number of samples among them is >= 500.

Re: [R] Conditional Random selection

2015-11-21 Thread Ashta
Thank you David! I rerun the your script and it is giving me the first three time periods is it doing random sampling? tab.fan time X1 X2 22 5 230 33 1 300 55 2 10 On Sat, Nov 21, 2015 at 12:20 PM, David L Carlson wrote: > Use dput() to send data to the list as it is

Re: [R] Conditional Random selection

2015-11-21 Thread David L Carlson
Use dput() to send data to the list as it is more compact: > dput(tab) structure(list(time = 1:8, X1 = c(0L, 5L, 1L, 0L, 2L, 3L, 1L, 4L), X2 = c(251L, 230L, 300L, 25L, 10L, 101L, 300L, 185L)), .Names = c("time", "X1", "X2"), class = "data.frame", row.names = c(NA, -8L)) You can just remove the

Re: [R] rank/sort problem

2015-11-21 Thread David Winsemius
> On Nov 21, 2015, at 4:44 AM, Axel Urbiz wrote: > > Hello, > > I would like to sort the df below, such that it sorts y1 in decreasing order > for tt == 1 and in increasing order for > tt == 0. My solution is below, but curious if there might be something better > (meaning faster in this cas

Re: [R] exporting tables from an access database using parallel foreach

2015-11-21 Thread Vivek Sutradhara
Hi John and Jeff, Thanks a lot for your help. I agree that row numbers are not a standard feature in SQL. What I am looking for is some kind of a hack. After all, the sqlFetch command is able to return a specific number of rows. And the sqlFetchMore command is able to take up the baton from that ro

[R] Conditional Random selection

2015-11-21 Thread Ashta
Hi all, I have a data set that contains samples collected over time. In each time period the total number of samples are given (X2) The goal is to select 500 random samples.The selection should be based on time (select time periods until I reach 500 samples). Also the time period should

Re: [R] rank/sort problem

2015-11-21 Thread Bert Gunter
I did not read your post in detail but have you not looked at ?rank ? Cheers, Bert Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." -- Clifford Stoll On Sat, Nov 21, 2015 at 4:44 AM, Axel Urbiz wrote: > Hello, > > I would like to

[R] rank/sort problem

2015-11-21 Thread Axel Urbiz
Hello, I would like to sort the df below, such that it sorts y1 in decreasing order for tt == 1 and in increasing order for tt == 0. My solution is below, but curious if there might be something better (meaning faster in this case). Actually, if instead if implicitly sorting, I could add a va