Re: [R] read.csv.sql() to select from a large csv file

2012-12-01 Thread Gabor Grothendieck
On Fri, Nov 23, 2012 at 5:05 PM, Juliane Struve wrote: > Rui, Anthony, and Gabor, > > I got this to work in the end: > > for(i in length(Names_EastCoast){ > name <- Names_EastCoast[i] > sql <- paste("select * from file where ID = > '",name,"'",sep = "") > Data <- read.csv.sql("filename",sql = sql)

Re: [R] qbinom

2012-12-01 Thread peter dalgaard
On Dec 1, 2012, at 01:00 , David Winsemius wrote: > > On Nov 30, 2012, at 1:05 PM, jaybell wrote: > >> sorry, I repost the question again > > Why? This was already answered. > >> >> a=c(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9) >> b=c(0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1) >> co

Re: [R] segfault debugging

2012-12-01 Thread Donatella Quagli
Thank you so far. Here is an excerpt from the gdb session after a crash:   Program received signal SIGSEGV, Segmentation fault.   0xb7509a6b in Rf_allocVector () from /usr/lib/R/lib/libR.so   (gdb) backtrace   #0  0xb7509a6b in Rf_allocVector () from /usr/lib/R/lib/libR.so   #1  0xb744b64c in ?? (

[R] Getting all possible contingency tables

2012-12-01 Thread Christofer Bogaso
Hello all, Let say I have 2-way contingency table: Tab <- matrix(c(8, 10, 12, 6), nr = 2) and the Chi-squared test could not reject the independence: > chisq.test(Tab) Pearson's Chi-squared test with Yates' continuity correction data: Tab X-squared = 1.0125, df = 1, p-value = 0.3143

Re: [R] segfault debugging

2012-12-01 Thread Duncan Murdoch
On 12-12-01 6:56 AM, Donatella Quagli wrote: Thank you so far. Here is an excerpt from the gdb session after a crash: Program received signal SIGSEGV, Segmentation fault. 0xb7509a6b in Rf_allocVector () from /usr/lib/R/lib/libR.so (gdb) backtrace #0 0xb7509a6b in Rf_allocVector () f

Re: [R] Getting all possible contingency tables

2012-12-01 Thread John Kane
Are you basically asking for all possible permutations of the table? If so see ?permn in the combinat package. John Kane Kingston ON Canada > -Original Message- > From: bogaso.christo...@gmail.com > Sent: Sat, 01 Dec 2012 18:10:15 +0545 > To: r-help@r-project.org > Subject: [R] Getting

[R] cubic spline

2012-12-01 Thread Steve Stephenson
Hallo, I'm facing a problem and I would really appreciate your support. I have to translate some Matalb code in R that I don't know very well but I would like to. I have to interpolate 5 point with a cubic spline function and then I expect my function returns the Y value as output a specific X valu

[R] How to built a pivot table of value

2012-12-01 Thread CE.KA
Hi R users Imagine the table "base": p=c("d","d","b","b","a","a") q=c("v1","v2","v1","v2","v1","v2") r=c(5,2,4,8,9,7) base=data.frame(p,q,r) base p q r 1 d v1 5 2 d v2 2 3 b v1 4 4 b v2 8 5 a v1 9 6 a v2 7 How programming R to get this result:

Re: [R] cubic spline

2012-12-01 Thread Jorge I Velez
Hi Steve, Check the "splint" function in the "fields" package. HTH, Jorge.- On Sat, Dec 1, 2012 at 11:09 PM, Steve Stephenson <> wrote: > Hallo, > I'm facing a problem and I would really appreciate your support. > I have to translate some Matalb code in R that I don't know very well but I > wo

Re: [R] How to built a pivot table of value

2012-12-01 Thread Jorge I Velez
Hi, One way could be with(base, tapply(r, list(p, q), sum)) HTH, Jorge.- On Sat, Dec 1, 2012 at 11:37 PM, CE.KA <> wrote: > Hi R users > > Imagine the table "base": > p=c("d","d","b","b","a","a") > q=c("v1","v2","v1","v2","v1","v2") > r=c(5,2,4,8,9,7) > base=data.frame(p,q,r) > base > >

Re: [R] Getting all possible contingency tables

2012-12-01 Thread Christofer Bogaso
Thanks John for your reply. However still not clear how I should proceed. My goal is to generate all possible contingency tables. Basically I want to see the distribution of Chi-squared Statistic under independence (NULL). So I was thinking if I can generate all possible permutation of integer

Re: [R] How to built a pivot table of value

2012-12-01 Thread Berend Hasselman
On 01-12-2012, at 13:37, CE.KA wrote: > Hi R users > > Imagine the table "base": > p=c("d","d","b","b","a","a") > q=c("v1","v2","v1","v2","v1","v2") > r=c(5,2,4,8,9,7) > base=data.frame(p,q,r) > base > > p q r > 1 d v1 5 > 2 d v2 2 > 3 b v1 4 > 4 b v2 8 > 5 a v1

Re: [R] How to built a pivot table of value

2012-12-01 Thread John Kane
One way, using the plyr package would be: library(plyr) dcast(base, p ~ q) John Kane Kingston ON Canada > -Original Message- > From: ce.kay...@yahoo.fr > Sent: Sat, 1 Dec 2012 04:37:02 -0800 (PST) > To: r-help@r-project.org > Subject: [R] How to built a pivot table of value > > Hi

Re: [R] Getting all possible contingency tables

2012-12-01 Thread John Kane
R can usually do almost anything but if the function exists I am not aware of it. Sorry. I did misunderstand what you were doing. John Kane Kingston ON Canada > -Original Message- > From: bogaso.christo...@gmail.com > Sent: Sat, 01 Dec 2012 19:33:09 +0545 > To: jrkrid...@inbox.com > Su

Re: [R] Getting all possible contingency tables

2012-12-01 Thread Bert Gunter
Christopher: Don't do this! If I understand you correctly, you want FIsher's exact test. This is already available in R, using far smarter algorithms then you would. See: ?fisher.test -- Bert On Sat, Dec 1, 2012 at 5:48 AM, Christofer Bogaso < bogaso.christo...@gmail.com> wrote: > Thanks Joh

Re: [R] How to built a pivot table of value

2012-12-01 Thread Berend Hasselman
On 01-12-2012, at 14:56, John Kane wrote: > One way, using the plyr package would be: > > library(plyr) > dcast(base, p ~ q) > Shouldn't that be library(reshape2) ? Berend > John Kane > Kingston ON Canada > > >> -Original Message- >> From: ce.kay...@yahoo.fr >> Sent: Sat, 1 Dec 20

Re: [R] Getting all possible contingency tables

2012-12-01 Thread Christofer Bogaso
Thanks Bert for your reply. I am trying to understand/visualize the Sample Chi-Squared Statistic's Null distribution. Therefore I need all possible Contingency tables under Independence case. What could be better way to visualize that? Thanks and regards, On 01 December 2012 20:03:00, Bert

Re: [R] segfault debugging

2012-12-01 Thread Martin Morgan
On 12/01/2012 04:51 AM, Duncan Murdoch wrote: On 12-12-01 6:56 AM, Donatella Quagli wrote: Thank you so far. Here is an excerpt from the gdb session after a crash: Program received signal SIGSEGV, Segmentation fault. 0xb7509a6b in Rf_allocVector () from /usr/lib/R/lib/libR.so (gdb) bac

Re: [R] How to built a pivot table of value

2012-12-01 Thread John Kane
Blast, you're right. I tend to load both at the same time and confused the two. It should be reshape2 John Kane Kingston ON Canada > -Original Message- > From: b...@xs4all.nl > Sent: Sat, 1 Dec 2012 15:20:13 +0100 > To: jrkrid...@inbox.com > Subject: Re: [R] How to built a pivot table

Re: [R] cubic spline

2012-12-01 Thread Steve Stephenson
Hi Jorge, many thanks for your suggestion! I tried the function you mentioned and it looks working!! Now I have just to check that splint (R) and interp1 (Matlab) functions provide me the same results. Kind regards! Steve -- View this message in context: http://r.789695.n4.nabble.com/cubic

Re: [R] Getting all possible contingency tables

2012-12-01 Thread Ted Harding
You will need to be clear about whether you are conditioning on the marginal totals as well as on the overall total. As stated, you are only asking for the overall total (36) to be fixed. In that case, one possible (and by no means unique) approach would be to: [A]: Choose any four "random intege

Re: [R] segfault debugging

2012-12-01 Thread William Dunlap
> valgrind is usually effective for this > > R -d valgrind -f myscript.R And adding the R command gctorture(TRUE) to the top of your script lets valgrind do a better job of find memory misuse. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-he

Re: [R] Getting all possible contingency tables

2012-12-01 Thread Ben Bolker
> > > > My goal is to generate all possible contingency tables. Basically I want > > to see the distribution of Chi-squared Statistic under independence > > (NULL). > > > > So I was thinking if I can generate all possible permutation of integer > > numbers having sum equal to (8 + 10 + 12 + 6) =

Re: [R] cubic spline

2012-12-01 Thread David Winsemius
On Dec 1, 2012, at 5:09 AM, Steve Stephenson wrote: Hallo, I'm facing a problem and I would really appreciate your support. I have to translate some Matalb code in R that I don't know very well but I would like to. I have to interpolate 5 point with a cubic spline function and then I expec

Re: [R] Getting all possible contingency tables

2012-12-01 Thread David Winsemius
On Dec 1, 2012, at 7:28 AM, Christofer Bogaso wrote: Thanks Bert for your reply. I am trying to understand/visualize the Sample Chi-Squared Statistic's Null distribution. Therefore I need all possible Contingency tables under Independence case. What could be better way to visualize that?

Re: [R] segfault debugging

2012-12-01 Thread Brian Ripley
On 1 Dec 2012, at 16:09, William Dunlap wrote: >> valgrind is usually effective for this >> >> R -d valgrind -f myscript.R > > And adding the R command >gctorture(TRUE) > to the top of your script lets valgrind do a better job of > find memory misuse. That makes things even slower: it r

[R] screen if a value is within range

2012-12-01 Thread Andras Farkas
Dear all,   could you please give me some pointers on how I could make R screen for a value if it falls within a certain range? I looked at the subset function, but is not doing it, perhaps because I only have 1 value to screen?   aptreciate the input   ex: a <-16.5 I would like to screen to see

Re: [R] screen if a value is within range

2012-12-01 Thread R. Michael Weylandt
15 < a & a < 20 Wrap it in a function if you like: in_interval <- function(x, interval){ stopifnot(length(interval) == 2L) interval[1] < x & x < interval[2] } in_interval(a, c(15, 20)) Cheers, Michael On Sat, Dec 1, 2012 at 4:50 PM, Andras Farkas wrote: > > could you please give me some

Re: [R] segfault debugging

2012-12-01 Thread David Winsemius
On Nov 30, 2012, at 10:02 AM, Donatella Quagli wrote: Hello everybody, I have written a script with two inline cfunctions. The script crashes from time to time with: *** caught segfault *** address 0x10, cause 'memory not mapped' The crashs happen within R code after the cfunctions we

Re: [R] screen if a value is within range

2012-12-01 Thread Robert Baer
On 12/1/2012 10:50 AM, Andras Farkas wrote: Dear all, could you please give me some pointers on how I could make R screen for a value if it falls within a certain range? I looked at the subset function, but is not doing it, perhaps because I only have 1 value to screen? aptreciate the inp

Re: [R] screen if a value is within range

2012-12-01 Thread David Winsemius
On Dec 1, 2012, at 9:55 AM, R. Michael Weylandt wrote: 15 < a & a < 20 Wrap it in a function if you like: in_interval <- function(x, interval){ stopifnot(length(interval) == 2L) interval[1] < x & x < interval[2] } in_interval(a, c(15, 20)) Could just use the findInterval function: fi

Re: [R] protentially serious R error

2012-12-01 Thread David L Carlson
Congratulations, you've reached the First Circle of the R Inferno. Only 8 more to go http://www.burns-stat.com/pages/Tutor/R_inferno.pdf -- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 > -O

Re: [R] Reading .gsheet within R

2012-12-01 Thread Luca Meyer
Thank you Henrik & the others that have commented. Accessing the actual online data is what I would need, but apparently this is not yet feasible… Luca Il giorno 01/dic/2012, alle ore 04:53, Henrik Bengtsson ha scritto: > On Fri, Nov 30, 2012 at 9:43 AM, Luca Meyer wrote: >> Hello R-experts,

Re: [R] segfault debugging

2012-12-01 Thread William Dunlap
While it is true that valgrind is most effective when R is built with special flags, it can be useful without the special build. Also, gctorture(TRUE) does make it run very slowly, but I have seen it show things that only sporadically show up otherwise. E.g., with an optimized 64-bit Linux build

Re: [R] Fw: quantreg installation and conflicts with R 2.15.2

2012-12-01 Thread Uwe Ligges
On 30.11.2012 22:10, Brian S Cade wrote: Just noticed that I get a similar error about object 'kronecker' in "Matrix" package when trying to load "lme4". So this is a more pervasive problem. Probably you have a mixture of packages for various versions of R around. So after checking if all

Re: [R] SVM using R

2012-12-01 Thread Uwe Ligges
On 30.11.2012 05:08, vivek kumar singh wrote: HI All, I am very new to R tool. Can some one please suggest me some tutorial links for understanding SVM using R. After reading some textbook about the SVM, go ahead and look for ?svm in package e1071. Best, Uwe Ligges Regards, Vivek

Re: [R] How to repeat replication

2012-12-01 Thread Uwe Ligges
On 30.11.2012 08:23, Kamontip Srihaset wrote: Dear all, I generate data under IRT mdel. I conducted 1000 replications. When I run, some replication was not fit with my model. So, replications were fit model were less than 1000 replication. If I want its run until 1000 replicaions. How sho

Re: [R] [R-pkgs] New package: gRain - gRAphical Independence Networks

2012-12-01 Thread Uwe Ligges
On 29.11.2012 20:46, fkh wrote: I am trying to use your package gRain using your book on graphical models in R to do predictions, I have 38 columns of vectors all factors and built a bayesian network using iamb() function, then I used the following command to make a grpahNEL (However, I have 38

Re: [R] deleting data of a given date range.

2012-12-01 Thread Uwe Ligges
On 29.11.2012 17:37, arun wrote: Hi, You haven't given any example dataset. So,not sure about the format of the date column. set.seed(5) dat1<-data.frame(Date1=c("10/25/2009","11/25/2009","12/25/2009","5/10/2010","8/10/2010","9/25/2011","11/28/2011","5/3/2012"),col2=sample(1:15,8,replace=TRU

Re: [R] NA return to NLM routine

2012-12-01 Thread Uwe Ligges
On 30.11.2012 23:55, Mac Gaulin wrote: Hello, I am trying to understand a small quirk I came across in R. The following code results in an error: k <- c(2, 1, 1, 5, 5) f <- c(1, 1, 1, 3, 2) loglikelihood <- function(theta,k,f){ if( theta<1 && theta>0 ) return(-1*sum(log(choose(k

Re: [R] CreateThread failure since R 2.15.2 (32-bit)

2012-12-01 Thread Uwe Ligges
On 30.11.2012 12:27, Martin Studer wrote: Dear R users & developers, I coming across the following issue since R 2.15.2 32-bit (running on Windows XP 32.bit; some output left out for conciseness): Works for me. Which Java version are you using is this? Perhaps Java changes the environment s

Re: [R] protentially serious R error

2012-12-01 Thread Ted Harding
That applies to the OP (Xiaofeng, aka "liuxf"), of course. Ben himself is a guardian of all Circles (loc.cit.). With regard to Ben's quote from the Posting Guide, it occurs to me that the more years one has been using R, the more rapdily one should (or should be able to) answer a question. The imp

Re: [R] cubic spline

2012-12-01 Thread Martin Maechler
> David Winsemius > on Sat, 1 Dec 2012 09:25:42 -0700 writes: > On Dec 1, 2012, at 5:09 AM, Steve Stephenson wrote: >> Hallo, I'm facing a problem and I would really appreciate >> your support. I have to translate some Matalb code in R >> that I don't know very well

[R] reading json tables

2012-12-01 Thread Michael Friendly
I'm trying to read two data sets in json format from a single .js file. I've tried fromJSON() in both RJSONIOIO and RJSON packages, but they require that the lines be pre-parsed somehow in ways I don't understand. Can someone help? > wheat <- readLines("http://mbostock.github.com/protovis/ex/wh

Re: [R] reading json tables

2012-12-01 Thread Duncan Temple Lang
Hi Michael The problem is that the content of the .js file is not JSON, but actual JavaScript code. You could use something like the following tt = readLines("http://mbostock.github.com/protovis/ex/wheat.js";) txt = c("[", gsub(";", ",", gsub("var [a-zA-Z]+ = ", "", tt)), "]") tmp = paste(tx

Re: [R] NA return to NLM routine

2012-12-01 Thread Berend Hasselman
On 30-11-2012, at 23:55, Mac Gaulin wrote: > Hello, > > I am trying to understand a small quirk I came across in R. The > following code results in an error: > > k <- c(2, 1, 1, 5, 5) > f <- c(1, 1, 1, 3, 2) > loglikelihood <- function(theta,k,f){ >if( theta<1 && theta>0 ) >return(-

Re: [R] Getting all possible contingency tables

2012-12-01 Thread Richard M. Heiberger
I believe you are looking for a detailed construction of Fisher's Exact Test. I have an example with code in my book and R package. The book discussion is Section 15.2 of Heiberger, Richard M., and Burt Holland (2004). Statistical Analysis and Data Display: An Intermediate Course with Examples in

Re: [R] cubic spline

2012-12-01 Thread Ben Bolker
Martin Maechler stat.math.ethz.ch> writes: [snip] > but definitely *no* need to use a function from an extra CRAN > package .. as someone else ``erronously'' suggested. > > Note that > spline() and splinefun() > together with > approx() and approxfun() > are among the several hundred funct

[R] x axis labels

2012-12-01 Thread apprentice
Hi, I have a problem with plotting my data as a histogram using barplot2. I am plotting the x axis using axis(). I want to label only every fifth bar and not all of them as they get too busy but I don't know how to do it. I was trying to set the labels for the axis using at=seq(min value, max valu

Re: [R] How to built a pivot table of value

2012-12-01 Thread arun
HI, You can also also ?reshape() res<-reshape(base,v.names="r",idvar="p",timevar="q",direction="wide")  res[order(res$p),] A.K. - Original Message - From: CE.KA To: r-help@r-project.org Cc: Sent: Saturday, December 1, 2012 7:37 AM Subject: [R] How to built a pivot table of value Hi R

[R] Daily Time Series, patterns.

2012-12-01 Thread mekbatub
Hi. I would like to ask You for help: I am new in R and i use R for forecasting, i have problem. I am trying to build daily time series: My data looks like this: Date| quantity ... 2012-11-01 | 142 2012-11-02 | 156 2012-11-05 | 151 2012-11-06 | 121 2012-11-07 | 118 2012-11-08 | 119 2012-

Re: [R] Daily Time Series, patterns.

2012-12-01 Thread mekbatub
Hi Arun, thx for Your reply. thats interesting, but its not what I mean. I know that there is some patterns in data, example: the highest value of the sale is on Monday, and the smallest on Wednesday and so on, there might be trend also I am trying to build forecasting model that will include p

[R] Simulation in R

2012-12-01 Thread mboricgs
Hello! How can I do 100 simulations of length 17 from bivariate bivariate normal distribution, if I know all 5 parameters? -- View this message in context: http://r.789695.n4.nabble.com/Simulation-in-R-tp4651578.html Sent from the R help mailing list archive at Nabble.com. __

[R] How to re-combine values based on an index?

2012-12-01 Thread Brian Feeny
I am able to split my df into two like so: dataset <- trainset index <- 1:nrow(dataset) testindex <- sample(index, trunc(length(index)*30/100)) trainset <- dataset[-testindex,] testset <- dataset[testindex,-1] So I have the index information, how could I re-combine the data using that back into

Re: [R] Simulation in R

2012-12-01 Thread Greg Snow
look at functions replicate and mvrnorm functions (the later in the MASS package). On Sat, Dec 1, 2012 at 12:02 PM, mboricgs wrote: > Hello! > > How can I do 100 simulations of length 17 from bivariate bivariate normal > distribution, if I know all 5 parameters? > > > > -- > View this message

Re: [R] How to re-combine values based on an index?

2012-12-01 Thread William Dunlap
> newdataset[testindex] = testset[testindex] > object 'dataset' not found Is that really what R printed? I get > newdataset[testindex] = testset[testindex] Error in newdataset[testindex] = testset[testindex] : object 'newdataset' not found but perhaps you have a different problem. Cop

Re: [R] How to re-combine values based on an index?

2012-12-01 Thread Brian Feeny
Thank you for your response, here is a better example of what I am trying to do: data(iris) index_setosa <- which(iris$Species == "setosa") iris_setosa <- data.frame() iris_setosa[index_setosa,] <-iris[index_setosa,] iris_others <- data.frame() iris_others[-index_setosa,] <- iris[-index_setosa,]

Re: [R] How to re-combine values based on an index?

2012-12-01 Thread arun
Hi, ?merge(), ?rbind(), or ?join() from library(plyr) set.seed(5) trainset<-data.frame(ID=1:10,col2=runif(10,0,1))  dataset <- trainset  trainset<-dataset[-testindex,] testset<-dataset[testindex,] merge(testset,trainset,by=c("ID","col2"),all=TRUE) #   ID  col2 #1   1 0.2002145 #2   2 0.6852186

Re: [R] How to re-combine values based on an index?

2012-12-01 Thread Berend Hasselman
On 02-12-2012, at 06:06, Brian Feeny wrote: > Thank you for your response, here is a better example of what I am trying to > do: > > data(iris) > index_setosa <- which(iris$Species == "setosa") > iris_setosa <- data.frame() > iris_setosa[index_setosa,] <-iris[index_setosa,] > iris_others <- da