Re: [R] [FORGED] Lattice barchart legend with panel.barchart
Works great, thank you Paul! On Wed, Jul 27, 2016 at 5:24 PM, Paul Murrell <p...@stat.auckland.ac.nz> wrote: > Hi > > Try this ... > > barchart(Class~Freq|Sex + Age, Titan, > groups=Survived, > panel = titanpanel, > stack=TRUE, layout=c(4,1), > key=simpleKey(title="Survived", text=levels(Titan$Survived), >rectangles=TRUE, points=FALSE, columns=2)) > > Paul > > On 28/07/16 09:02, Seth Bigelow wrote: > >> I have constructed a barchart that requires a panel call, but the panel >> reduces the facsimiles of bars in the legend to small colored circles. You >> can see this behavior in the following example: >> >> Titan <- as.data.frame(Titanic) >> >> titanpanel <- function(x,y,...){ >> panel.barchart(x,y,...) >> } >> >> barchart(Class~Freq|Sex + Age, Titan, >> groups=Survived, >> panel = titanpanel, >> stack=TRUE, layout=c(4,1), >> auto.key=list(title="Survived", columns=2)) >> >> ...if you comment out the panel and run the barchart statement you will >> see >> nice blocks displayed in the legend. Is there any easy way to retain these >> blocks with panel.barchart? >> >> >> > -- > Dr Paul Murrell > Department of Statistics > The University of Auckland > Private Bag 92019 > Auckland > New Zealand > 64 9 3737599 x85392 > p...@stat.auckland.ac.nz > http://www.stat.auckland.ac.nz/~paul/ > -- Seth W. Bigelow, Ph.D. Assistant Scientist of Forest Ecology Joseph W. Jones Ecological Research Center Newton, GA (229)-734-4706 x-270 [[alternative HTML version deleted]] __ R-help@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.
[R] Lattice barchart legend with panel.barchart
I have constructed a barchart that requires a panel call, but the panel reduces the facsimiles of bars in the legend to small colored circles. You can see this behavior in the following example: Titan <- as.data.frame(Titanic) titanpanel <- function(x,y,...){ panel.barchart(x,y,...) } barchart(Class~Freq|Sex + Age, Titan, groups=Survived, panel = titanpanel, stack=TRUE, layout=c(4,1), auto.key=list(title="Survived", columns=2)) ...if you comment out the panel and run the barchart statement you will see nice blocks displayed in the legend. Is there any easy way to retain these blocks with panel.barchart? -- Seth W. Bigelow, Ph.D. Assistant Scientist of Forest Ecology Joseph W. Jones Ecological Research Center Newton, GA [[alternative HTML version deleted]] __ R-help@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.
[R] Error: missing value where TRUE/FALSE needed
Hi, I am getting the following error: Error in if ((sum > 0 && sums1 > 0 && sums2 > 0) != NA) { : missing value where TRUE/FALSE needed I have including my code below for your review: fitness_1_data [[alternative HTML version deleted]] __ R-help@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.
[R] very long processing time
Hi, I have implemented following program in R, that reads data from the "dtm_mydata.csv". file size is 114,029 kB, saved document Term matrix. Prog. performing some calculation and writing in a file. my computer RAM is 16 GB. To execute this program its taking around 25 hours. can any body help me what is wrong, why this much time is taken. Although it is doing the job what is required fitness_1_data [[alternative HTML version deleted]] __ R-help@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.
[R] Frequency count of terms only in a given column in R
i have a text file with data of the given format: white snow lived snow in snow lived place in place a place called place as place here i have to find the frequency of the terms only in the first column (i.e.) white - 1 lived- 2 in -2 a-1 called - 1 as -1 Could you please guide me how to do the above in R. [[alternative HTML version deleted]] __ R-help@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.
[R] function that calculates using preceding records
Greetings: My dataframe has 4 variables: treecode, year, rw (tree ring width), and d (tree diameter). The d variable only has data for 2014. I wish to calculate earlier diameters by subtracting each year's growth (rw) from the previous year's diameter, by treecode. Can anyone help me with a function or statement that will do this? Sample dataset below: In this example, d in year 2013 for treecode TC149 would be 7.92 = 8.0 - 0.080. treecode,year,rw,d 1,TC149,2014,NA,8 2,TC149,2013,0.08,NA 3,TC149,2012,0.125,NA 4,TC149,2011,0.12,NA 5,TC149,2010,0.125,NA 6,TC148,2014,NA,34 7,TC148,2013,0.3,NA 8,TC148,2012,0.335,NA 9,TC148,2011,0.315,NA 10,TC148,2010,0.455,NA 11,TC147,2014,NA,55.5 12,TC147,2013,1.26,NA 13,TC147,2012,1.115,NA 14,TC147,2011,1.025,NA 15,TC147,2010,1.495,NA 16,TC146,2014,NA,60 17,TC146,2013,1.75,NA 18,TC146,2012,1.81,NA 19,TC146,2011,1.39,NA 20,TC146,2010,1.94,NA Seth W. Bigelow [[alternative HTML version deleted]] __ R-help@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.
Re: [R] function that calculates using preceding records
Petr, Your code works therefore I pronounce it beautiful. Many many thanks --Seth -Original Message- From: PIKAL Petr [mailto:petr.pi...@precheza.cz] Sent: Tuesday, February 10, 2015 11:23 AM To: Seth Bigelow; r-help@r-project.org Subject: RE: [R] function that calculates using preceding records Hi I found an extremely ugly code :-) # first reverse levels of treecode to correspond with order of values in data frame temp$treecode-factor(temp$treecode, rev(levels(temp$treecode))) # add zeroes and values to rw and d temp$rw[is.na(temp$rw)]-0 library(zoo) temp$d-na.locf(temp$d) # split your data acording to treecode temp.l-split(temp, temp$treecode) # subtract from d cumulative sum of rw mat-sapply(sapply(temp.l, [, 4), mean)-t(sapply(sapply(temp.l, [,3), cumsum)) # transpose mat and remove dimension from mat mat-t(mat) dim(mat)-NULL Now temp - cbind(temp, dsub=mat) shall put subtracted values in correct order to your object. Cheers Petr -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Seth Bigelow Sent: Tuesday, February 10, 2015 3:30 PM To: r-help@r-project.org Subject: [R] function that calculates using preceding records Greetings: My dataframe has 4 variables: treecode, year, rw (tree ring width), and d (tree diameter). The d variable only has data for 2014. I wish to calculate earlier diameters by subtracting each year's growth (rw) from the previous year's diameter, by treecode. Can anyone help me with a function or statement that will do this? Sample dataset below: In this example, d in year 2013 for treecode TC149 would be 7.92 = 8.0 - 0.080. treecode,year,rw,d 1,TC149,2014,NA,8 2,TC149,2013,0.08,NA 3,TC149,2012,0.125,NA 4,TC149,2011,0.12,NA 5,TC149,2010,0.125,NA 6,TC148,2014,NA,34 7,TC148,2013,0.3,NA 8,TC148,2012,0.335,NA 9,TC148,2011,0.315,NA 10,TC148,2010,0.455,NA 11,TC147,2014,NA,55.5 12,TC147,2013,1.26,NA 13,TC147,2012,1.115,NA 14,TC147,2011,1.025,NA 15,TC147,2010,1.495,NA 16,TC146,2014,NA,60 17,TC146,2013,1.75,NA 18,TC146,2012,1.81,NA 19,TC146,2011,1.39,NA 20,TC146,2010,1.94,NA Seth W. Bigelow [[alternative HTML version deleted]] __ R-help@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. Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům. Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému. Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat. Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu. V případě, že je tento e-mail součástí obchodního jednání: - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu. - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce s dodatkem či odchylkou. - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným dosažením shody na všech jejích náležitostech. - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi či osobě jím zastoupené známá. This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients. If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system. If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner. The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email. In case that this e-mail forms part of business dealings: - the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning. - if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation. - the sender insists
Re: [R] function that calculates using preceding records
Aha, this solution is even more elegant than that of the previous suggestion. Thanks for alerting me to the capabilities of plyr! --Seth -Original Message- From: Dennis Murphy [mailto:djmu...@gmail.com] Sent: Tuesday, February 10, 2015 2:14 PM To: Seth Bigelow Subject: Re: [R] function that calculates using preceding records Hi: Here's another way. If I understand this correctly, you can get the diameters by setting the NA values in d to zero, taking the cumulative sum of d (within treecode) and then subtracting the result from diam[1]. Since I'm used to doing this type of thing in data manipulation packages, I prefer to write a function to do the work and then run it in concert with plyr::ddply(). Letting DF represent the name of your data frame, # Function to apply to each subgroup (treecode ID) f - function(d) { d - d[order(-d$year), ] # order by decreasing year d$rw[is.na(d$rw)] - 0 # set NAs in rw to 0 d$diam - d$d[1] - cumsum(d$rw)# compute past diams d# return modified data frame } library(plyr) # This applies the function f to each sub-data frame defined # by unique values of treecode ddply(DF, .(treecode), f) treecode yearrwd diam 1 TC146 2014 0.000 60.0 60.000 2 TC146 2013 1.750 NA 58.250 3 TC146 2012 1.810 NA 56.440 4 TC146 2011 1.390 NA 55.050 5 TC146 2010 1.940 NA 53.110 6 TC147 2014 0.000 55.5 55.500 7 TC147 2013 1.260 NA 54.240 8 TC147 2012 1.115 NA 53.125 9 TC147 2011 1.025 NA 52.100 10TC147 2010 1.495 NA 50.605 11TC148 2014 0.000 34.0 34.000 12TC148 2013 0.300 NA 33.700 13TC148 2012 0.335 NA 33.365 14TC148 2011 0.315 NA 33.050 15TC148 2010 0.455 NA 32.595 16TC149 2014 0.000 8.0 8.000 17TC149 2013 0.080 NA 7.920 18TC149 2012 0.125 NA 7.795 19TC149 2011 0.120 NA 7.675 20TC149 2010 0.125 NA 7.550 HTH, Dennis On Tue, Feb 10, 2015 at 6:30 AM, Seth Bigelow s...@forestadapt.org wrote: Greetings: My dataframe has 4 variables: treecode, year, rw (tree ring width), and d (tree diameter). The d variable only has data for 2014. I wish to calculate earlier diameters by subtracting each year's growth (rw) from the previous year's diameter, by treecode. Can anyone help me with a function or statement that will do this? Sample dataset below: In this example, d in year 2013 for treecode TC149 would be 7.92 = 8.0 - 0.080. treecode,year,rw,d 1,TC149,2014,NA,8 2,TC149,2013,0.08,NA 3,TC149,2012,0.125,NA 4,TC149,2011,0.12,NA 5,TC149,2010,0.125,NA 6,TC148,2014,NA,34 7,TC148,2013,0.3,NA 8,TC148,2012,0.335,NA 9,TC148,2011,0.315,NA 10,TC148,2010,0.455,NA 11,TC147,2014,NA,55.5 12,TC147,2013,1.26,NA 13,TC147,2012,1.115,NA 14,TC147,2011,1.025,NA 15,TC147,2010,1.495,NA 16,TC146,2014,NA,60 17,TC146,2013,1.75,NA 18,TC146,2012,1.81,NA 19,TC146,2011,1.39,NA 20,TC146,2010,1.94,NA Seth W. Bigelow [[alternative HTML version deleted]] __ R-help@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. __ R-help@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.
[R] decreasing blank space in ggplot2 geom_area
I wish to shrink the automatically inserted blank space at either end of the x axis of my area plot, so that the colorful graphic in the center takes up more of the available space. When I use the scale_x_discrete(limits...) command to expand the displayed area, the graphic shrinks away from the x-axis ticks so that there is still the same amount of blank space at the edges. An example: df1 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] decreasing blank space in ggplot2 geom_area
expand works perfectly, thanks VERY much Ista! -Seth - Original Message - From: Ista Zahn To: Cc: Sent:Thu, 26 Jun 2014 14:35:19 -0400 Subject:Re: [R] decreasing blank space in ggplot2 geom_area Hi Seth, See the expand argument to ?discrete_scale Best, Ista On Thu, Jun 26, 2014 at 7:01 AM, wrote: I wish to shrink the automatically inserted blank space at either end of the x axis of my area plot, so that the colorful graphic in the center takes up more of the available space. When I use the scale_x_discrete(limits...) command to expand the displayed area, the graphic shrinks away from the x-axis ticks so that there is still the same amount of blank space at the edges. An example: df1 [[alternative HTML version deleted]] __ R-help@r-project.org [1] mailing list https://stat.ethz.ch/mailman/listinfo/r-help [2] PLEASE do read the posting guide http://www.R-project.org/posting-guide.html [3] and provide commented, minimal, self-contained, reproducible code. Links: -- [1] mailto:R-help@r-project.org [2] https://stat.ethz.ch/mailman/listinfo/r-help [3] http://www.R-project.org/posting-guide.html [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] Data labels in R
Yes Mac, text function did it. Thanks All for your help. text(dfPlot$Date, dfPlot$RECLTD,dfPlot$Labels, col=642) On Tue, Sep 17, 2013 at 12:00 AM, MacQueen, Don macque...@llnl.gov wrote: Possibly the text() function. -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 9/15/13 9:43 AM, Ankur Seth ankurset...@gmail.com wrote: I want to put labels a,b,c,d on the data points x-data.frame(c(1,2,3,4),c(1,4,9,16),c(a,b,c,d), as.Date(c(01-10-2013, 02-10-2013,03-10-2013,04-10-2013), %d-%m-%Y)) colnames(x)-c(x, sq, lables,dates) y-subset(x, select=c(dates,x,sq)) y-read.zoo(y) plot(y, plot.type=single, xlab=Date, ylab=Price) On Sun, Sep 15, 2013 at 9:16 PM, jim holtman jholt...@gmail.com wrote: Read the help file on 'plot' and look at some of the examples to see how to place labels in various places on a plot. This is not difficult if you have read any of the documentation. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Sun, Sep 15, 2013 at 11:37 AM, Ankur Seth ankurset...@gmail.com wrote: I need to put labels in plot in R. Can someone please help? The labels are in the excel file and loaded into lables library(xlsx) library(zoo) fPTAnalysis-Input.xls data-read.xlsx(fPTAnalysis,9) lables-subset(data, select=c(Labels)) data-subset(data, select=c(Date,col1, col2 )) data-read.zoo(data) plot(data) -- Regards, Ankur Seth [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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. -- Regards, Ankur Seth [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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. -- Regards, Ankur Seth [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
[R] Data labels in R
I need to put labels in plot in R. Can someone please help? The labels are in the excel file and loaded into lables library(xlsx) library(zoo) fPTAnalysis-Input.xls data-read.xlsx(fPTAnalysis,9) lables-subset(data, select=c(Labels)) data-subset(data, select=c(Date,col1, col2 )) data-read.zoo(data) plot(data) -- Regards, Ankur Seth [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] Data labels in R
I want to put labels a,b,c,d on the data points x-data.frame(c(1,2,3,4),c(1,4,9,16),c(a,b,c,d), as.Date(c(01-10-2013, 02-10-2013,03-10-2013,04-10-2013), %d-%m-%Y)) colnames(x)-c(x, sq, lables,dates) y-subset(x, select=c(dates,x,sq)) y-read.zoo(y) plot(y, plot.type=single, xlab=Date, ylab=Price) On Sun, Sep 15, 2013 at 9:16 PM, jim holtman jholt...@gmail.com wrote: Read the help file on 'plot' and look at some of the examples to see how to place labels in various places on a plot. This is not difficult if you have read any of the documentation. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Sun, Sep 15, 2013 at 11:37 AM, Ankur Seth ankurset...@gmail.com wrote: I need to put labels in plot in R. Can someone please help? The labels are in the excel file and loaded into lables library(xlsx) library(zoo) fPTAnalysis-Input.xls data-read.xlsx(fPTAnalysis,9) lables-subset(data, select=c(Labels)) data-subset(data, select=c(Date,col1, col2 )) data-read.zoo(data) plot(data) -- Regards, Ankur Seth [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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. -- Regards, Ankur Seth [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
[R] Simple Model in R
Hello All, I am trying to build a model in R. I am facing the following problem... My Data Frame contains the following data... DateValue 08/01/2013100 08/02/2013 100.5 08/03/2013 102 Now I want to add a column to this data frame where New Column Value = Difference of two subsequent observations. For Eg. on 08/02/2013 the new value = 100.5 - 100=0.5 I want to do this dynamically such that if I change the value in Value column the new column should recalculate automatically. Is there a way to do this in R? Regards, Ankur Seth [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] Simple Model in R
Thanks Rui, but this does not change the value in the new column automatically if I change the value in the data column. Any ideas? Regards, Ankur Seth On Sat, Sep 7, 2013 at 2:11 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, Try the following. dat - read.table(text = DateValue 08/01/2013100 08/02/2013 100.5 08/03/2013 102 , header = TRUE) dat$New - c(NA, diff(dat$Value)) dat Hope this helps, Rui Barradas Em 07-09-2013 06:06, Ankur Seth escreveu: Hello All, I am trying to build a model in R. I am facing the following problem... My Data Frame contains the following data... DateValue 08/01/2013100 08/02/2013 100.5 08/03/2013 102 Now I want to add a column to this data frame where New Column Value = Difference of two subsequent observations. For Eg. on 08/02/2013 the new value = 100.5 - 100=0.5 I want to do this dynamically such that if I change the value in Value column the new column should recalculate automatically. Is there a way to do this in R? Regards, Ankur Seth [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Regards, Ankur Seth [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] Simple Model in R
Is there a way in which I can setup a model like that? Regards, Ankur Seth On Sat, Sep 7, 2013 at 4:49 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, It will not change the value automatically, you will have to rerun the code. Rui Barradas Em 07-09-2013 11:52, Ankur Seth escreveu: Thanks Rui, but this does not change the value in the new column automatically if I change the value in the data column. Any ideas? Regards, Ankur Seth On Sat, Sep 7, 2013 at 2:11 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, Try the following. dat - read.table(text = DateValue 08/01/2013100 08/02/2013 100.5 08/03/2013 102 , header = TRUE) dat$New - c(NA, diff(dat$Value)) dat Hope this helps, Rui Barradas Em 07-09-2013 06:06, Ankur Seth escreveu: Hello All, I am trying to build a model in R. I am facing the following problem... My Data Frame contains the following data... DateValue 08/01/2013100 08/02/2013 100.5 08/03/2013 102 Now I want to add a column to this data frame where New Column Value = Difference of two subsequent observations. For Eg. on 08/02/2013 the new value = 100.5 - 100=0.5 I want to do this dynamically such that if I change the value in Value column the new column should recalculate automatically. Is there a way to do this in R? Regards, Ankur Seth [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-helphttps://stat.ethz.ch/mailman/**listinfo/r-help https://stat.**ethz.ch/mailman/listinfo/r-**helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/**posting-guide.htmlhttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Regards, Ankur Seth [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
[R] peering inside functions in a package?
Let's say I would like to look inside the function corBrownian in library (ape). When I type in the function name I get the following, which is not nearly the detail that goes into this function. I am wondering how to begin cracking this function open (and others) so I can learn more about it and perhaps code my own corClass one day. Thanks. corBrownian function (value = 1, phy, form = ~1) { if (!inherits(phy, phylo)) stop(object \phy\ is not of class \phylo\) attr(value, formula) - form attr(value, fixed) - TRUE attr(value, tree) - phy class(value) - c(corBrownian, corPhyl, corStruct) value } environment: namespace:ape [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
[R] negative correlation with corSymm in nlme or another way?
Hi, I have a nonlinear model with residuals that are negatively autocorrelated at short distances. I can find no spatial correlation structures in nlme that can easily handle negative autocorrelation as most have bounds on parameter values so that correlation is from 0 to 1. First, is there something I am missing? I tried to roll my own by calculating a correlation matrix with some negative values off the diagonal and then setting the correlation structure as follows within the function gnls: correlation=corSymm(corr9x[lower.tri(corr9x)]) where corr9x is the n x n matrix of correlations that I set up based upon distances between points in the data set. Some of these correlations are positive and some are negative. They are based on a Moran's I correlogram that I calculated from the residuals returned from a gnls model fit with NO spatial correlation employed. I get the following error: Initial values for corSymm do not define a positive-definite correlation structure I am unsure if the matrix is rejected out of hand because it contains negative values or if there is something I can do to coerce it. I have checked the lower triangle matrix returned and it matches what I intended. Any input is appreciated. Seth Myers -- View this message in context: http://r.789695.n4.nabble.com/negative-correlation-with-corSymm-in-nlme-or-another-way-tp4666357.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
[R] R Regular Expressions - Metacharacters
I thought that I can use metacharacters such as \w to match word characters with one backslash. But for some reason, I need to include two backslashes. grepl(pattern='\w', x=what) Error: '\w' is an unrecognized escape in character string starting \w grepl(pattern='\\w', x=what) [1] TRUE I can't find the reason for this on the help pages. Does anyone know why? Thanks! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
[R] Comparing x-intercepts between linear regression lines
Is anyone familiar with a way to test for differences in the x-intercepts (not y-intercepts) of two simple linear regression lines in R? I'm familiar with a method to calculate standard error estimates of the x-intercept (http://www.mail-archive.com/r-help@r-project.org/msg50241.html), and ANCOVA, which can test for differences in the y-intercepts. Any help would be much appreciated. Thanks, Seth [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
[R] Remove wireframe outer box but keep ticks
I would like to eliminate the outer box around a lattice wireframe graph, but the usual recommended solution, which is to assign a color of 'transparent' to the axis.line parameter, eliminates ticks if the 'arrows=F' command is used, as shown in the following example: test = data.frame(expand.grid(c(1:10), c(1:10))) z = test[,1] + test[,2] test = cbind(test, z) names(test) = c(x, y, z) require(lattice) wireframe(z ~ x*y, data = test, scales=list(arrows=F), par.settings = list(axis.line = list(col = transparent)), ) Is there a way to eliminate the box but keep the ticks? Seth W. Bigelow, Ph.D. Research Ecologist USDA-FS Pacific Southwest Research Station Ph: (802)-379-3444 This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] Remove wireframe outer box but keep ticks
ilai/keren: Thanks for your response. It's not the 3d bounding box that I wish to eliminate, but the box that surrounds the whole figure and is drawn automatically (I call this the outer box, in contrast to the inner, 3d bounding box). The ticks attached to the bounding box are connected, in the software, to the outer box. I'm assembling a number of these graphs on one page, and the outer box makes the whole figure look clunky. Lattice is an incredible piece of software! but these small details can be difficult to nail down. --Seth -Original Message- From: ila...@gmail.com [mailto:ila...@gmail.com] On Behalf Of ilai Sent: Friday, March 23, 2012 11:10 AM To: Bigelow, Seth W -FS Cc: r-help@r-project.org Subject: Re: [R] Remove wireframe outer box but keep ticks See 'box.3d' in trellis.par.get() : wireframe(z ~ x*y, data = test, scales=list(arrows=F), par.settings = list(box.3d = list(col=NA))) Note you can have some finer control: wireframe(z ~ x*y, data = test, scales=list(arrows=F), par.settings = list(box.3d = list(col=c(1,2,NA,NA,3,NA,4,5,6))) ) Hope this helps On Fri, Mar 23, 2012 at 3:59 AM, Bigelow, Seth W -FS sbige...@fs.fed.us wrote: I would like to eliminate the outer box around a lattice wireframe graph, but the usual recommended solution, which is to assign a color of 'transparent' to the axis.line parameter, eliminates ticks if the 'arrows=F' command is used, as shown in the following example: test = data.frame(expand.grid(c(1:10), c(1:10))) z = test[,1] + test[,2] test = cbind(test, z) names(test) = c(x, y, z) require(lattice) wireframe(z ~ x*y, data = test, scales=list(arrows=F), par.settings = list(axis.line = list(col = transparent)), ) Is there a way to eliminate the box but keep the ticks? Seth W. Bigelow, Ph.D. Research Ecologist USDA-FS Pacific Southwest Research Station Ph: (802)-379-3444 This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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. __ R-help@r-project.org mailing list 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.
Re: [R] Remove wireframe outer box but keep ticks
Wow, that worked liked a charm. I will include the entire working example of how to remove the outer box without losing the ticks: test = data.frame(expand.grid(c(1:10), c(1:10))) z = test[,1] + test[,2] test = cbind(test, z) names(test) = c(x, y, z) require(lattice) wireframe(z ~ x*y, data = test, scales=list(arrows=F,col=1), par.settings = list(axis.line = list(col = transparent)), ) Many thanks!!! --Seth This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately. __ R-help@r-project.org mailing list 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.
[R] [R-pkgs] RSQLite 0.11.0
A new version of RSQLite has been uploaded to CRAN. Details on the enhancements and fixes are below. Please direct questions to the R-sig-db mailing list. Version 0.11.0 - Enhance type detection in sqliteDataType (dbDataType). The storage mode of a data.frame column is now used as part of the type detection. Prior to this patch, all vectors with class other than numeric or logical were mapped to a TEXT column. This patch uses the output of storage.mode to map to integer and double vectors to INTEGER and REAL columns, respectively. All other modes are mapped to a TEXT column. - Detection of BLOBs was narrowed slightly. The code now treats only objects with data.class(obj) == list as BLOBs. Previously, is.list was used which could return TRUE for lists of various classes. - Fix bug in sqliteImportFile (used by dbWriteTable) that prevented a comment character from being specified for the input file. - Increase compile-time SQLite limits for maximum number of columns in a table to 3 and maximum number of parameters (?N) in a SELECT to 4. Use of wide tables is not encouraged. The default values for SQLite are 2000 and 999, respectively. Databases containing tables with more than 2000 columns may not be compatible with versions of SQLite compiled with default settings. - Upgrade to SQLite 3.7.9. -- Seth Falcon | @sfalcon | http://userprimary.net/ ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list 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.
[R] issue with available.packages() and download.file()
Dear R-Users, I think I have encountered a potential bug (or at least unwanted behavior), but I'm not sure so I wanted to post here first. Lately I've been encountering an error when running a package I put together. I have my package set up to check for updates when it loads but this error occurs and stops the package from loading: Error : .onLoad failed in loadNamespace() for 'rNMR', details: call: read.dcf(file = tmpf) error: Line starting 'SCRIPT language=Jav ...' is malformed! Error: package/namespace load failed for 'rNMR' I tracked to the following line of code from my package: available.packages(contrib.url(repos = http://rnmr.nmrfam.wisc.edu/R/;, type = win.binary)) I dug a little deeper and found the following line of code from available.packages() to be causing the problem: z - tryCatch(download.file(url = paste(repos, PACKAGES.gz, sep = /), destfile = tmpf, method = method, cacheOK = FALSE, quiet = TRUE, mode = wb), error = identity) The problem occurs because PACKAGES.gz does not exist in the repository, so my router redirects the invalid URL to a search page and some JavaScript is downloaded instead. The error is generated when R tries to read the downloaded file: res0 - read.dcf(file = tmpf) Error in read.dcf(file = tmpf) : Line starting 'SCRIPT language=Jav ...' is malformed! The repository does have a PACKAGES file, but it never gets read because download.file() does not generate an error. I've fixed the issue by uploading a PACKAGES.gz file to the repository, but I wanted to point out the issue in case anybody else has encountered this problem. This problem may be unique to my particular system configuration, in which case a fix may not be justified. Otherwise, it may be a good idea to check for a PACKAGES file in the repository if an error is encountered when trying to read the downloaded PACKAGES.gz file. Thanks, Seth R Version: platform = i386-pc-mingw32 arch = i386 os = mingw32 system = i386, mingw32 status = Patched major = 2 minor = 13.1 year = 2011 month = 08 day = 19 svn rev = 56771 language = R version.string = R version 2.13.1 Patched (2011-08-19 r56771) Windows 7 (build 7601) Service Pack 1 Locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 Search Path: .GlobalEnv, package:tcltk, package:stats, package:graphics, package:grDevices, package:utils, package:datasets, package:methods, Autoloads, package:base [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
[R] optimize weights for a weighted average?
Hi, I have a simple problem where I have two or more predictor variables that range from 0 to 1 and binary response variable (0 or 1). In the two variable case, the model to fit with maximum likelihood would simply be: P(Y=1) = (B1*X1 + B2*X2)/(B1+B2) or if least squares is to be minimized the model would just be Y = (B1*X1 + B2*X2)/(B1+B2) I know that I can write these in nls and other packages and fit using least squares or maximum likelihood. However, since this is just a weighted average (a regression with the constraint that all slope coefficients or weights sum to 1); it seems there should be a simpler method I am not finding. Anyone have a quick point to a package/function that will optimze weights in a weighted average or similarly allow a constraint of all regression coefficients sum to 1? Thanks, Seth -- View this message in context: http://r.789695.n4.nabble.com/optimize-weights-for-a-weighted-average-tp3613194p3613194.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
[R] Accessing elements of a list
I have a list that is made of lists of varying length. I wish to create a new vector that contains the last element of each list. So far I have used sapply to determine the length of each list, but I'm stymied at the part where I index the list to make a new vector containing only the last item of each list mylist = list(c(1,2,3),c(cat,dog),c(x,y,z,zz)) # Create list last - sapply(mylist,length) # Make vector with list lengths last_only - mylist[[1:length(mylist)]][last] # Crash and burn trying to make new vector with last items! How do I do this last step? Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California sbige...@fs.fed.us / ph. 530 759 1718 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] Decimals in R/SQL
On Wed, Apr 13, 2011 at 1:34 PM, Rachel Licata rach...@kff.org wrote: Thanks again Jim - that is really helpful and I apologize that I am new to R. How can I convert to numeric in SQL and when I am working on a table in a database? The file is huge so that is why I am using SQL and the database to work through it. I believe that RSQLite will do the right thing if you provide the correct types in your schema. So for a new database, you want to make sure that the columns that you want to be numeric are created like: CREATE table sometable (my_data REAL); You should be able to create a new table from an existing table using SQL where the new table has the types you want. + seth -- Seth Falcon | @sfalcon | http://userprimary.net/ __ R-help@r-project.org mailing list 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.
[R] function to compare Brier scores from two models?
Hi, I have probability estimates from two predictive models. I have these estimates and also a binary outcome for a validation data set not used in calibrating either model. I would like to calculate the Brier score for both models on this binary outcome and test the hypothesis that the Brier scores are equal from the two models. I have not been able to find an R function to do this, can someone point me to the appropriate library and function if one exists? Thanks, Seth -- View this message in context: http://r.789695.n4.nabble.com/function-to-compare-Brier-scores-from-two-models-tp3409714p3409714.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
[R] Does POSIXlt extract date components properly?
I would like to use POSIX classes to store dates and extract components of dates. Following the example in Spector (Data Manipulation in R), I create a date mydate = as. POSIXlt('2005-4-19 7:01:00') I then successfully extract the day with the command mydate$day [1] 19 But when I try to extract the month mydate$mon [1] 3 it returns the wrong month. And mydate$year is off by about 2,000 years. Am I doing something wrong? Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California sbige...@fs.fed.us / ph. 530 759 1718 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] Data type problem when extract data from SQLite to R by using RSQLite
On Tue, Mar 1, 2011 at 10:06 AM, chen jia chen_1...@fisher.osu.edu wrote: Hi Seth, Thanks so much for identifying the problem and explaining everything. I think the first solution that you suggest--make sure the schema has well defined types--would work the best for me. But, I have one question about how to implement it, which is more about sqlite itself. First, I found out that the columns that don't have the expected data types in the table annual_data3 are created by aggregate functions in a separate table. These columns are later combined with other columns that do. I read the link that you provide, http://www.sqlite.org/datatype3.html. One paragraph says When grouping values with the GROUP BY clause values with different storage classes are considered distinct, except for INTEGER and REAL values which are considered equal if they are numerically equal. No affinities are applied to any values as the result of a GROUP by clause. If I understand it correctly, the columns created by aggregate functions with a GROUP by clause do not have any expected data types. My solution is to use CREATE TABLE clause to declare the expected datatype and then insert the values of columns created by the aggregate functions with the GROUP by clause. However, this solution requires a CREATE TABLE cause every time the aggregate function and the GROUP by clause is used. My question is: Is this the best way to make sure that the columns as a result of a GROUP by clause have the expected data types? Thanks. That might be a good question to post to the SQLite user's list :-) I don't have an answer off the top of my head. My reading of the SQLite docs would lead me to expect that a GROUP BY clause would not change/remove type if the column being grouped contains all the same declared type affinity. + seth Best, Jia On Tue, Mar 1, 2011 at 1:16 AM, Seth Falcon s...@userprimary.net wrote: Hi Jia, On Mon, Feb 28, 2011 at 6:57 PM, chen jia chen_1...@fisher.osu.edu wrote: The .schema of table annual_data3 is sqlite .schema annual_data3 CREATE TABLE annual_data3( PERMNO INT, DATE INT, CUSIP TEXT, EXCHCD INT, SICCD INT, SHROUT INT, PRC REAL, RET REAL, ... pret_var, pRET_sd, nmret, pya_var, [snip] Is there a reason that you've told SQLite the expected data type for only some of the columns? Interestingly, I find that the problem I reported does not for columns labeled real in the schema info. For example, the type of column RET never changes no matter what the first observation is. Yes, that is expected and I think it is the solution to your problem: setup your schema so that all columns have a declared type. For some details on SQLite's type system see http://www.sqlite.org/datatype3.html. RSQLite currently maps NA values to NULL in the database. Pulling data out of a SELECT query, RSQLite uses the sqlite3_column_type SQLite API to determine the data type and map it to an R type. If NULL is encountered, then the schema is inspected using sqlite3_column_decltype to attempt to obtain a type. If that fails, the data is mapped to a character vector at the R level. The type selection is done once after the first row has been fetched. To work around this you can: - make sure your schema has well defined types (which will help SQLite perform its operations); - check whether the returned column has the expected type and convert if needed at the R level. - remove NA/NULL values from the db or decide on a different way of encoding them (e.g you might be able to use -1 in the db in some situation to indicate missing). Your R code would then need to map these to proper NA. Hope that helps. + seth -- Seth Falcon | @sfalcon | http://userprimary.net/ -- 700 Fisher Hall 2100 Neil Ave. Columbus, Ohio 43210 http://www.fisher.osu.edu/~chen_1002/ -- Seth Falcon | @sfalcon | http://userprimary.net/ __ R-help@r-project.org mailing list 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.
Re: [R] Data type problem when extract data from SQLite to R by using RSQLite
Hi Jia, On Mon, Feb 28, 2011 at 12:37 PM, chen jia chen_1...@fisher.osu.edu wrote: When I extract data from SQLite to R, the data types (or modes) of the extracted data seems to be determined by the value of the first row. Please see the following example. It would help to provide the output of sessionInfo() as well as the schema definition for the table in SQLite (or at least description of how it was created). Here's an example that works as you'd like: library(RSQLite) db = dbConnect(SQLite(), dbname = :memory:) dbGetQuery(db, create table t (a int, b real, c text)) df = data.frame(a=c(NA, 1L, 2L), b=c(NA, 1.1, 2.2), c=c(NA, x, y),stringsAsFactors=FALSE) df a bc 1 NA NA NA 2 1 1.1x 3 2 2.2y dbGetPreparedQuery(db, insert into t values (?, ?, ?), df) dbGetQuery(db, select * from t) a bc 1 NA NA NA 2 1 1.1x 3 2 2.2y sapply(dbGetQuery(db, select * from t), typeof) a b c integerdouble character sapply(dbGetQuery(db, select * from t limit 1), typeof) a b c integerdouble character sapply(dbGetQuery(db, select a from t limit 1), typeof) a integer sapply(dbGetQuery(db, select a from t limit 2), typeof) a integer sapply(dbGetQuery(db, select a from t limit 1), typeof) a integer sessionInfo() R version 2.11.1 (2010-05-31) x86_64-apple-darwin9.8.0 locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices datasets utils methods base other attached packages: [1] RSQLite_0.9-4 DBI_0.2-5 loaded via a namespace (and not attached): [1] tools_2.11.1 -- Seth Falcon | @sfalcon | http://userprimary.net/ __ R-help@r-project.org mailing list 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.
Re: [R] Data type problem when extract data from SQLite to R by using RSQLite
Hi Jia, On Mon, Feb 28, 2011 at 6:57 PM, chen jia chen_1...@fisher.osu.edu wrote: The .schema of table annual_data3 is sqlite .schema annual_data3 CREATE TABLE annual_data3( PERMNO INT, DATE INT, CUSIP TEXT, EXCHCD INT, SICCD INT, SHROUT INT, PRC REAL, RET REAL, ... pret_var, pRET_sd, nmret, pya_var, [snip] Is there a reason that you've told SQLite the expected data type for only some of the columns? Interestingly, I find that the problem I reported does not for columns labeled real in the schema info. For example, the type of column RET never changes no matter what the first observation is. Yes, that is expected and I think it is the solution to your problem: setup your schema so that all columns have a declared type. For some details on SQLite's type system see http://www.sqlite.org/datatype3.html. RSQLite currently maps NA values to NULL in the database. Pulling data out of a SELECT query, RSQLite uses the sqlite3_column_type SQLite API to determine the data type and map it to an R type. If NULL is encountered, then the schema is inspected using sqlite3_column_decltype to attempt to obtain a type. If that fails, the data is mapped to a character vector at the R level. The type selection is done once after the first row has been fetched. To work around this you can: - make sure your schema has well defined types (which will help SQLite perform its operations); - check whether the returned column has the expected type and convert if needed at the R level. - remove NA/NULL values from the db or decide on a different way of encoding them (e.g you might be able to use -1 in the db in some situation to indicate missing). Your R code would then need to map these to proper NA. Hope that helps. + seth -- Seth Falcon | @sfalcon | http://userprimary.net/ __ R-help@r-project.org mailing list 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.
[R] R implementation of S-distribution
I'm working with data that can exhibit either strong right- or left-skew. I understand the S-distribution is useful in such cases (e.g., Voit and Schwacke, 2000. Random Number Generation from Right-Skewed, Symmetric, and Left-Skewed Distributions. Risk Analysis 20 (1): 59-71). Does anyone know of any R implementation of this distribution? Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California sbige...@fs.fed.us / ph. 530 759 1718 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] python-like dictionary for R
On Wed, Dec 22, 2010 at 7:05 PM, Martin Morgan mtmor...@fhcrc.org wrote: On 12/22/2010 05:49 PM, Paul Rigor wrote: Hi, I was wondering if anyone has played around this this package called rdict? It attempts to implement a hash table in R using skip lists. Just came across it while trying to look for simpler text manipulation methods: http://userprimary.net/posts/2010/05/29/rdict-skip-list-hash-table-for-R/ kind of an odd question, so kind of an odd answer. I'd say this was an implementation of skip lists in C with an R interface. I had to play around with the rdict package in order to write it, but haven't used it much since :-P Be sure to look at R's native environment objects which provide a hash table structure and are suitable for many uses. + seth -- Seth Falcon | @sfalcon | http://userprimary.net/ __ R-help@r-project.org mailing list 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.
[R] how to remove grid lines from coplot graphs
coplot() usually puts grid lines in the panels it makes. To see examples, example(coplot). How can I remove those grid lines? Seth Roberts [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] How to Read a Large CSV into a Database with R
Hi Abhijit, [I've cc'd R-help to keep the discussion on the list] On Tue, Nov 16, 2010 at 8:06 AM, Abhijit Dasgupta adasgu...@araastat.com wrote: Seth, I was looking for something like this too. I've a question. If you're reading the data from a connection, does R start reading the next chunk of data right after the previous chunk, or do we need to keep track of things using skip The purpose of using a file connection is to allow R to keep its place in the file as it reads and not have to re-read or skip. This is considerably more efficient. -- Seth Falcon | @sfalcon | http://userprimary.net/ __ R-help@r-project.org mailing list 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.
Re: [R] How to Read a Large CSV into a Database with R
Hi Anthony, On Mon, Nov 15, 2010 at 7:07 AM, Anthony Damico ajdam...@gmail.com wrote: Hi, I'm working in R 2.11.1 x64 on Windows x86_64-pc-mingw32. I'm trying to insert a very large CSV file into a SQLite database. I'm pretty new to working with databases in R, so I apologize if I'm overlooking something obvious here. Working with large data and doing operations in bounded memory tends not to be among the most obvious things to accomplish in R for new comers. I need to combine both of these CSV files into one table (within a database), so I think that I'd need a SQL manipulation technique that reads everything line by line, instead of pulling it all into memory. Yes, that sounds like the right approach. Below is some sample code that does this and avoids reading the entire data set into memory. The key points are to use read.table on a file connection and to read in a batch of lines at a time. Each batch is inserted into the db using a prepared query. The example is complicated a bit because read.table on a file connection raises an error if no lines are available, so I chose to use tryCatch to handle that. A cleaner approach might be to check the number of rows read and break out of the while loop if the count is less than the batch size. Anyhow, see if this approach works for you. library(RSQLite) file_list - c(ss09pusa.csv, ss09pusb.csv) input - file(file_list[1], r) db - dbConnect(SQLite(), dbname=example.sqlite) header - readLines(input, n = 1) fields - strsplit(header, ,)[[1]] colTypes - rep(TEXT, length(fields)) colDecl - paste(fields, colTypes) sql - sprintf(CREATE TABLE ss09 (%s), paste(colDecl, collapse = , )) dbGetQuery(db, sql) colClasses - rep(character, length(fields)) sql.in - sprintf(INSERT INTO ss09 VALUES (%s), paste(rep(?, length(fields)), collapse = ,)) chunk_size - 25 dbBeginTransaction(db) tryCatch({ while (TRUE) { part - read.table(input, nrows=chunk_size, sep=,, colClasses = colClasses, comment.char = ) dbGetPreparedQuery(db, sql.in, bind.data = part) } }, error = function(e) { if (grepl(no lines available, conditionMessage(e))) TRUE else stop(conditionMessage(e)) }) dbCommit(db) -- Seth Falcon | @sfalcon | http://userprimary.net/ __ R-help@r-project.org mailing list 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.
Re: [R] Doing operations by grouping variable
Thanks, Bill and Michael, you have answered the question I asked, but not the one I wished to ask I want to obtain the maximum in each group of variables, so I could scale each variable by the maximum for its group. If I use tapply, as in the example below, there's a mismatch in dimensions of the output of tapply [5] and the data frame with the variables[25]. group = rep(1:5, each=5) # define grouping variable variable = rnorm(25)# generate data d - data.frame(group,variable) # bundle together in a data frame d$scaled - d$variable/(with(d,tapply(variable,group,max))) # crash and burn Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California bill.venab...@csiro.au 09/20/2010 06:24 PM To michael.bedw...@gmail.com, sbige...@fs.fed.us, r-help@r-project.org cc Subject RE: [R] Doing operations by grouping variable That's if the variables are visible. If they are only in the data frame it's not much more difficult d - data.frame(group = rep(1:5, each=5), variable = rnorm(25)) with(d, tapply(variable, group, max)) (Tip: avoid using attach().) Bill Venables. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Michael Bedward Sent: Tuesday, 21 September 2010 11:15 AM To: Seth W Bigelow; Rhelp Subject: Re: [R] Doing operations by grouping variable Not sure why you think tapply is awkward. Your example would be... group - rep(1:5, each=5) variable - rnorm(25) tapply(variable, group, max) ...which looks quite elegant to me :) Meanwhile, the reason your expression doesn't work is that you are asking mistakenly for elements 1:5 repeatedly from the variable col. If you just type d$variable[ d$group ] and compare the values to your variable vector this should be clear. Michael On 21 September 2010 10:59, Seth W Bigelow sbige...@fs.fed.us wrote: I'm writing an expression that requires searching a vector according to group. As an example, I want to find the maximum value in each of 5 groups. group=rep(1:5, each=5) # create grouping variable variable=rnorm(25) # generate data d - data.frame(group,variable) # make data frame max(d$variable[d$group])# try expression that doesn't work I'm expecting a vector containing the maximum variable value, per group. What am I doing wrong? I know I can use aggregate, tapply, etc. but that seems awkward and bulky, is there a simpler way? Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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. __ R-help@r-project.org mailing list 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@r-project.org mailing list 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.
Re: [R] Doing operations by grouping variable
Bill, I'd never heard of ave( ) before, but it works like a charm for the purpose outlined below Thanks!! Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California William Dunlap wdun...@tibco.com 09/21/2010 08:52 AM To Seth W Bigelow sbige...@fs.fed.us, R-help R-help@r-project.org cc Subject RE: [R] Doing operations by grouping variable Have you tried using ave()? group - rep(1:5,each=5) variable - log(1:25) d - data.frame(group, variable) d$scaled - d$variable/with(d, ave(variable, group, FUN=max)) Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Seth W Bigelow Sent: Tuesday, September 21, 2010 8:43 AM To: bill.venab...@csiro.au Cc: r-help@r-project.org Subject: Re: [R] Doing operations by grouping variable Thanks, Bill and Michael, you have answered the question I asked, but not the one I wished to ask I want to obtain the maximum in each group of variables, so I could scale each variable by the maximum for its group. If I use tapply, as in the example below, there's a mismatch in dimensions of the output of tapply [5] and the data frame with the variables[25]. group = rep(1:5, each=5) # define grouping variable variable = rnorm(25) # generate data d - data.frame(group,variable) # bundle together in a data frame d$scaled - d$variable/(with(d,tapply(variable,group,max))) # crash and burn Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California bill.venab...@csiro.au 09/20/2010 06:24 PM To michael.bedw...@gmail.com, sbige...@fs.fed.us, r-help@r-project.org cc Subject RE: [R] Doing operations by grouping variable That's if the variables are visible. If they are only in the data frame it's not much more difficult d - data.frame(group = rep(1:5, each=5), variable = rnorm(25)) with(d, tapply(variable, group, max)) (Tip: avoid using attach().) Bill Venables. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Michael Bedward Sent: Tuesday, 21 September 2010 11:15 AM To: Seth W Bigelow; Rhelp Subject: Re: [R] Doing operations by grouping variable Not sure why you think tapply is awkward. Your example would be... group - rep(1:5, each=5) variable - rnorm(25) tapply(variable, group, max) ...which looks quite elegant to me :) Meanwhile, the reason your expression doesn't work is that you are asking mistakenly for elements 1:5 repeatedly from the variable col. If you just type d$variable[ d$group ] and compare the values to your variable vector this should be clear. Michael On 21 September 2010 10:59, Seth W Bigelow sbige...@fs.fed.us wrote: I'm writing an expression that requires searching a vector according to group. As an example, I want to find the maximum value in each of 5 groups. group=rep(1:5, each=5) # create grouping variable variable=rnorm(25) # generate data d - data.frame(group,variable) # make data frame max(d$variable[d$group])# try expression that doesn't work I'm expecting a vector containing the maximum variable value, per group. What am I doing wrong? I know I can use aggregate, tapply, etc. but that seems awkward and bulky, is there a simpler way? Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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. __ R-help@r-project.org mailing list 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@r-project.org mailing list 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R
Re: [R] Doing operations by grouping variable
Aah, that is the sort of truly elegant solution I have been seeking. And it's wrapped up in a nice programming shortcut to boot (i.e., the within statement). I retract anything I may have said about tapply being clunky. Many thanks --Seth Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California bill.venab...@csiro.au 09/21/2010 03:15 PM To sbige...@fs.fed.us cc michael.bedw...@gmail.com, r-help@r-project.org Subject RE: [R] Doing operations by grouping variable You left out the subscript. Why not just do d - within(data.frame(group = rep(1:5, each = 5), variable = rnorm(25)), scaled - variable/tapply(variable, group, max)[group]) and be done with it? (Warning: if you replace the second '-' above by '=', it will not work. It is NOT true that you can always replace '-' by '=' for assignment. Why?) Bill Venables. -Original Message- From: Seth W Bigelow [mailto:sbige...@fs.fed.us] Sent: Wednesday, 22 September 2010 1:43 AM To: Venables, Bill (CMIS, Cleveland) Cc: michael.bedw...@gmail.com; r-help@r-project.org Subject: RE: [R] Doing operations by grouping variable Thanks, Bill and Michael, you have answered the question I asked, but not the one I wished to ask I want to obtain the maximum in each group of variables, so I could scale each variable by the maximum for its group. If I use tapply, as in the example below, there's a mismatch in dimensions of the output of tapply [5] and the data frame with the variables[25]. group - rep(1:5, each=5) # define grouping variable variable - rnorm(25) # generate data d - data.frame(group,variable) # bundle together in a data frame d$scaled - d$variable/(with(d,tapply(variable,group,max)))# crash and burn Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California bill.venab...@csiro.au 09/20/2010 06:24 PM To michael.bedw...@gmail.com, sbige...@fs.fed.us, r-help@r-project.org cc Subject RE: [R] Doing operations by grouping variable That's if the variables are visible. If they are only in the data frame it's not much more difficult d - data.frame(group = rep(1:5, each=5), variable = rnorm(25)) with(d, tapply(variable, group, max)) (Tip: avoid using attach().) Bill Venables. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Michael Bedward Sent: Tuesday, 21 September 2010 11:15 AM To: Seth W Bigelow; Rhelp Subject: Re: [R] Doing operations by grouping variable Not sure why you think tapply is awkward. Your example would be... group - rep(1:5, each=5) variable - rnorm(25) tapply(variable, group, max) ...which looks quite elegant to me :) Meanwhile, the reason your expression doesn't work is that you are asking mistakenly for elements 1:5 repeatedly from the variable col. If you just type d$variable[ d$group ] and compare the values to your variable vector this should be clear. Michael On 21 September 2010 10:59, Seth W Bigelow sbige...@fs.fed.us wrote: I'm writing an expression that requires searching a vector according to group. As an example, I want to find the maximum value in each of 5 groups. group=rep(1:5, each=5) # create grouping variable variable=rnorm(25) # generate data d - data.frame(group,variable) # make data frame max(d$variable[d$group])# try expression that doesn't work I'm expecting a vector containing the maximum variable value, per group. What am I doing wrong? I know I can use aggregate, tapply, etc. but that seems awkward and bulky, is there a simpler way? Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide https://stat.ethz.ch/mailman/listinfo/r-help http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list http://www.r-project.org/posting-guide.html https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide https://stat.ethz.ch/mailman/listinfo/r-help http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. http://www.r-project.org/posting-guide.html [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R
[R] Doing operations by grouping variable
I'm writing an expression that requires searching a vector according to group. As an example, I want to find the maximum value in each of 5 groups. group=rep(1:5, each=5) # create grouping variable variable=rnorm(25) # generate data d - data.frame(group,variable) # make data frame max(d$variable[d$group])# try expression that doesn't work I'm expecting a vector containing the maximum variable value, per group. What am I doing wrong? I know I can use aggregate, tapply, etc. but that seems awkward and bulky, is there a simpler way? Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] 64 bit RSQLite
Hi, On 8/14/10 11:43 PM, Stephen Liu wrote: Could you please explain a little bid further whether after connecting the website I can select either 32 or 64 bit version? R packages come in pre-compiled binary flavors for some OS/architectures and always as source packages. If you are on Linux, you typically use source packages and native code is compiled as part of the R package installation process. In this case, you don't have to worry about 32/64 bit and the right thing should happen. I'd suggest reading through the manuals that come with R for more details and suggestions. + seth __ R-help@r-project.org mailing list 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.
Re: [R] Limited output
Hi, On 7/21/10 1:58 AM, confusedcius wrote: The details of my problem are as follows: I have an sql that returns 2192 rows in sqlite. In R, I typed the following: library(RSQLite) con - dbConnect(dbDriver(SQLite), dbname = C:\\sqlite\\... .sqlite) dbListTables(con) #[1] tbl_n... tbl_s...# cur - dbSendQuery(con,select ... from tbl_n... where... ) bru - fetch(cur) bru This returns the first 500 of the 2192 rows of sqlite. See the help page for fetch. If you want all of the rows at once, you can say: fetch(cur, n=-1) If you want all the rows at once you can use dbGetQuery instead and skip dealing with the result set and fetch. Or you can call fetch again and get the next 500 rows... + seth __ R-help@r-project.org mailing list 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.
Re: [R] 64 bit RSQLite
Hi Stephen, On 8/12/10 7:10 PM, Stephen Liu wrote: Hi folks, Ubuntu 10.04 64 bit Where can I find 64 bit RSQLite? It seems not there; RSQLite: SQLite interface for R http://cran.r-project.org/web/packages/RSQLite/index.html You should be able to install the RSQLite source package to obtain a 64 bit package. install.packages(RSQLite, type=source) + seth __ R-help@r-project.org mailing list 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.
[R] specifying column names in a vector of characters and the use?
Hi, What I would like to do is have a data.frame with column names and have these column names stored as strings in another vector. Then I would like to be able to access the data.fram columns via referencing the vector of names. The code below shows the last few executions that failed to retrieve the values for column named X1. Seth table.1-cbind(c(1,2,3,2,2),c(0,9,0,7,9),c(7,5,9,8,8)) table.1 [,1] [,2] [,3] [1,]107 [2,]295 [3,]309 [4,]278 [5,]298 table.1-data.frame(table.1) table.1 X1 X2 X3 1 1 0 7 2 2 9 5 3 3 0 9 4 2 7 8 5 2 9 8 hold-c(X1,X2,X3) hold [1] X1 X2 X3 table.1$X1 [1] 1 2 3 2 2 hold[1] [1] X1 table.1$hold[1] # FROM HERE DOWN ARE MY ATTEMPTS TO ACCESS X1 NULL table.1$(hold[1]) Error: unexpected '(' in table.1$( table.1$get(hold[1]) Error: attempt to apply non-function table.1$(get(hold[1])) Error: unexpected '(' in table.1$( -- View this message in context: http://r.789695.n4.nabble.com/specifying-column-names-in-a-vector-of-characters-and-the-use-tp2293494p2293494.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] Compress string memCompress/Decompress
On Mon, Jul 12, 2010 at 9:17 AM, Erik Wright eswri...@wisc.edu wrote: Hi Seth, Can you recreate the example below using dbWriteTable? Not sure if that is possible with the current dbWriteTable code (don't have time to explore that right now). You are welcome to poke around. You could wrap the example in a helper function to provide your own BLOB respecting write table function if you can't get dbWriteTable to work for your case. + seth -- Seth Falcon | @sfalcon | http://userprimary.net/ __ R-help@r-project.org mailing list 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.
Re: [R] RSQLite install R x86_64 fail
Hi David, On Sun, Jul 11, 2010 at 12:27 PM, David Ruau dr...@stanford.edu wrote: On a fresh install of R on mac os x 10.6.4 (snow leopard) RSQLite did not install while running biocLite() How did you install R? $ R biocLite(RSQLite) Using R version 2.11.1, biocinstall version 2.6.7. Installing Bioconductor version 2.6 packages: [1] RSQLite Please wait... Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared library '/Users/druau/R/x86_64-apple-darwin10.4.0-library/2.11/RSQLite/libs/RSQLite.so': dlopen(/Users/druau/R/x86_64-apple-darwin10.4.0-library/2.11/RSQLite/libs/RSQLite.so, 6): Symbol not found: _sqlite3_backup_finish Referenced from: /Users/druau/R/x86_64-apple-darwin10.4.0-library/2.11/RSQLite/libs/RSQLite.so Expected in: flat namespace in /Users/druau/R/x86_64-apple-darwin10.4.0-library/2.11/RSQLite/libs/RSQLite.so ERROR: loading failed * removing ‘/Users/druau/R/x86_64-apple-darwin10.4.0-library/2.11/RSQLite’ * restoring previous ‘/Users/druau/R/x86_64-apple-darwin10.4.0-library/2.11/RSQLite’ What version of XCode do you have? I have 3.2.1 and can build RSQLite from source from an R that I have compiled from source. If you have an earlier version, please try upgrading and repeating the install. The binary install work with install.packages(RSQLite, type='mac.binary') or 'mac.binary.leopard' but the package does not load properly. library('RSQLite') Error: package 'RSQLite' was built for universal-apple-darwin9.8.0 The mac binary package is intended to work with the R binary installer for OS X. So if you want to use it, you need to install R that way. Hope that helps some. + seth -- Seth Falcon | @sfalcon | http://userprimary.net/ __ R-help@r-project.org mailing list 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.
Re: [R] Compress string memCompress/Decompress
On Sun, Jul 11, 2010 at 11:31 AM, Matt Shotwell shotw...@musc.edu wrote: On Fri, 2010-07-09 at 20:02 -0400, Erik Wright wrote: Hi Matt, This works great, thanks! At first I got an error message saying BLOB is not implemented in RSQLite. When I updated to the latest version it worked. SQLite began to support BLOBs from version 3.0. And RSQLite began supporting BLOBs only just recently :-) See the NEWS file for details. Below is a minimal example of how you might use BLOBs: db - dbConnect(SQLite(), dbname = :memory:) dbGetQuery(db, CREATE TABLE t1 (name TEXT, data BLOB)) z - paste(hello, 1:10) df - data.frame(a = letters[1:10], z = I(lapply(z, charToRaw))) dbGetPreparedQuery(db, insert into t1 values (:a, :z), df) a - dbGetQuery(db, select name from t1) checkEquals(10, nrow(a)) a - dbGetQuery(db, select data from t1) checkEquals(10, nrow(a)) a - dbGetQuery(db, select * from t1) checkEquals(10, nrow(a)) checkEquals(2, ncol(a)) checkEquals(z, sapply(a$data, rawToChar)) dbDisconnect(db) -- Seth Falcon | @sfalcon | http://userprimary.net/ __ R-help@r-project.org mailing list 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.
Re: [R] RSQLite install R x86_64 fail
On Sun, Jul 11, 2010 at 4:25 PM, David Ruau dr...@stanford.edu wrote: Hi Seth, Thanks for the answer. I have install R using macport (since many years now). It compile R from source using gcc 4.4 by default. But I don't think this is the problem because I manage to install many other package that do not need RSQLite. The configure options for the macport port are at: http://trac.macports.org/browser/trunk/dports/math/R/Portfile I have Xcode 3.2.3 downloaded yesterday. The thing is that it compile correctly but the RSQLite.so is not at the place specified. Instead of being at ~/R/x86_64-apple-darwin10.4.0-library/2.11/RSQLite/libs/ it is in a subfolder ~/R/x86_64-apple-darwin10.4.0-library/2.11/RSQLite/libs/x86_64/ I could create a symbolic link only if biocLite would not erase the folder at the end of the failed install. I don't use macports so I'm afraid I can't be of much help. I suspect that something isn't getting configured properly for 64bit R in macports. When I build R from source on OS X and install RSQLite, I see the package in .../libs/x86_64 and this works. Maybe it will be useful to review the advice here: http://r.research.att.com/building.html + seth David On Jul 11, 2010, at 4:09 PM, Seth Falcon wrote: Hi David, On Sun, Jul 11, 2010 at 12:27 PM, David Ruau dr...@stanford.edu wrote: On a fresh install of R on mac os x 10.6.4 (snow leopard) RSQLite did not install while running biocLite() How did you install R? $ R biocLite(RSQLite) Using R version 2.11.1, biocinstall version 2.6.7. Installing Bioconductor version 2.6 packages: [1] RSQLite Please wait... Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared library '/Users/druau/R/x86_64-apple-darwin10.4.0-library/2.11/RSQLite/libs/RSQLite.so': dlopen(/Users/druau/R/x86_64-apple-darwin10.4.0-library/2.11/RSQLite/libs/RSQLite.so, 6): Symbol not found: _sqlite3_backup_finish Referenced from: /Users/druau/R/x86_64-apple-darwin10.4.0-library/2.11/RSQLite/libs/RSQLite.so Expected in: flat namespace in /Users/druau/R/x86_64-apple-darwin10.4.0-library/2.11/RSQLite/libs/RSQLite.so ERROR: loading failed * removing ‘/Users/druau/R/x86_64-apple-darwin10.4.0-library/2.11/RSQLite’ * restoring previous ‘/Users/druau/R/x86_64-apple-darwin10.4.0-library/2.11/RSQLite’ What version of XCode do you have? I have 3.2.1 and can build RSQLite from source from an R that I have compiled from source. If you have an earlier version, please try upgrading and repeating the install. The binary install work with install.packages(RSQLite, type='mac.binary') or 'mac.binary.leopard' but the package does not load properly. library('RSQLite') Error: package 'RSQLite' was built for universal-apple-darwin9.8.0 The mac binary package is intended to work with the R binary installer for OS X. So if you want to use it, you need to install R that way. Hope that helps some. + seth -- Seth Falcon | @sfalcon | http://userprimary.net/ -- Seth Falcon | @sfalcon | http://userprimary.net/ __ R-help@r-project.org mailing list 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.
[R] way to get t-values from glm.fit output?
Hi, I am working with a function that makes use of glm.fit. Without modifying the somewhat long code too much, I would like to have t-values returned for the predictor variables used in the fitting process. Is there a relatively straightforward way to do this? Thanks, Seth Myers -- View this message in context: http://r.789695.n4.nabble.com/way-to-get-t-values-from-glm-fit-output-tp2281737p2281737.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] way to get t-values from glm.fit output?
Sorry to bother everyone. Soon after posting my question I found out what summary.glm() will do to a glm.fit object. Gotta love having your learning curve exposed in public :) Seth -- View this message in context: http://r.789695.n4.nabble.com/way-to-get-t-values-from-glm-fit-output-tp2281737p2281746.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] use a data frame whose name is stored as a string variable?
Thanks! Works like a charm. -Seth -- View this message in context: http://r.789695.n4.nabble.com/use-a-data-frame-whose-name-is-stored-as-a-string-variable-tp2269095p2269732.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
[R] use a data frame whose name is stored as a string variable?
Hi, Let's say I have a data frame (called example) with numeric values stored (columns V1 and V2). I also have a string variable storing this name x1-example Is there a way to use the variable x so that R knows that I want the specified action to occur on the data frame? For example, summary (x) would return a summary of the data frame? I am considering this because I need to compare many data frames within 2 nested for loops. In the first iteration of the loop I could concatenate x and 1 and then use it to represent the data frame. I'm open to a better solution. Thanks, Seth Myers -- View this message in context: http://r.789695.n4.nabble.com/use-a-data-frame-whose-name-is-stored-as-a-string-variable-tp2269095p2269095.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
[R] Lattice legend
I have a moderately complex graph with three panels. There are data points plotted, and fitted lines are added using a panel function, which includes with(alt.data[[which.packet()[1]]] statements. It all graphs out beautifully, but none of the usual tricks to get the proper legend to plot are working, i.e., using auto.key, key, etc. One message I keep getting is Error in key[[i]][[1]] - NULL : more elements supplied than there are to replace Any suggestions will be appreciated --Seth Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis Californiayear,survey,tx,bk,dayt,t,CC,doy,dep 2007,1,Control,Tamarack,2007-07-26,0.06356556,72,207,0-15 2007,2,Control,Tamarack,2007-08-30,0.03400111,72,242,0-15 2007,3,Control,Tamarack,2007-09-26,0.1054356,72,269,0-15 2007,1,50% target,Tamarack,2007-07-26,0.1115322,57,207,0-15 2007,2,50% target,Tamarack,2007-08-30,0.07165444,57,242,0-15 2007,3,50% target,Tamarack,2007-09-26,0.1154533,57,269,0-15 2007,1,30% target,Tamarack,2007-07-26,0.0654,40.25,207,0-15 2007,2,30% target,Tamarack,2007-08-30,0.03566778,40.25,242,0-15 2007,3,30% target,Tamarack,2007-09-26,0.0729,40.25,269,0-15 2007,1,Group,Tamarack,2007-07-26,0.147,6.11,207,0-15 2007,2,Group,Tamarack,2007-08-30,0.10344,6.11,242,0-15 2007,3,Group,Tamarack,2007-09-26,0.1612267,6.11,269,0-15 2007,1,Control,Deanes,2007-07-24,0.09867445,79,205,0-15 2007,2,Control,Deanes,2007-08-28,0.08022,79,240,0-15 2007,3,Control,Deanes,2007-09-24,0.1117922,79,267,0-15 2007,1,50% target,Deanes,2007-07-24,0.11711,51.5,205,0-15 2007,2,50% target,Deanes,2007-08-28,0.08067111,51.5,240,0-15 2007,3,50% target,Deanes,2007-09-24,0.1418667,51.5,267,0-15 2007,1,30% target,Deanes,2007-07-24,0.07089889,52.75,205,0-15 2007,2,30% target,Deanes,2007-08-28,0.04844556,52.75,240,0-15 2007,3,30% target,Deanes,2007-09-24,0.06822444,52.75,267,0-15 2007,1,Group,Deanes,2007-07-24,0.1215567,12.46,205,0-15 2007,2,Group,Deanes,2007-08-28,0.07945333,12.46,240,0-15 2007,3,Group,Deanes,2007-09-24,0.131,12.46,267,0-15 2007,1,Control,Pineleaf,2007-07-25,0.08367222,79.5,206,0-15 2007,2,Control,Pineleaf,2007-08-29,0.07334333,79.5,241,0-15 2007,1,50% target,Pineleaf,2007-07-25,0.09167111,62.63,206,0-15 2007,2,50% target,Pineleaf,2007-08-29,0.06644556,62.63,241,0-15 2007,3,50% target,Pineleaf,2007-09-25,0.07610778,62.63,268,0-15 2007,1,30% target,Pineleaf,2007-07-25,0.1068889,54.25,206,0-15 2007,2,30% target,Pineleaf,2007-08-29,0.08655111,54.25,241,0-15 2007,1,Group,Pineleaf,2007-07-25,0.06344667,18.84,206,0-15 2007,2,Group,Pineleaf,2007-08-29,0.04310889,18.84,241,0-15 2007,3,Group,Pineleaf,2007-09-25,0.07510889,18.84,268,0-15 2007,1,Control,Tamarack,2007-07-26,0.0968,72,207,15-40 2007,2,Control,Tamarack,2007-08-30,0.0902,72,242,15-40 2007,3,Control,Tamarack,2007-09-26,0.107,72,269,15-40 2007,1,50% target,Tamarack,2007-07-26,0.141,57,207,15-40 2007,2,50% target,Tamarack,2007-08-30,0.119,57,242,15-40 2007,3,50% target,Tamarack,2007-09-26,0.1127778,57,269,15-40 2007,1,30% target,Tamarack,2007-07-26,0.105,40.25,207,15-40 2007,2,30% target,Tamarack,2007-08-30,0.0867,40.25,242,15-40 2007,3,30% target,Tamarack,2007-09-26,0.0978,40.25,269,15-40 2007,1,Group,Tamarack,2007-07-26,0.238,6.11,207,15-40 2007,2,Group,Tamarack,2007-08-30,0.2187778,6.11,242,15-40 2007,3,Group,Tamarack,2007-09-26,0.2258889,6.11,269,15-40 2007,1,Control,Deanes,2007-07-24,0.185,79,205,15-40 2007,2,Control,Deanes,2007-08-28,0.178,79,240,15-40 2007,3,Control,Deanes,2007-09-24,0.1935556,79,267,15-40 2007,1,50% target,Deanes,2007-07-24,0.161,51.5,205,15-40 2007,2,50% target,Deanes,2007-08-28,0.1356667,51.5,240,15-40 2007,3,50% target,Deanes,2007-09-24,0.127,51.5,267,15-40 2007,1,30% target,Deanes,2007-07-24,0.207,52.75,205,15-40 2007,2,30% target,Deanes,2007-08-28,0.1745,52.75,240,15-40 2007,3,30% target,Deanes,2007-09-24,0.1926667,52.75,267,15-40 2007,1,Group,Deanes,2007-07-24,0.253,12.46,205,15-40 2007,2,Group,Deanes,2007-08-28,0.2568889,12.46,240,15-40 2007,3,Group,Deanes,2007-09-24,0.257,12.46,267,15-40 2007,1,Control,Pineleaf,2007-07-25,0.156,79.5,206,15-40 2007,2,Control,Pineleaf,2007-08-29,0.125125,79.5,241,15-40 2007,1,50% target,Pineleaf,2007-07-25,0.1175,62.63,206,15-40 2007,2,50% target,Pineleaf,2007-08-29,0.11525,62.63,241,15-40 2007,3,50% target,Pineleaf,2007-09-25,0.127375,62.63,268,15-40 2007,1,30% target,Pineleaf,2007-07-25,0.235,54.25,206,15-40 2007,2,30% target,Pineleaf,2007-08-29,0.19775,54.25,241,15-40 2007,1,Group,Pineleaf,2007-07
Re: [R] Lattice legend
Here is the code for my recent query: The first part just sets up the data. It's the last part titled individual depth graph where the actual graphics code comes in Thx --Seth library(lattice) setwd(c:/sethdocs/3 Light and PLAS txs/8 Figures/Fg 6 Soil wetness) d - read.table(2007 data.txt, header=TRUE, sep = ,) str(d) CC - rep(6:96,3) depth - rep(1:3, each=91) g - data.frame(depth, CC) ### 0 - 15 PRE parms model - function(a, b, f, CC){ t - a + exp(f-(b*CC)) return(t) } a = 0.08 b = 0.275 f = -1.18 g$t - ifelse(g$depth==1,round(model(a, b, f, g$CC),3),g$t==NA) # g$depth = rep(0-15,nrow(g)) ### 15 - 40 PRE parms ## a - 0.14 b - 0.0683 f - -1.9 g$t - ifelse(g$depth==2, round(model(a, b, f, g$CC),3),g$t) ### 40 - 70 PRE parms, graphs ## a - 0.291 b - -0.00094 } a - 0.25 g$t - ifelse(g$depth==3, a, g$t) s - split(g, depth) Individual depth graph ### sup.sym - Rows(trellis.par.get(superpose.symbol),1:4) sup.sym sup.sym$pch[1:4] - c(6,2,0,1) # show.settings() mypanel - function(..., alt.data){ panel.xyplot(...) with(alt.data[[which.packet()[1]]], # 'with' evaluates statement and includes with version of dataset in local workspace panel.xyplot(x = CC, y = t, type=l, col=black)) } graf - xyplot(t~CC|dep,d, groups=tx, alt.data=s, pch = sup.sym$pch, cex=1.5,# symbol size layout = c(3,1), xlab = list(Canopy cover (%), cex=1.7), ylab = list(expression(paste(soil moisture (m^{3},/m^{3},))), cex=1.2), scales=list(x = list(cex=1.3), y = list(cex=1.3)), strip = strip.custom(bg=transparent), panel = mypanel, key = list( text = c(heavy thin,light thin, control, group), columns=2, points=list(pch=sup.sym) ), aspect=xy) graf Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California Felix Andrews fe...@nfrac.org Sent by: foolish.andr...@gmail.com 06/22/2010 04:29 PM To Seth W Bigelow sbige...@fs.fed.us cc Subject Re: [R] Lattice legend Plase post your code (to the list). We can't help if we don't know what you are doing. Cheers -Felix On 23 June 2010 08:54, Seth W Bigelow sbige...@fs.fed.us wrote: I have a moderately complex graph with three panels. There are data points plotted, and fitted lines are added using a panel function, which includes with(alt.data[[which.packet()[1]]] statements. It all graphs out beautifully, but none of the usual tricks to get the proper legend to plot are working, i.e., using auto.key, key, etc. One message I keep getting is Error in key[[i]][[1]] - NULL : more elements supplied than there are to replace Any suggestions will be appreciated --Seth Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California __ R-help@r-project.org mailing list 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. -- Felix Andrews / 安福立 Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ year,survey,tx,bk,dayt,t,CC,doy,dep 2007,1,Control,Tamarack,2007-07-26,0.06356556,72,207,0-15 2007,2,Control,Tamarack,2007-08-30,0.03400111,72,242,0-15 2007,3,Control,Tamarack,2007-09-26,0.1054356,72,269,0-15 2007,1,50% target,Tamarack,2007-07-26,0.1115322,57,207,0-15 2007,2,50% target,Tamarack,2007-08-30,0.07165444,57,242,0-15 2007,3,50% target,Tamarack,2007-09-26,0.1154533,57,269,0-15 2007,1,30% target,Tamarack,2007-07-26,0.0654,40.25,207,0-15 2007,2,30% target,Tamarack,2007-08-30,0.03566778,40.25,242,0-15 2007,3,30% target,Tamarack,2007-09-26,0.0729,40.25,269,0-15 2007,1,Group,Tamarack,2007-07-26,0.147,6.11,207,0-15 2007,2,Group,Tamarack,2007-08-30,0.10344,6.11,242,0-15 2007,3,Group,Tamarack,2007-09-26,0.1612267,6.11,269,0-15 2007,1,Control,Deanes,2007-07-24,0.09867445,79,205,0-15 2007,2,Control,Deanes,2007-08-28,0.08022,79,240,0-15 2007,3,Control,Deanes,2007-09-24,0.1117922,79,267,0-15 2007,1,50% target,Deanes,2007-07-24,0.11711,51.5,205,0-15 2007,2,50% target,Deanes,2007-08-28,0.08067111,51.5,240,0-15 2007,3,50% target,Deanes,2007-09-24,0.1418667,51.5,267,0-15 2007,1,30% target,Deanes,2007-07-24,0.07089889,52.75,205,0-15
[R] [R-pkgs] New package RSQLite.extfuns and minor upgrade for RSQLite
RSQLite.extfuns provides SQLite extension functions for use with RSQLite. The package is a wrapper of extension functions written by Liam Healy and made available through the SQLite website (http://www.sqlite.org/contrib). You can make the extension functions available on a per db connection basis like this: library(RSQLite.extfuns) db - dbConnect(SQLite(), dbname = :memory:) init_extensions(db) The extension functions provided by the package include: Math: acos, asin, atan, atn2, atan2, acosh, asinh, atanh, difference, degrees, radians, cos, sin, tan, cot, cosh, sinh, tanh, coth, exp, log, log10, power, sign, sqrt, square, ceil, floor, pi. String: replicate, charindex, leftstr, rightstr, ltrim, rtrim, trim, replace, reverse, proper, padl, padr, padc, strfilter. Aggregate: stdev, variance, mode, median, lower_quartile, upper_quartile. RSQLite has been modified to provide the SQLite header files in the installed include directory so that RSQLite.extfuns (and other packages wishing to provide SQLite extension functions) can use LinkingTo. The default value of loadable.extensions is now TRUE. + seth -- Seth Falcon | @sfalcon | http://userprimary.net/ ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list 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.
Re: [R] RSQLite equivalent of .schema?
On 5/12/10 9:58 AM, Jonathan Greenberg wrote: Rhelpers: (Thanks for the previous help with getting a where statement working). Now on to my next question -- our database guru has asked me to run .schema on an sqlite database, and I was wondering if there is an equivalent in R to do this? Thanks! dbGetQuery(db, select * from sqlite_master where tbl_name = 'yourTable') -- Seth Falcon | @sfalcon | http://userprimary.net/ __ R-help@r-project.org mailing list 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.
Re: [R] dbSendQuery with R variables
On 5/11/10 5:01 AM, jim holtman wrote: ?paste On Mon, May 10, 2010 at 6:21 PM, Jonathan Greenberg greenb...@ucdavis.eduwrote: Rhelpers: I'd like to modify this RSQLite statement: rs_stations-dbSendQuery(con_stations, select * from stations) so that stations is actually an R variable, e.g.: stations=c(stationA,stationB) How would I modify the above statement to query from stations[[1]] (aka stationA)? In the end, I think paste is your only option. The latest version of RSQLite does support parameterized SELECT queries, but you cannot use the parameters to specify table names, only values. For details of what is supported, try reading through the examples in help(dbSendPreparedQuery) + seth -- Seth Falcon | @sfalcon | http://userprimary.net/ __ R-help@r-project.org mailing list 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.
[R] r matrix inconsistencies?
-- View this message in context: http://r.789695.n4.nabble.com/r-matrix-inconsistencies-tp2165121p2165121.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
[R] [R-pkgs] Release announcement: RSQLite 0.9-0 now with more BLOBs
RSQLite is an R package conforming to the R DBI interface that allows for interaction with SQLite. Version 0.9-0 highlights: * Support for SQLite BLOBs using raw vectors in R * New memory model for db connections allows for more familiar R semantics and no predefined limit to the number of connections you can have in an R session. * Upgrade to SQLite 3.6.23.1 * Removed an unnecessary validity check on process ID for the manager handle. This should make use of RSQLite with the multicore package easier. * RSQLite now depends on R = 2.10.0 You can read more details about these and other changes here: http://cran.r-project.org/web/packages/RSQLite/NEWS + seth -- Seth Falcon | @sfalcon | http://userprimary.net/ ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list 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.
Re: [R] Odp: better way to trick data frame structure?
Thanks, works beautifully and saved hours of run time. -seth -- View this message in context: http://r.789695.n4.nabble.com/better-way-to-trick-data-frame-structure-tp2130470p2130486.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] Two Questions on R (call by reference and pre-compilation)
As far as large data sets, I've just discovered readLines and writeLines functions. I'm using it now to read in single rows, calculate things on them, and then write a single row to a file. -- View this message in context: http://r.789695.n4.nabble.com/Two-Questions-on-R-call-by-reference-and-pre-compilation-tp2126314p2130631.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
[R] readLines with space-delimiter?
Hi, I am reading a large space-delimited text file into R (41 columns and many rows) and need to do run each row's values through another R object and then write to another text file. So, far using readLines and writeLines seems to be the best bet. I've gotten the data exchange working except each row is read in as one 'chunk', meaning the row has all values between two quotes (41 numbers). I need to split these based upon the spaces between them. What is the simplest means of doing this? Code so far. datin-file(C:\\rforest\\data\\aoidry_predictors_85.txt, open=rt) datout-file(C:\\rforest\\prob85.txt,open=wt) x-readLines(datin,n=1) writeLines(x,con=datout) Thanks, Seth -- View this message in context: http://r.789695.n4.nabble.com/readLines-with-space-delimiter-tp2130255p2130255.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] readLines with space-delimiter?
Thanks. I wasn't aware that scan or read.table allowed you to read in a single line, process it, output results, and then read in the next line. This is what I need to do because the data set is too large to hold in RAM. I did manage to do this with readLines and overcome the space-delimiter issue. -- View this message in context: http://r.789695.n4.nabble.com/readLines-with-space-delimiter-tp2130255p2130434.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
[R] better way to trick data frame structure?
Hi, I have a data frame where 1 variable is a factor with only 1 level. I need the data frame structure to reflect that there are 2 levels for this factor, even though this is not the case. I am currently adding extra 'fake' rows to the data frame to ensure that 2 levels are present, but this is slowing processing time in a loop quite a bit. Can I manually specify that this factor variable has two levels (even though this is lying to R)? Thanks,Seth -- View this message in context: http://r.789695.n4.nabble.com/better-way-to-trick-data-frame-structure-tp2130470p2130470.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
[R] how is xerror calculated in rpart?
Hi, I've searched online, in a few books, and in the archives, but haven't seen this. I believe that xerror is scaled to rel error on the first split. After fitting an rpart object, is it possible with a little math to determine the percentage of true classifications represented by a xerror value? -seth -- View this message in context: http://r.789695.n4.nabble.com/how-is-xerror-calculated-in-rpart-tp2076402p2076402.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
[R] gnls for negative autocorrelation?
Hi, I have data with negative spatial autocorrelation at short lags. It is well described by a spherical model, but flipped upside from what is normally seen. It seems that gnls will work with this correlated residual type IF one parameter in the spherical model can be negative (it is usually positive). Does anyone know if this parameter is constrained to be positive? -seth -- View this message in context: http://n4.nabble.com/gnls-for-negative-autocorrelation-tp1838023p1838023.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
[R] using varFunc in gnls to replicate Wedderburn-style variance?
Hi, I'm fitting a gnls on a response that varies from 0 to 1 using a basic logistic equation (1/(1+e^-bx)). I'm using gnls because this is spatial data with correlation in residuals well described by corSpher. Residual variance is compressed for fitted values near 0 and 1, and realtively constant in the 'middle'. Wedderburn suggested using (1-fitted value)*fitted value for nonlinear regression with data like mine (proportions), similar to what is expected for a binomial distribution. Is it possible to specify weight using varFunc so that the variance is a function of the fitted values? I've only seen examples for varFunc where covariates are used. Thanks, Seth -- View this message in context: http://n4.nabble.com/using-varFunc-in-gnls-to-replicate-Wedderburn-style-variance-tp1836537p1836537.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
[R] Re : Eliminate border in wireframe plot
Scott: This may work for you. Just include the statement par.settings - par.set1 in your wire graph statement par.set1 -list( axis.line=list(col=transparent), # Get rid of box around fig? clip=list(panel=FALSE), # disarm lurking panel settings? ) Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California sbige...@fs.fed.us / ph. 530 759 1718 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] Eliminate border in wireframe plot
Scott, I asked this same question a few years back, here's what Deepayan wrote. I think the last hint about scales will help you --Seth On 5/9/07, Seth W Bigelow sbige...@fs.f... wrote: I would like to remove the outermost box from my wireframe plots -- this is the box that is automatically generated, and is not the inner cube that frames the data. There was a thread on this 4 yrs ago but none of the fixes work (e.g., grid.newpage(), grid.lines(gp = gpar(col = NA)) or par.box=list(col=1),col=NA. These just make the data or the cube disappear. Has anyone solved this issue? Here's some sample code. In case you are wondering, I have indeed purchased Paul Murrel's book. But have you looked at example(wireframe)? The last example is what you want. You might also want to add scales = list(col = black) to the call. -Deepayan Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California sbige...@fs.fed.us / ph. 530 759 1718 Waichler, Scott R scott.waich...@pnl.gov 03/16/2010 05:12 PM To Seth W Bigelow sbige...@fs.fed.us cc Subject RE: R-help Digest, Vol 85, Issue 16 Seth, Thank for you for the suggestion. I found that the axis.line setting does get rid of the panel border, but unfortunately also the tick marks that go with the bounding box (but not the bounding box itself). The clip command doesn?t seem to do anything. Below is the code I?m using for testing. Scott Waichler # Test script for figuring out how to use contour3d and wireframe together. # # source(/projects/rifle/scripts/test_3d.r) library(lattice) library(misc3d) xlim - c(7, 18) ylim - c(0, 10) zlim - c(1613.22, 1619.52) z.ticks - rev(seq(gs, wasatch, by=-1)) z.tick.labels - gs - z.ticks pdf(file = ?test_3d.pdf, paper=special, width=7.5, height=6, pointsize=12) # Note about screen settings, which determine point of view: After each rotation, new axes are defined for # the next rotation as at the start: x is to the right of the 2D view, y is towards the top, and z # is positive out of the page towards you. Rotations follow the right-hand rule: positive angles follow # curved fingers of right hand, with thumb pointing in positive direction of associated axis. w - wireframe(matrix(zlim[1], 2, 2) ~ rep(xlim,2)*rep(ylim,each=2), xlim = xlim, ylim = ylim, zlim = zlim, aspect=c(diff(ylim) / diff(xlim), diff(zlim) / diff(xlim)), xlab = X (m), ylab = Y (m), zlab = Z (m), scales = list(arrows = FALSE, z=list(at = z.ticks, labels = z.tick.labels)), #zoom=1.05, panel.aspect=0.75, par.settings = list(#box.3d = list(col = transparent, alpha = 0), # remove the axes axis.line = list(col = transparent) # remove the panel border ), #screen=list(x=-90, y=-40), # looking from side screen=list(x=-100, y=-40, z=5), # looking from side and slightly up main=Testing with /projects/rifle/scripts/test_3d.r, panel.3d.wireframe = function(x, y, z, rot.mat, distance, xlim.scaled, ylim.scaled, zlim.scaled, ...) { scale - c(diff(xlim.scaled) / diff(xlim), diff(ylim.scaled) / diff(ylim), diff(zlim.scaled) / diff(zlim)) shift - c(mean(xlim.scaled) - mean(xlim) * scale[1], mean(ylim.scaled) - mean(ylim) * scale[2], mean(zlim.scaled) - mean(zlim) * scale[3]) if(!is.na((isoc[[nc]][[ic]][[j]])[1])) { P - rbind(cbind(diag(scale), shift), c(0, 0, 0, 1)) rot.mat - rot.mat %*% P #drawScene(isoc[[nc]][[ic]][[j]], R.mat = rot.mat, screen = NULL, # distance = distance, add = TRUE, scale = FALSE, # light = c(.5,0,1), engine = grid) } } ) print(w) dev.off() From: Seth W Bigelow [mailto:sbige...@fs.fed.us] Sent: Tuesday, March 16, 2010 2:12 PM To: Waichler, Scott R Cc: r-help@r-project.org Subject: Re: R-help Digest, Vol 85, Issue 16 Scott: This may work for you. Just include the statement par.settings - par.set1 in your wire graph statement par.set1 -list( axis.line=list(col=transparent), # Get rid of box around fig? clip=list(panel=FALSE),# disarm lurking panel settings? ) Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California sbige...@fs.fed.us / ph. 530 759 1718 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
[R] [R-pkgs] RSQLite 0.8-4 now on CRAN
A new version of RSQLite (0.8-4) is now available on CRAN. Highlights of this release: Version 0.8-4 - Fix a memory leak in bound parameter management and resolve a missing PROTECT bug that caused spurious crashes when performing many prepared queries. - There is now a fairly comprehensive example of using prepared queries in the man page for dbSendQuery-methods. - Upgrade to SQLite 3.6.21 = 3.6.22 (minor bug fixes). - Enable full-text search module by default. See http://www.sqlite.org/fts3.html for details on this SQLite module. - Add support for prepared queries that involve a SELECT. This was previously unsupported. SELECT queries can now be used with dbSendPreparedQuery. The return value is the same as rbind'ing the results of the individual queries. This means that parameters that return no results are ignored in the result. Full NEWS items available here: http://cran.r-project.org/web/packages/RSQLite/NEWS + seth -- Seth Falcon | @sfalcon | http://userprimary.net/ ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list 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.
Re: [R] conditioning variable in panel.xyplot?
Ah, wonderful, thank you for the code Deepayan. To recap for posterity: I have two datafiles, d and q: each has x-y coordinates that are conditioned by site (The actual data, for me, is maps of parent trees and their seedlings). I wanted to superimpose the xy plots of d and q, by site, without going to the trouble of merging the d q datasets into a single dataset. The solution is to use the which.packet statement is d - data.frame(site = c(rep(A,12), rep(B,12)), x=rnorm(24),y=rnorm(24))# Create the main xy dataset q - data.frame(site = c(rep(A,7), rep(B,7)), x=rnorm(14),y=rnorm(14))# Create the alternate xy dataset q.split - split(q, q$site) # Split up the alternate dataset by site mypanel - function(..., alt.data) { with(alt.data[[ which.packet()[1] ]], # which.packet passes index of the relevant data subset... panel.xyplot(x = x, y = y, col=red)) # ... to panel.xyplot() panel.xyplot(...) } xyplot(y ~ x | site, d, alt.data = q.split, # After providing the alternative dataset and the panel... panel = mypanel) # ...everything prints out properly, like magic! Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] conditioning variable in panel.xyplot?
I'm stumped after an hour or so reading about subscripts in panel.xyplot. Apparently the panel function is executed for each subset of data in the main dataset (specified by the conditioning variable, 'site' in my example), and the 'subscripts' keyword passes a vector of the corresponding row numbers to the panel function. But, if I want the panel function to simultaneously plot data from a different dataframe, as in the example below, I don't understand how having a vector of row numbers from a subset of the dataframe used in the main xyplot statement helps me with selecting data from an entirely different dataframe ('q' in my example). library(lattice) d - data.frame(site = c(rep(A,12), rep(B,12)), x=rnorm(24),y=rnorm(24)) q - data.frame(site = c(rep(A,7), rep(B,7)), x=rnorm(14),y=rnorm(14)) mypanel - function(...){ panel.xyplot(q$x, q$y, col=red) panel.xyplot(...)} xyplot(y ~ x | site, d, panel = mypanel ) --Seth On Thu, Mar 4, 2010 at 4:42 PM, Seth W Bigelow sbige...@fs.fed.us wrote: I wish to create a multipanel plot (map) from several datasets (d and q in the example below). I can condition the main xyplot statement on the site variable, but I don't know how to pass a conditioning variable to panel.xyplot plot so that the x-y coordinates from dataset q are only plotted at the appropriate site. The keyword is 'subscripts'. Look at the entry for 'panel' in ?xyplot, and let us know if you still have doubts. -Deepayan library(lattice) d - data.frame(site = c(rep(A,12), rep(B,12)), x=rnorm(24),y=rnorm(24))# Create dataframe d, with 12 x-y coordinates for each site q - data.frame(site = c(rep(A,7), rep(B,7)), x=rnorm(14),y=rnorm(14))# Create dataframe q, with 7 pairs of x-y coordinates for each site. mypanel - function(...){ panel.xyplot(q$x, q$y, col=red) # Statement that needs a Site conditioning variable panel.xyplot(...)} xyplot(y~x|site, d, panel=mypanel) # Statement erroneously plots all 14 x-y points in q on panels for sites A B Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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@r-project.org mailing list 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.
[R] conditioning variable in panel.xyplot?
I wish to create a multipanel plot (map) from several datasets (d and q in the example below). I can condition the main xyplot statement on the site variable, but I don't know how to pass a conditioning variable to panel.xyplot plot so that the x-y coordinates from dataset q are only plotted at the appropriate site. library(lattice) d - data.frame(site = c(rep(A,12), rep(B,12)), x=rnorm(24),y=rnorm(24))# Create dataframe d, with 12 x-y coordinates for each site q - data.frame(site = c(rep(A,7), rep(B,7)), x=rnorm(14),y=rnorm(14))# Create dataframe q, with 7 pairs of x-y coordinates for each site. mypanel - function(...){ panel.xyplot(q$x, q$y, col=red) # Statement that needs a Site conditioning variable panel.xyplot(...)} xyplot(y~x|site, d, panel=mypanel) # Statement erroneously plots all 14 x-y points in q on panels for sites A B Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
[R] Help with multtest (rawp2adjp)
Hello R experts, I am trying to analyze this dataset and am stuck on this problem for quite some time now. I am using mt.rawp2adjp. the output that came out was a matrix with two colums since I had asked it to calculate the adjusted p values using one method. so it has the two columns as: rawp BH I combined these using cbind with my actual dataframe. checked using head all was fine. thereafter I am trying to extract the rows where the values in BH are below a particular value(alpha say 0.05): by the command: partMult - subset(multData,BH 0.05) this gives a error saying that the operator is not valid for factors. Initally it seemed that the column BH is a factor, but typeof(BH) revealed that it is a integer variable. I also tried converting it into doube, and it did convert but then the values just changed: 0.0008 became 34 .0009 become say 28 and so on. It would be great to have your inputs on the issue. I am currently exploring the mt.reject function. thanks Sahil [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
[R] effective sample size in logistic regression w/spat autocorr
Hi, There's lit on how to adjust variance in the presence of positive spatial autocorrelation to properly inflate standard error estimates in linear regression by changing observed N to effective N. There is an R package to do this too. Is anyone aware of a way in R (or by hand) to do the same for logistic regression? I'm drawing a blank as SE estimation in logistic regression is not as straightforward of an affair. Thanks.-Seth Myers -- View this message in context: http://n4.nabble.com/effective-sample-size-in-logistic-regression-w-spat-autocorr-tp1563246p1563246.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
[R] Using getSYMBOL, annotate package on a list with empty elements.
Hi, I have been trying to find a solution to this issue, but have not been able to so ! I am trying to use sapply on the function getSYMBOL, an extract from the list is: test.goP[13:14] $`GO:050` IEA IEA IEA IEA TAS TAS TAS IEA 5270753 5720725 1690128 4850681 110433 2640544 4900370 1430280 IEA NAS TAS IEA 6110044 1170615 6590546 1690632 $`GO:052` [1] NA goG=sapply(test.goP,getSYMBOL,data=hgu95av2) error: Error in .checkKeysAreWellFormed(keys) : keys must be supplied in a character vector with no NAs In this the 14th element has missing values, thus getSYMBOL raises issues. GetSYMBOL has to be given a char array, so a simple solution is infact to delete the missing elements from the list. I have been trying to find a solution for it, but in vain: tried: completecases(goP), na.omit(goP) and several other things. Any suggestions please ? Thanks a lot ! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
[R] nlme w/no groups and spatially correlated residuals
Hi, I would like to specify a spherical correlation structure for spatially autocorrelated residuals in a model based upon the logistic function of a response that is a proportion (0 to 1) (so usual binary logistic regression is not an option). There is no need for a g-side random effect with grouping in this model. Am I correct that nlme requires this (meaning a correlated error structure only is not permissible)? I have tried to replicate the 'abuse' of the lme function I've seen for similar problems (specifying that all observations belong to one group), but this does not seem to work for nlme. Any legitimate work arounds? Thanks, Seth -- View this message in context: http://n4.nabble.com/nlme-w-no-groups-and-spatially-correlated-residuals-tp1477982p1477982.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] using setMethod or setGeneric to change S4 accessor symbol from @ to $
Hi Markus, On 2/9/10 4:12 PM, Markus Weisner wrote: Thanks so much for your help. I am realizing that I may be over-complicating things for myself. I have learned a ton about creating methods, but I feel like I am trying to reinvent the data.frame class. Basically, I am trying to create a data.frame type object where I can enforce the header names and column data types. I am trying to force the user to setup the following fields: - event_number (character) - agency (factor) - unit_num (factor) - alarm (POSIXct) - priority (factor) A user might use the following code: event_number = c(1:5) agency = c(CFD, rep(ACFR, 3), CFD) unit_num = c(E1, T10, E3, E2, BC1) temp = c(00:52:35, 06:58:18, 13:42:18, 20:59:45, 21:19:00) alarm = as.POSIXct(strptime(temp, format=%H:%M:%S)) priority = c(A, E, A, C, C) data = data.frame(event_number=event_number, agency=agency, unit_number=unit_num, alarm=alarm, priority=priority) I have all sorts of functions that I am trying to incorporate into a package for analyzing fire department data, but keep having problems with small deviations in data format causing errors. In this example, the following might cause issues in my functions: - event_number should be of type character - agency, unit_number, and priority, should be of type factor - unit_number should actually have name unit_num Perhaps you could simply provide a helper function for creating plain data.frames that does this validity checking? You could also provide a validate function that takes a data.frame and either says OK or describes the ways in which the input does not conform. I think the benefits you would get out of a complete S4 wrapping of data.frame do not outweigh the complexity introduced. + seth -- Seth Falcon | @sfalcon | http://userprimary.net/user __ R-help@r-project.org mailing list 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.
Re: [R] shared object location
Hi, On 1/29/10 12:58 PM, Murat Tasan wrote: problem is, i haven't been able to do this yet. my workaround is to constantly swap into myRPackage/libs/ directory a version of the shared object library called myRPackage.so, and load it via the useDynLib(...) directive in the NAMESPACE file of the package. but this is cumbersome and doesn't allow other people to have a single version of the R package to use as part of a team effort to debug/test both the package's R code and my C code for the library functions. hopefully this makes a bit more sense, and if anyone has any tips on how R actually loads shared objects it would be greatly appreciated. I'm afraid I don't have a solution for you. Reading through your post, I'm confused about why you want to have your .so file outside of the package? Why not follow the usual scheme and R CMD INSTALL yourPkg with the version of R code and C code you want to use/test. This would best allow other people to have a single version of the R package, no? + seth -- Seth Falcon | @sfalcon | http://userprimary.net/user __ R-help@r-project.org mailing list 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.
Re: [R] [Fwd: Re: question on sqldf syntax]
On 1/26/10 2:11 AM, Christian Schulz wrote: Sorry mistake from me. This was another problem in my mind , but with RMySQL. Christian library(RMySQL) library(sqldf) sqldf(Select * from mtcars) Fehler in mysqlNewConnection(drv, ...) : RS-DBI driver: (Failed to connect to database: Error: Access denied for user 'user'@'localhost' (using password: NO) ) Fehler in if (dbname == :memory:) dbDisconnect(connection) else if (!dbPreExists : Argument hat Länge 0 detach(package:RMySQL) sqldf(Select * from mtcars) That sqldf only works if RMySQL is not attached seems like something worth investigating and fixing. It should be possible to avoid such conflicts by proper use of name spaces, but I have not looked into the details of what's going on. + seth -- Seth Falcon | @sfalcon | http://userprimary.net/user __ R-help@r-project.org mailing list 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.
[R] finding values for arguments?
Hi, Is there a code that will return the appropriate values/structure for arguments within a function? I seem to remember a code that will return detailed info about a function within the R console, but now can't find it anywhere. Thanks. Seth -- View this message in context: http://n4.nabble.com/finding-values-for-arguments-tp1288978p1288978.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] finding values for arguments?
Thanks! So frustrating to self-teach a new language sometimes! Seth -- View this message in context: http://n4.nabble.com/finding-values-for-arguments-tp1288978p1288988.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
[R] tree()...binary reponse giving only one split
Hi, I'm new to CART. I have a data set with a binary reponse (0/1) and several predictors. I chose 2 continuous predictors to start and used the following code. testdata.ltr-tree(nondev85dev06~dist_rampm_wa + dis_prim_wa,testdata) The two predictors should be quite explanatory based upon previous work. After running this code, I am getting only one split using the first predictor listed. I've tried this with other sets of 2 and 3 predictors and it is always the same case, only one is used for a single split. I thought perhaps it was the binary nature of my data set. So, I constructed another where the response was 0,1, or 2. I got the same result. I've also tried the same experiment with predictors that are binary and got the same results. I've searched the help but can't find any answers. Thanks. Seth -- View this message in context: http://n4.nabble.com/tree-binary-reponse-giving-only-one-split-tp1288546p1288546.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
[R] (nlme, lme, glmmML, or glmmPQL)mixed effect models with large spatial data sets
Hi, I have a spatial data set with many observations (~50,000) and would like to keep as much data as possible. There is spatial dependence, so I am attempting a mixed model in R with a spherical variogram defining the correlation as a function of distance between points. I have tried nlme, lme, glmmML, and glmmPQL. In all case the matrix needed (seems to be (N^2)/2 - N) is too large for my machine to handle even when maxed (memory.limit and virtual memory in vista). Past the range of my variogram (which I have a good estimate of), the matrix that R is trying to allocate will have 0 values (I believe). Therefore, it seems wasteful to allocate the full matrix. Is there a way to 'trim' it so that the matrix size (and hopefully processing wait time) is decreased? Further, it seems the matrix is now being filled with double precision data. Is there a way to lessen precision and so save memory? If I do find a way (probably will be forced to decrease N), for a logistic regression, which of the functions I mentioned is likely to execute more quickly with usual settings/output? I'm asking for a rough idea in advance because of processing time limits. I believe glmmPQL will likely be slower due to the multiple calls to lme. Thanks for any advice/insight. -seth -- View this message in context: http://n4.nabble.com/nlme-lme-glmmML-or-glmmPQL-mixed-effect-models-with-large-spatial-data-sets-tp1217808p1217808.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] (nlme, lme, glmmML, or glmmPQL)mixed effect models with large spatial data sets
Update on above. I sampled my data to create a 10,000 observation data set. I then tried lme with a correlation = corSpher and only one predictor, as a test. I set my memory.limit to the max allowable. It ran for a while then returned Error: cannot allocate vector of size 64.0 Mb. I can see how 50K obs busted it. But 64 Mb? Perhaps there is another limit set by the lme function? -seth -- View this message in context: http://n4.nabble.com/nlme-lme-glmmML-or-glmmPQL-mixed-effect-models-with-large-spatial-data-sets-tp1217808p1236563.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] Help deciphering segfault in make check
Hi, On 1/19/10 12:05 PM, Karl-Dieter Crisman wrote: I work with the Sage project, and we are trying to improve the ability to use R through Sage. Most things work, but make check seems to cause problems on certain platforms, and now that we want to upgrade to 2.10.1 I thought we should ask for help! This discussion might be more appropriate for R-devel. I'm not all that familiar with the Sage project and it isn't clear to me whether what you are seeing is in any way Sage-specific. If you are getting this segfault from a basic configure/make/make check sequence and you can reproduce the crash, then further debugging steps will likely be of interest. R builds just fine on both Mac and Linux, but some things in make check seem to break on certain Linux boxes that don't on Mac or other machines. Here is an example from (Red Hat?) in doing the basic tests, in src/tests/Examples/, where base-Ex.R seems to have a problem, at the end of base-Ex.Rout.fail: ### Name: groupGeneric ### Title: S3 Group Generic Functions ### Aliases: S3groupGeneric .Group Math Math.data.frame Ops Ops.data.frame ### Summary Summary.data.frame Complex 'group generic' ### Keywords: methods ### ** Examples require(utils) d.fr- data.frame(x=1:9, y=stats::rnorm(9)) class(1 + d.fr) == data.frame ##-- add to d.f. ... [1] TRUE methods(Math) *** caught segfault *** address 0x4b8, cause 'memory not mapped' You might be able to reproduce this and get some more information like this: R -d gdb run source(src/tests/Examples/base-Ex.R) Assuming you get a crash, type bt in the gdb console and send output. + seth -- Seth Falcon | @sfalcon | http://userprimary.net/user __ R-help@r-project.org mailing list 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.
Re: [R] R package dependencies
On 1/13/10 11:21 AM, James W. MacDonald wrote: Hi Colin, The pkgDepTools package from Bioconductor will help with question #1: http://bioconductor.org/packages/2.5/bioc/html/pkgDepTools.html I am not positive on this, but I believe this package is also used to determine the reverse dependencies that would be listed on that page if there were any for this package. An example with reverse dependencies is e.g., the IRanges package: http://bioconductor.org/packages/2.5/bioc/html/IRanges.html The maintainer (Seth Falcon) would know for sure if the package will do reverse dependencies as well. There is an example in the vignette for pkgDepTools that shows how to get reverse dependencies: The edge directions of the dependency graph can be reversed and the resulting graph used to determine the set of packages that make use of (even indirectly) a given package. For example, one might like to know which packages make use of the methods package. Here is one way to do that: example follows in the vignette + seth -- Seth Falcon | @sfalcon | http://userprimary.net/user __ R-help@r-project.org mailing list 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.
Re: [R] Directory operations
On 1/10/10 5:46 AM, anupam sinha wrote: Hi Uwe, Thanks for your suggestion . Here's my code. I am confused as to how to initialize an empty list . Here I have used pairlist() *list.files()-org_xml_dirs ## the following is much preferred: org_xml_dirs - list.files() for (i in org_xml_dirs) { setwd(file.path(/home/anupam/Research/Anupam_data/ORG_XML_FILES/,i)) org_xml-list.files() for(j in org_xml) { graph_list-pairlist() graph_list - list() ## in general, avoid pairlist graph-parseKGML2Graph(j,genesOnly=TRUE) graph_list-c(graph_list,list(graph)) } org_met_net-mergeKEGGgraphs(graph_list) met_org-igraph.from.graphNEL(org_met_net,name=TRUE) write.graph(met_org,/home/anupam/Research/Anupam_data/ORG_XML_FILES/i.metnet,format=c(NCOL)) } * This is giving an error: Error in UseMethod(xmlAttrs, node) : no applicable method for xmlAttrs I apologise for asking a Bioconductor list related question on this list. Can you figure out the problem ? Thanks in advance. Without output of sessionInfo() it is hard to diagnose further, but this looks like a bug that has been resolved in latest version of the XML package. Please make sure you are using the latest R release and latest Bioconductor and CRAN packages. + seth -- Seth Falcon Bioconductor Core Team | FHCRC __ R-help@r-project.org mailing list 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.
[R] weight by obs # in spatial 'nest' in NLME?
Hi, I am constructing a series of nonlinear mixed regression models at multiple spatial scales on the same data. The data is a regular grid of cells. A coarser scale is achieved, for example, by aggregating cells in blocks that are 2x2 cells in dimension and averaging dependent and independent data over this block. Some 2x2 blocks will be missing data for several expected reasons and these blocks are of interest and so cannot be easily discarded (they are also likely not at random). I would like to take this into account when fitting the model. A simple weighting of each block by number of complete component observations (e.g. no missing data would have a weight of 2x2=4) seems intuitive. I've reviewed the NLME documentation and weighting schemes seem to be the usual variety of accounting for unequal variance. Is there a work around to specify the integer weights I described above? I've toyed with a work around where I duplicate each block observation by the number of observations summarized within it. Of course, this is difficult to do correctly as the sample size will be inflated and most statistics not easily interpretable. Any advice on how to proceed is welcome. Thanks. -seth -- View this message in context: http://n4.nabble.com/weight-by-obs-in-spatial-nest-in-NLME-tp1009168p1009168.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] The RSQLite version of dbGetQuery drops colums
Hi Magnus, Magnus Torfason zulutime.net at gmail.com writes: I just noticed (the hard way of course) that when a query returns 0 rows, the columns in the resulting data.frame get dropped as well. See the following example code (where conn is an active connection to an SQLite db): dbGetQuery(conn, select 1 as hey, 2 as ho where 1) hey ho 1 1 2 dbGetQuery(conn, select 1 as hey, 2 as ho where 0) data frame with 0 columns and 0 rows I believe that the second query should return a 0x2 data.frame instead, that is, the same value as: I agree that keeping the column dimension is sensible. I will see about fixing that for the next release. Any thoughts? Is this a bug, and are the developers of RSQLite reading this? A much better forum for RSQLite issues is the r-sig-db list. + seth __ R-help@r-project.org mailing list 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.
[R] subsetting by groups, with conditions
I have a data set similar to this: P1idVeg1Veg2AreaPoly2 P2ID 1 p p 1 1 1 p p 1.5 2 2 p p 2 3 2 p h 3.5 4 For each group of Poly1id records, I wish to output (subset) the record which has largest AreaPoly2 value, but only if Veg1=Veg2. For this example, the desired dataset would be P1idVeg1Veg2AreaPoly2 P2ID 1 p p 1.5 2 2 p p 2 3 Can anyone point me in the right direction on this? Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
[R] nonlinear (especially logistic) regression accounting for spatially correlated errors
Hello, Sorry to be a bit longwinded, but I've struggled quite a bit with the following over the last few days. I've read all entries related to spatial autocorrelation in R help and haven't found what I'm after. If it's okay, I'm going to first describe my general understanding of the process by which a mixed model can account for correlated errors. If possible, please briefly point out any misunderstanding I have to help my work overall (the literature I've found on this area does not go into extensive explanation). I'm aware that mixed models are currently in use to fit fixed effects while controlling for correlation among residuals. I believe this is often done by specifying a theoretical variogram that one believes describes the spatial structure of the error correlation and which is then used to modify the variance-covariance error matrix that is used in model fitting (which I think in this case would be block diagonal with distance input into chosen variogram model determining matrix element value). So, as the fixed effects are adjusted algorithmically to maximize likelihood, simultaneously the parameters of the theoretical variogram (which enter as a random effect) are similarly adjusted which in turn influences the variance-covariance error matrix. The combined goal of these two parallel adjustments (I believe) would be to maximize overall model likelihood. I have been looking for an example of R code that uses a nonlinear mixed model in this way. I've only found this so far. http://www.ats.ucla.edu/stat/r/faq/spatial_regression.htm It seems that in the example given in this link, the incorporated correlation structure is not specifically on the error term but instead on the reponse itself. Therefore, it seems that the effect of the explanatory variable is diluted by this approach. For instance, if you had a 'true' model where temperature was only a function of elevation but elevation was strongly autocorrelated, the approach in the link would likely leave elevation as a nonsignificant part of the model. Versus, if the correlation structure was assigned to model error this would not happen. Is this true or am I speaking of 6 of one and half dozen of the other (that in practice it makes no difference to results)? If the above example is not an example of modeling the correlation among model errors, is there a good example of R code somewhere that does this that I can reference? Thanks, Seth Myers PS I plan to read all the excellent books suggested in other threads, but ask this now to help me digest this material more quickly. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
[R] Help with printing fixed width
Hello R users, I am writing a summary() for a custom class, and am to display the integers right justified, Say where x is the vector with integers, I am using the following: cat(\t,format(x),\t...other columns) this way I am trying to pass the format(x), to the cat function to display it, but still I am getting a kink(b/w the 9th and 10th row). 6 81 170 251 1.998026e-08 7 26 93 119 4.937587e-10 8 96 209 305 8.750939e-11 9 94 211 305 1.758285e-11 10 88 205 293 6.47853e-12 11 82 244 326 7.943691e-20 12 57 145 202 4.964509e-10 Thanks, -- Regards, Sahil Seth JHSPH [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
[R] xyplot: Can I identify groups but not use them for regression?
I wish to identify groups representing different treatments, but to plot them and do a regression using a continuous variable (cover) ignoring the groupings. d$year - NA d$year -c(rep(2007,12), rep(2008,12)) d$treatment - c(rep(A,4),rep(B,4),rep(C,4), rep(A,4), rep(B,4), rep(C,4)) d$cover - rnorm(24) d$variable - rnorm(24) xyplot(variable ~ cover | year, d, type=c(p,r), groups=treatment ) As it stands, a different regression line is plotted for each treatment. Oh, and how do I display the actual numeric value of year (e.g., 2007) in the strip, rather than the word year? --Seth Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
[R] [R-pkgs] New version of RSQLite on CRAN
Hi, RSQLite 0.7-2 is available on CRAN. Version 0.7-2 - Fixed some partial argument matching warnings. Thanks to Matthias Burger for reporting and sending a patch. - Added dbBuildTableDefinition to exports per user request. + seth ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list 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.
[R] .First and loading a package in a workspace
Hi, I'm writing a package called rNMR and I'd like to be able to save a workspace with rNMR loaded, exit R, and then load the workspace, loading rNMR at the same time. This is no problem on Windows but on Linux and Macs I can't get it to work. Here's the deal. rNMR has includes a .onLoad function: .onLoad = function(lib,pkg){ print(rNMR version 1.0) } and also calls a different function which writes a .First to the global environment: .First - function(){ require(rNMR) } Actually these have been simplified from there original versions in order to easier diagnose the problem. I've tested both versions and neither work. I open R and load rNMR. I know .onLoad runs because I see [1] rNMR version 1.0 in R. Then I create the .First function as above (normally this is done internally by rNMR, but I'm doing this manually here to ensure it gets done correctly). Just to make sure I check that .First is in the right place: getAnywhere(.First) 2 differing objects matching ‘.First’ were found in the following places .GlobalEnv namespace:rNMR Use [] to view one of them .First function(){ require(rNMR) } Both versions of .First are identical. So, you'd expect that if I saved this workspace and exited, when I reopen R and load the workspace, .First should run, loading the rNMR package, and calling .onLoad. Here's what I get when I load the workspace: load(/home/undergrad/Desktop/test.RData) [1] rNMR version 1.0 but if I check for rNMR: search() [1] .GlobalEnvpackage:stats package:graphics [4] package:grDevices package:utils package:datasets [7] package:methods Autoloads package:base it's clearly not attached. I can't access any rNMR functions without loading rNMR again. .First still exists in the workspace, but somehow rNMR hasn't loaded. If this is the case, why is .onLoad running (indicated by the printed rNMR version info)? Odder still, the original version of .First was designed to open a tk toplevel containing rNMR menus, which it does. Commands from these menus work but commands typed in the console don't and everything else seems to indicate that rNMR is not attached. Any thoughts? Thanks in advance, Seth -- View this message in context: http://www.nabble.com/.First-and-loading-a-package-in-a-workspace-tp23431418p23431418.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
[R] illegal levels in yaImpute() / AsciiGridImpute()
I'm using randomForest in yaImpute to create a yai-type object which associates L with landscape features. Then I use the sp() package to impute L to a landscape consisting of four ascii files) I keep getting the message NA's generated due to illegal level(s) when I do the imputation. It's probably because one of the landscape features (as, for aspect/slope) is stored in numeric form but is treated as a factor when the yai object is created. as is also stored in numeric form in the ascii grids, of course. I included an xtypes argument in the AsciiGridImpute statement, but that did not help. Some relevant statements are: xfiles - list(DEM_10 = dem_10.asc, EASTING = easting.asc, NORTHING = northing.asc, as = asp_slop.asc) AsciiGridImpute(yai_ob, xfiles, outfiles, xtypes=list(numeric, numeric, integer, character)) Any insights will be appreciated. I'd particularly like to know how to gain access to the invisible list, VALUE, containing unexpectedNA's, illegal levels, and other information that would help me to troubleshoot the issue. Dr. Seth W. Bigelow Biologist, USDA-FS Sierra Nevada Research Center 1731 Research Park Drive, Davis California [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
[R] Confidence interval?
hi folks, I need help fitting/plotting a confidence interval to a frequency distribution Can someone help with this? thanks, tsd -Original Message- Date: Mon Apr 06 15:08:20 MST 2009 From: r-help-requ...@r-project.org Subject: Welcome to the R-help mailing list To: t...@nau.edu Welcome to the R-help@r-project.org mailing list! To post to this list, send your email to: r-help@r-project.org General information about the mailing list is at: https://stat.ethz.ch/mailman/listinfo/r-help If you ever want to unsubscribe or change your options (eg, switch to or from digest mode, change your password, etc.), visit your subscription page at: https://stat.ethz.ch/mailman/options/r-help/tsd3%40nau.edu You can also make such adjustments via email by sending a message to: r-help-requ...@r-project.org with the word `help' in the subject or body (don't include the quotes), and you will get back a message with instructions. You must know your password to change your options (including changing the password, itself) or to unsubscribe. It is: davis234 Normally, Mailman will remind you of your r-project.org mailing list passwords once every month, although you can disable this if you prefer. This reminder will also include instructions on how to unsubscribe or change your account options. There is also a button on your options page that will email your current password to you. __ R-help@r-project.org mailing list 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.