Re: [R] how R implement qnorm()

2012-10-18 Thread peter dalgaard
On Oct 19, 2012, at 06:05 , Thomas Lumley wrote: > On Fri, Oct 19, 2012 at 12:21 PM, Sheng Liu wrote: >> Thanks a lot. It's very helpful. >> I've read through the c code. Just FYI and for my completion of the >> question, I post some of my thought on it: >> To me it looks like the algorithm is a

Re: [R] summation coding

2012-10-18 Thread djbanana
I am aware of the most basic stuff, especially vectorization and subscripting. I only gave a simple example with length 4. I need to do that for vectors of length 190. Are there any in-built commands? Or should I write the loops myself? Thank you. -- View this message in context: http://r.7

[R] MLE of negative binomial distribution parameters

2012-10-18 Thread Zoraida
I need to estimate the parameters for negative binomial distribution (pdf) using maximun likelihood, I also need to estimate the parameter for the Poisson by ML, which can be done by hand, but later I need to conduct a likelihood ratio test between these two distributions and I don't know how to st

Re: [R] summation coding

2012-10-18 Thread Bert Gunter
Have you read the Introduction to R tutorial? You seem unaware of even the most basic stuff, especially vectorization and subscripting. Also, this smells like homework, and we don't do homework here. -- Bert On Thu, Oct 18, 2012 at 12:33 PM, djbanana wrote: > I would like to code the following

[R] help finding edge connecting two nodes

2012-10-18 Thread dha...@mit.edu
I'm new to R and igraph and I was wondering if anybody can help me with the following. I want to find the edge weight between two vertices in a graph. My graph structure is defined by the normal ego (node1), alter (node2) and the weight of the edge between them. I know that I can get the weight f

[R] likelihood function involving integration, error in nlm

2012-10-18 Thread stats12
Dear R users, I am trying to find the mle that involves integration. I am using the following code and get an error when I use the nlm function d<-matrix(c(1,1,0,0,0,0,0,0,2,1,0,0,1,1,0,1,2,2,1,0),nrow=10,ncol=2) h<-matrix(runif(20,0,1),10) integ<-matrix(c(0),nrow=10, ncol=2) ll<-function(p){

[R] Mapping

2012-10-18 Thread dorothy borowy
I am a new user of R and am crunching through the system. I have reached an impasse with mapping; I want to make a bubble map and lay it over a grid that is composed of a standard x,y axis. Within this, are 16 (4x4) gridded blocks, numbered 1-16. And, within these individual hectares(1-16) i

[R] summation coding

2012-10-18 Thread djbanana
I would like to code the following in R: a1(b1+b2+b3) + a2(b1+b3+b4) + a3(b1+b2+b4) + a4(b1+b2+b3) or in summation notation: sum_{i=1, j\neq i}^{4} a_i * b_i I realise this is the same as: sum_{i=1, j=1}^{4} a_i * b_i - sum_{i=j} a_i * b_i would appreciate some help. Thank you. -- View this

[R] want to count 2 NULLS as disimilar with DIANA/DAISY/GOWER

2012-10-18 Thread jmpapa
I am using DIANA/DAISY/GOWER. Some of my categorical data include NULLS. When assessing disimilarity, these NULLS are considered similar. I do not want these NULLS to contribute towards similarity. Instead is there a way for these NULLS to each be considered different so as to contribute to disimi

[R] Keep loop running after webpage times out?

2012-10-18 Thread Cess
Hi I have created a loop to obtain data from several webpages but the loop keeps crashing with the error "Error in function (type, msg, asError = TRUE) : Operation timed out after 5000 milliseconds with 9196 bytes received" Page = getURLContent(page[i], followlocation=TRUE, curl = curl,.o

Re: [R] how R implement qnorm()

2012-10-18 Thread Thomas Lumley
On Fri, Oct 19, 2012 at 12:21 PM, Sheng Liu wrote: > Thanks a lot. It's very helpful. > I've read through the c code. Just FYI and for my completion of the > question, I post some of my thought on it: > To me it looks like the algorithm is actually inquiring through an > approximation table (the a

Re: [R] speeding read.table

2012-10-18 Thread arun
HI, You can also try this.   Should remove the problematic lines, but it may not match up to Rui's method in terms of speed. input<-readLines(textConnection("TABLE NO.  1  COL1    COL2    COL3    COL4    COL5    COL6    COL7    COL8    COL9    COL10   C

Re: [R] svyboxplot - library (survey)

2012-10-18 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hi Dr. Lumley, Further thoughts: To get the histogram of age with proportions (relative frequencies) on y-axis, I probably need to rescale the weight for each subgroup separately so that the rescaled weight would sum to 1 for the respective subgroup. Am I correct? Thanks, Pradip Muhuri

Re: [R] spTransform longlat to utm

2012-10-18 Thread MacQueen, Don
r-sig-geo is a better place to ask this question. There doesn't appear to be anything wrong with how you are using spTransform(). "x" should be longitude "y" should be latitude More precisely, the first column of your matrix matrix(c(x,y), ncol=2) should be longitude, the second column la

Re: [R] Re-projecting geotiff

2012-10-18 Thread MacQueen, Don
r-sig-geo would be a better place to ask this question. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 10/18/12 6:52 AM, "Filoche" wrote: >Dear R users, > >I'm currently trying to re-project a geotiff in another coord

Re: [R] how R implement qnorm()

2012-10-18 Thread Sheng Liu
Thanks a lot. It's very helpful. I've read through the c code. Just FYI and for my completion of the question, I post some of my thought on it: To me it looks like the algorithm is actually inquiring through an approximation table (the approximations, at least for pnom, is "derived from those in "R

Re: [R] bigmemory for dataframes?

2012-10-18 Thread steven mosher
i believe ff has a dataframe class. as for your object data im less clear. how big is it On Oct 18, 2012 12:45 PM, "Alexander Shenkin" wrote: > Hi Folks, > > I've been bumping my head against the 4GB limit for 32-bit R. I can't > go to 64-bit R due to package compatibility issues (ROBDC - possib

Re: [R] ccf(x,y) vs. cor() of x and lagged values of y

2012-10-18 Thread R. Michael Weylandt
Hi Mihnea, I'm afraid I don't have much time to look at this right now -- I'm sort of swamped for the next 5 days -- so I'm forwarding back to the list so more eyeballs pass over it. In general, you should always cc the list so the archives remain complete and so that you get a quicker response.

Re: [R] sliding window analysis with rollapply

2012-10-18 Thread R. Michael Weylandt
Hi Li, I'm afraid I don't have much time to look at this right now -- I'm sort of swamped for the next 5 days -- so I'm forwarding back to the list so more eyeballs pass over it. In general, you should always cc the list so the archives remain complete and so that you get a quicker response. On T

Re: [R] svyboxplot - library (survey)

2012-10-18 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello Dr. Lumley, Thank you for your advice/suggestions. I have rescaled the weight (i.e., "original weight" divided by "total weighted count" averaged across 8 surveys - NHIS). As can be seen below (R console), the new weight sums to 1. I have used the freq=TRUE argument in the svyhist () fun

Re: [R] svyplot and svysmooth with hexbin

2012-10-18 Thread Thomas Lumley
Here's an example. The problem is that hexbin uses grid graphics, not the base graphics that plot.svysmooth() uses, so you need to do the plotting yourself with grid. The necessary viewport is returned by svyplot() hexstuff<-svyplot(api00~api99, design=dstrat, style="hex", xlab="1999 API",ylab="

Re: [R] bigmemory for dataframes?

2012-10-18 Thread Alexander Shenkin
System Info: R 2.14.2 Windows 7 Pro x64 SP1 8GB RAM On 10/18/2012 3:42 PM, Alexander Shenkin wrote: > Hi Folks, > > I've been bumping my head against the 4GB limit for 32-bit R. I can't > go to 64-bit R due to package compatibility issues (ROBDC - possible but > painful, xlsReadWrite - not possi

[R] bigmemory for dataframes?

2012-10-18 Thread Alexander Shenkin
Hi Folks, I've been bumping my head against the 4GB limit for 32-bit R. I can't go to 64-bit R due to package compatibility issues (ROBDC - possible but painful, xlsReadWrite - not possible, and others). I have a number of big dataframes whose columns all sorts of data types - factor, character,

Re: [R] svyplot and svysmooth with hexbin

2012-10-18 Thread Paul Murrell
Hi On 19/10/2012 6:49 a.m., Durant, James T. (ATSDR/DCHI/SSB) wrote: Hi all- So sorry to bother you all with something pretty basic. I am trying to add the lines method output from svysmooth to a svyplot with style="grayhex". However, the line either appears in the wrong place or if I am runn

Re: [R] "State Space" + "Kalman Filter "

2012-10-18 Thread nserdar
So I do not find example what I expect. I plan to estimate the multi-factor model for Kalman Filter Mean Reverting, Random Walk and Random Coefficient. For example: R(it)= Alpha(it)+ Beta(it)R(mt)+Gamma(it)(R(mt)^2)+delta(it)(R(mt)^3)+ V(it) KF Random walk Alpha(it)= Alpha(it-1)+W(i1t) Beta

Re: [R] WGCNA: Combining block-wise dendrograms and modules into a single figure

2012-10-18 Thread Derek55
Hi Peter, Thank you for your time and input on this matter. I will take your advice and reconstruct the blocks using a different maximum cutoff and plot the figures next to one another. I also wanted to thank you for creating the WGCNA package and including the section on exporting to other visual

Re: [R] "State Space" + "Kalman Filter "

2012-10-18 Thread nserdar
I know these package but I plan to analyse financial multi factorial data set, and also estimate diffuse initial values for these models. I generated my own code, but I had problem with optim() package problem. I need some constraints and I do not apply it in my code. Do you have any suggesti

[R] how to add mean value to regression line using ggplot?

2012-10-18 Thread autumnlin
I have generated plot using ggplot, and i would like to add mean value to the regression line as a marker. how to do it? p <- ggplot(data, aes(x = x, y = y, color = a, shape = factor(sex), linetype = factor(sex))) p0 <- p + scale_color_man

[R] looping survdiff?

2012-10-18 Thread Charles Determan Jr
Hello, I am trying to set up a loop that can run the survdiff function with the ultimate goal to generate a csv file with the p-values reported. However, whenever I try a loop I get an error such as "invalid type (list) for variable 'survival_data_variables[i]". This is a subset of my data: str

Re: [R] speeding read.table

2012-10-18 Thread Rui Barradas
Hello, Time down by a factor of 4. It still takes some minutes, 2 mins for a file of 380Mb/3.6M lines. So maybe system commands (maybe awk?) can do the job better. fun <- function(infile, outfile, lines = 1L){ remove <- function(x){ i1 <- grep("TABLE", x) i2 <- grep("C

Re: [R] svyplot and svysmooth with hexbin

2012-10-18 Thread Durant, James T. (ATSDR/DCHI/SSB)
Good suggestion - I tried it - it does not work (line appears too high with the data I am working with). VR James James T. Durant, MSPH CIH Environmental Health Scientist US Agency for Toxic Substances and Disease Registry Atlanta, GA 30341 770-488-0668 From: Anthony Damico [mailto:ajdam...@

Re: [R] svyplot and svysmooth with hexbin

2012-10-18 Thread Anthony Damico
try adding legend = 0 to your svyplot() On Thu, Oct 18, 2012 at 1:49 PM, Durant, James T. (ATSDR/DCHI/SSB) < h...@cdc.gov> wrote: > Hi all- > > So sorry to bother you all with something pretty basic. > > I am trying to add the lines method output from svysmooth to a svyplot > with style="grayhex"

Re: [R] How to import data from text file using scan() Function?

2012-10-18 Thread arun
Hi, I agree with Sarah that read.table() will much easier in this case. If you want scan(), then you can try this: dat1<-scan(what=list("numeric","character","character","numeric"),text=" id    name    sex    age 111    HELEN    f    22 112    DONNA    f    22 113    ERIC    m    21 114    LINDA 

Re: [R] converting a string to an integer vector

2012-10-18 Thread arun
Hi, You can also try this: a <- "1,2" as.numeric(c(gsub("(.*)\\,(.*)","\\1",a), gsub("(.*)\\,(.*)","\\2",a))) #[1] 1 2 - Original Message - From: BenM To: r-help@r-project.org Cc: Sent: Thursday, October 18, 2012 10:17 AM Subject: Re: [R] converting a string to an integer vector T

[R] svyplot and svysmooth with hexbin

2012-10-18 Thread Durant, James T. (ATSDR/DCHI/SSB)
Hi all- So sorry to bother you all with something pretty basic. I am trying to add the lines method output from svysmooth to a svyplot with style="grayhex". However, the line either appears in the wrong place or if I am running in R Studio it causes the system to crash. I know this is somethi

Re: [R] Help with

2012-10-18 Thread arun
Hi Rainer, Thanks for notifying me.  You are right. Sorry, I was working with library(reshape) instead of reshape2.  So, I guess the cast() will not work if we load only reshape2. A.K. - Original Message - From: Rainer Schuermann To: arun Cc: Sent: Thursday, October 18, 2012 1:33

Re: [R] Help with

2012-10-18 Thread Greg Snow
Another option would be to read the data using read.table or similar to get the data into a data frame then use the xtabs function, something like: result <- xtabs( count ~ docID + wordID, data=mydf) On Thu, Oct 18, 2012 at 6:44 AM, Rui Esteves wrote: > Hi, > > I downloaded a dataset from UCI

Re: [R] Getting a table of coefficients from R

2012-10-18 Thread Greg Snow
You have a list of models, the coef and confint functions only work on a single model, so you need to use lapply or sapply to get the information from each model. Possibly something like (untested): tableOfOddsRatios <- sapply( models, function(x) exp(c( coef(x)[2], confint(x)[2,]) ) I included

Re: [R] WGCNA: Combining block-wise dendrograms and modules into a single figure

2012-10-18 Thread Peter Langfelder
Hi Derek, the simple answer is that the block-specific dendrograms cannot be meaningfully combined into a single dendrogram. You have to plot them separately. You can create a multi-panel figure that shows all block dendrograms in one big figure, although with 10 blocks I would not necessarily att

Re: [R] legend of maps generated by function symbols

2012-10-18 Thread Greg Snow
Possible? Yes. (see fortune("Yoda")) Automated using the legend function? No Automated using another function? possbly somewhere in the 4,000+ packages on CRAN, but I don't know which. It is doable with the basic tools. You could either find a part of your graph with open area to put the legend i

Re: [R] good documentation on use of Rscript. where to find?

2012-10-18 Thread Duncan Murdoch
On 18/10/2012 12:56 PM, Paul Johnson wrote: What is the correct format for the shebang line and what options are allowed or necessary along with this? I find plenty of blogs and opinions, but few authoritative answers. The authoritative source for the options is the R help page ?Rscript. The

[R] good documentation on use of Rscript. where to find?

2012-10-18 Thread Paul Johnson
What is the correct format for the shebang line and what options are allowed or necessary along with this? I find plenty of blogs and opinions, but few authoritative answers. I want an R script to run and update packages periodically, with a cron job that launches it. What is necessary to put in

Re: [R] Upper limit in nlsLM not working as expected

2012-10-18 Thread Berend Hasselman
On 18-10-2012, at 14:16, Martin Hehn wrote: > Dear all, > > I am using the nlsLM function to fit a Lorentzian function to my experimental > data. > The LM algorithm should allow to specify limits, but the upper limit appears > not to work as expected in my code. > The parameter 'w', which is p

Re: [R] Help with

2012-10-18 Thread arun
Hi, You can also try this: dat1<-read.table(text=" 1 1 3 1 2 54 1 3 11 1 4 17 2 1 5 2 4 78 2 5 20 ",sep="",header=FALSE) library(reshape2) dat2<-cast(dat1,V1~V2) dat2<-dat2[,-1] dat2[is.na(dat2)]<-0 dat3<-as.matrix(dat2)  dat3 # [,1] [,2] [,3] [,4] [,5] #[1,]    3   54   11   17    0 #[2,]    5

Re: [R] "State Space" + "Kalman Filter "

2012-10-18 Thread Giovanni Petris
Package dlm does it, as well as other contributed packages (KFAS, sspir, dse,...) Best, Giovanni From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] on behalf of nserdar [snes1...@hotmail.com] Sent: Thursday, October 18, 2012 8:40 AM To: r-

Re: [R] how to concatenate factor vectors?

2012-10-18 Thread R. Michael Weylandt
On Thu, Oct 18, 2012 at 4:20 PM, Sam Steingold wrote: >> * R. Michael Weylandt [2012-10-18 16:01:37 >> +0100]: >> >> On Thursday, October 18, 2012, Sam Steingold wrote: >> >>> > * Bert Gunter [2012-10-17 23:21:44 -0700]: >>> > >>> > However, Is level "5" in 'a' the same as level "5" in 'b' ? >>

Re: [R] Time Series Analysis and Forecasting

2012-10-18 Thread Jose Iparraguirre
And there's a wealth of textbooks on time series based in R. Two to start with: Paul S.P. Cowpertwait and Andrew V. Metcalfe (2009). Introductory Time Series with R. Use R! Series. Springer. Robert H. Shumway and David S. Stoffer (2006). Time Series Analysis and Its Applications With R Examples

Re: [R] For loop with i and j and multiple if statements... help!

2012-10-18 Thread Pieter Schoonees
Replace the y[1] with x[2] in the apply function - there is no 'y' defined in the function passed to apply. In the apply function, x is an 2-element vector representing a single row of the data (since the 1 in the second argument of apply says that it is applied row-wise). So the second element,

Re: [R] mean value calculation

2012-10-18 Thread arun
Hi, Are you looking for something like this? #dat1 aggregate(dat1[,2:4],by=list(dat1[,1]),FUN=mean) #  Group.1 val1 val2. val3 #1 AKT  2.2  5.00    6 #2 CKT  4.5  5.75    7 A.K. - Original Message - From: Nico Met To: R help Cc: Sent: Thursday, October 18, 2012 11:59 AM Sub

Re: [R] how to concatenate factor vectors?

2012-10-18 Thread Sam Steingold
> * William Dunlap [2012-10-18 15:33:38 +]: > > c() has an unfortunate history. :-) ISTR reading in the R manual ~15(?) years ago that the language was in a flux and one could not expect code written for the current release to work in the next release. I was considering R as the graphing bac

Re: [R] Autorun when library("xxx") is called

2012-10-18 Thread R. Michael Weylandt
? .onAttach ? .onLoad at slightly different points in the load process. Cheers, Michael On Wed, Oct 17, 2012 at 10:12 PM, Marc Girondot wrote: > Dear List Member > > Is there a mechanism to automatically run a piece of R code when a package > is loaded using library("xxx") ? Preferentially that

[R] mean value calculation

2012-10-18 Thread Nico Met
Dear all, I want to calculate mean values for multiple rows: structure(list(Name = structure(c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), .Label = c("AKT", "CKT"), class = "factor"), val1 = c(2, 3, 2, 2, 2, 5, 3, 8, 2), val2. = c(4, 5, 4, 8, 4, 8, 4, 7, 4), val3 = c(5, 6, 5, 9, 5, 9, 5, 9, 5)), .Na

Re: [R] For loop with i and j and multiple if statements... help!

2012-10-18 Thread Sarah Goslee
There are a bunch of things wrong with your code, from not understanding subsetting to only returning a single value rather than a vector of values. I highly recommend that you read the Introduction to R document that came with your R installation and is readily available online. In the meantime:

Re: [R] Time Series Analysis and Forecasting

2012-10-18 Thread Ista Zahn
Sure: http://cran.r-project.org/web/views/TimeSeries.html Next time please try google first. Best, Ista On Thu, Oct 18, 2012 at 11:29 AM, vas wrote: > Hello, > > I am totally new in the field of time series analysis and forecasting and R. > > I read that R is a powerful tool for time series. C

Re: [R] How to import data from text file using scan() Function?

2012-10-18 Thread Sarah Goslee
Why do you need to use scan()? read.table() would be much easier. Sarah On Thu, Oct 18, 2012 at 9:14 AM, killerkarthick wrote: > Hi > I have one text file which containing 4 variables with 10 observations. > I would like to import with scan() function. Please give some > suggestion.

Re: [R] how to concatenate factor vectors?

2012-10-18 Thread William Dunlap
c() has an unfortunate history. Originally, c(x) stripped the attributes, except names but including dim, dimnames, and class, from x. Also, c(x,y) stripped the attributes from both x and y and concatenated them. Also, c(nameA=1,nameB=2) constructed a vector with a names attribute. Then c() bec

[R] Assessing overdispersion and using quasi model with lmer, possible?

2012-10-18 Thread swertie
Hello! I am trying to model data on species abundance (count data) with a poisson error distribution. I have a fixed and a random variables and thus needs a mixed model. I strongly doubt that my model is overdispersed but I don't know how to get the overdispersion parameter in a mixed model. Maybe

Re: [R] speeding read.table

2012-10-18 Thread Rui Barradas
Hello, Try the following, readaing your file into 'x', using readLines. tc <- textConnection(" TABLE NO. 1 COL1COL2COL3COL4COL5 COL6 COL7COL8COL9COL10 COL11 COL12 1.0010E+05 0.E+00 1.E+00 1.E+03 -1.E+0

[R] "State Space" + "Kalman Filter "

2012-10-18 Thread nserdar
I analyzed the kalman filter based approaches like mean reverting, random coefficient and random walk. At this point Automatic package is inadequate and need some constraints. I also found Kalman Filter code in Shumway$Stoffer book, but it did not provide the correct optimization. Can you su

Re: [R] replacing random repeated numbers with a series of sequenced numbers

2012-10-18 Thread york8866
Hi Arun, Thanks, it works now. Hi Rui, Your code also works. Thanks, -- View this message in context: http://r.789695.n4.nabble.com/replacing-random-repeated-numbers-with-a-series-of-sequenced-numbers-tp4646559p4646609.html Sent from the R help mailing list archive at Nabble.com. __

[R] spTransform longlat to utm

2012-10-18 Thread Alexander Belousov
Dear all, I am trying to project my LongLat-maps to a plane. The ultimate purpose is to do a search of points in vicinity of other points using overlay-commands (sp) with radius in km. I am applying spTransform (package rgdal) and it gives my some curious results. An example. Let's take a poin

[R] Time Series Analysis and Forecasting

2012-10-18 Thread vas
Hello, I am totally new in the field of time series analysis and forecasting and R. I read that R is a powerful tool for time series. Could anyone give me navigation what models of time series are availiable in R etc? -- View this message in context: http://r.789695.n4.nabble.com/Time-Series

Re: [R] how to concatenate factor vectors?

2012-10-18 Thread Sam Steingold
> * Jeff Newmiller [2012-10-18 07:53:24 -0700]: > > If you HAVE defined your factors using explicit levels definitions, you > should have no trouble combining them. http://article.gmane.org/gmane.comp.lang.r.general:277719 -- Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11

[R] WGCNA: Combining block-wise dendrograms and modules into a single figure

2012-10-18 Thread Derek55
Hello fellow R users, I am currently learning to use R, so please forgive me if there is an obvious explanation for the following problem. My goal is to perform WGCNA on a dataset of 19776 genes, so I opted to follow the block-wise network construction (Section 2c) in the WGCNA R Tutorial by Peter

[R] Re-projecting geotiff

2012-10-18 Thread Filoche
Dear R users, I'm currently trying to re-project a geotiff in another coordinate system. For instance, I have a tif image in UTM 19 zone which I would like to reproject into UTM 18. I was wondering if it was possible in R. Furthermore, I looked into 'rgdal' package, but I can't really find out if

[R] How to import data from text file using scan() Function?

2012-10-18 Thread killerkarthick
Hi I have one text file which containing 4 variables with 10 observations. I would like to import with scan() function. Please give some suggestion Thanks... Mydata set is. id namesex age 111 HELEN f 22 112 DONNA f 22 113 ERICm

Re: [R] For loop with i and j and multiple if statements... help!

2012-10-18 Thread ingaschwabe
Dear all, Thanks for the many replies! Indeed, the function does not represent my explanation. It should have been: if (x[i] > 170 && x[i] < 1250 && y[j] > 150 && y[j] < 480) Sorry, my mistake. My data looks like this: head(input[,3:4]) x y 1 701 209 2 685 209 3 566 248 4 562 234 5

Re: [R] converting a string to an integer vector

2012-10-18 Thread Sarah Goslee
Depending on what exactly you are trying to accomplish: > as.numeric(unlist(strsplit(a, ","))) [1] 1 2 > read.csv(textConnection(a), header=FALSE) V1 V2 1 1 2 Sarah On Thu, Oct 18, 2012 at 9:08 AM, BenM wrote: > Hi All, > Thanks in advance for your help. I'm trying to convert a strin

Re: [R] how to concatenate factor vectors?

2012-10-18 Thread Sam Steingold
> * R. Michael Weylandt [2012-10-18 16:01:37 > +0100]: > > On Thursday, October 18, 2012, Sam Steingold wrote: > >> > * Bert Gunter [2012-10-17 23:21:44 -0700]: >> > >> > However, Is level "5" in 'a' the same as level "5" in 'b' ? >> >> yes, of course. >> would anyone want to _different_ factors

[R] Getting a table of coefficients from R

2012-10-18 Thread danibelle
Hi,  I'm trying to obtain a table of coefficients and confidence intervals from a logistic regression analysis in R. My code is as follows: # read in csv file datafile<-read.csv("file.csv", row.names=1) # read in the variable list varlist<-names(datafile)[66:180] models<-lapply(varlist, functio

[R] converting a string to an integer vector

2012-10-18 Thread BenM
Hi All, Thanks in advance for your help. I'm trying to convert a string to an integer vector. For instance, I will start with a <- "1,2" The result I want to end up with will be the equivalent of c(1,2) What's the best way to make the conversion? I've tried using as.integer(a), but R s

Re: [R] converting a string to an integer vector

2012-10-18 Thread BenM
Thank you very much. That appears to be what I wanted. -- View this message in context: http://r.789695.n4.nabble.com/converting-a-string-to-an-integer-vector-tp4646610p4646624.html Sent from the R help mailing list archive at Nabble.com. __ R-help@

[R] multivariate way to aaply on different arrays

2012-10-18 Thread Jannis
Dear R community, is there any efficient way to use aaply on different datacubes? I have 3 dimesniolan datacubes/arrays with dimensions lon x lat x time. Now I would like to do caclulations on each individual time series (e.g. all vectors along the third dimension) using a time series (or mor

Re: [R] how to concatenate factor vectors?

2012-10-18 Thread Sam Steingold
hi Jorge, > * Jorge I Velez [2012-10-18 16:43:58 +1100]: > >> a <- factor(5:1,levels=1:9) >> b <- factor(9:1,levels=1:9) >> lev <- sort(unique(f <- c(a, b))) >> f <- factor(f, levels = lev) >> str(f) > Factor w/ 9 levels "1","2","3","4",..: 5 4 3 2 1 9 8 7 6 5 ... is sort(unique()) really neces

Re: [R] how to concatenate factor vectors?

2012-10-18 Thread R. Michael Weylandt
On Thursday, October 18, 2012, Sam Steingold wrote: > > * Bert Gunter [2012-10-17 23:21:44 -0700]: > > > > However, Is level "5" in 'a' the same as level "5" in 'b' ? > > yes, of course. > would anyone want to _different_ factors with identical string > representations?! > > Off the cuff, studyin

Re: [R] how to concatenate factor vectors?

2012-10-18 Thread Jeff Newmiller
mood <- factor(c("blue", "sunny")) skycolor <- factor(c("azure","blue","teal") If factors are not defined with levels specifications, automatic merging should never be allowed. The fact that read.table automatically generates factors using default levels is why I nearly always import using as.is

Re: [R] how to concatenate factor vectors?

2012-10-18 Thread Sam Steingold
> * Bert Gunter [2012-10-17 23:21:44 -0700]: > > However, Is level "5" in 'a' the same as level "5" in 'b' ? yes, of course. would anyone want to _different_ factors with identical string representations?! -- Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000 http:

Re: [R] speeding read.table

2012-10-18 Thread Fisher Dennis
Jason Are you suggesting grep in R or grep in the system? If the latter, this won't work because I need to implement this same procedure in Windows (sorry about not mentioning this), in which grep does not exist. If in R, the syntax is not obvious -- could you provide an example? Dennis Den

Re: [R] speeding read.table

2012-10-18 Thread Jason Edgecombe
On 10/18/2012 09:57 AM, Fisher Dennis wrote: R 2.15.1 OS X Colleagues, I am reading a 1 GB file into R using read.table. The file consists of 100 tables, each of which is headed by two lines of characters. The first of these lines is: TABLE NO. 1 The second is a list of column header

Re: [R] filling NA gaps according to previous data mean and following data mean

2012-10-18 Thread jeff6868
Still so perfect Rui! A bit much more complicated as what I thought, nevertheless it's what I want! Thank you Rui! -- View this message in context: http://r.789695.n4.nabble.com/filling-NA-gaps-according-to-previous-data-mean-and-following-data-mean-tp4646613p4646620.html Sent from the R help

Re: [R] converting a string to an integer vector

2012-10-18 Thread jeff6868
Hello, Try this, It'll maybe help you: a <- "1,2" b <- strsplit(a,",") #split your data according to "," b <- unlist(b) # it creates a list, so we unlist the result to obtain a vector like c(1,2) -- View this message in context: http://r.789695.n4.nabble.com/converting-a-string-to-an-in

[R] speeding read.table

2012-10-18 Thread Fisher Dennis
R 2.15.1 OS X Colleagues, I am reading a 1 GB file into R using read.table. The file consists of 100 tables, each of which is headed by two lines of characters. The first of these lines is: TABLE NO. 1 The second is a list of column headers. For example: TABLE NO. 1 COL1CO

Re: [R] filling NA gaps according to previous data mean and following data mean

2012-10-18 Thread Rui Barradas
Hello, The function below fails if any of the followind conditions is met. 1. The first value in the vector is NA 2. There are less than n = 5 (or 500) values before/after the first/last, respectively, NA. fun <- function(x, n){ na <- is.na(x) rna <- rle(na) sna <- cumsum(rna$len

[R] filling NA gaps according to previous data mean and following data mean

2012-10-18 Thread jeff6868
Hi everybody, I have a little problem about filling some gaps of NAs in my data. These gaps are between nearly constant data (temperature under snow). Here's a fake example to illustrate how it looks like approximately: DF <- data.frame(data=c(-0.51,-0.51,-0.48,-0.6,-0.54,-0.38,-0.6,-0.42,NA,NA,

Re: [R] Help with

2012-10-18 Thread Rui Barradas
Hello, It's much easier than you think, the first two columns of the input matrix are the row and column numbers into the output matrix, therefore those columns form an index matrix. Just see: x <- scan(text=" 1 1 3 1 2 54 1 3 11 1 4 17 2 1 5 2 4 78 2 5 20 ") mat <- matrix(x, ncol = 3, byro

Re: [R] Kaplan-Meier plotting quirks

2012-10-18 Thread Terry Therneau
Better would be to use interval censored data. Create your data set so that you have (time1, time2) pairs, each of which describes the interval of time over which the tag was lost. So an animal first captured at time 10 sans tag would be (0,10); with tag at 5 and without at 20 would be (5,2

Re: [R] For loop with i and j and multiple if statements... help!

2012-10-18 Thread Jessica Streicher
- Why are you making a matrix for lookzone if it is ever only one number? - changing a variable used for iteration is bad practice (input in this case) though you aren't changing the rows i guess. - There are too many x and too few y in those ifs. Plus this is shorter: test<-apply(input,

[R] Help with

2012-10-18 Thread Rui Esteves
Hi, I downloaded a dataset from UCI repositories named Bag of Words: http://archive.ics.uci.edu/ml/machine-learning-databases/bag-of-words/readme.txt The dataset is in a text file with the following structure: --- docID1 wordID1 count docID1 wordID2 count docID1 wordID3 count docID1 wordID4 cou

Re: [R] For loop with i and j and multiple if statements... help!

2012-10-18 Thread Sarah Goslee
If you use ifelse() you don't need the loops at all since ifelse() is vectorized. But I don't have any idea why you need two loops: do you really need to compare all pairs of observations? Also, the logic in your if statements is not the same as the logic in your problem description. Sarah On T

Re: [R] how to concatenate factor vectors?

2012-10-18 Thread arun
Hi, May be this also works:  a <- factor(c(1,3,5))  b <- factor(c(5,7)) f1<-as.numeric(c(as.character(a),as.character(b))) lev<-as.numeric(c(levels(a),setdiff(levels(b),levels(a f2<-factor(f1,levels=lev)  f2 #[1] 1 3 5 5 7 #Levels: 1 3 5 7 a1<-factor(5:1,levels=1:9)  b1<-factor(9:1,levels=1:9)

[R] Upper limit in nlsLM not working as expected

2012-10-18 Thread Martin Hehn
Dear all, I am using the nlsLM function to fit a Lorentzian function to my experimental data. The LM algorithm should allow to specify limits, but the upper limit appears not to work as expected in my code. The parameter 'w', which is peak width at half maximuim always hits the upper limit if t

Re: [R] For loop with i and j and multiple if statements... help!

2012-10-18 Thread Pieter Schoonees
Without commenting on the method itself, shouldn't you be using both x and y twice within each loop instead of x three times and y only once? Please provide a snippet of your data by including the output of dput(head(data,30)) for example. > -Original Message- > From: r-help-boun...@r-p

Re: [R] bugs and misfeatures in polr(MASS).... fixed!

2012-10-18 Thread ahs
Hello, I am trying to use this fix for the convergence problem in polr, but I don't seem to get the change of code right. I redefine the function polr by the lines tjb wrote > if(missing(start)) { > # try something that should always work -tjb > u <- as.integer(table(y)) > u

[R] vertical slices in persp or drape.plot

2012-10-18 Thread TomR
Hi List, I want to show three matrices in a 3D plot, one horizontal, and the other two as vertical slices. Ideally this would use the persp or drape.plot functions. I have found a means of assigning one matrix to the lower xy plane (like a carpet), thus: mat_2D <- matrix(runif(100),nrow=10,ncol=1

[R] legend of maps generated by function symbols

2012-10-18 Thread Marion Jacquot
I generated maps with the function symbols (graphics). These are basic maps generated with : symbols(x,y,circles=myvariable) where x et y are spatial coordinates corresponding to replicates of "myvariable". I would associate legend to this kind of maps, is it possible? Regards, Marion. --

[R] For loop with i and j and multiple if statements... help!

2012-10-18 Thread ingaschwabe
Dear all! I'm quite new to R and at this moment a little bit lost in trying to make a function work with a for loop that has two variables (i and j) and multiple if statements.. I hope that someone of you could help me. I would very appreciate it! What do I want to do? I am analysing the data o

Re: [R] Function hatTrace in package lme4

2012-10-18 Thread ingaschwabe
Thanks for the reply!! Inga -- View this message in context: http://r.789695.n4.nabble.com/Function-hatTrace-in-package-lme4-tp4646071p4646593.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https:/

[R] siar error

2012-10-18 Thread adamc
Hello, I am trying to run the demoscript for the package "siar". However, using the example script and example data supplied I cannot get 1) the model to run unless I specify iterations =500 and burnin = 500 and 2) if the model does work without crashing R then the function "siarhistograms" does

Re: [R] adding a new individual

2012-10-18 Thread Pieter Schoonees
As Rui said, this is a pretty vague question... Nonetheless, if you are using lm() for example you should use the newdata argument in predict(). Have a look at ?predict.lm for example. > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On B

Re: [R] Please help a struggling student with data set-up for

2012-10-18 Thread Asa Johannesen
Hi, I agree with Ista that you need the second option. So long as you don't want to look at interactions between condition and item it shouldn't be a problem that you don't have the same items in each condition. However, it may be difficult to find a main effect of condition that couldn't also

  1   2   >