Re: [R] function logit() vs logistic regression

2012-10-18 Thread Achim Zeileis
On Wed, 17 Oct 2012, swertie wrote: Hello! When I am analyzing proportion data, I usually apply logistic regression using a glm model with binomial family. For example: m - glm( cbind(not realized, realized) ~ v1 + v2 , family=binomial) However, sometimes I don't have the number of cases

Re: [R] how to concatenate factor vectors?

2012-10-18 Thread Bert Gunter
No. You need to test more carefully. a - factor(c(1,3,5)) b - factor(c(5,7)) c(a,b) [1] 1 2 3 1 2 lev - sort(unique(f - c(a,b))) f - factor(f,levels=lev) f [1] 1 2 3 1 2 Levels: 1 2 3 ## but unlist(list(a,b),use.names=FALSE) [1] 1 3 5 5 7 Levels: 1 3 5 7 However, Is level 5 in 'a' the

Re: [R] how to concatenate factor vectors?

2012-10-18 Thread Jorge I Velez
Thank you for clarifying, Dr. Gunter. My bad. Regards, Jorge.- On Thu, Oct 18, 2012 at 5:21 PM, Bert Gunter gunter.ber...@gene.com wrote: No. You need to test more carefully. a - factor(c(1,3,5)) b - factor(c(5,7)) c(a,b) [1] 1 2 3 1 2 lev - sort(unique(f - c(a,b))) f -

[R] Can R load ICS calendar files?

2012-10-18 Thread Daniel Roberts
I need to load ICS calendar event files in R. Is there a package with a function that does this already? Many thanks! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE

Re: [R] aggregate function not working?

2012-10-18 Thread arun
HI, Hi, Try this:  str(PriceList) 'data.frame': 161 obs. of  3 variables:  $ Price  : num  0 8.18 8.27 10.42 10.5 ...  $ Size   : int  664640 440 407 180 690 851 190 480 720 74 ...  $ bandNum:List of 161  PriceList1-within(PriceList,{bandNum-as.numeric(bandNum)}) str(PriceList1)

Re: [R] How to count rows with a condition

2012-10-18 Thread arun
HI, I tried the code with unsorted ac_names column and found to be working.  So, couldn't identify exactly the problem.  If you can provide a subset of your dataset using ?dput(), then it would be much helpful. set.seed(1)

Re: [R] subtotals based on price bands?

2012-10-18 Thread arun
HI, Try this: seq1 = seq(0, 100, by = 5) seq2 = seq(100, 1000, by = 100) Bands = c(seq1, seq2) DF1 - data.frame(matrix(ncol=2,nrow=200)) colnames(DF1)- c(Price, Size) set.seed(1) DF1$Price - sample(1:1000, 200, replace=F) set.seed(300) DF1$Size - sample(1:1000, 200, replace=F)

[R] how R implement qnorm()

2012-10-18 Thread Sheng Liu
how R implement qnorm() I wonder anyone knows the mathematical process that R calculated the quantile? The reason I asked is soly by curiosity. I know the probability of a normal distribution is calculated through integrate the Gaussian function, which can be implemented easily (see code),

Re: [R] as.xts

2012-10-18 Thread sf631
Thanks for your response as well. It turned out that this was already a date typed file but I'll file this away for future reference when I come up against a string of characters -- View this message in context: http://r.789695.n4.nabble.com/as-xts-tp3028280p4646558.html Sent from the R help

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

2012-10-18 Thread york8866
Hi arun, Thanks, I used your code, however, there's error message Error: could not find function count. Thanks, -- View this message in context: http://r.789695.n4.nabble.com/replacing-random-repeated-numbers-with-a-series-of-sequenced-numbers-tp4646559p4646562.html Sent from the R help

Re: [R] Retaining X axis labels when combining lattice graphs

2012-10-18 Thread Bevan
Hi Duncan, Thanks for taking the time to look at my problem. I apologize for sending in my data in an improper format, I have included the dput output for my data at the bottom of this message. I guess I was not clear on the exact problem I was trying to solve. I want to keep each trellis

Re: [R] Creating Optimization Constraints

2012-10-18 Thread boylangc
Dr. Varadhan: Perfect. Package Rsolnp is exactly what I was looking for. Thank you very much. r/ Greg -Original Message- From: Ravi Varadhan ravi.varad...@jhu.edu Sent: Oct 17, 2012 10:24 AM To: 'boyla...@earthlink.net' boyla...@earthlink.net Cc: r-help@r-project.org

[R] Need Iteration and convergence in R

2012-10-18 Thread mithunum
I want to iterate the program until it converge? can anybody help me? I just write it manual, but i need to generalize it so that simulation can stop if the difference between two iteration is less than 0.0001. The following are the program : rm(list=ls(all=T)) x=rnorm(50,2,0.7)

[R] Adding labels to spatial line objects

2012-10-18 Thread V Zintzen
Hi there, a very simple question: I would like to add nice labels to SpatialLinesDataFrame which have been plotted using the 'plot' function. Those lines are bathymetry and I would like to have labels for the different depths. The function 'contour' does it nicely but does not directly read

[R] Job opportunity in Beijing, China at Xian-Janssen Pharmaceutical Ltd

2012-10-18 Thread Fei Chen
The Quantitative Decision Strategies group at Janssen Research Development, Johnson Johnson, is looking for a candidate to represent QDS in Beijing, China in the subsidiary company of Xian-Janssen Pharmacetical Ltd. The basic requirements for this candidate are 1) 3+ years experience in

Re: [R] how R implement qnorm()

2012-10-18 Thread Prof Brian Ripley
On 18/10/2012 00:16, Sheng Liu wrote: how R implement qnorm() I wonder anyone knows the mathematical process that R calculated the quantile? It's on the help page! 'For qnorm, the code is a C translation of Wichura, M. J. (1988) Algorithm AS 241: The Percentage Points of the Normal

Re: [R] combine unadjusted and adjusted forest plots

2012-10-18 Thread Viechtbauer Wolfgang (STAT)
Dear Romita, It is not quite clear to me what exactly you want the graph to look like. What do you mean by plots of the unadjusted and adjusted models? In general though, it sounds to me as if the graph you have in mind is rather complex. It may be possible to accomplish this with the forest()

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

2012-10-18 Thread Rui Barradas
Hello, Try the following. dat - read.table(text= ID 1001 1001 1001 1122 1122 1122 1421 1421 1789 1789 , header = TRUE) r - rle(dat$ID) dat$SID - rep(seq_along(r$lengths), r$lengths) + 1000 Hope this helps, Rui Barradas Em 18-10-2012 02:16, york8866 escreveu: Hi all, I have a dataset with

Re: [R] function logit() vs logistic regression

2012-10-18 Thread swertie
Thank you very much for replies and the nice explanation about variance stabilization. I heard about the arcsin transformation, but some recent papers were very critical about it (i.e., Warton Hui, 2011), so that I would better try another way. I will have a look at beta regression. Best, V.

Re: [R] help in R

2012-10-18 Thread Berend Hasselman
On 18-10-2012, at 09:55, namrata mohapatra wrote: Hello Sir/Madam I want to reverse the colour distribution . I want the lowest value of error to be in blue and highest in red . Please provide a reproducible example in the form of R code. Berend With Regards Namrata

Re: [R] help in R

2012-10-18 Thread Jim Lemon
On 10/18/2012 06:55 PM, namrata mohapatra wrote: Hello Sir/Madam I want to reverse the colour distribution . I want the lowest value of error to be in blue and highest in red . With Regards Namrata Mohapatra Hi Namrata, Let's see, where is my crystal ball? Ah, right. I see that you are

Re: [R] how R implement qnorm()

2012-10-18 Thread peter dalgaard
On Oct 18, 2012, at 09:55 , Prof Brian Ripley wrote: R is a bit confusing as it requires inverse error function (X = - sqrt(2)* erf-1 (2*P)), while R doesn't have a build in one. The InvErf function most people use is through qnorm( InvErf=function(x) I think you are wrong about 'most

Re: [R] adding a new individual

2012-10-18 Thread Rui Barradas
Hello, Yes it is. Hope this helps, Rui Barradas P.S. You must be much more specific in your question. 1. Provide a data example using ?dput. dput( head(MyData, 50) ) # paste the output of this in a post. 2. What type of model are you talking about? What exactly does prediction mean? 3. At

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

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

[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] 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

[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

[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] 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 -

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 -

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] 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

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)

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

[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

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:

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

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,

[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 -

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 -

[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 COL1

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:

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] 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

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

Re: [R] how to concatenate factor vectors?

2012-10-18 Thread Sam Steingold
* Bert Gunter thagre.ore...@trar.pbz [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

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=TRUE,

Re: [R] how to concatenate factor vectors?

2012-10-18 Thread R. Michael Weylandt
On Thursday, October 18, 2012, Sam Steingold wrote: * Bert Gunter thagre.ore...@trar.pbz [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,

Re: [R] how to concatenate factor vectors?

2012-10-18 Thread Sam Steingold
hi Jorge, * Jorge I Velez wbetrvinair...@tznvy.pbz [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

[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

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] 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

[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, function(x)

Re: [R] how to concatenate factor vectors?

2012-10-18 Thread Sam Steingold
* R. Michael Weylandt zvpunry.jrlyn...@tznvy.pbz [2012-10-18 16:01:37 +0100]: On Thursday, October 18, 2012, Sam Steingold wrote: * Bert Gunter thagre.ore...@trar.pbz [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

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 bmmos...@amath.washington.edu wrote: Hi All, Thanks in advance for your help. I'm

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 601 225 6

[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

[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

[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

Re: [R] how to concatenate factor vectors?

2012-10-18 Thread Sam Steingold
* Jeff Newmiller wqarj...@qpa.qnivf.pn.hf [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

[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:

[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

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] 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

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+00

[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.

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()

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 karthick@gmail.com wrote: Hi I have one text file which containing 4 variables with 10 observations. I would like to import with scan() function. Please give

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 mpapoutsog...@gmail.com 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

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:

[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)), .Names =

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 marc_...@yahoo.fr wrote: Dear List Member Is there a mechanism to automatically run a piece of R code when a package is loaded using library(xxx) ?

Re: [R] how to concatenate factor vectors?

2012-10-18 Thread Sam Steingold
* William Dunlap jqha...@gvopb.pbz [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

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 nicome...@gmail.com To: R help r-help@r-project.org Cc: Sent:

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

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

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 s...@gnu.org wrote: * R. Michael Weylandt zvpunry.jrlyn...@tznvy.pbz [2012-10-18 16:01:37 +0100]: On Thursday, October 18, 2012, Sam Steingold wrote: * Bert Gunter thagre.ore...@trar.pbz [2012-10-17 23:21:44 -0700]: However, Is level 5 in

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:

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    0   

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 peak

[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] 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

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

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

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] 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 ruimax...@gmail.com wrote: Hi, I downloaded a

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 rainer.schuerm...@gmx.net To: arun

[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

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 bmmos...@amath.washington.edu To: r-help@r-project.org Cc: Sent: Thursday, October 18, 2012 10:17 AM Subject: Re: [R] converting a string to

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    f   

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] 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

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(COL, x)

[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:

[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 +

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

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

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)

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

  1   2   >