Re: [R] AR(1) with an error term arima.sim parameter question

2014-12-11 Thread Rolf Turner
On 11/12/14 20:09, Michael Selevan wrote: This makes sense, thank you for the thorough response! One follow up question though. Would your #2 option be the same as, say, not using the rand.gen at all and providing the following parameters instead? y3 - arima.sim(n=10, list(ar=0.8),

Re: [R] AR(1) with an error term arima.sim parameter question

2014-12-11 Thread Michael Selevan
Thanks for all the help! Ill give them a shot and compare the results. On Thu, Dec 11, 2014 at 12:29 AM, Rolf Turner r.tur...@auckland.ac.nz wrote: On 11/12/14 20:09, Michael Selevan wrote: This makes sense, thank you for the thorough response! One follow up question though. Would your #2

[R] to calculate c(rep(1, 43), rep(2,43),...., rep(10,43))

2014-12-11 Thread Arnaud Michel
Hello I would like to find an elegant way of calculating c(rep(1, 43), rep(2,43),, rep(10,43)) Any idea ? Thank you -- Michel ARNAUD DGDRD-Drh - TA 174/04 tel : 04.67.61.75.38 port: 06.47.43.55.31 __ R-help@r-project.org mailing list -- To

Re: [R] to calculate c(rep(1, 43), rep(2, 43), ...., rep(10, 43))

2014-12-11 Thread Rui Barradas
Hello, Try the following. unlist(lapply(1:10, function(n) rep(as.character(n), 43))) Hope this helps, Rui Barradas Em 11-12-2014 10:12, Arnaud Michel escreveu: Hello I would like to find an elegant way of calculating c(rep(1, 43), rep(2,43),, rep(10,43)) Any idea ? Thank you

Re: [R] to calculate c(rep(1, 43), rep(2, 43), ...., rep(10, 43))

2014-12-11 Thread Ivan Calandra
Hi Michel, What about rep(1:10, each=43) If you need to have characters, you could do something like: as.character(1:10) HTH, Ivan -- Ivan Calandra, ATER University of Reims Champagne-Ardenne GEGENA² - EA 3795 CREA - 2 esplanade Roland Garros 51100 Reims, France +33(0)3 26 77 36 89

[R] Working with data frames

2014-12-11 Thread Sun Shine
Hello I am struggling with data frames and would appreciate some help please. I have a data set of 13 observations and 80 variables. The first column is the names of different political area boundaries (e.g. MHad, LBNW, etc), the first row is a vector of variable names concerning various

Re: [R] Working with data frames

2014-12-11 Thread Ivan Calandra
Hi Sun, If I understood correctly (a reproducible example would be of great help), it seems you're struggling with factors. Read on this topic to better understand how it works. For your plots, you would need to set the labels with the argument 'xlab' for plot(). To access the names of the

[R] How to pass a nested random effect with frailty in coxph() - survival package?

2014-12-11 Thread David Villegas Ríos
Hi, I have a very simple Cox regression model in which I need to include a nested random effect: individual nested in treatment. I know how to pass a single random effect - e.g. frailty(id)- but how can I specify the nested random (id nested in treatment) effect using frailty? The equivalent in

Re: [R] Working with data frames

2014-12-11 Thread jim holtman
If you are using 'read.csv' (or 'read.table') to input, then use the 'as.is = TRUE' parameter to prevent the conversion to factors of the data. You can also do as.character(df$col_with_factors) to get the character values back. Jim Holtman Data Munger Guru What is the problem that you are

[R] Create previous dates from date with consideration of leap year

2014-12-11 Thread Kuma Raj
Dear R Community, I wish to create 5 preceding dates from the date variable by ID. How could I create such dates? The code should consider leap year. Thanks Sample data follows: structure(list(id = 1:12, date = structure(c(9L, 6L, 11L, 8L, 7L, 5L, 4L, 3L, 12L, 1L, 10L, 2L), .Label =

Re: [R] Working with data frames

2014-12-11 Thread William Dunlap
Here is a reproducible example d - read.csv(text=Name,Age\nBob,2\nXavier,25\nAdam,1) str(d) 'data.frame': 3 obs. of 2 variables: $ Name: Factor w/ 3 levels Adam,Bob,Xavier: 2 3 1 $ Age : int 2 25 1 Do you get something similar? If not, show us what you have (you could trim it

[R] Using gregexpr and regmatches but getting Iconv error

2014-12-11 Thread Adel
Hi I have stumbled upon a problem when using gregexpr and regmatches, with the following error-message: Error in iconv(x, latin1, ASCII) : 'x' must be a list of NULL or raw vectors The data: (1) I have two journal articles and after some regex manipulation I am at the following

Re: [R] Create previous dates from date with consideration of leap year

2014-12-11 Thread Lee, Chel Hee
The sample data you provided has the variable 'date'. Since the type of this variable is 'factor', you may try to convert type of variable from 'factor' to 'date' as shown in the below: x$rval - as.Date(x$date, format=%d%b%Y)-5 x id date case rval 1 1 27apr19931

Re: [R] Create previous dates from date with consideration of leap year

2014-12-11 Thread jim holtman
Here is an example of converting the 'date' your dataframe to 'time' (POSIXct) and then taking the first 'time' and creating the 5 previous days from that date: id date case 1 1 27apr19931 2 2 13feb20051 3 3 29may20021 4 4 22sep20051 5 5 18dec19911 6 6

Re: [R] Working with data frames

2014-12-11 Thread Sun Shine
Hello William, Ivan and Jim I appreciate your replies. I did suppress the factors using stringsAsFactors=FALSE and in that way was able to progress some more on getting a sense of the data set, so thanks for that suggestion. I had previously overlooked it. Also thanks William, I never

Re: [R] Working with data frames

2014-12-11 Thread Jeff Newmiller
Ggplot2 also depends on factors, so learn about them asap. It does have some support for automatically converting strings to factors in some cases, but it doesn't always work the way you want it to. --- Jeff Newmiller

Re: [R] Working with data frames

2014-12-11 Thread William Dunlap
Sun Shine wrote with(MHP.def, {plot(as.integer(MHP.def$Names),cH.E, axes=FALSE, xlab='Area') axis(side=2) axis(side=1, at=seq_along(levels(MHP.def$Names)), lab=levels(MHP.def$Names))}) Error: unexpected symbol in with(MHP.def, {plot(as.integer(MHP.def$Names), MHP.def$cH.E, axes=FALSE,

Re: [R] NA problem in rbind of an apply summary

2014-12-11 Thread Raffaello Vardavas
Thank you Karim, I'll try that. Thanks! Raff Sent from my iPhone On Dec 10, 2014, at 1:48 PM, Karim Mezhoud kmezh...@gmail.com wrote: Hi, Could you try rbind.na.R function. karim Ô__ c/ /'_;kmezhoud (*) \(*) ⴽⴰⵔⵉⵎ ⵎⴻⵣⵀⵓⴷ http://bioinformatics.tn/ On Wed, Dec 10,

[R] Unmarked

2014-12-11 Thread Brian Ortman
I am trying to write a script to run occupancy analysis for very large sets of data for multiple species. I have in the past used PRESENCE but would like to use R. I am having trouble getting the ObsCov into the data frame. I get the following error message:

Re: [R] Unmarked

2014-12-11 Thread Bert Gunter
Your query is incoherent, at least to me. If others are similarly flummoxed and you receive no useful reply, read and follow the posting guide (link below) to provide code, data, etc. for a minimal example to explain what you wish to do. In PLAIN TEXT -- no HTML. Cheers, Bert Bert Gunter

Re: [R] DIF

2014-12-11 Thread munevver kaya
Thank you so much Phil, I will try that. Best On Wed, Dec 10, 2014 at 9:42 PM, Phil Chalmers rphilip.chalm...@gmail.com wrote: As well, the mirt package contains a function for DIF using likelihood ratio tests via multiple-group estimation methods (the multiple group estimation generally goes

[R] make matrices as many as possible with a constraint

2014-12-11 Thread Kathryn Lord
Dear R users, I'd like to make 4 by 7 matrices as many as possible with natural numbers 1 through 28 such that each matrix have different elements of each column. For example, simply here is one a1 - matrix(1:28, 4,7) a1 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [1,]159 13 17

Re: [R] make matrices as many as possible with a constraint

2014-12-11 Thread David Winsemius
On Dec 11, 2014, at 4:38 PM, Kathryn Lord wrote: Dear R users, I'd like to make 4 by 7 matrices as many as possible with natural numbers 1 through 28 such that each matrix have different elements of each column. I was tempted to respond: We're very sorry. The Soduko Challenge Contest was

[R] Is there a plotmath symbol \mapsto?

2014-12-11 Thread Marius Hofert
Hi, Is there a plotmath symbol like LaTeX's \mapsto? I need this comparably often, for example if you want to plot a two-place function in one variable (and thus would like to have ylab=t \mapsto f(t,s), for example). If there is such a symbol, I'd be great to have it as an example on ?plotmath.