Re: [R] Automatically naming subsets in a for loop

2014-01-31 Thread denys
Thank you very much ! -- View this message in context: http://r.789695.n4.nabble.com/Automatically-naming-subsets-in-a-for-loop-tp4684518p4684524.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https

[R] Problem connecting to database via RPostgreSQL/RS-DBI: "could not connect" error

2014-01-31 Thread andrewH
In the description section of the RPostgreSQL package documentation, it states: "In order to build and install this package from source, PostgreSQL itself must be present your system to provide PostgreSQL functionality via its libraries and header files. . . . On Microsoft Windows system the atta

Re: [R] Controlling visibility of top-level functions

2014-01-31 Thread Duncan Murdoch
On 14-01-31 5:09 PM, Rolf Turner wrote: On 01/02/14 08:13, Duncan Murdoch wrote: On 31/01/2014 1:46 PM, Paul A. Steckler wrote: I'm fairly new to R, and have checked the R FAQ and done an RSiteSearch for help on this topic, to no avail. I want to write some R code that has functions at the top

Re: [R] Controlling font size on code chunk outputs using Knitr

2014-01-31 Thread Jeff Johnson
Yihui/Jeff, I'm trying to determine where the default CSS file is located as I don't see this in any of the documentation. I can definitely find a markdwon.css file in C:\Program Files\RStudio\resources I also see an R.css file in that directory. I also have R.css in C:\Users\jeffjohn\Dropbox\R

Re: [R] Controlling visibility of top-level functions

2014-01-31 Thread Bert Gunter
I think you will find that using namespaces and export directives are a better way of controlling visibility with packages. That is their intended purpose. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And know

Re: [R] sapply returning list instead of matrix

2014-01-31 Thread Jeff Newmiller
Pot, meet kettle. You claim to be able to read documentation, yet you don't reference knowledge gained or clarity lost from such activity in your question. I think this is a case of inertia of history that we all have to live with at this point. If you thoroughly read the documentation for ?sapp

Re: [R] sapply returning list instead of matrix

2014-01-31 Thread William Dunlap
> I can read the documentation, I see why it happens, but who in their right > mind would design a function this way? Can you imagine how many bugs are > lurking because people haven't yet hit the right set of input that is going > to cause sapply() to return a list instead of a matrix(). If you

Re: [R] Controlling visibility of top-level functions

2014-01-31 Thread Paul A. Steckler
Thanks for the suggestions. I'm going to need to create an R package, eventually, so I'll use that mechanism to control visibility. -- Paul On Fri, Jan 31, 2014 at 11:13 AM, Duncan Murdoch wrote: > On 31/01/2014 1:46 PM, Paul A. Steckler wrote: >> >> I'm fairly new to R, and have checked the R

Re: [R] sapply returning list instead of matrix

2014-01-31 Thread chris warth
Hey thanks for the helpful snark, Bert. To everyone else, I apologize for neglecting to actually include the examples. a <- function(i) { list(1) } b <- function(i) { list(1,2) } ll <- sapply(seq(3), a, simplfy="list") mm <- sapply(seq(3), b) class(ll) class(mm) > class(ll) [1] "list" > class(mm)

Re: [R] Controlling visibility of top-level functions

2014-01-31 Thread Rolf Turner
On 01/02/14 08:13, Duncan Murdoch wrote: On 31/01/2014 1:46 PM, Paul A. Steckler wrote: I'm fairly new to R, and have checked the R FAQ and done an RSiteSearch for help on this topic, to no avail. I want to write some R code that has functions at the top-level that are not visible when the code

Re: [R] sapply returning list instead of matrix

2014-01-31 Thread Bert Gunter
As you ignored the posting guide and posted in HTML, your "below" didn't get through. So one can only guess that it has something to do with (see ?sapply) "Simplification in sapply is only attempted if X has length greater than zero and if the return values from all elements of X are all of the sa

[R] sapply returning list instead of matrix

2014-01-31 Thread chris warth
Can anyone suggest a rationale for why sapply() returns different types (list and matrix) in the two examples below? Is there any way to get sapply() or any other apply() function to return a matrix in both cases? simplify=TRUE doesn't change the outcome. I understand why it is happening, I just

Re: [R] Automatically naming subsets in a for loop

2014-01-31 Thread jim holtman
Here is one way by just truncating your data to integers based on what you are doing: > # create some test data > n <- 1000 > G <- data.frame(Lat = runif(n, 38, 50), Long = runif(n, -72, -65)) > # add a 'key' for segment - based on truncating data > G$key <- paste(as.integer(G$Lat), as.integer(G$L

Re: [R] Automatically naming subsets in a for loop

2014-01-31 Thread Jeff Newmiller
The standard way to do this is to use the cut function to define group categories, and then manipulate data in lists of subsets using lapply function and relatives. There are also tools such as the plyr package, data.table package, sqldf package, and the new dplyr package. If you want more expl

[R] Automatically naming subsets in a for loop

2014-01-31 Thread denys
Hello, I'm trying to subet my data based on long/lat. I have written a for loop however I am not sure how to get R to name all my subsets different things. Here is my code so far... for(i in 0:31){ latl=38+(i*1) latu=39+(i*1) for(j in 0:33){ longl=(-72)+(j*1) longu=(-71)+(j*1) G$i$j<-subset(G, La

Re: [R] plotting points over a map using R

2014-01-31 Thread Barry Rowlingson
Try reading the R Spatial Task View: http://cran.r-project.org/web/views/Spatial.html or this brilliant intro, and other files in that github repository: https://github.com/Robinlovelace/Creating-maps-in-R/blob/master/intro-spatial.md or any of the tutorials I've written on the subject! Barry

Re: [R] plotting points over a map using R

2014-01-31 Thread Jim Lemon
On 01/31/2014 08:58 PM, 李德磊 wrote: > Hello everyone, > I have no idea how to plotting points over a map using R, in which the colors > of the points stand for the points' value. I'd like to get a map as shown in > attachment picture which was plotted using matlab. Does anyone know how to do > it

Re: [R] Defining function help

2014-01-31 Thread arun
Hi, Not sure if this is what you wanted: t.control=function(m, a){(1-exp(-a*m)*((1-(1/30))*m))}   t.sham=function(m, a, d){(1-exp(-a*(1-d)*m)*((1-(1/30))*m))} t.control(2,2) #[1] 0.9645898 t.sham(2,2,0.1) #[1] 0.9471741 A.K. On Friday, January 31, 2014 12:29 PM, Mathew Nagendran wrote: Hello

Re: [R] Controlling visibility of top-level functions

2014-01-31 Thread Duncan Murdoch
On 31/01/2014 1:46 PM, Paul A. Steckler wrote: I'm fairly new to R, and have checked the R FAQ and done an RSiteSearch for help on this topic, to no avail. I want to write some R code that has functions at the top-level that are not visible when the code is loaded. So in fun1 <- function(...

Re: [R] Defining function help

2014-01-31 Thread Duncan Murdoch
On 31/01/2014 12:29 PM, Mathew Nagendran wrote: Hello everyone. I am quite new to R and I would appreciate some help in figuring out what I am doing wrong. For the following code: > #with cost > > m.control=c(1.45,9.40,9.96,4.2,1.86,0.2) > m.sham=c(3.39,23.94,23.62,10.08,2.99,1.09) > > t.contr

[R] Problem relocating the R installation tree

2014-01-31 Thread Zhang,Jun
After moving the R installation tree, I modified the "R" script with a new RHOME value, and it worked. There seems a hard coded RHOME in Rscript, which is a binary file. Is there a way to regenerate the Rscript file for the new location, without re-installing the whole thing? Jun [[alt

[R] Problem relocating the R installation tree

2014-01-31 Thread Zhang,Jun
After moving the R installation tree, I modified the "R" script with a new RHOME value, and it worked. There seems a hard coded RHOME in Rscript, which is a binary file. Is there a way to regenerate the Rscript file for the new location, without re-installing the whole thing? Jun [[alt

[R] Generalized Ordered Logit in R

2014-01-31 Thread B. Longhurst
Dear community, I am replicating a paper (The Effect of Structures and Power on State Bargaining Strategies, http://tinyurl.com/oyk289c) for a class project. The author used “gologit” in STATA, and I need the equivalent function in R. She used a “Generalized Ordered Logit” (see below model de

[R] Defining function help

2014-01-31 Thread Mathew Nagendran
Hello everyone. I am quite new to R and I would appreciate some help in figuring out what I am doing wrong. For the following code: > #with cost > > m.control=c(1.45,9.40,9.96,4.2,1.86,0.2) > m.sham=c(3.39,23.94,23.62,10.08,2.99,1.09) > > t.control=function(m, a){(1-exp(-a*m)*(1-(1/30)*m))} > t.

[R] Fw: 2 phase coxian phase distribution

2014-01-31 Thread nelson Sibanda
On Saturday, January 18, 2014 9:20 PM, nelsonsibbs78 wrote:   Can you pliz  send me the R code for estimating parameters of a 2 phase distribution given some data to fit. Im nelson sibanda , a final year student at Nust [[alternative HTML version deleted]] ___

[R] Controlling visibility of top-level functions

2014-01-31 Thread Paul A. Steckler
I'm fairly new to R, and have checked the R FAQ and done an RSiteSearch for help on this topic, to no avail. I want to write some R code that has functions at the top-level that are not visible when the code is loaded. So in fun1 <- function(...) { ... } fun2 <- function(...) { ... fun1 ..

Re: [R] plotting points over a map using R

2014-01-31 Thread Ista Zahn
The ggmap package (http://journal.r-project.org/archive/2013-1/kahle-wickham.pdf) is also quite good. Best, Ista On Fri, Jan 31, 2014 at 6:23 AM, Mohammed Ouassou wrote: > library(RgoogleMaps); # download a static map from the Google server > library(geomapdata);# Topographic and Geologic

Re: [R] Fit Negbin glm model with autoregressive correlation structure

2014-01-31 Thread Cristiano Varin
You may also introduce ARMA errors in negative binomial regression via Gaussian copulas. The following webpage illustrates how to use the package gcmr ("Gaussian Copula Marginal Regression") for fitting negative binomial regression model with ARMA(2,1) errors: http://cristianovarin.weebly.com/

Re: [R] package mgcv - predict with bam: Error in X[ind, ] : subscript out of bounds

2014-01-31 Thread Simon Wood
Hi Katharina, Could you try upgrading to mgcv_1.7-28, please? There was an occasional problem to do with matching factor levels, which is fixed, but I'm not very confident that is what is going on. If upgrading doesn't work, is there any chance you could send me a small example dataset and c

[R] use of "effects coding" in instrumental variables estimation

2014-01-31 Thread Franckx Laurent
Dear all, I am estimating a model with instrumental variables using ivreg() (from the "AER" library). When the regressors and the instruments are limited to continuous variables, things work fine. However, I have some regressors, such as "income", for which I only have categorical data (very l

Re: [R] plotting points over a map using R

2014-01-31 Thread Mohammed Ouassou
library(RgoogleMaps); # download a static map from the Google server library(geomapdata);# Topographic and Geologic Mapping lbrary(PBSmapping); # Draw Maps and Implement Other GIS Procedures STEP1: my_map = GetMap(center=my_center, zoom =my_zoom , destfile=my_out_file ,ma

Re: [R] Error Help "only 0's may be mixed with negative subscripts"

2014-01-31 Thread Kehl Dániel
Dear Agapitus, we do not know what your variables look like but I assume ((zlim[2] - z_invDist)/zlen) * 7 produces a vector with both positive and negative numbert and you are using these numbers to extract elements of an other vector. If the numbers were all positive or negative, it would

[R] Error Help "only 0's may be mixed with negative subscripts"

2014-01-31 Thread Agapitus Kato
Help Please. Iam drawing a plot i R_Studio but consistently get this error: Error in colorlut2[((zlim[2] - z_invDist)/zlen) * 7] : only 0's may be mixed with negative subscripts-- *"Whenever you are confronted with an opponent. Conquer him with love." Mahatma Gadhi* [[alternative HTML

[R] truncated cone / frustum in R rgl

2014-01-31 Thread Omphalodes Verna
Dear list! Here is a simplified script for cone in RGL (from rgl demos). I would like to draw a truncated cone / frustum using RGL in R. Do you have any suggestion how to modify code? Thanks a lot, OV library(rgl) cone3d <- function(base=c(0,0,0), tip=c(0,0,1), rad=1, n=30) {     trans <- d

[R] Fit Negbin glm model with autoregressive correlation structure

2014-01-31 Thread flavie.vial
Hello, I am attempting to estimate the effect of various variables on the time-series of counts of reported cattle stillbirths. We investigate the effect of day-of-week, month, holidays etc...and also the effect of non-temporal variables. We performed model comparisons between Gaussian glm, Pois

Re: [R] Change points in R

2014-01-31 Thread Achim Zeileis
On Fri, 31 Jan 2014, Benjamin Ward (ENV) wrote: Hi R helpers, I have a set of data best shown in this below graph. Each coloured line represents a statistic calculated across pairs of DNA sequences. And for each coloured line, I would like to identify breakpoints - so identify the chunks whe