Re: [R] Publication-ready figures with two plots

2014-06-19 Thread ONKELINX, Thierry
Dear Adam, ggsave() works only with single ggplot object. You need the standard R way of saving those plots. 1) open a suitable device 2) plot the figures 3) close the device tiff(filename = Figure 1.tiff, scale = 1, width = 10, height = 5, units = cm, dpi = 300) grid.arrange(plot1, plot2,

[R] extract a subset of non-contiguous elements of a matrix

2014-06-19 Thread carol white
Hi, Is there a way to extract a subset of non-contiguous elements of a matrix elegantly and with 1 or very few scripts? Suppose I have a matrix of positive and negative numbers (m) and I want to retrieve only the positive number. This I can do which(m0, arr.ind=T) which gives the indices of

Re: [R] extract a subset of non-contiguous elements of a matrix

2014-06-19 Thread Bart Kastermans
On 19 Jun 2014, at 13:19, carol white wht_...@yahoo.com wrote: Hi, Is there a way to extract a subset of non-contiguous elements of a matrix elegantly and with 1 or very few scripts? Suppose I have a matrix of positive and negative numbers (m) and I want to retrieve only the positive

Re: [R] extract a subset of non-contiguous elements of a matrix

2014-06-19 Thread carol white
The extracted values don't form a matrix and that's the question how to extract because which returns the indexes? that is, from 1,1 2,1 1,2 how to retrieve values? Or if at the position 2,1, there is a negative value, how to retrieve 1,1 1,2 Carol On Thursday, June 19, 2014 1:29 PM, Bart

Re: [R] extract a subset of non-contiguous elements of a matrix

2014-06-19 Thread peter dalgaard
This _was_ in the answer you got, but to clarify things, perhaps try this: (M - matrix(1:9,3,3)) (ix - rbind(c(3,2),c(1,3))) M[3,2] M[1,3] M[ix] -pd On 19 Jun 2014, at 14:12 , carol white wht_...@yahoo.com wrote: The extracted values don't form a matrix and that's the question how to

Re: [R] extract a subset of non-contiguous elements of a matrix

2014-06-19 Thread Bart Kastermans
If you give an example of input and desired output I can think about this. But at this point I do not understand what you want. In the example I gave the positive elements do not form a submatrix in any way I can think of. On 19 Jun 2014, at 15:04, carol white wht_...@yahoo.com wrote: well

Re: [R] extract a subset of non-contiguous elements of a matrix

2014-06-19 Thread carol white
 tm.1=rbind(c(1,-3,2,-4), c(1,-3,2,-4),c(1,-3,2,-4)) which(tm.1 0, arr.ind=TRUE)      row col [1,]   1   1 [2,]   2   1 [3,]   3   1 [4,]   1   3 [5,]   2   3 [6,]   3   3 so the answer should have the elements of tm.1 with the following indexes 1,1 1,3 2,1 2,3

Re: [R] extract a subset of non-contiguous elements of a matrix

2014-06-19 Thread Bart Kastermans
On 19 Jun 2014, at 15:16, carol white wht_...@yahoo.com wrote: tm.1=rbind(c(1,-3,2,-4), c(1,-3,2,-4),c(1,-3,2,-4)) which(tm.1 0, arr.ind=TRUE) row col [1,] 1 1 [2,] 2 1 [3,] 3 1 [4,] 1 3 [5,] 2 3 [6,] 3 3 so the answer should have the elements of

[R] How to delete designated sequences in alignment (DNAbin object)

2014-06-19 Thread Juan Antonio Balbuena
This is a simple question but could not find any specific help information: I have a DNAbin object created with read.dna() of ape and would like to remove several sequences of conflicting taxa. How can I do it using a vector with the lables of the taxa to remove? Thanks in advance

Re: [R] extract a subset of non-contiguous elements of a matrix

2014-06-19 Thread Frede Aakmann Tøgersen
As Peter and Bart I really have a problem understanding you. Perhaps if you tell us what your desired result is going to used for we can be more helpful. You can do that using your latest example. In that example you want a matrix of sets of row and column indices. This will probably have to

[R] apply diff type function to matrix

2014-06-19 Thread message
Readers, For a matrix: 1 10 20 30 2 15 40 60 3 20 80 120 Using a spreadsheet, a differential function can be applied to the data as a formula: |(10-15)/(1-2)| ... repeated for each pair of adjacent values What is the corresponding function in R please? Is it better to write a new function, or

[R] bar plot stacked

2014-06-19 Thread message
Readers, For data set: a, 90, 10 b, 60, 40 c, , d, , 50 A plot was attempted: dataset-as.matrix(read.csv(datafile.csv,header=FALSE)) barplot-(dataset,horiz=TRUE) A warning message is returned, about NAs introduced by coercion and an undesirable graph. The desired output is something similar

Re: [R] extract a subset of non-contiguous elements of a matrix

2014-06-19 Thread carol white
I realize that that the problem arises if there is a different number of negative numbers in the rows and columns of the original matrix. In this case, the resulting matrix won't have the same number of rows for all columns. The problem for ex doesn't arise for my example but for Bart's example

Re: [R] plot in package psych with function error.bars.by

2014-06-19 Thread William Revelle
Dear Tham, The example you were running was filtering out the subjects less than 10 years old and more than 80. Somehow you suppressed this filtering which lead to the error message. The filtering was done to avoid the problem you detected. I have fixed error.bars.by so that it now will

Re: [R] extract a subset of non-contiguous elements of a matrix

2014-06-19 Thread Frede Aakmann Tøgersen
You are really not helpful here. Are we talking the same scientific language? Br. Frede Sendt fra Samsung mobil Oprindelig meddelelse Fra: carol white Dato:19/06/2014 15.46 (GMT+01:00) Til: Frede Aakmann Tøgersen ,Bart Kastermans Cc: r-help@r-project.org Emne: Re: [R]

Re: [R] bar plot stacked

2014-06-19 Thread Bart Kastermans
On 19 Jun 2014, at 15:42, message let...@openmailbox.org wrote: Readers, For data set: a, 90, 10 b, 60, 40 c, , d, , 50 A plot was attempted: Wonder who attempted this. :-) dataset-as.matrix(read.csv(datafile.csv,header=FALSE)) Look at your dataset; I’d say it is clearly not

Re: [R] apply diff type function to matrix

2014-06-19 Thread David L Carlson
I'm not sure we have enough information, but given your matrix: mt - matrix(c(1, 2, 3, 10, 15, 20, 20, 40, 80, 30, 60, 120), 3, 4) mt [,1] [,2] [,3] [,4] [1,]1 10 20 30 [2,]2 15 40 60 [3,]3 20 80 120 # Get differences between adjacent values in each column

Re: [R] How can I avoid the for and If loops in my function?

2014-06-19 Thread Martin Maechler
lmramba lmra...@ufl.edu on Wed, 18 Jun 2014 20:00:15 + writes: Hi Jim. If I avoid the dataframe, how can use the function model.matrix() to build the incident matrices X, And Z? I tried saving the design as matrix but ghen I got the wrong design matrix. I think you are

Re: [R] bar plot stacked

2014-06-19 Thread William Dunlap
dataset-as.matrix(read.csv(datafile.csv,header=FALSE)) You should always inspect the dataset immediately after reading it in, before doing other manipulations on it. Converting data from one format to another is always going to be error-prone. Plotting it, say with pairs() or just plot(), is

Re: [R] How can I avoid the for and If loops in my function?

2014-06-19 Thread Mramba,Lazarus K
Hi Martin, Thanks for the useful comments. It has greatly improved the efficiency of my functions. I am sorry that I forgot to paste the functions varG and others which I have done here for reproducibility. # ## a function to calculate h2 ## (heritability)

Re: [R] Publication-ready figures with two plots

2014-06-19 Thread Nelson Martins
An alternative would be to use the arrangeGrob function of the gridExtra package to generate the final montage, and then use ggsave: figure1-arrangeGrob(plot1,plot2,ncol=2) ggsave(...) Best regards Nelson On Thu, Jun 19, 2014 at 8:45 AM, ONKELINX, Thierry thierry.onkel...@inbo.be wrote:

Re: [R] empty density plot for point pattern in spatstat

2014-06-19 Thread Adrian Baddeley
I think I have the solution to the problem experienced by users of 'spatstat' on Windows machines, who are finding that plot.im() gives empty colour images. Short answer: set useRaster=FALSE in the call to plot.im. Long answer: spatstat::plot.im calls graphics::image.default with the argument

Re: [R] empty density plot for point pattern in spatstat

2014-06-19 Thread Adrian Baddeley
Dear Pablo Please provide details of the system you are using (Windows - version? R version? spatstat version?) Also, when you issue the plot command, what graphics device are you using? [To find out, type dev.cur() after performing the plot, and read the printout] Try changing the colour map

[R] Convert nlme formula to nlmer

2014-06-19 Thread Roxane Foulser-Piggott
R version 3.1.0 (2014-04-10) -- Spring Dance”. Platform: x86_64-apple-darwin13.1.0 (64-bit). I would like to convert the following function from nlme to nlmer. I am finding it difficult to apply the documentation I can find on this procedure to this problem. The function predicts earthquake

Re: [R] plot in package psych with function error.bars.by

2014-06-19 Thread William R Revelle
Tham, What you have found is that the cats eyes of the error bars will throw an error if there no variance for a cell (or, just one person in a cell). This I will fix so that it complains but doesn’t quit. The example you were running was filtering out the subjects less than 10 years old

[R] Creating a Series of Maxima

2014-06-19 Thread Hafizuddin Arshad
Dear R users, I have this kind of data set: structure(list(Year = c(1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L, 1985L), Day = 1:20, Month = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,

[R] Output levels of categorical data to Excel using with()

2014-06-19 Thread Daniel Schwartz
I have coded qualitative data with many (20+) different codes from a survey in an excel file. I am using the with() function to output the codes so we know what's there. Is it possible to direct the output from with() to an excel file? If not, what's another function that has the same, er,

[R] Principal component analysis with EQUAMAX rotation

2014-06-19 Thread Wagner
Hello, I need to do a principal component analysis with EQUAMAX-rotation. Unfortunately the function principal() I use normally for PCA does not offer this rotation specification. I could find out that this might be possible somehow with the package GPArotation but until now I could not figure out

[R] Rgl: rotation and colorbar

2014-06-19 Thread Céline b
Hello, I'm trying to add a colorbar to a 3d map using rgl. For this purpose, I draw the map in a similar way of persp3d example : lat - matrix(seq(90,-90, len=50)*pi/180, 50, 50, byrow=TRUE) long - matrix(seq(-180, 180, len=50)*pi/180, 50, 50) r - 6378.1 # radius of Earth in km x -

Re: [R] Pulling data based on the quater

2014-06-19 Thread arun
Hi Raghu, Using the example you provided. If you want Q3 for year 2011 and 2013. dat[grep(2011 Q3|2013 Q3, Qtr1),] #change accordingly #    ID Phase RESEARCH Area  Date   Result #1  100    IV   S_Care  AP 7/23/2013 Positive #5 2005    IV    Speci   TH  8/4/2011 NA #6 2006   III    Speci  

[R] infix paste and package

2014-06-19 Thread Christian Hoffmann
Hi, I can successfully define in .R and in R %% - function(a,b) { paste(a,b,sep=) } nd use in R a %% b [1] ab but in a package definition .Rd \name{pasteInfix} \alias{pasteInfix} \alias{\%\% } \usage{ a \%\% b } will fail in R CMD check --as-cran saying I am %% + hungry #

Re: [R] empty density plot for point pattern in spatstat

2014-06-19 Thread Pablo Ramón
Dear Adrian, Yes, effectively utilizanddo useRaster = FALSE, the plot is printed. Only the ribbon appears without color. I'm using R version 3.0.2, Windows 7 system, and spatstat 1.33-0 package version. Best wishes Pablo 2014-06-18 19:50 GMT-05:00 Adrian Baddeley adrian.badde...@uwa.edu.au:

Re: [R] How can I avoid the for and If loops in my function?

2014-06-19 Thread Richard M. Heiberger
Now that it is simplified, we see that you are incrementing the size of an array at each step. This is a very inefficient practice in R. For comparison, ## what you are doing system.time({ tmp - NULL for (i in 1:1) tmp - rbind(tmp, 1:2) }) ## user system elapsed ## 0.622 0.297

Re: [R] Rgl: rotation and colorbar

2014-06-19 Thread Duncan Murdoch
On 19/06/2014, 1:00 PM, Céline b wrote: Hello, I'm trying to add a colorbar to a 3d map using rgl. For this purpose, I draw the map in a similar way of persp3d example : lat - matrix(seq(90,-90, len=50)*pi/180, 50, 50, byrow=TRUE) long - matrix(seq(-180, 180, len=50)*pi/180, 50, 50) r

Re: [R] infix paste and package

2014-06-19 Thread Duncan Murdoch
On 19/06/2014, 3:10 PM, Christian Hoffmann wrote: Hi, I can successfully define in .R and in R %% - function(a,b) { paste(a,b,sep=) } nd use in R a %% b [1] ab but in a package definition .Rd \name{pasteInfix} \alias{pasteInfix} \alias{\%\% } \usage{ a \%\% b }

[R] HLM time series using Bayesian Inference in R.

2014-06-19 Thread Nicole Ford
Hey there, I was wondering if anyone might happen to know of any books that cover this? I've read and been working through 'introductory time series in R' by Cowpertwait/ Metcalfe and chapter 12 is mostly devoted to the Bayesian approach but the examples aren't really relevant to what I'm

Re: [R] Creating a Series of Maxima

2014-06-19 Thread arun
Hi, You may try: df - structure(list()   lapply(split(df, df$Year), function(x) sapply(1:(nrow(x)-2), function(i) with(x, mean(Amount[i:(i+2)],na.rm=TRUE #$`1985` # [1] 4.167 3.833 0.833 0.333 0.333 0.000 0.000 # [8] 0.000 0.000 0.000 0.000

Re: [R] Creating a Series of Maxima

2014-06-19 Thread arun
To get the maximum: lapply(split(df, df$Year), function(x) max(sapply(1:(nrow(x)-2), function(i) with(x, mean(Amount[i:(i+2)],na.rm=TRUE) #$`1985` #[1] 4.17 A.K. On , arun smartpink...@yahoo.com wrote: Hi, You may try: df - structure(list()   lapply(split(df, df$Year),

Re: [R] Output levels of categorical data to Excel using with()

2014-06-19 Thread Marc Schwartz
On Jun 18, 2014, at 11:31 PM, Daniel Schwartz das2...@gmail.com wrote: I have coded qualitative data with many (20+) different codes from a survey in an excel file. I am using the with() function to output the codes so we know what's there. Is it possible to direct the output from with() to

Re: [R] empty density plot for point pattern in spatstat

2014-06-19 Thread Prof Brian Ripley
On 19/06/2014 07:00, Adrian Baddeley wrote: I think I have the solution to the problem experienced by users of 'spatstat' on Windows machines, who are finding that plot.im() gives empty colour images. Short answer: set useRaster=FALSE in the call to plot.im. Long answer: spatstat::plot.im

[R] Working with Oracle large objects in R

2014-06-19 Thread Sebastien Bihorel
Hi, I was wondering if anybody could share their experience with interfacing R with Oracle databases for extraction of large objects. I would be more specifically interested in how to extract large objects storing big text files. Thank you Sebastien

[R] Restrict a SVAR A-Model on Matrix A and Variance-Covariance-Matrix

2014-06-19 Thread chili
Hello folks! I'm using R-Package {vars} and I'm trying to estimate an A-Model. I have serious problems regarding the restrictions. 1) My A-Matrix needs (!) to have the following form: # 1 NA NA NA # 0 1 NA NA # 0 0 1 NA # 0 0 0 1 That is done in R by: A_Matrix - diag(4) #

Re: [R] How to invert a matrix in R?

2014-06-19 Thread Douglas Bates
On Wed, Jun 18, 2014 at 2:26 PM, Judson judsonbl...@msn.com wrote: Dear Dr. Bates, I'm just learning R and I want to use it for statistical problems and also some problems that are just mathematical. Apparently I'm not using the packages right and none of the books I've found cover

[R] selecting columns based on partial names

2014-06-19 Thread Chris Dolanc
Hello, I have a data frame with 5000 columns and I'd like to be able to make subsets of that data frame made up of certain columns by using part of the column names. I've had a surprisingly hard time finding something that works by searching online. For example, lets say I have a data

[R] CoDA DataFrame: Change Column to Row Name

2014-06-19 Thread Rich Shepard
I recall reading how to do this somewhere, but I cannot find just where I read it. I have compositional data frames of this format: sampdate filter gather graze predate shred 1 2000-07-18 0.0550 0.5596 0.0734 0.2294 0.0826 2 2003-07-08 0.0734 0.6147 0.0183 0.2294 0.0642 3 2005-07-13

Re: [R] selecting columns based on partial names

2014-06-19 Thread Uwe Ligges
On 19.06.2014 23:50, Chris Dolanc wrote: Hello, I have a data frame with 5000 columns and I'd like to be able to make subsets of that data frame made up of certain columns by using part of the column names. I've had a surprisingly hard time finding something that works by searching online.

Re: [R] bar plot stacked

2014-06-19 Thread Jim Lemon
On Thu, 19 Jun 2014 01:42:30 PM message wrote: Readers, For data set: a, 90, 10 b, 60, 40 c, , d, , 50 A plot was attempted: dataset-as.matrix(read.csv(datafile.csv,header=FALSE)) barplot-(dataset,horiz=TRUE) A warning message is returned, about NAs introduced by coercion and

Re: [R] selecting columns based on partial names

2014-06-19 Thread Jim Lemon
On Thu, 19 Jun 2014 02:50:20 PM Chris Dolanc wrote: Hello, I have a data frame with 5000 columns and I'd like to be able to make subsets of that data frame made up of certain columns by using part of the column names. I've had a surprisingly hard time finding something that works by

Re: [R] selecting columns based on partial names

2014-06-19 Thread Chris Dolanc
Thank you. That worked. On 19-Jun-2014 3:24 PM, Uwe Ligges wrote: On 19.06.2014 23:50, Chris Dolanc wrote: Hello, I have a data frame with 5000 columns and I'd like to be able to make subsets of that data frame made up of certain columns by using part of the column names. I've had a

Re: [R] CoDA DataFrame: Change Column to Row Name

2014-06-19 Thread Adams, Jean
Rich, If your data frame is called df, try row.names(df) - df$sampdate Jean On Thu, Jun 19, 2014 at 5:07 PM, Rich Shepard rshep...@appl-ecosys.com wrote: I recall reading how to do this somewhere, but I cannot find just where I read it. I have compositional data frames of this format:

Re: [R] CoDA DataFrame: Change Column to Row Name [RESOLVED]

2014-06-19 Thread Rich Shepard
On Thu, 19 Jun 2014, Adams, Jean wrote: If your data frame is called df, try row.names(df) - df$sampdate Jean, Yep. That looks familiar. Many thanks, Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE

[R] CoDA: Count Zeros in Biological Data

2014-06-19 Thread Rich Shepard
I have several small biological count-based data sets with one or more rows having zero proportion. The other proportions in the row sum to 1.000 (or 0. in the sixth data row below because of rounding errors in the computer). An example is: sampdate filter gather graze predate shred

Re: [R] empty density plot for point pattern in spatstat

2014-06-19 Thread Adrian Baddeley
Dear Pablo, Yes, effectively utilizando useRaster = FALSE, the plot is printed. Muy bien! Only the ribbon appears without color. Try setting ribargs=list(useRaster=TRUE). I'm using R version 3.0.2, Windows 7 system, and spatstat 1.33-0 package version. Things may improve if you

[R] R is converting arg input to scientific notation, which is bad!

2014-06-19 Thread efridge
Hello, Firstly, real new to R here. I have a function intended to evaluate the values in columns spread over many tables. I have an argument in the function that allows the user to input what sequence of tables they want to draw data from. The function seems to work fine, but when the user

[R] as.Date(Sys.time()) returns tomorrow !

2014-06-19 Thread ce
Dear all, Sys.time() [1] 2014-06-19 22:19:17.976818 EDT as.Date(Sys.time()) [1] 2014-06-20 why this happens ? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

Re: [R] R is converting arg input to scientific notation, which is bad!

2014-06-19 Thread David Winsemius
On Jun 19, 2014, at 12:08 PM, efridge wrote: Hello, Firstly, real new to R here. I have a function intended to evaluate the values in columns spread over many tables. I have an argument in the function that allows the user to input what sequence of tables they want to draw data from.

Re: [R] CoDA: Count Zeros in Biological Data

2014-06-19 Thread Bert Gunter
1. This is a question about statistical methodology, not R. Hence inappropriate here. 2. Replies should therefore be private. 3. Consult the literature. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And

Re: [R] as.Date(Sys.time()) returns tomorrow !

2014-06-19 Thread William Dunlap
Is it a time zone issue? I get: R Sys.time() [1] 2014-06-19 20:09:25 PDT R as.Date(Sys.time()) [1] 2014-06-20 R as.Date(Sys.time(),tz=US/Pacific) [1] 2014-06-19 R as.Date(Sys.time(),tz=PDT) [1] 2014-06-20 Warning message: In as.POSIXlt.POSIXct(x, tz = tz) : unknown timezone 'PDT' Bill Dunlap

Re: [R] as.Date(Sys.time()) returns tomorrow !

2014-06-19 Thread ce
I guessed it too, but my command as.Date(Sys.time(),tz=EDT) [1] 2014-06-20 doesn't give warning message you got for PDT . I thought EDT was a valid TZ ! Now I changed it to : as.Date(Sys.time(),tz=America/New_York) [1] 2014-06-19 Thanks. -Original Message- From: William Dunlap

[R-es] Acabo de quedaR alucinadoR

2014-06-19 Thread palazon
Hola: Acabo de encontrar esta página http://www.rdocumentation.org/ y he quedado gratamente alucinado. No se si la conocíais, pero me parece de alto interés. En cabecera dice: Search the R documentation of *6688* R packages and *136342* R functions Lo que aumenta el número que se ofrece