Re: [R] Intersecting two matrices

2013-07-31 Thread Jeff Newmiller
I would appreciate it if you would follow the Posting Guide and give a reproducible example and post all messages using plain text. Try m1 - matrix(sample(0:999,2*1057837,TRUE),ncol=2) m2 - matrix(sample(0:999,2*951980,TRUE),ncol=2) df1 - as.data.frame(m1) df2 - as.data.frame(m2) library(sqldf)

Re: [R] Plot a series of plots without using a loop

2013-07-31 Thread Rui Barradas
Hello, There's a bug in the line for (i in 1:length(dim(somdata.xyf$codes$X)[2])) length() is always 1, you can use simply 1:dim(...)[2] or even simpler for(i in 1:ncol(somdata.xyf$codes$X)) As for a way without a loop, you could use ?sapply: sapply(1:ncol(somdata.xyf$codes$X), function(i)

[R] Using If loop in R how to extract even and odd ids

2013-07-31 Thread ravi.raghava1
I have 500 ids ; i want to take out even and odd ids separately and store it another data files. How can it be done in R by using *If and for loop* ?? -- View this message in context: http://r.789695.n4.nabble.com/Using-If-loop-in-R-how-to-extract-even-and-odd-ids-tp4672707.html Sent from the

Re: [R] List of lists

2013-07-31 Thread mohan . radhakrishnan
Hi Jim, close(filedescriptors$cpufiledescriptors[[1]]) close(filedescriptors$cpufiledescriptors[[2]]) close(filedescriptors$cpufiledescriptors[[3]]) I might be doing something wrong. Error is Error in UseMethod(close) : no applicable method for 'close' applied to an object of

[R] Add a column to a data frame with value based on the percentile of the row

2013-07-31 Thread Dark
Hi all, I think this should be an easy question for the guru's out here. I have this large data frame (2.500.000 rows, 15 columns) and I want to add a column named SEGMENT to it. The first 5% rows (first 125.000 rows) should have the value Top 5% in the SEGMENT column Then the rows from 5% to

[R] comparing real set vs sampled sets

2013-07-31 Thread PQuery
Dear R helper, I have a statistic question. I have a vector of 500 values for which I need to assess the statistical significance of occurrence real.dist - realValues For that, I sampled from my data large data pool 1000 other vectors of 500 values each. I then run ks.test with my real vec vs

[R] parfm frailty model and post hoc testing

2013-07-31 Thread Raoul Van Oosten
Dear all, I'm running a model with one fixed factor which has four groups called species, and a clustering factor called nest. My dependent variable (timeto) is ttm (time to moult) which is number of days

[R] detect multivariate outliers with aq.plot {mvoutliers} high dimensions

2013-07-31 Thread monaR
Hei, i have a species abundance data set CommData, with n (samples)=40 and p (species)=107. Sample Species A Species B Species C Species D …. 411_201040 20 0 0 412_201030 20 0 0 413_20100 0

Re: [R] Using If loop in R how to extract even and odd ids

2013-07-31 Thread Rui Barradas
Hello, Who told you you need a loop or an if? even - function(x) x %% 2 == 0 x - 1:50 idx - even(x) x[idx] Hope this helps, Rui Barradas Em 31-07-2013 08:46, ravi.raghava1 escreveu: I have 500 ids ; i want to take out even and odd ids separately and store it another data files. How can

Re: [R] Add a column to a data frame with value based on the percentile of the row

2013-07-31 Thread Rui Barradas
Hello, Combine quantile() with findInterval(). Something like the following. # sample data x - rnorm(100) val - c(Bottom 50, 20 to 50, 5 to 20, Top 5%) qq - quantile(x, probs = c(0, 0.50, 0.70, 0.95, 1)) idx - findInterval(x, qq) val[idx] Hope this helps, Rui Barradas Em 31-07-2013

Re: [R] Using If loop in R how to extract even and odd ids

2013-07-31 Thread arun
Hi, May be this helps: set.seed(24) dat1- data.frame(ID=1:500,value=rnorm(500)) res- split(dat1,dat1$ID%%2) A.K. - Original Message - From: ravi.raghava1 ravi.ragh...@classle.co.in To: r-help@r-project.org Cc: Sent: Wednesday, July 31, 2013 3:46 AM Subject: [R] Using If loop in R how

Re: [R] Add a column to a data frame with value based on the percentile of the row

2013-07-31 Thread arun
Hi, May be this helps: set.seed(24) dat1- data.frame(ID=1:500,value=rnorm(500)) indx-round(quantile(as.numeric(row.names(dat1)),probs=c(0.05,0.20,0.50,1))) indx1-findInterval(row.names(dat1),indx,rightmost.closed=TRUE) dat1$SEGMENT- as.character(factor(indx1,labels=c(Top 5%,5 to 20,20 to 50,

[R] heatmap scale parameter question

2013-07-31 Thread Witold E Wolski
Would anyone of the more experienced r-users explain to me the behaviour of the scale parameter in the heatmap function. different options for scale (R 3.0.1) do change only the colors but do not affect the dendrograms. Please see for yourself executing the following code: d -

[R] Please take me out of the mailing list

2013-07-31 Thread Mirjam Appel
[[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained,

Re: [R] Please take me out of the mailing list

2013-07-31 Thread S Ellison
Subject: [R] Please take me out of the mailing list Please follow the instructions on the mailing list page. The link is given at the bottom of every mail from the list. *** This email and any attachments are confidential. Any

Re: [R] Add a column to a data frame with value based on the percentile of the row

2013-07-31 Thread arun
Hi,  set.seed(24) dat1- data.frame(ID=1:500,value=rnorm(500))  dat1 - dat1[order(-dat1$value),] row.names(dat1)-1:nrow(dat1) indx-round(quantile(as.numeric(row.names(dat1)),probs=c(0.05,0.20,0.50,1))) indx1-findInterval(row.names(dat1),indx,rightmost.closed=TRUE) dat1$SEGMENT-

[R] merge matrix row data

2013-07-31 Thread Elaine Kuo
Dear list, I have a matrix showing the species presence-absence on a map. Its rows are map locations, represented by GridCellID, such as GID1 and GID 5. Its columns are species ID, such as D0989, D9820, and D5629. The matrix is as followed. Now I want to merge the GridCellID according to

Re: [R] merge matrix row data

2013-07-31 Thread arun
HI, Please use ?dput() mat1- as.matrix(read.table(text= D0989  D9820  D5629  D4327  D2134 GID_1    1    0    0  1  0 GID_2    0    1    1  0  0 GID_4    0    0    1  0  0 GID_5    1    1    0  0  0 GID_7    0    1    0  0 

[R] Highlight selected bar in barplot

2013-07-31 Thread Jurgens de Bruin
Hi All, I am new at R so any help would be appreciate. Below my current R-code/script: initial.dir-getwd() setwd('/Users/jurgens/VirtualEnv/venv/Projects/QTLS/Resaved_Results') dataset - read.table(LWxANNA_FinalReport_resaved_spwc.csv, header=TRUE, sep=\t ) n - length(dataset$X..No.Call) x -

[R] R number format with Hmisc and knitr

2013-07-31 Thread Simon Zehnder
Dear R-Users and R-Devels, I have a problem when using knitr in combination with Hmisc. I generate a data.frame which has mixed scientific and non-scientific numbers inside. In my Latex Table I just want to have non-scientific format, so I call latex(myDataFrame, file = '', cdec = c(0, rep(4,

Re: [R] R number format with Hmisc and knitr

2013-07-31 Thread Simon Zehnder
Errata: it must say: latex(myDataFrame, file = '', cdec = c(0, rep(4, NCOL(myDataFrame) - 1)) ) But this does not work. Scientific notation is very robust :) Apologize Simon On Jul 31, 2013, at 5:05 PM, Simon Zehnder szehn...@uni-bonn.de wrote: Dear R-Users and R-Devels, I have a

Re: [R] Correlation Loops in time series

2013-07-31 Thread arun
Hi, May be this helps: set.seed(25) mt1- matrix(sample(c(NA,1:40),20*200,replace=TRUE),ncol=200) set.seed(487) mt2- matrix(sample(c(NA,1:80),20*200,replace=TRUE),ncol=200) res- sapply(seq_len(ncol(mt1)),function(i) cor(mt1[,i],mt2[,i],use=complete.obs,method=pearson)) A.K. Hello, I've

Re: [R] heatmap scale parameter question

2013-07-31 Thread David Carlson
In your example all of the values are drawn from the same distribution so there will not be substantial differences (row means/variances and column means/variances will be approximately the same). set.seed(42) d - matrix(rnorm(100),nrow=20) # Start with your example and modify the row/col means

Re: [R] Add a column to a data frame with value based on the percentile of the row

2013-07-31 Thread Rui Barradas
Hello, Sorry, that should be 0.80, not 0.70. qq - quantile(x, probs = c(0, 0.50, 0.80, 0.95, 1)) Rui Barradas Em 31-07-2013 12:22, Rui Barradas escreveu: Hello, Combine quantile() with findInterval(). Something like the following. # sample data x - rnorm(100) val - c(Bottom 50, 20 to

Re: [R] Greek symbols in study labels and custom summary lines in forest plot (meta)

2013-07-31 Thread David Winsemius
On Jul 29, 2013, at 11:52 AM, Rapsomaniki, Eleni wrote: Dear R helpers, Is there a way to display mathematical notations (e.g. greek characters, subscripts) properly in study (studlab) and group (byvar) labels in a forest plot created using the meta package? #Example: library(meta)

Re: [R] Highlight selected bar in barplot

2013-07-31 Thread John Kane
It's a bit difficult to know what you are doing without any data. Would you supply some data please. See ?dput for the easiest way to supply it. Also have a look at https://github.com/hadley/devtools/wiki/Reproducibility and/or

Re: [R] xmlToDataFrame very slow

2013-07-31 Thread Duncan Temple Lang
Hi Stavros xmlToDataFrame() is very generic and so doesn't know anything about the particulars of the XML it is processing. If you know something about the structure of the XML, you should be able to leverage that for performance. xmlToDataFrame is also not optimized as it is just a convenience

[R] Does a general latex table-making function exist?

2013-07-31 Thread Frank Harrell
Our Hmisc package summary.formula function and its latex methods can make some fairly advanced tables. But the tables have to be regular. For example, all rows of the tables are based on the same data frame. I'm thinking that what is needed is a ggplot2-like set of functions for building a

Re: [R] Does a general latex table-making function exist?

2013-07-31 Thread Duncan Murdoch
On 13-07-31 4:03 PM, Frank Harrell wrote: Our Hmisc package summary.formula function and its latex methods can make some fairly advanced tables. But the tables have to be regular. For example, all rows of the tables are based on the same data frame. I'm thinking that what is needed is a

[R] qgraph: how to create legend (scale) for edge thickness?

2013-07-31 Thread María Antonieta Sánchez Farrán
Hello R community, I am creating some network representations using the qgraph package (big thanks to Sacha Epskamp for developing it!). The package is very well documented, but I am unable to find how to create a legend (scale) for edge thickness. In one of his qgraph examples, Sacha shows such

[R] geocoding using the Google API with a key

2013-07-31 Thread Vergari, Fabiano
Hello, I am trying to geocode an address using the Google API and R. So far, I have used the following code: location-c('120 Avenue de la Republique, 92120 Montrouge, France') location - gsub(' ', '+', location) sensor-c('FALSE') sensor4url - paste('sensor=', tolower(as.character(sensor)), sep =

[R] resampling

2013-07-31 Thread Rita Gamito
Could anyone tell me how,from a pool of 1002 observations (one variable), can I resample 1000 samples of 20 observations? And then calculate the mean and standard deviation between 2, 3, 4, ..., 1000 samples and plot them? Thank you! _ Rita Gamito Centro de

[R] R help

2013-07-31 Thread Mª Teresa Martinez Soriano
Hi First of all, thanks for this service, it is being very useful for me. I am new in R so I have a lot of doubts. I have to do imputation in a data set, this is a sample of my data set which looks like: NUMERO Data1 Data2 IE.2003 IE.2004 IE.2005 IE.2006 IE.2007 IE.2008 IE.2009

[R] Split in blocks

2013-07-31 Thread Dominic Roye
Hello, I am a little bit lost on my search for a solution and idea. I would like to split my time serie in blocks of night. V1 indicates if its night or not. How can i split this kind of cases? Best regards, str(ou[,c(1,3,8)]) 'data.frame': 863 obs. of 3 variables: $ Fecha: POSIXct,

Re: [R] Add a column to a data frame with value based on the percentile of the row

2013-07-31 Thread Dark
Works like a charm, thanks a lot! -- View this message in context: http://r.789695.n4.nabble.com/Add-a-column-to-a-data-frame-with-value-based-on-the-percentile-of-the-row-tp4672711p4672728.html Sent from the R help mailing list archive at Nabble.com.

[R] problem about mean function in ffbase package

2013-07-31 Thread Chaos Chen
Hi all, I experienced some unmatched result using mean function in ffbase package  and cannot figure out what's wrong. I have a simulated ff vector with 10 numbers inside and want to calculate its mean. But the results are quite different. With mean( ) function in ffbase package, the

[R] Correlation Loops in time series

2013-07-31 Thread TMiller
Hello, I've got the following problem. I have to matrices each containing 200 time series. Now I want to calculate the correlation of the first time series of each of the matrices. I use the following command: cor(mts1[,1],mts2[,1], use=complete.obs, method=c(pearson)) cor(mts1[,2],mts2[,2],

Re: [R] Add a column to a data frame with value based on the percentile of the row

2013-07-31 Thread Dark
Hi Arun Kirshna, I have tested your method and it will work for me. I only run into one problem. Before I want to do this operation I have sorted my data frame so my rownumbers ar not subsequent. You can see if you first order your example data frame like: dat1 - dat1[order(-dat1$value),]

Re: [R] resampling

2013-07-31 Thread andrija djurovic
Hi. See ?sample, ?replicate,?colMeans, ?plot.. Here is the simple example: sample(1:1000,20) replicate(5, sample(1:1000,20)) colMeans(replicate(5, sample(1:1000,20))) Andrija On Wed, Jul 31, 2013 at 1:23 PM, Rita Gamito rslo...@fc.ul.pt wrote: Could anyone tell me how,from a pool of 1002

[R] Canadian common CV: how to cite R packages?

2013-07-31 Thread Michael Friendly
A Q for Canadians who have filled out the new Canadian common CV for grant applications: is there any way to cite research contributions of software such as R packages, aside from published journal articles? If so, where/how in the online application can they be entered? For example, under

Re: [R] Correlation Loops in time series

2013-07-31 Thread David Carlson
sapply(1:200, function(x) cor(mts1[,x], mts2[,x], use=complete.obs, method=c(pearson))) - David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org

Re: [R] merge matrix row data

2013-07-31 Thread Elaine Kuo
Dear Arun Thank you for the very useful help. However, please kindly explain the code below. row.names(mat1)- gsub([_], ,row.names(mat1)) 1. what does [_] mean? 2. what doesmean? 3. what does row.names(mat1) mean? I checked ?gsub but still did not get the idea. Thank you again Elaine On

Re: [R] Split in blocks

2013-07-31 Thread Bert Gunter
Enter ?help at the prompt to learn how to use R's (extensive) Help system to answer questions like this. For this question: ?split ## what else? Also ?tapply, ?ave, ?aggregate, ?by may be relevant. Also, read AN Introduction to R if you haven't already done so to start learning about R's many

Re: [R] merge matrix row data

2013-07-31 Thread Bert Gunter
Time to do some homework, Elaine: ?regexp There are also numerous online tutorials on regular expressions that you can use to educate yourself. Cheers, Bert On Wed, Jul 31, 2013 at 2:07 PM, Elaine Kuo elaine.kuo...@gmail.com wrote: Dear Arun Thank you for the very useful help. However,

[R] double matrix?

2013-07-31 Thread bruce087
Hi- I have a 37 X 473971 character matrix that I am trying to convert into a numeric matrix. When I use the code: class(matrix) = numeric I end up with something called a double matrix whose dimensions are still 37 X 473971 I have also tried new = apply(matrix,2, as.numeric) and got

Re: [R] Does a general latex table-making function exist?

2013-07-31 Thread Frank Harrell
Duncan, I had read your excellent tables package vignette at http://cran.r-project.org/web/packages/tables/vignettes/tables.pdf when it first came out. It is extremely impressive. I'm glad to be reminded to give it another look. Is there a way to make the special symbols n and 1 refer to

Re: [R] double matrix?

2013-07-31 Thread Don McKenzie
What are the entries in your matrix? If they are something that won't coerce to numeric, you need to backtrack. Note how R distinguishes types of characters. as.numeric(a) [1] NA Warning message: NAs introduced by coercion as.character(2) [1] 2 as.numeric(2) [1] 2 On Jul 31, 2013, at 1:47

Re: [R] double matrix?

2013-07-31 Thread Richard M. Heiberger
In R, double is a synonym for numeric. Please see ?numeric The details section of ?numeric begins with Details: 'numeric' is identical to 'double' (and 'real'). It creates a double-precision vector of the specified length with each element equal to '0'. Rich On Wed, Jul 31,

Re: [R] double matrix?

2013-07-31 Thread Rui Barradas
Hello, double and numeric are the same. From the help page for ?double, section Note on names It is a historical anomaly that R has two names for its floating-point vectors, double and numeric (and formerly had real). Apparently you are successfully converting characters to double

Re: [R] double matrix?

2013-07-31 Thread David Carlson
It is hard to understand that your R code will not work with a double matrix since double is just short for double precision floating point matrix. Your only alternative would be integer. From ?numeric It is a historical anomaly that R has two names for its floating-point vectors, double and

[R] Convert rbind of lists to data.frame

2013-07-31 Thread Shaun Jackman
I'm trying to build a data.frame row-by-row like so: df - data.frame(rbind(list('a',1), list('b', 2), list('c', 3))) I was surprised to see that the columns of the resulting data.frame are stored in lists rather than vectors. str(df) 'data.frame': 3 obs. of 2 variables: $ X1:List of 3 ..$ :

Re: [R] double matrix?

2013-07-31 Thread William Dunlap
In R double and numeric mean essentially the same thing. I think you are fine. (What called the result a double matrix?) z - cbind(c(11, 12), c(3.14, 2.718)) str(z) chr [1:2, 1:2] 11 12 3.14 2.718 class(z) [1] matrix class(z) - numeric str(z) num [1:2, 1:2] 11 12 3.14

Re: [R] resampling

2013-07-31 Thread Rui Barradas
Hello, The best way seems to be ?replicate. set.seed(3997) # make it reproducible x - rnorm(1002) # make up some data sim - replicate(1000, sample(x, 20)) colSds - function(x, na.rm = FALSE) apply(x, 2, sd, na.rm = na.rm) mu - colMeans(sim) sigma - colSds(sim) Hope this helps, Rui

Re: [R] Convert rbind of lists to data.frame

2013-07-31 Thread arun
May be this helps: l1- list('a',1)  l2- list('b',2)  l3- list('c',3) df1-data.frame(mapply(`c`,l1,l2,l3,SIMPLIFY=FALSE),stringsAsFactors=FALSE)  colnames(df1)-paste0(X,1:2)   str(df1) #'data.frame':    3 obs. of  2 variables: # $ X1: chr  a b c # $ X2: num  1 2 3 A.K. - Original Message

Re: [R] merge matrix row data

2013-07-31 Thread arun
Hi Elaine, In that case: Do you have GID in the IslandA and IslandBs? IslandA-c(GID 1, GID 5) IslandB- c(GID 2, GID 4, GID 7) If there is no change in the two Islands, then using the same dataset: mat1- as.matrix(read.table(text= D0989  D9820  D5629  D4327  D2134 GID_1    1    0    0  

Re: [R] Split in blocks

2013-07-31 Thread arun
Hi, Not clear about your desired output. source(ou.txt) split(ou,ou$V1) #split based on values of V1 (1 and 0) #or #may be you wanted 1 followed by 0 in one block, again 1 followed by 0 in second block etc.. #In that case: lst1-split(ou,cumsum(c(TRUE,diff(ou$V1)==1))) A.K. On Wed, Jul 31,

Re: [R] Split in blocks

2013-07-31 Thread arun
Hi, In that case: lst1-split(ou,cumsum(c(TRUE,diff(ou$V1)==1)))  lst2-lapply(lst1,function(x) x[x$V1==1,]) A.K. From: Dominic Roye dominic.r...@gmail.com To: arun smartpink...@yahoo.com Sent: Wednesday, July 31, 2013 7:17 PM Subject: Re: [R] Split in

[R] R and S+ Courses: Brisbane, Melbourne, Sydney in Aug and Sep.

2013-07-31 Thread Kris Angelovski
R and S+ Courseshttp://www.solutionmetrics.com.au/ Brisbane, Melbourne Sydneyhttp://www.solutionmetrics.com.au/ Hi, Apologies for cross-posting SolutionMetrics is presenting R and S+ courses in Brisbane, Melbourne Sydney - August September, 2013 To book, please email

Re: [R] R help

2013-07-31 Thread Jim Lemon
On 07/31/2013 10:03 PM, Mª Teresa Martinez Soriano wrote: Hi First of all, thanks for this service, it is being very useful for me. I am new in R so I have a lot of doubts. I have to do imputation in a data set, this is a sample of my data set which looks like: NUMERO Data1

[R] ggplot2: color histograms by quintile

2013-07-31 Thread David Chertudi
Hello,   I have a basic panel of histograms as follows, whose current colors don't matter:     binsize=diff(range(thing$Rate))/64 ggplot(thing, aes(x=Rate, fill=Series)) + geom_histogram(binwidth=binsize) + facet_grid(Series~.,scales=free)+   labs(fill=Index) +   xlab(Growth Rate (%)) +