[R] Kite Diagrams

2013-08-04 Thread Ruth Chan
Dear R help, I would like to teach my students to do a simple kite diagram with some simulated data. I have these columns: *Forest.Type* *Altitude.percent* *Total* Primary 20 827 Primary 20 917 Primary 10 946 Primary 10 516 Primary 1 775 Primary 1 777 Secondary 20 22

[R] Avoiding slow for-loops (once again)

2013-08-04 Thread Kulupp
# Dear R-experts, # (Once again) I want to avoid the usage of for-loops but unfortunately I don't know how. # I know functions like e.g. 'apply' but don't know how to use them for the solution of the following problem: # I have a data frame 'a' giving the number of columns in data frame 'b' th

[R] obtain triplets from Data Frame columns

2013-08-04 Thread PQuery
Hi Guys, I have a list elements in two columns of a data frame. I want first to subselect on V1 and then to form and count all possible and unique triplets of V1 with the corresponding elements in V2 but exclude triplets for which a pair (V1 V2) does not exists: Example input V1 V2 AB A

[R] Having problem with forecast.Arima() function

2013-08-04 Thread Salaam Batur
Dear R users, I am having a problem using forecast.Arima fuction. Here is the whole code: d=scan("D:/Data.txt") d D=ts(data=d, start=1981,end=2012, frequency=1) D Time Series: Start = 1981 End = 2012 Frequency = 1 [1] 384 403 427 450 499 550 575 615 640 680 702 730 760 790 [15] 79

Re: [R] cannot base64decode string which is base64encode in R

2013-08-04 Thread Qiang Wang
Thanks for your reply! Sorry I did not clarify that I was using base64encode and base64decode functions provide from "caTools" package. It seems that if I convert the string to the raw type first, it still solves my problem. My original problem actually is that I have a string: secret <- '5Kwug+B

Re: [R] Variable panel sizes in box plot

2013-08-04 Thread Aziz, Muhammad Fayez
Hi Jim, Your example works perfectly. Any possibility that the sizing could be automated. I am using bwplot. I can also use a prepanel function if needed. Please find attached the code, data and output. Fayez From: Jim Lemon [j...@bitwrit.com.au] Sent:

Re: [R] Variable panel sizes in box plot

2013-08-04 Thread Aziz, Muhammad Fayez
Hi Jeff, Thank you for your response. Pardon my lapse. Please find attached the code, data and output. I have used bwplot. Fayez From: Jeff Newmiller [jdnew...@dcn.davis.ca.us] Sent: Sunday, August 04, 2013 5:29 PM To: Aziz, Muhammad Fayez; r-help@r-pro

Re: [R] Variable panel sizes in box plot

2013-08-04 Thread Jim Lemon
On 08/05/2013 08:01 AM, Aziz, Muhammad Fayez wrote: Hi, My question is how to make panel sizes variable in box plots. I mean if a panel has 10 box plots and another has only two, I need to make the later panel thinner than the first. Hi Fayex, Try this: xdat<-data.frame(a=rnorm(100),b=rnor

Re: [R] Variable panel sizes in box plot

2013-08-04 Thread Jeff Newmiller
There are a variety of ways to make box plots (e.g. base graphics, lattice, and ggplot2). As the message footer says, you should be reading the Posting Guide and providing a reproducible example (with sample data). --- Jeff N

Re: [R] Internalization of help pages

2013-08-04 Thread Rolf Turner
On 05/08/13 03:15, John Kane wrote: (In a discussion on translating R help pages into other languages.) Personally I'd like to see the help tranlated into English too. Fortune nomination. cheers, Rolf Turner __ R-help@r-project.org m

Re: [R] R-help Digest, Vol 126, Issue 6

2013-08-04 Thread Aziz, Muhammad Fayez
Hi, My question is how to make panel sizes variable in box plots. I mean if a panel has 10 box plots and another has only two, I need to make the later panel thinner than the first. Regards, Fayez Grad Student UIUC, USA __ R-help@r-project.org mailing

[R] Variable panel sizes in box plot

2013-08-04 Thread Aziz, Muhammad Fayez
Hi, My question is how to make panel sizes variable in box plots. I mean if a panel has 10 box plots and another has only two, I need to make the later panel thinner than the first. Regards, Fayez Grad Student UIUC, USA __ R-help@r-project.org mailin

Re: [R] fortran random number

2013-08-04 Thread Simon Zehnder
Hi Filippo, I would advice you to use the RcppArmadillo package - maybe in combination with the inline package. It is extremely fast and very flexible. A simple RNGScope() lets you take the RNG from R. I myself programmed an MCMC sampler with this package and it is much faster, than the one I h

Re: [R] fortran random number

2013-08-04 Thread Prof Brian Ripley
On 04/08/2013 21:38, Filippo wrote: Hi, I need an advice. I'm writing a Markov Chain Monte Carlo subroutine in F95 which should be called from R. I noticed that the subroutine RANDOM_NUMBER takes the seed from R (is that correct?). It is not correct. I was wondering if is better initialize th

Re: [R] why my R^2 is so small while there do seem to be a dependency there?

2013-08-04 Thread Bert Gunter
The model given, ~0 +factor, omitted an intercept. R^2 is meaningless without an intercept. Further discussion should go to a statistics list like stats.stackexchange.com, as these are statistics, not R, issues. Cheers, Bert On Sun, Aug 4, 2013 at 1:41 PM, Rui Barradas wrote: > Hello, > > Hoe d

Re: [R] why my R^2 is so small while there do seem to be a dependency there?

2013-08-04 Thread Rui Barradas
Hello, Hoe did you get 0.002? Can you ?dput your data? d <- read.table(text = " factor observation -0.003 -2 -0.002 -2 -0.001 -1 0.000 1 0.001 0 0.002 1 0.003 2 ", header = TRUE) fit <- lm(observation ~ 0 + factor, data = d) summary(fit) # R2

[R] fortran random number

2013-08-04 Thread Filippo
Hi, I need an advice. I'm writing a Markov Chain Monte Carlo subroutine in F95 which should be called from R. I noticed that the subroutine RANDOM_NUMBER takes the seed from R (is that correct?). I was wondering if is better initialize the random seed inside the F95 subroutine or use the R seed

Re: [R] question: data.frame data conversion

2013-08-04 Thread arun
You could also try: z$id<-with(z,ave(x,x,FUN=seq)) library(reshape2) dcast(z,id~x,value.var="y")[-1] #    a    b  c #1 1.0 1.01  2 #2 1.2 1.03  3 #3 1.1 1.00 NA A.K. - Original Message - From: Rui Barradas To: Brijesh Gulati Cc: r-help@r-project.org Sent: Sunday, August 4, 2013 3:47

Re: [R] question: data.frame data conversion

2013-08-04 Thread Brijesh Gulati
Hello Rui: Thanks for the solution. It does work to the specification. Just one follow-up. I get an error if the number of repeating values are different. For instance, in the following example, "c" is repeated only 2 times; whereas "a" and "b" three times. I am fine with the output shows NA for th

Re: [R] Converting string to date

2013-08-04 Thread arun
HI, May be this helps:  MyString1 <- c("Sun Sep 01 00:20:00 EDT 2013", "Sun Dec 01 00:00:00 EST 2013")  as.POSIXct(gsub("EDT|EST","",MyString1), format="%a %b %d %H:%M:%S  %Y") #[1] "2013-09-01 00:20:00 EDT" "2013-12-01 00:00:00 EST" as.Date(gsub("EDT|EST","",MyString1), format="%a %b %d %H:%M:%S

Re: [R] question: data.frame data conversion

2013-08-04 Thread arun
Hi Brijesh, No problem. z<- data.frame(x,y,stringsAsFactors=FALSE)  v1<-max(with(z,tapply(x,list(x),length)))  res<-data.frame(lapply(split(z[,-1],z$x),function(.x) {x1<-if(length(.x)!=v1) c(.x,rep(NA,v1-length(.x))) else .x;x1} )) res #    a    b  c #1 1.0 1.01  2 #2 1.2 1.03  3 #3 1.1 1.00 NA

Re: [R] question: data.frame data conversion

2013-08-04 Thread arun
Hi, May be: z<-data.frame(x,y,stringsAsFactors=FALSE)  simplify2array(split(z[,-1],z$x)) #   a    b #[1,] 1.0 1.01 #[2,] 1.2 1.03 #[3,] 1.1 1.00  as.data.frame(simplify2array(split(z[,-1],z$x))) A.K. - Original Message - From: Brijesh Gulati To: r-help@r-project.org Cc: Sent: Su

Re: [R] question: data.frame data conversion

2013-08-04 Thread arun
#actually, this would be more compact data.frame(split(z[,-1],z$x)) A.K. - Original Message - From: arun To: Brijesh Gulati Cc: R help Sent: Sunday, August 4, 2013 1:27 PM Subject: Re: [R] question: data.frame data conversion Hi, May be: z<-data.frame(x,y,stringsAsFactors=FALSE)  s

[R] why my R^2 is so small while there do seem to be a dependency there?

2013-08-04 Thread CHEN, Cheng
Hi gurus! What I need to do is to find a model, which can predict what the * observation* should look like given a *factor* input. i am doing a simple linear fit in R: lm(observation~0+factor, data=d), the R^2 is 0.002, which is really small. however, when I do a 'SELECT AVG observation by 0.00

Re: [R] question: data.frame data conversion

2013-08-04 Thread Brijesh Gulati
Wow... great and really compact solution. One follow-up question. How do I solve the problem if the number of repeating values are different. For instance, in the following "z", the data value "a" and "b" are repeating 3 times, but "c" is only repeating 2 times. Hence, I will get an error. I am fin

Re: [R] Fwd: (nonparametric) Copula density estimation

2013-08-04 Thread Jeff Newmiller
Perhaps she forgot that you have to call the function by putting parentheses and arguments after the function name. --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#.

Re: [R] import function without overwriting function with the same name

2013-08-04 Thread Michael Friendly
On 03/08/2013 10:27 PM, Martin Batholdy wrote: I have to import multiple R-files. Each file consists of several functions with the same function name across the R-files. When I import all files one by one (with source()) I overwrite the function definition of the previous file until only the v

Re: [R] Converting string to date

2013-08-04 Thread Jeff Newmiller
On Sun, 4 Aug 2013, Ron Michael wrote: Hi,   I want to convert following string to a Date format (mm/dd/):   MyString <- c("Sun Sep 01 00:00:00 EDT 2013", "Sun Dec 01 00:00:00 EST 2013")   Can somebody point me if it is possible to do that? I think the answer to "is it possible" is a quali

Re: [R] question: data.frame data conversion

2013-08-04 Thread Rui Barradas
Hello, You're insisting in as.data.frame(cbind(...)). Don't do that. Just see the difference: z = data.frame(x, y) str(z) 'data.frame': 8 obs. of 2 variables: $ x: Factor w/ 3 levels "a","b","c": 1 1 1 2 2 2 3 3 $ y: num 1 1.2 1.1 1.01 1.03 1 2 3 z2 = as.data.frame(cbind(x,y)) str(z2) '

Re: [R] question: data.frame data conversion

2013-08-04 Thread Rui Barradas
Hello, First of all, do _not_ create a data frame with as.data.frame(cbind(...)) Instead, use z = data.frame(x, y) As for your question, try the following. library(reshape2) fun <- function(z){ zs <- split(z, x) n <- length(zs) m <- nrow(zs[[1]]) zz <- cbind(

[R] question: data.frame data conversion

2013-08-04 Thread Brijesh Gulati
Hello, I have a data.frame with repeating rows and corresponding value. For instance, "z" will be an example of that. x = c("a","a", "a", "b","b","b") y = c(1.0, 1.2, 1.1, 1.01, 1.03, 1.0) z = as.data.frame(cbind(x,y)) > z xy 1 a1 2 a 1.2 3 a 1.1 4 b 1.01 5 b 1.03

[R] Converting string to date

2013-08-04 Thread Ron Michael
Hi,   I want to convert following string to a Date format (mm/dd/):   MyString <- c("Sun Sep 01 00:00:00 EDT 2013", "Sun Dec 01 00:00:00 EST 2013")   Can somebody point me if it is possible to do that?   Thank you. __ R-help@r-project.org mailing lis

Re: [R] Fwd: (nonparametric) Copula density estimation

2013-08-04 Thread David Winsemius
That instance of 's' is a function and you were offering it (multiplied by 5) as a data argument to the theta parameter of 'persp'. I can't intuit what your reasoning might have been because you haven't explained why you thought that would succeed. -- David Sent from my iPhone On Aug 3, 2013

Re: [R] How to replace NA values

2013-08-04 Thread Bert Gunter
... and learn to use the Help system to avoid wasting space on this list and wasting your time waiting for an answer. ?NA (what else?!) would have immediately gotten what you were looking for. Cheers, Bert On Sun, Aug 4, 2013 at 9:09 AM, William Revelle wrote: > Bruce, > use the is.na functi

Re: [R] How to replace NA values

2013-08-04 Thread William Revelle
Bruce, use the is.na function, e.g., Bats.cast[is.na(Bats.cast)] <- 0 Bill On Jul 28, 2013, at 8:12 AM, Bruce Miller wrote: > Hi all, > > I am using reshape2 to reformat a data frame and all is great using: > > Bats.melt <- melt(data = Bats) > > Bats.cast <- dcast(data = Bats.melt, formul

Re: [R] Internalization of help pages

2013-08-04 Thread John Kane
I tried it in French and there a few hiccups but it's not too bad. Personally I'd like to see the help tranlated into English too.l John Kane Kingston ON Canada > -Original Message- > From: j...@bitwrit.com.au > Sent: Sun, 04 Aug 2013 10:28:42 +1000 > To: tomas.gr...@collectionspro.eu

Re: [R] import function without overwriting function with the same name

2013-08-04 Thread Bert Gunter
Because that exposes the identically named functions and forces the user to sort them out, inviting mistakes, especially when trying to maintain/update them. My view is that one should try to program to make code as robust and maintainable as possible. Nevertheless, as I said, maybe this approach

Re: [R] Display plot in Browser

2013-08-04 Thread Rmh
look at the shiny package on CRAN. it is from RStudio Rich Sent from my iPhone On Aug 4, 2013, at 4:34, Christofer Bogaso wrote: > Hello again, > > I am exploring the option how I can display my plot (generated within R) in > Browser (like IE, Chrome). Obviously one option is with googleVis.

Re: [R] Simulation in R

2013-08-04 Thread Prof Brian Ripley
On 04/08/2013 09:30, Rui Barradas wrote: Hello, See the help page for ?sample. X <- sample(0:1, 1, replace = TRUE, prob = c(0.25, 0.75)) Hope this helps, ?rbinom would have been a better answer since simpler, faster, algorithms are available in that case. Or even as.integer(runif(100

Re: [R] Simulation in R

2013-08-04 Thread Preetam Pal
Thank you very much guys On Sun, Aug 4, 2013 at 3:51 PM, Prof Brian Ripley wrote: > On 04/08/2013 09:30, Rui Barradas wrote: > >> Hello, >> >> See the help page for ?sample. >> >> X <- sample(0:1, 1, replace = TRUE, prob = c(0.25, 0.75)) >> >> Hope this helps, >> > > ?rbinom would have been

Re: [R] Display plot in Browser

2013-08-04 Thread Prof Brian Ripley
On 04/08/2013 09:34, Christofer Bogaso wrote: Hello again, I am exploring the option how I can display my plot (generated within R) in Browser (like IE, Chrome). Obviously one option is with googleVis. However in that case I need to have internet access to display. What are other choices availa

Re: [R] Display plot in Browser

2013-08-04 Thread Jim Lemon
On 08/04/2013 06:34 PM, Christofer Bogaso wrote: Hello again, I am exploring the option how I can display my plot (generated within R) in Browser (like IE, Chrome). Obviously one option is with googleVis. However in that case I need to have internet access to display. What are other choices ava

Re: [R] Method dispatch in S4

2013-08-04 Thread Simon Zehnder
So, I found a solution: First in the "initialize" method of class C coerce the C object into a B object. Then call the next method in the list with the B class object. Now, in the "initialize" method of class B the object is a B object and the respective "generateSpec" method is called. Then, in

Re: [R] Simulation in R

2013-08-04 Thread Jeff Newmiller
So you looked at some unspecified help pages online and tried some unspecified stuff? Try being more specific next time you post. For example, try reading the footer of any R-help email. Note that it says read the Posting Guide, and provide a reproducible example (at least of what you tried that

[R] Display plot in Browser

2013-08-04 Thread Christofer Bogaso
Hello again, I am exploring the option how I can display my plot (generated within R) in Browser (like IE, Chrome). Obviously one option is with googleVis. However in that case I need to have internet access to display. What are other choices available? Thanks for your pointer. Thanks and regar

Re: [R] Simulation in R

2013-08-04 Thread Rui Barradas
Hello, See the help page for ?sample. X <- sample(0:1, 1, replace = TRUE, prob = c(0.25, 0.75)) Hope this helps, Rui Barradas Em 04-08-2013 08:51, Preetam Pal escreveu: Hi All, I want to simulate a random variable X which takes values 1 and 0 with probabilities 75% and 25% respectively

Re: [R] Internalization of help pages

2013-08-04 Thread Jim Lemon
On 08/04/2013 03:34 PM, Berend Hasselman wrote: ... I had a go with Google Translate and translated into Dutch. The result is terrible. Garbage. Laughable. It also translated R function names in the examples and some of the Rd directives. And look at the last line and admire what Google Transla

Re: [R] descriptive stats by cells in factorial design

2013-08-04 Thread Mike Miller
Summary of my question: "I have a 5-way factorial design, two levels per factor, so 32 cells, and I mostly just want the means and standard deviations for the contents of every cell. Similarly, it would be nice to also have the range and maybe some percentiles, if there is a function that wou

[R] Simulation in R

2013-08-04 Thread Preetam Pal
Hi All, I want to simulate a random variable X which takes values 1 and 0 with probabilities 75% and 25% respectively and then repeat the procedure 1 times. I am sure this is trivial, I tried to look at the help pages online, but I can't quite find it. Appreciate your help. Thanks and Reg