Re: [R] is.na behavior

2015-11-18 Thread Richard M. Heiberger
Maybe the way to rephrase my question is to ask why there is not an is.na.expression method that does that task for me? > is.na(as.list(expression("defg"))) [1] FALSE > is.na(expression("defg")) [1] FALSE Warning message: In is.na(expression("defg")) : is.na() applied to non-(list or vector) of

Re: [R] is.na behavior

2015-11-18 Thread Richard M. Heiberger
It is in context of determining if an input argument for a graph title is missing or null or na. In any of those cases the function defines a main title. If the incoming title is not one of those, then I use the incoming title. When the incoming title is an expression I see the warning. library(l

Re: [R] is.na behavior

2015-11-18 Thread William Dunlap
You can convert the expression to a list and use is.na on that: > e <- expression(1+NA, NA, 7, function(x)x+1) > is.na(as.list(e)) [1] FALSE TRUE FALSE FALSE and you can do the same for a call object > is.na(as.list(quote(func(arg1, tag2=NA, tag3=log(NA) tag2 tag3

Re: [R] is.na behavior

2015-11-18 Thread Richard M. Heiberger
David, Your answer begs the question. What is the problem with non-(list or vector) of type language. To my eye both expression(abcd) and call("mean") look like they have non-missing values, hence I anticipated that they are not NA, and therefore that is.na() would return FALSE without a warning.

Re: [R] is.na behavior

2015-11-18 Thread David Winsemius
> On Nov 18, 2015, at 5:54 PM, Richard M. Heiberger wrote: > > What is the rationale for the following warning in R-3.2.2? > >> is.na(expression(abcd)) > [1] FALSE > Warning message: > In is.na(expression(abcd)) : > is.na() applied to non-(list or vector) of type ‘expression’ Well, the R inte

[R] is.na behavior

2015-11-18 Thread Richard M. Heiberger
What is the rationale for the following warning in R-3.2.2? > is.na(expression(abcd)) [1] FALSE Warning message: In is.na(expression(abcd)) : is.na() applied to non-(list or vector) of type 'expression' [[alternative HTML version deleted]] __

Re: [R] [FORGED] How to find the likelihood, MLE and plot it?

2015-11-18 Thread Rolf Turner
On 19/11/15 11:31, C W wrote: Dear R list, I am trying to find the MLE of the likelihood function. I will plot the log-likelihood to check my answer. Here's my R code: xvec <- c(2,5,3,7,-3,-2,0) fn <- function(theta){ sum(0.5 * (xvec - rep(theta, 7)) ^ 2 / 1 + 0.5 * log(1)) } gn <- Vector

Re: [R] [FORGED] Problem running mvrnorm

2015-11-18 Thread Rolf Turner
On 19/11/15 10:54, Gang Chen wrote: Thanks a lot for the pointer, Rolf! You're correct that E <- eigen(Sigma,symmetric=TRUE) does lead to the same error on the RedHat machine. However, the same computation on my Mac works fine: E <- eigen(Sigma,symmetric=TRUE) E$values I used your cons

[R] How to find the likelihood, MLE and plot it?

2015-11-18 Thread C W
Dear R list, I am trying to find the MLE of the likelihood function. I will plot the log-likelihood to check my answer. Here's my R code: xvec <- c(2,5,3,7,-3,-2,0) fn <- function(theta){ sum(0.5 * (xvec - rep(theta, 7)) ^ 2 / 1 + 0.5 * log(1)) } gn <- Vectorize(fn) curve(gn, -5, 20) opti

Re: [R] [FORGED] Problem running mvrnorm

2015-11-18 Thread peter dalgaard
I have a sense of a tiny bell ringing faintly from the distant past... There may be an issue with some versions of BLAS/LAPACK on some systems showing up in eigendecompositions. Checking... hmm, there have been several issues over time but I don't see anything that would be directly related to

Re: [R] [FORGED] Problem running mvrnorm

2015-11-18 Thread Gang Chen
Thanks a lot for the pointer, Rolf! You're correct that E <- eigen(Sigma,symmetric=TRUE) does lead to the same error on the RedHat machine. However, the same computation on my Mac works fine: E <- eigen(Sigma,symmetric=TRUE) E$values [1] 4.6 2.6 2.6 2.6 2.6 2.6 2.6 2.6 2.6 2.6 2.6 2.6 2.6

Re: [R] Get means of matrix

2015-11-18 Thread Dennis Murphy
Hi: Here's another way to look at the problem. Instead of manually adding a new column after k datasets have been read in, read your individual data files into a list, as long as they all have the same variable names and the same class (in this case, data.frame). Then create a vector of names for

Re: [R] [FORGED] Problem running mvrnorm

2015-11-18 Thread Rolf Turner
I cobbled together a 190 x 190 positive definite matrix Sigma and ran your example. I got a result instantaneously, with no error message. (I'm running Linux; an ancient Fedora 17 system.) So the problem is peculiar to your particular Sigma. As the error message tells you, the problem comes

[R] Problem running mvrnorm

2015-11-18 Thread Gang Chen
I’m running R 3.2.2 on a Linux server (Redhat 4.4.7-16), and having the following problem. It works fine with the following: require('MASS’) var(mvrnorm(n = 1000, rep(0, 2), Sigma=matrix(c(10,3,3,2),2,2))) However, when running the following in a loop with simulated data (Sigma): # Sigma defin

Re: [R] SWEAVE - a gentle introduction

2015-11-18 Thread John Maindonald
What’s more, for pdf output one can use R Markdown and judiciously sneak in html and/or LaTeX (consider however what the processing steps might do to such markup). John Maindonald email: john.maindon...@anu.edu.au On 19/11/2015, at 00:00, r-help-

Re: [R] SWEAVE - a gentle introduction

2015-11-18 Thread Greg Snow
John, One additional point that I have not seen brought up yet. If your main goal is to have all the output from an existing R script put into a single output file then you should look at the `stitch` function in the knitr package. This will take an existing R script and convert it to one of the

[R] Glmnet penalty.factor with multigaussian response

2015-11-18 Thread Maria Vila Casadesús
Hi all, I'm trying to use glmnet with penalty factors in a multigaussian response model. In case of the gaussian response the input for penalty factors is a vector, but I haven't figured out how can I use penalty factors with a multigaussian response, and even if it's possible. I've tried to use a

[R] WGCNA cluster

2015-11-18 Thread Giovanni Calice
Hi all, I am using WGCNA for methylation level network construction e modules detection. In my network there are 26 modules with assigned colors and numeric labels, id. Which Is the best way to reassign different color to each module? How to know the elements associated to each colored module in

Re: [R] WGCNA cluster

2015-11-18 Thread Peter Langfelder
Hi Giovanni, please follow Tutorial I, section 3 (particularly 3d, "Summary output of network analysis results") at http://labs.genetics.ucla.edu/horvath/CoexpressionNetwork/Rpackages/WGCNA/Tutorials/index.html . This will show you how to output module membership of each CpG into a file. If you wa

Re: [R] Getting rid of unwanted csv files

2015-11-18 Thread Par Leijonhufvud
WRAY NICHOLAS [2015.11.18] wrote: > > I'd like to get shot of the junk files, but I can't distinguish them by > names/label from the ones I want to keep -- the only criterion is the date of > making them, but I cannot see a way of telling R to look at the date rather > than > the name/label Ob

Re: [R] SWEAVE - a gentle introduction

2015-11-18 Thread Therneau, Terry M., Ph.D.
As a digest reader I am late to the discussion, but let me toss in 2 further notes. 1. Three advantages of knitr over Sweave a. The book "Dynamic documents with R and knitr". It is well written; sitting down for an evening with the first half (70 pages) is a pretty good way to learn the pack

Re: [R] Getting rid of unwanted csv files

2015-11-18 Thread John Laing
?file.info On Wed, Nov 18, 2015 at 6:12 AM, WRAY NICHOLAS wrote: > Hi I have got a large folder with hundreds of csv files in it The > problem is > that some of them are junk, and I know which ones are junk because they > were > created on certain days, that is before I had honed the programme

[R] Getting rid of unwanted csv files

2015-11-18 Thread WRAY NICHOLAS
Hi I have got a large folder with hundreds of csv files in it The problem is that some of them are junk, and I know which ones are junk because they were created on certain days, that is before I had honed the programme generating them to ultimate perfection I'd like to get shot of the junk file

Re: [R] Get means of matrix

2015-11-18 Thread Jim Lemon
Hi Jesus, While I do not have your data and cannot test this, the problem may be that you are using two different names for the data frame. Is this more or less what you want? datos<-data.frame(x1=sample(20:40,40,TRUE),x2=sample(20:40,40,TRUE), x3=sample(20:40,40,TRUE),csvdata=rep(1:2,each=20)) s

Re: [R] Get means of matrix

2015-11-18 Thread PIKAL Petr
Hi See in line > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jesús > Para Fernández > Sent: Wednesday, November 18, 2015 11:20 AM > To: r-help@r-project.org > Subject: [R] Get means of matrix > > Hi everyone > > I have a dataframe "data" wich is th

[R] Get means of matrix

2015-11-18 Thread Jesús Para Fernández
Hi everyone I have a dataframe "data" wich is the result of join multiple csv (400 rows and 600cols every csv). The "data" dataframe has n rows and m columns (20 rows and 600 cols) , and I have add a new colum, "csvdata", in which I specify the number of csv at wich those data belong. So,

[R] R hist density wrong?

2015-11-18 Thread Luca Cerone
Dear all, this is probably a very naive question but I can't understand what hist() means by density. A very simple example: h <- hist(c(1,1,2,3), plot=F) h$counts [1] 2 1 0 1 h$density [1] 1.0 0.5 0.0 0.5 The counts are as I expect, but density is quite puzzling for me. I would have expected

Re: [R] R hist density wrong?

2015-11-18 Thread Duncan Murdoch
On 18/11/2015 3:49 AM, Luca Cerone wrote: Dear all, this is probably a very naive question but I can't understand what hist() means by density. A very simple example: h <- hist(c(1,1,2,3), plot=F) h$counts [1] 2 1 0 1 h$density [1] 1.0 0.5 0.0 0.5 The counts are as I expect, but density is q

Re: [R] Converting daily time series to monthly?

2015-11-18 Thread PIKAL Petr
Hi You can use various ways. I would recommend to look at ?aggregate together with cut ?cut.POSIXt. Your data shall be converted to POSIX type ?strptime before using them for cut and aggregate. Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On B