Re: [R] minimizing a numerical integration

2013-02-16 Thread Hans W Borchers
Dear all, I am a new user to R and I am using pracma and nloptr libraries to minimize a numerical integration subject to a single constraint . The integrand itself is somehow a complicated function of x and y that is computed through several steps. i formulated the integrand in a separate

[R] Creating a Double Bar Graph With Provided DataSet

2013-02-16 Thread Brian Ngo
To the volunteers of R-Help. Hello, I am currently stuck on an RStudio assignment. The assignment involves creating a double bar graph with the provided info http://math.fullerton.edu/mori/data/introstats/pennstate3.txt My professor has only gone over the very basics of RStudio and we only

Re: [R] data formatting

2013-02-16 Thread arun
Dear Eliza, Thank you for testing the code.  Sorry, it was a mistake. I created one more file Eliza3.txt (attached) Try this. library(stringr) lapply(list.files(),function(i) str_count(gsub( $,,readLines(i)), ))  #[[1]] # [1] 7 7 7 7 6 7 7 7 7 7 6 6 7 7 7 7 6 7 7 7 7 7 6 6 #[[2]] # [1] 7 7 7 7

Re: [R] subplot (Hmisc) and radial.plot (plotrix) problem

2013-02-16 Thread Jim Lemon
On 02/16/2013 05:30 PM, Andrew Roberts wrote: Folks, I am having problems with a plot I want to create to give an impression of changes in an ordinal scale measure (1-5) at three time points (0, 14 and 21 days). I can produce a radial plot of bare vectors but getting this to appear on the base

Re: [R] odd behavior within R2HTML

2013-02-16 Thread Milan Bouchet-Valat
Le vendredi 15 février 2013 à 20:52 -0600, Erin Hodgess a écrit : Dear R People: I'm using R2HTML but having a strange result. Here is the original data: resp trt block 90.3 A I 89.2 A II 98.2 A III 93.9 A IV 87.4 A V 97.9 A VI 92.5 B I 89.5 B II 90.6 B III 94.7 B IV 87.0 B V

Re: [R] Creating a Double Bar Graph With Provided DataSet

2013-02-16 Thread David Winsemius
On Feb 15, 2013, at 11:31 PM, Brian Ngo wrote: To the volunteers of R-Help. Hello, I am currently stuck on an RStudio assignment. The assignment involves creating a double bar graph with the provided info http://math.fullerton.edu/mori/data/introstats/pennstate3.txt My professor has only

Re: [R] Creating a Double Bar Graph With Provided DataSet

2013-02-16 Thread Rmh
You could use the likert plot in the HH package. Look particulsrly at the population pyramid example. Sent from my iPhone On Feb 16, 2013, at 2:31, Brian Ngo brianng...@csu.fullerton.edu wrote: To the volunteers of R-Help. Hello, I am currently stuck on an RStudio assignment. The

Re: [R] Creating a Double Bar Graph With Provided DataSet

2013-02-16 Thread Ista Zahn
On Sat, Feb 16, 2013 at 10:21 AM, Rmh r...@temple.edu wrote: You could use the likert plot in the HH package. Look particulsrly at the population pyramid example. Or better yet, ask your professor! Sent from my iPhone On Feb 16, 2013, at 2:31, Brian Ngo brianng...@csu.fullerton.edu

Re: [R] Creating a Double Bar Graph With Provided DataSet

2013-02-16 Thread John Kane
No solution since it is a school work exercise but some hints: First read the barplot help. Enter ?barplot to bring it up. I find it best to Then have a look at ?par specifically the mfcol, mfrow entry. Also just google for something like R statistics barplot color / colour and so on

[R] Handling NA values

2013-02-16 Thread Christofer Bogaso
Hello again, I have a question on who sum() handle the NA values. sum(c(NA, 1), na.rm = TRUE) [1] 1 I understand this. However could not agree with following: sum(c(NA, NA), na.rm = TRUE) [1] 0 Where this '0' is coming from? Should not it be NA itself? Thanks and regards,

Re: [R] Handling NA values

2013-02-16 Thread Marc Schwartz
On Feb 16, 2013, at 11:55 AM, Christofer Bogaso bogaso.christo...@gmail.com wrote: Hello again, I have a question on who sum() handle the NA values. sum(c(NA, 1), na.rm = TRUE) [1] 1 I understand this. However could not agree with following: sum(c(NA, NA), na.rm = TRUE) [1] 0

Re: [R] Handling NA values

2013-02-16 Thread Berend Hasselman
On 16-02-2013, at 18:55, Christofer Bogaso bogaso.christo...@gmail.com wrote: Hello again, I have a question on who sum() handle the NA values. sum(c(NA, 1), na.rm = TRUE) [1] 1 I understand this. However could not agree with following: sum(c(NA, NA), na.rm = TRUE) [1] 0

Re: [R] Handling NA values

2013-02-16 Thread Christofer Bogaso
Thanks Marc for your reply. However this leads to my problem of handling rowSums() function (hence colSums()). Let take following matrix: Mat - matrix(c(1, 1, NA, -1, 1, NA, NA, 1, NA), nc = 3) Mat [,1] [,2] [,3] [1,]1 -1 NA [2,]111 [3,] NA NA NA rowSums(Mat,

Re: [R] MIMIC latent variable with PLS Path Modelling with R ?

2013-02-16 Thread Jeremy Miles
By MIMIC do you mean multiple indicator/multiple cause? Something like this: http://www.jeremymiles.co.uk/misc/fun/img059.gif If so, you can use sem, Lavaan, or openMx. Jeremy On 13 February 2013 05:11, Hervé Guyon herve.gu...@yahoo.fr wrote: I want estimate MIMIC latent variable with R

Re: [R] Misundertanding of Levels

2013-02-16 Thread David Arnold
I am replying so that this will be accepted by the list. D. -- View this message in context: http://r.789695.n4.nabble.com/Misundertanding-of-Levels-tp4658320p4658781.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] Handling NA values

2013-02-16 Thread Marc Schwartz
Nothing comes to mind immediately for rowSums() or colSums() given the way in which they handle things, however using apply() you have more flexibility, albeit at the price of some speed: apply(Mat, 1, function(x) if (all(is.na(x))) NA else sum(x, na.rm = TRUE)) [1] 0 3 NA Essentially, if

[R] Extracting Numeric Columns from Data Fram

2013-02-16 Thread Barry DeCicco
Hello, I've got a data frame with a mix of numeric, integer and factor columns. I'd like to pull out (or just operate only on) the numeric/integer columns. Every thing I've found in searches is about how to subset by rows, or how to operate assuming you have the column names.  I'd like to pull by

Re: [R] How to stack row vector on top of each other?

2013-02-16 Thread Uwe Ligges
On 15.02.2013 16:37, Giovanni Petris wrote: How about c(a, b) But then, if he is actually going to have a row vector, t() is needed - and one may want to answer the OP who may not read this list Best, Uwe Ligges ? HTH, Giovanni From:

Re: [R] Extracting Numeric Columns from Data Fram

2013-02-16 Thread Marc Schwartz
On Feb 16, 2013, at 12:15 PM, Barry DeCicco bdecicco2...@yahoo.com wrote: Hello, I've got a data frame with a mix of numeric, integer and factor columns. I'd like to pull out (or just operate only on) the numeric/integer columns. Every thing I've found in searches is about how to subset by

Re: [R] Extracting Numeric Columns from Data Fram

2013-02-16 Thread Phil Spector
Barry = Suppose your data frame is called mydat. Then something like mydat[,sapply(mydat,class) %in% c('numeric','integer')] might do what you want. - Phil On Sat, 16 Feb 2013, Barry DeCicco wrote: Hello, I've got a data frame

Re: [R] Extracting Numeric Columns from Data Fram

2013-02-16 Thread John Kane
http://stackoverflow.com/questions/5863097/selecting-only-numeric-columns-from-a-data-frame John Kane Kingston ON Canada -Original Message- From: bdecicco2...@yahoo.com Sent: Sat, 16 Feb 2013 10:15:35 -0800 (PST) To: r-help@r-project.org Subject: [R] Extracting Numeric Columns from

Re: [R] two dimensional integration

2013-02-16 Thread Rui Barradas
Hello, Though I think you should compute that integral symbolically by hand and then define a function with the result, maybe package pracma can do what you want. [functions dblquad(9 and quad2d()] Hope this helps, Rui Barradas Em 16-02-2013 17:01, julia cafnik escreveu: Dear R-users,

Re: [R] Misundertanding of Levels

2013-02-16 Thread David Winsemius
On Feb 16, 2013, at 10:25 AM, David Arnold wrote: I am replying so that this will be accepted by the list. I don't think you achieved your goal. Some posting from Nabble are never accepted. A couple of months ago the spam filters were tightened (in response to a robotic mediated mass forgery

Re: [R] Extracting Numeric Columns from Data Fram

2013-02-16 Thread Rui Barradas
Hello, You should provide us with a data example, like the posting guide says. Anyway, see the following example. # make up some data dat - data.frame(X = 1:4, Y = rnorm(4), Z = letters[1:4]) str(dat) # this returns the numeric/integer columns dat[sapply(dat, is.numeric)] Hope this helps,

Re: [R] two dimensional integration

2013-02-16 Thread David Winsemius
On Feb 16, 2013, at 9:01 AM, julia cafnik wrote: Dear R-users, I'm wondering how to calculate this double integral in R: int_a^b int_c^y g(x, y) dx dy where g(x,y) = exp(- alpha (y - x)) * b Thanks for answering! One way would be to install the cubature package. -- David

Re: [R] Extracting Numeric Columns from Data Fram

2013-02-16 Thread Barry DeCicco
Thanks to all who responded! I've taken those responses, and found out what works: myNumericColumns-mydataframe[sapply(mydataframe, is.numeric)] produces a subset of columns with just the numeric vectors. Sincerely, Barry [[alternative HTML version deleted]]

Re: [R] Extracting Numeric Columns from Data Fram

2013-02-16 Thread arun
Hi, set.seed(15) dat1-data.frame(col1=rnorm(6),col2=rep(1:2,each=3),col3=rep(letters[1:3],2),col4=runif(6),col5=rep(LETTERS[3:5],2)) dat1[,sapply(dat1,class)!=factor] #    col1 col2  col4 #1  0.2588229    1 0.5090904 #2  1.8311207    1 0.7066286 #3 -0.3396186    1 0.8623137 #4  0.8971982   

Re: [R] Handling NA values

2013-02-16 Thread arun
Hi, Try this: ifelse(rowSums(is.na(Mat))==ncol(Mat),NA,rowSums(Mat,na.rm=TRUE)) #[1]  0  3 NA A.K. - Original Message - From: Christofer Bogaso bogaso.christo...@gmail.com To: Marc Schwartz marc_schwa...@me.com Cc: r-help r-help@r-project.org Sent: Saturday, February 16, 2013 1:22 PM

Re: [R] reading data

2013-02-16 Thread arun
Hi, Try by putting quotes ie. res- do.call(c,...) A.K. From: Vera Costa veracosta...@gmail.com To: arun smartpink...@yahoo.com Sent: Saturday, February 16, 2013 7:10 PM Subject: Re: reading data Thank you. In mine, I have an error 'what' must be a

[R] detecting entry into a recursive function

2013-02-16 Thread Benjamin Tyner
Given a function that calls itself, what's the best way to detect the entry point? The best I came up with is: IsEntryPoint - function(){ par - sys.call(-1L)[[1]] grandpar - sys.call(-2L)[[1]] !identical(par, grandpar) } but this won't work for functions that don't directly

[R] tidy.source() gets confused when # is not a comment but a part of a literal string?

2013-02-16 Thread Andre Zege
I needed to clean someone else code and run it through tidy.source. It encountered a number of hangups which after some experimentation lead me to suspect that the culprit is # symbol when it is a part of literal string. For example if i copy the following to the clipboard confuse.tidy -   

Re: [R] tidy.source() gets confused when # is not a comment but a part of a literal string?

2013-02-16 Thread Yihui Xie
Please scroll down to Section 7: https://github.com/yihui/formatR/wiki And this has been reported at https://github.com/yihui/formatR/issues/26 I'll try to fix it after R 3.0 is released. Regards, Yihui -- Yihui Xie xieyi...@gmail.com Phone: 515-294-2465 Web: http://yihui.name Department of

Re: [R] Select components of a list

2013-02-16 Thread arun
Hi Gustav, Try this: lapply(1:length(models),function(i) lapply(models[[i]],function(x) summary(x)$coef[2,]))[[1]] #1st list component [[1]] #    Estimate   Std. Error  z value Pr(|z|) # pm10 #5.999185e-04 1.486195e-04 4.036606e+00 5.423004e-05 #[[2]] #    Estimate   Std. Error  z

Re: [R] Select components of a list

2013-02-16 Thread arun
HI Gustav, If you need the combined output: res-lapply(1:length(models),function(i) do.call(rbind,lapply(models[[i]],function(x) summary(x)$coef[row.names(summary(x)$coef)%in%c(pm10,ozone,so2),c(1:2,4)])))  names(res)-1:length(res) res1-do.call(rbind,lapply(res,function(i)

[R] Terapia para Bebés: Aprenda a ajudá-los

2013-02-16 Thread Almasoma
Se não pode visualizar este e-mail corretamente, clique aqui http://www.almasoma.pt/newsletter--terapia-para-bebes-aprenda-a-ajuda-los . http://www.almasoma.pt/ Formação em Terapia para Bebés Lisboa, Outono 2013 - Primavera 2016 Workshop: Baby Clinic, 6 e 7 de Abril de 2013

Re: [R] detecting entry into a recursive function

2013-02-16 Thread Jim Lemon
On 02/17/2013 12:55 PM, Benjamin Tyner wrote: Given a function that calls itself, what's the best way to detect the entry point? The best I came up with is: IsEntryPoint - function(){ par - sys.call(-1L)[[1]] grandpar - sys.call(-2L)[[1]] !identical(par, grandpar) } but this won't work for

Re: [R] cumulative sum by group and under some criteria

2013-02-16 Thread arun
do.call(rbind,lapply(2:3,function(m1) do.call(rbind,lapply(2:2,function(n1) do.call(rbind,lapply(0:(m1-1),function(x1) do.call(rbind,lapply(0:(n1-1),function(y1) expand.grid(m1,n1,x1,y1) #   Var1 Var2 Var3 Var4 #1 2    2    0    0 #2 2    2    0    1 #3 2    2    1    0 #4 

Re: [R] cumulative sum by group and under some criteria

2013-02-16 Thread arun
d2- data.frame() for (m1 in 2:3) {     for (n1 in 2:2) {     for (x1 in 0:(m1-1)) {     for (y1 in 0:(n1-1)) {         for (m in (m1+2): (7-n1)){           for (n in (n1+2):(9-m)){           for (x in x1:(x1+m-m1)){  d2- rbind(d2,c(m1,n1,x1,y1,m,n,x))  }}}