[R] Vertex names by creating a network object via an edgelist [package: network]

2013-06-28 Thread Daniel Stefan Hain
Dear R community, I have the following problem, and kindly ask for some support. I want to create a network object, representing a directed network on basis of an edgelist. The first column contains some unique ID of project leaders, the second project partners, let's say: x <- cbind(rbind(1,1

Re: [R] choicemodelr is misbehaving under R3.0

2013-06-28 Thread John Colias
I found that if I comment out the matplot function within the choicemodelr function (i.e. remove plotting from within the choicemodelr function while it is running), then ChoiceModelR does not slow down during estimation. So, there must be an issue with the plotting from within a function while it

Re: [R] Data Package Query

2013-06-28 Thread Yasmine Refai
hello, please advice what is wrong at the below syntax: "Trial<-read.table("Trial.txt",header=TRUE) Trial save.image(file="Trial.RData") data(Trial) fit<-logistf(data=Trial, y~x1+x2) " and here is the error I get: "Warning message: In data(Trial) : data set ‘Trial’ not found " regards, yasmin

[R] "actuar" package query

2013-06-28 Thread Charles Thuo
I run the following: library(actuar) x <- seq(0, 22, 0.5) fl <- discretize(plnorm(x, 2.1), from = 0, to = 22, step = 0.5, method ="lower") Fs <- aggregateDist("recursive", model.freq = "poisson",model.sev = fl, lambda = 10, x.scale = 0.5) Warning message: In panjer(fx = model.sev, dist = dist, p0 =

[R] what is the difference between the function "expand.grid" and "data.frame"?

2013-06-28 Thread Zhaoran Zhou
Hello everyone, i found that both of the 2 functions ("expand.grid" and "data.frame") can be used to produce data frame. are there any difference between them? thanks for your help! zhaoran [[alternative HTML version deleted]] __ R-help@r-pro

Re: [R] How to avoid overlapping labels

2013-06-28 Thread gregk
There were some issues with the CRAN submission and I was confused about the earlier package availability. It is available now in source form ( http://cran.r-project.org/web/packages/FField/index.html) The sequence for the demo of label repulsion: install.packages("FField", type = "source") libr

[R] KalmanForecast (stats)

2013-06-28 Thread Csima Gabriella
Dear List members, I would like to use the Kalman-filter program for forecasting - namely for postprocessing numerical model results of 2m temperature. I have looked through the help of the Kalman-filtering programs, mainly the KalmanForecast and I have read about the newer packages like KFAS

Re: [R] Quantile Regression/(package (quantreg))

2013-06-28 Thread Frank Harrell
Mike, Do something like: require(rms) dd <- datadist(mydatarame); options(datadist='dd') f <- Rq(y ~ rcs(age,4)*sex, tau=.5) # use rq function in quantreg summary(f) # inter-quartile-range differences in medians of y (b/c tau=.5) plot(Predict(f, age, sex)) # show age effect on median as a co

Re: [R] Lexical scoping is not what I expect

2013-06-28 Thread Yihui Xie
I just realized this was also possible: > assign('TRUE', FALSE) > TRUE [1] TRUE > get('TRUE') [1] FALSE but it is probably a different story. Regards, Yihui -- Yihui Xie Phone: 206-667-4385 Web: http://yihui.name Fred Hutchinson Cancer Research Center, Seattle On Fri, Jun 28, 2013 at 6:30 PM,

Re: [R] Lexical scoping is not what I expect

2013-06-28 Thread Rolf Turner
On 29/06/13 02:54, John Fox wrote: Dear Duncan and Steve, Since Steve's example raises it, I've never understood why it's legal to change the built-in global "constants" in R, including T and F. That just seems to me to set a trap for users. Why not treat these as reserved symbols, like TRUE, In

Re: [R] Transforming boolean subsetting into index subsetting

2013-06-28 Thread William Dunlap
And there is no real magic in which(). You already know that V[I] where 'I' is a logical vector the length of 'V' extracts the values in 'V' corresponding to the TRUE's in 'I'. Replace 'V' with the vector made by seq_along(I), (== 1, 2, ..., length(I)), and you have the essentials of which(I).

Re: [R] Transforming boolean subsetting into index subsetting

2013-06-28 Thread Bert Gunter
?which -- Bert On Fri, Jun 28, 2013 at 2:58 PM, Julio Sergio wrote: > One of the techniques to subset, a vector for instance, is the following: > > V <- c(18, 8, 5, 41, 8, 7) > V > ## [1] 18 8 5 41 8 7 > ( I <- abs(V - 9) <= 3 ) > ## [1] FALSE TRUE FALSE FALSE TRUE TRUE > V[I]

Re: [R] Transforming boolean subsetting into index subsetting

2013-06-28 Thread peter dalgaard
On Jun 28, 2013, at 23:58 , Julio Sergio wrote: > One of the techniques to subset, a vector for instance, is the following: > > V <- c(18, 8, 5, 41, 8, 7) > V > ## [1] 18 8 5 41 8 7 > ( I <- abs(V - 9) <= 3 ) > ## [1] FALSE TRUE FALSE FALSE TRUE TRUE > V[I] > ## [1] 8 8 7 > > Howe

[R] Transforming boolean subsetting into index subsetting

2013-06-28 Thread Julio Sergio
One of the techniques to subset, a vector for instance, is the following: V <- c(18, 8, 5, 41, 8, 7) V ## [1] 18 8 5 41 8 7 ( I <- abs(V - 9) <= 3 ) ## [1] FALSE TRUE FALSE FALSE TRUE TRUE V[I] ## [1] 8 8 7 However, sometimes we are interested in the indexes of the elements w

[R] RE : use of formula in survey analysis with replicated weights

2013-06-28 Thread LE TERTRE Alain
Thanks for the workaround and the explanation Alain De : Milan Bouchet-Valat [nalimi...@club.fr] Date d'envoi : vendredi 28 juin 2013 19:20 À : LE TERTRE Alain Cc : 'R-help@r-project.org' Objet : Re: [R] use of formula in survey analysis with replicated wei

Re: [R] Changing legend to fill colour in ggplot

2013-06-28 Thread Brian Diggs
On 6/27/2013 12:34 AM, Suparna Mitra wrote: > Hello R experts, >I am having a problem to edit legend in ggplot using four variables. > > My data structure is : > str(df) > 'data.frame': 10 obs. of 6 variables: > $ id: Factor w/ 2 levels "639A","640": 1 1 1 1 1 2 > 2 2

Re: [R] use of formula in survey analysis with replicated weights

2013-06-28 Thread Milan Bouchet-Valat
Le vendredi 28 juin 2013 à 17:44 +0200, LE TERTRE Alain a écrit : > Hi there, > I would like to use a formula inside a call to withReplicates in a survey > analysis. > If the initial call with formula expressed inside the function works as > expected, defining the formula outside gives an error m

[R] R Benchmarks

2013-06-28 Thread ivo welch
Dear R group: I just bought a Haswell i7-4770k machine, so I went through the trouble of creating a small website with some comparative benchmarks. I also made it easy for others to contribute benchmarks. if you are interested, it's all at http://R.ivo-welch.info/ . enjoy. /iaw Ivo Welch (

Re: [R] Lexical scoping is not what I expect

2013-06-28 Thread John Fox
Dear Brian, > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Prof Brian Ripley > Sent: Friday, June 28, 2013 11:16 AM > To: r-help@r-project.org > Subject: Re: [R] Lexical scoping is not what I expect > > On 28/06/2013 15:54,

[R] use of formula in survey analysis with replicated weights

2013-06-28 Thread LE TERTRE Alain
Hi there, I would like to use a formula inside a call to withReplicates in a survey analysis. If the initial call with formula expressed inside the function works as expected, defining the formula outside gives an error message. See example below, adapted from survey:withReplicates help page. li

Re: [R] Lexical scoping is not what I expect

2013-06-28 Thread John Fox
Dear Duncan, I think that it's reasonable to make a distinction between symbols representing functions and those representing built-in constants, even if, as in the case of pi and T (and letters, etc.), the latter are technically implemented as variables. Although it may be natural to use the va

Re: [R] How to create a function returning an array ?

2013-06-28 Thread Kaptue Tchuente, Armel
Your comments #2 and 3 are correct. The closing brace is missing and. Normally the end of the pr after the instruction For the comment #1 relate to the declaration img, I don't know if there is another way to import data from fortran in R. Armel -Original Message- From: Duncan Murdoch

Re: [R] Lexical scoping is not what I expect

2013-06-28 Thread Prof Brian Ripley
On 28/06/2013 15:54, John Fox wrote: Dear Duncan and Steve, Since Steve's example raises it, I've never understood why it's legal to change the built-in global "constants" in R, including T and F. That just seems to me to set a trap for users. Why not treat these as reserved symbols, like TRUE,

Re: [R] Lexical scoping is not what I expect

2013-06-28 Thread Duncan Murdoch
On 28/06/2013 10:54 AM, John Fox wrote: Dear Duncan and Steve, Since Steve's example raises it, I've never understood why it's legal to change the built-in global "constants" in R, including T and F. That just seems to me to set a trap for users. Why not treat these as reserved symbols, like TRU

Re: [R] Lexical scoping is not what I expect

2013-06-28 Thread John Fox
Dear Duncan and Steve, Since Steve's example raises it, I've never understood why it's legal to change the built-in global "constants" in R, including T and F. That just seems to me to set a trap for users. Why not treat these as reserved symbols, like TRUE, Inf, etc.? Best, John > -Origina

Re: [R] How to create a function returning an array ?

2013-06-28 Thread Duncan Murdoch
On 28/06/2013 10:46 AM, Kaptue Tchuente, Armel wrote: Please could you explain what you mean by several typos in my code? 1. img is passed as an argument, but never used. 2. There is no closing brace on the function body. 3. You set the dimension to n*m, when I believe you wanted c(n, m). Dun

Re: [R] How to create a function returning an array ?

2013-06-28 Thread Kaptue Tchuente, Armel
Please could you explain what you mean by several typos in my code? Anyway, it works very well and keep in minds that here I just wrote a very simple code to illustrate what I really want since in the reality, the program is more complex than what you see. May be I'm wrong but I also prefer to c

Re: [R] How to create a function returning an array ?

2013-06-28 Thread Duncan Murdoch
On 28/06/2013 10:18 AM, Kaptue Tchuente, Armel wrote: @ Duncan, I have already used the syntax that you proposed before asking for help by writing something like > read_ts<-function(n,m,img) { > out<-.Fortran("read_ts", >as.integer(n), >as.integer(m), >

Re: [R] How to create a function returning an array ?

2013-06-28 Thread Kaptue Tchuente, Armel
@ Duncan, I have already used the syntax that you proposed before asking for help by writing something like > read_ts<-function(n,m,img) { > out<-.Fortran("read_ts", >as.integer(n), >as.integer(m), >img=as.single(rnorm(n*m))) > return(out$img) > al

Re: [R] Data Package Query

2013-06-28 Thread Jeff Newmiller
You need to learn to execute one statement at a time in order to debug this yourself. Copy and paste is your friend. Hint: I already told you that the data function is inappropriate if the data does not come from a package. You should be learning to use the str(), head(), and ls() functions to e

Re: [R] Help with tables

2013-06-28 Thread arun
HI, May be this helps: dat1<- read.table(text=" date1 time  date    timeSec topic pupilId correct 02/01/2013 14:58 02/01/2013 140323 fdp.fdp 40 TRUE 02/01/2013 14:59 02/01/2013 140372 fdp.fdp 150 TRUE 03/01/2013 11:23 03/01/2013 213833 fdp.percentage_calc_foundation 15 TRUE 03/0

Re: [R] Lexical scoping is not what I expect

2013-06-28 Thread Duncan Murdoch
On 28/06/2013 9:28 AM, S Ellison wrote: > > I too find R's lexical scoping rules straightforward. > > However, I'd say that if your code relies on lexical > > scoping to find something, you should probably rewrite your code. > > Except of course that almost every function relies on lexical > s

Re: [R] Lexical scoping is not what I expect

2013-06-28 Thread S Ellison
> > I too find R's lexical scoping rules straightforward. > > However, I'd say that if your code relies on lexical > > scoping to find something, you should probably rewrite your code. > > Except of course that almost every function relies on lexical > scoping to some extent! This could get m

Re: [R] choicemodelr is misbehaving under R3.0

2013-06-28 Thread John Kane
I have encountered what looks to be a problem with ggpairs in ggally. No idea it is from 3.0 as I had never used ggpairs before update to 3.0 but it sounds a bit similar http://support.rstudio.org/help/discussions/problems/6796-ggpairs-in-ggally-very-slow-in-rstudio-and-may-cause-a-crash John Ka

Re: [R] How to create a function returning an array ?

2013-06-28 Thread Duncan Murdoch
On 27/06/2013 11:38 PM, David Winsemius wrote: On Jun 27, 2013, at 8:04 PM, Kaptue Tchuente, Armel wrote: > Hi there, > > I would like to know how to change the line "img=as.single(rnorm(m)))" such that instead of being a vector of length m as it is now, img is an array of dimension c=(n,m,o)

Re: [R] choicemodelr is misbehaving under R3.0

2013-06-28 Thread Dimitri Liakhovitski
Dear R-studio and R colleagues, I've interacted with the authors of the package "ChoiceModelR" and it looks like there is a problem in the way RStudio interacts with R3.0. At least the package ChoiceModelR works just fine under both R gui and Rstudio when R version is < 3.0 When R3.0 is tested -

Re: [R] Changing legend to fill colour in ggplot

2013-06-28 Thread John Kane
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example While the str() data is useful it is much better to provide real sample data. Use dput() to supply it. If it is a large file send a sample head(dput(df, "somenumber)) with somenumber just enough to provide

Re: [R] multiple csv files for T-test

2013-06-28 Thread arun
HI, According to ?t.test() documentation If ‘paired’ is ‘TRUE’ then both ‘x’ and ‘y’ must be specified and they must be the same length.  Missing values are silently removed (in pairs if ‘paired’ is ‘TRUE’) #Example with missing values set.seed(24) dat1<- as.data.frame(matrix(sample(c(NA

Re: [R] Scatter plot with error bars

2013-06-28 Thread beginner
Thank you very much for your help ! -- View this message in context: http://r.789695.n4.nabble.com/Scatter-plot-with-error-bars-tp4670502p4670530.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https

Re: [R] multivariate version of aggregate

2013-06-28 Thread arun
Hi,  set.seed(45)  testframe <- data.frame(a=rnorm(100), b = rnorm(100))  indices  <- rep(c(1,2), each = 50) library(plyr) ddply(testframe,.(indices),summarize, Cor1=cor(a,b)) #  indices Cor1 #1   1  0.002770524 #2   2 -0.10173 A.K. - Original Message - From: J

Re: [R] multivariate version of aggregate

2013-06-28 Thread Jannis
Thanks a lot to everybody who responded! My solution now looks similar to Ruis and Davids suggestions. Jannis On 28.06.2013 11:00, Rui Barradas wrote: Hello, You can solve your problem using only base R, with no need for an external package. The two instrucitons below are two ways of doing

Re: [R] multivariate version of aggregate

2013-06-28 Thread Rui Barradas
Hello, You can solve your problem using only base R, with no need for an external package. The two instrucitons below are two ways of doing the same. sapply(split(testframe, indices), function(x) cor(x[, 1], x[, 2])) as.vector(by(testframe, indices, function(x) cor(x[, 1], x[, 2]))) Hope

Re: [R] multivariate version of aggregate

2013-06-28 Thread Jannis
Yes, I had a look at that function. From the documentation, however, it did not get clear to me how to split the dataframe into subsets of rows based on an index argument. Like: testframe <- data.frame(a=rnorm(100), b = rnorm(100)) indices <- rep(c(1,2), each = 50) results <- ddply(.dat