Re: [R] How to calculate the spatial correlation of several files?

2012-12-04 Thread Jonsson
So where is the final correlation map Can we write it: to.write = file(paste(C:\\Users\\aalyaari\\desktop\\corr1.bin,sep=),wb) writeBin(as.double(results[[.f]]), to.write, size = 4) -- View this message in context:

Re: [R] xlsx file read in R

2012-12-04 Thread Martin Studer
Hi Nico, please let me know the details of sessionInfo() in R. Also, what version of Java are you running? If you could post the output of java -version from the command line that would be great. Note that XLConnect requires at least Java 1.6. Best regards, Martin -- View this message in

[R] question about sum of (column) elements in R

2012-12-04 Thread T Bal
Hi, I have the following data: 0 12 1 10 1 4 1 6 1 7 1 13 2 21 2 23 2 20 3 18 3 17 3 16 3 27 3 33 4 11 4 8 4 19 4 16 4 9 In this data file I would like to sum the numbers of second column which belong to the same number in the first column. So the output

Re: [R] question about sum of (column) elements in R

2012-12-04 Thread Pascal Oettli
Hi, You can follow this example: test - structure(list(V1 = c(0L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L), V2 = c(12L, 10L, 4L, 6L, 7L, 13L, 21L, 23L, 20L, 18L, 17L, 16L, 27L, 33L, 11L, 8L, 19L, 16L, 9L)), .Names = c(V1, V2), class = data.frame, row.names =

[R] problem with factor levels

2012-12-04 Thread Jeremy.Shearman
Hi I have a data.frame with 371,718 obs. of 12 variables (see below for an str). My problem is with V1, a Factor w/ 93144 levels, there should actually be 93994 levels. Each entry looks like: comp[number]_c[number]_seq[number] for example comp215489_c0_seq40 R is grouping as though the last

Re: [R] problem with factor levels

2012-12-04 Thread Milan Bouchet-Valat
Le mardi 04 décembre 2012 à 00:34 -0800, Jeremy.Shearman a écrit : Hi I have a data.frame with 371,718 obs. of 12 variables (see below for an str). My problem is with V1, a Factor w/ 93144 levels, there should actually be 93994 levels. Each entry looks like:

Re: [R] question about sum of (column) elements in R

2012-12-04 Thread Gerrit Eichner
Hi, T. Bal, homework? Take a look at ?tapply Regards -- Gerrit On Tue, 4 Dec 2012, T Bal wrote: Hi, I have the following data: 0 12 1 10 1 4 1 6 1 7 1 13 2 21 2 23 2 20 3 18 3 17 3 16 3 27 3 33 4 11 4 8 4 19 4 16 4 9 In this data file I would

[R] partial analisys of a time series

2012-12-04 Thread Antonio Silva
Dear list members I want to analyze separately the months of a time series. In other words, I want to plot and fit models for each month separately. Taking the example of http://a-little-book-of-r-for-time-series.readthedocs.org/en/latest/src/timeseries.html births -

Re: [R] problem with factor levels

2012-12-04 Thread PIKAL Petr
Hi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Jeremy.Shearman Sent: Tuesday, December 04, 2012 9:35 AM To: r-help@r-project.org Subject: [R] problem with factor levels Hi I have a data.frame with 371,718 obs.

Re: [R] problem with factor levels

2012-12-04 Thread Jeremy.Shearman
Oh, your skepticism was spot on! I was using excel to check the output (silly, but I am still in the process of moving from excel to R) and there was a discrepancy in the number of output from R and excel. Turns out the problem was with excel and not with R at all. That's a relief. SOLVED --

[R] computing marginal values based on multiple columns?

2012-12-04 Thread Simon
Hello all, I have what feels like a simple problem, but I can't find an simple answer. Consider this data frame: x - data.frame(sample1=c(35,176,182,193,124), sample2=c(198,176,190,23,15), sample3=c(12,154,21,191,156), class=c('a','a','c','b','c')) x sample1 sample2 sample3 class 1 35

Re: [R] partial analisys of a time series

2012-12-04 Thread PIKAL Petr
Hi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Antonio Silva Sent: Tuesday, December 04, 2012 10:26 AM To: R-help@r-project.org Subject: [R] partial analisys of a time series Dear list members I want to analyze

Re: [R] problem with factor levels

2012-12-04 Thread PIKAL Petr
Hi That is quite usual. Excel is so widespread that almost everybody assumes it shall not contain mistakes and behaves correctly. The contrary is true. Spreadsheet often guess what user have on mind and corrects values to fit such assumption, let aside mistakes in coded functions. R expects

Re: [R] question about sum of (column) elements in R

2012-12-04 Thread Berend Hasselman
On 04-12-2012, at 08:59, T Bal wrote: Hi, I have the following data: 0 12 1 10 1 4 1 6 1 7 1 13 2 21 2 23 2 20 3 18 3 17 3 16 3 27 3 33 4 11 4 8 4 19 4 16 4 9 In this data file I would like to sum the numbers of second column

Re: [R] question about sum of (column) elements in R

2012-12-04 Thread Jose Iparraguirre
Hi, Imagine the data you have is in a data frame, c, with columns a and b. Then you can do this: res=tapply(b,c[,-2],sum) res[is.na(res)]-0 res 0 1 2 3 4 12 40 64 111 63 Hope it helps, José José Iparraguirre Chief Economist Age UK -Original Message- From:

Re: [R] partial analisys of a time series

2012-12-04 Thread Antonio Silva
Thanks Petr I thought there might be an equivalent for birthstimeseries[,1] if it were a dataframe, but split function sounds great. I could not reproduce the second line of your suggestion l.blist - lapply(blist, HoltWinters). I receive the message: Error in decompose(ts(x[1L:wind], start =

Re: [R] computing marginal values based on multiple columns?

2012-12-04 Thread Gerrit Eichner
Hello, Simon, see below! On Tue, 4 Dec 2012, Simon wrote: Hello all, I have what feels like a simple problem, but I can't find an simple answer. Consider this data frame: x - data.frame(sample1=c(35,176,182,193,124), sample2=c(198,176,190,23,15), sample3=c(12,154,21,191,156),

Re: [R] Resampling Help Needed

2012-12-04 Thread Suzen, Mehmet
You can use, 'sample' function for sampling and may consider using partition clustering for selecting your regions, see Cluster task view: http://cran.r-project.org/web/views/Cluster.html On 4 December 2012 00:53, KoopaTrooper ncoop...@tulane.edu wrote: I am using package ks() to build 3D

[R] Réponse automatique

2012-12-04 Thread j . boutet
Bonjour, Je serais en congés jusqu'au Jeudi 6 Décembre. Pour des raisons d'urgence, vous pourrez me contacter par téléphone au 06 46 34 81 03. Cordialement, -- Jérôme Boutet Conservatoire d'espaces naturels de Picardie 1, place Ginkgo - village Oasis 80 044

Re: [R] Forest plot

2012-12-04 Thread Michael Dewey
At 20:39 03/12/2012, Min Dong wrote: Hi, I am a novice in R. It will be greatly appreciated if someone can advise me with the following questions. There are at least three packages available from CRAN (meta, metafor, rmeta) which draw forest plots so it would help us if you had told us which

Re: [R] partial analisys of a time series

2012-12-04 Thread R. Michael Weylandt
Try period.apply() from the xts package. MW On Tue, Dec 4, 2012 at 9:26 AM, Antonio Silva aolinto@gmail.com wrote: Dear list members I want to analyze separately the months of a time series. In other words, I want to plot and fit models for each month separately. Taking the example of

Re: [R] partial analisys of a time series

2012-12-04 Thread PIKAL Petr
Hi I am not an expert in time series. The problem is that resulting list is not time series any more. So you need to convert it again to time series and you need to give it frequency greater than 1. something like l.blist - lapply(blist, function (x) HoltWinters(ts(x, frequency=2))) But this

Re: [R] partial analisys of a time series

2012-12-04 Thread arun
HI, You can subset by: birthstimeseriesJan-subset(birthstimeseries,cycle(birthstimeseries)==1) A.K. - Original Message - From: Antonio Silva aolinto@gmail.com To: R-help@r-project.org Cc: Sent: Tuesday, December 4, 2012 4:26 AM Subject: [R] partial analisys of a time series Dear

Re: [R] Using multicores in R

2012-12-04 Thread moriah
Thanks for the help, Perhaps I should elaborate a bit, I am working on bioinformatics project in which I am trying to run a forward selection algorithm for machine learning classification of two biological conditions. At each iteration I want to find the gene that in addition to those I have

[R] do.call

2012-12-04 Thread Dominic Roye
Hello, I have a problem with the do.call-function. I would like to merge the values of more than 30 columns, but not in all of the rows exist values, so with this commando i get a lot of ; or NA. How get i only the merge of cells with a number? datos$NEW - do.call(paste, c(datos[,19:53], sep =

Re: [R] question about sum of (column) elements in R

2012-12-04 Thread arun
HI, You can use either ?tapply(), ?aggregate(), ?ddply() from library(plyr) dat1-read.table(text= 0  12 1  10 1  4 1  6 1  7 1  13 2  21 2  23 2  20 3  18 3  17 3  16 3  27 3  33 4  11 4  8 4  19 4  16 4  9 ,sep=,header=FALSE)  with(dat1,aggregate(dat1[,2],by=list(V1=dat1[,1]),sum))  # V1   x #1 

Re: [R] Chi-squared test when observed near expected

2012-12-04 Thread David L Carlson
When you typed x as a command, R runs the command print(x). That function produces a summary of the results which may include round off numbers to a few decimal places to make them more readable. When you typed x$statistic, you got the unrounded version of the result 5.6e-31 which I think you will

[R] julia language unfair comparisons against R

2012-12-04 Thread Suzen, Mehmet
Hello List, Probably many of you aware of the Julia language (http://julialang.org/), It is a promising project. However it seems like R is very slow in their benchmarks. Very important point they omit, they did not use R's own JIT ! I had a feeling that R is mistreaded there :) Also another

Re: [R] How do I make R randomForest model size smaller?

2012-12-04 Thread Liaw, Andy
Try the following: set.seed(100) rf1 - randomForest(Species ~ ., data=iris) set.seed(100) rf2 - randomForest(iris[1:4], iris$Species) object.size(rf1) object.size(rf2) str(rf1) str(rf2) You can try it on your own data. That should give you some hints about why the formula interface should be

Re: [R] julia language unfair comparisons against R

2012-12-04 Thread R. Michael Weylandt
There been, that done. http://stackoverflow.com/questions/9968578/speeding-up-julias-poorly-written-r-examples/10712158#10712158 MW On Tue, Dec 4, 2012 at 2:34 PM, Suzen, Mehmet msu...@gmail.com wrote: Hello List, Probably many of you aware of the Julia language (http://julialang.org/), It

Re: [R] Subsetting columns in data.table

2012-12-04 Thread anto.r
DT = data.frame(x=rep(c(a,b,c),each=3), y=c(1,3,6), v=1:9, w=3:11, z=LETTERS[1:9]) If I understand you right, and you want to select all rows where v3 and W10 with(DT, DT[which(v3 w10),]) x y v w z 4 b 1 4 6 D 5 b 3 5 7 E 6 b 6 6 8 F 7 c 1 7 9 G you can use colSums, rowSums on this, but

[R] Winbugs from R

2012-12-04 Thread Günal Bilek
Hi, I am trying to covert a Winbugs code into R code. Here is the winbugs code model{# model’s likelihoodfor (i in 1:n){time[i] ~ dnorm( mu[i], tau ) # stochastic componenent# link and linear predictormu[i] - beta0 + beta1 * cases[i] + beta2 * distance[i]}# prior distributionstau ~ dgamma(

[R] Help for a function

2012-12-04 Thread anoumou
Hello all, I need a help. I am modeling a disease and a create a R function like that: Lambda-function (x,date1,r,h,a){ ndate1 - as.Date(date1, %d/%m/%Y) t1 - as.numeric(ndate1) x[order(x$i),] t -x[,t] i -x[,i] CONTAGIEUX -x[,CONTAGIEUX] while ( t1 min(t) ){ for (i in 1:length(i)

Re: [R] r function definition

2012-12-04 Thread FJ M
Are you using windows? If you are you may want to try to run your R code from a batch file: REM on Microsoft Windows (adjust the path to R.exe as needed) C:\Program Files\R\R-2.13.2\bin\x64\R.exe CMD BATCH C:\Users\Frank\Documents\R\Projects\Heinrich\Heinrich.txt

Re: [R] help with if statement

2012-12-04 Thread anto.r
DT-data.frame(time=c(0,1,5,24,36,48,72),DV=seq(0,60,10)) time DV 10 0 21 10 35 20 4 48 30 5 84 40 6 96 50 7 120 60 You want to add 24 to values that are =24 in 'time' DT[DT$time=24,'time']-DT[DT$time=24,'time']+24 time DV 10 0 21 10 35 20 4 48 30 5 60 40 6

Re: [R] partial analisys of a time series

2012-12-04 Thread arun
HI, I am getting an error message: l.blist-lapply(blist,HoltWinters) #Error in decompose(ts(x[1L:wind], start = start(x), frequency = f), seasonal) :  # time series has no or less than 2 periods A.K. - Original Message - From: PIKAL Petr petr.pi...@precheza.cz To: Antonio Silva

Re: [R] do.call

2012-12-04 Thread arun
Hi, Try this: set.seed(15) datos-as.data.frame(matrix(sample(c(1:20,NA),30,replace=TRUE),ncol=6))  do.call(paste,c(na.omit(datos),sep=;)) #[1] 5;18;14;10;17;3  14;15;15;3;2;20  8;18;19;17;12;11 A.K. - Original Message - From: Dominic Roye dominic.r...@gmail.com To: r-help@r-project.org

Re: [R] partial analisys of a time series

2012-12-04 Thread arun
Hi, If the frequency is 1, the error message will  be gone. For e.g. birthstimeseriesJanFeb-subset(birthstimeseries,cycle(birthstimeseries)==c(1,2))  birthstimeseriesJanFeb1-ts(birthstimeseriesJanFeb,frequency=2,start=c(1946,1))  plot.ts(birthstimeseriesJanFeb1)  

Re: [R] Different results from random.Forest with test option and using predict function

2012-12-04 Thread Liaw, Andy
Without data to reproduce what you saw, we can only guess. One possibility is due to tie-breaking. There are several places where ties can occur and are broken at random, including at the prediction step. One difference between the two ways of doing prediction is that when it's all done

Re: [R] Histogram plot help

2012-12-04 Thread YAddo
Thanks, Rui and David! -- View this message in context: http://r.789695.n4.nabble.com/Histogram-plot-help-tp4651958p4652065.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list

[R] Spatial AND Temporal Dependency with lme, or other function?

2012-12-04 Thread Anne-Sophie Julien
Hi, I've got a new dataset which I don't know how to analyze with R. My knowledge about R is limited for this kind of problem. I've tried to find a solution with some spatio temporel packages and lme/lmer functions, but didn't find any similar example. I've got 10 locations on a coast on

Re: [R] model selection with spg and AIC (or, convert list to fitted model object)

2012-12-04 Thread Ravi Varadhan
Adam, Getting the variance of MLE estimator when the true parameter is on the boundary is a very difficult problem. It is known that the standard bootstrap does not work. There are some sub-sampling approaches (Springer book: Politis, Romano, Wolff), but I am not an expert on this.

[R] lme: subject-specific slopes.

2012-12-04 Thread John Sorkin
I am running a random intercept random slope regression: fitRIRT - lme(echogen~time,random=~ 1+time|subject,data=repeatdata,na.action=na.omit) summary(fitRIRT) I would like to get the subject-specific slopes, i.e. the slope that the model computes for each subject. If I have 10-subjects I

Re: [R] lme: subject-specific slopes.

2012-12-04 Thread John Sorkin
Ken, Thank you for your help. ranef(fitRIRT) does not give me what I expect. The subject-specific slopes, and subject-specific intercepts are not anywhere close to what I would expect them to be; the mean of the subject-specfic values should be close to those reported by summary(fitRIRT) and

Re: [R] lme: subject-specific slopes.

2012-12-04 Thread Kenneth Frost
I think the random effects represent the subject adjustments to the population averages. You may have to do the addition yourself to get the subject specific slopes and intercepts. Someone will hopefully correct me if I'm wrong. On 12/04/12, John Sorkin wrote: Ken, Thank you for your

Re: [R] lme: subject-specific slopes.

2012-12-04 Thread John Sorkin
Yes, you are correct. Thanks, John John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax)

[R] How to reset R settings to original state other than remove .Rdata and .Rhistory

2012-12-04 Thread Tian3507
Dear all, Do you know how to return all the R settings to original state? Other than .Rdata and .Rhistory Some weid thing happened to my machine. I was trying to get shaded confidence band ploted using survplot from rms liberary. It worked on one machine, but not on the other. I tried

[R] Solve system of equations (nleqslv) only returns origin

2012-12-04 Thread Alicia Ellis
I'm solving 4 complex equations simultaneously. Code is below. The code returns only zero's for the solution though there should also be a non-zero result. I'm pretty confident that the equations are correct because they are straight from a published paper and I checked them pretty thoroughly.

Re: [R] lme: subject-specific slopes.

2012-12-04 Thread Brian S Cade
John: I think you want the output from coef(fitRIRT). The ranef(fitRIRT) will give you the subject specific random effect deviations from the fixed effects means. The coef(fitRIRT) will give you the combination of the fixed effect means with the subject specific random effect deviations

Re: [R] computing marginal values based on multiple columns?

2012-12-04 Thread arun
HI, I am not sure the output you wanted is correct: sample1 sample2 sample3 1      1.0    0    0.5 because 0.2*colMeans(x[,-4]) sample1 sample2 sample3 #  28.40   24.08   21.36 This might help you: apply(x[-4],2,function(y) length(y[y 0.2*mean(y) x$class==a])/length(x[x$class==a]))

Re: [R] Help for a function

2012-12-04 Thread Jeremy Miles
What are you expecting? What do you get? What is the problem? J On 4 December 2012 06:01, anoumou teko_maur...@yahoo.fr wrote: Hello all, I need a help. I am modeling a disease and a create a R function like that: Lambda-function (x,date1,r,h,a){ ndate1 - as.Date(date1, %d/%m/%Y) t1

[R] Labelling x axis in plot function

2012-12-04 Thread T Bal
Hi, In the plot function I want to label x axis as the numbers between 1 and 12 (so 1, 2, 3, 4, 5, ..., 12). How should I do it? The range of x values are different than this range. Thanks! Kind regards, T. Bal [[alternative HTML version deleted]]

Re: [R] Labelling x axis in plot function

2012-12-04 Thread Rui Barradas
Hello, You should provide sample data and code. plot(3:10, xlim = c(0, 12), xaxt = n) axis(1, at = 1:12) See the help page ?par for a description of the graphical parameters 'xlim' and 'xaxt', and of ?axis. Hope this helps, Rui Barradas Em 04-12-2012 17:24, T Bal escreveu: Hi, In the

Re: [R] Solve system of equations (nleqslv) only returns origin

2012-12-04 Thread Berend Hasselman
On 04-12-2012, at 17:06, Alicia Ellis wrote: I'm solving 4 complex equations simultaneously. Code is below. The code returns only zero's for the solution though there should also be a non-zero result. I'm pretty confident that the equations are correct because they are straight from a

[R] odd behavior of browser()

2012-12-04 Thread David Romano
Hi everyone, I normally include a call to browser() as I'm working out the kinks in my scripts, and I am always able to step through each line by hitting Return, but for some reason, in the scripts I'm working on now, hitting Return seems to cause execution of *all* the lines in my script. I've

Re: [R] Solve system of equations (nleqslv) only returns origin

2012-12-04 Thread Berend Hasselman
On 04-12-2012, at 18:50, Berend Hasselman wrote: You should return the vector y i.e. function values. But y has length 4 and x has length 4. x has length 5 of course. Berend So where is the fifth value for y? } Xstart=c(1, 200, 0.5, 0.5, 12) fstart=

[R] error reading xlsm file with read.xls

2012-12-04 Thread Sebastian Kruk
Dear all, I cannot reading a .xlsm file using read.xls. I executed: read.xls(resultados.xlsm, colNames = TRUE, sheet = 1, type = data.frame, from = 1, rowNames = NA, colClasses = character, checkNames = TRUE, dateTime = numeric, naStrings = NA, stringsAsFactors = F) Error: Call(ReadXls, file,

Re: [R] odd behavior of browser()

2012-12-04 Thread R. Michael Weylandt
Untested, I think it's the blank line in your script which exits the debugger and then you're seeing regular execution. MW On Tue, Dec 4, 2012 at 5:54 PM, David Romano drom...@stanford.edu wrote: Hi everyone, I normally include a call to browser() as I'm working out the kinks in my scripts,

[R] Read.csv

2012-12-04 Thread Torus Insurance
Hi list, I am using read.csv to read data from csf files, but noticed that the numeric data (those larger than 10 power 9) are rounded to the nearest million (10 power 6). Any solution? Thanks Arvin -- Sent from my mobile device __

Re: [R] Read.csv

2012-12-04 Thread Duncan Murdoch
On 04/12/2012 1:02 PM, Torus Insurance wrote: Hi list, I am using read.csv to read data from csf files, but noticed that the numeric data (those larger than 10 power 9) are rounded to the nearest million (10 power 6). Any solution? What makes you think that is happening? R rounds values for

Re: [R] Read.csv

2012-12-04 Thread Sarah Goslee
Hi Arvin, How are you preparing the data to be read: a spreadsheet? How are you reading the data? How have you verified that the CSV file is correct? How have you verified that the data frame is incorrect? Can you provide a reproducible example using a small portion of your dataset? Sarah On

[R] monte carlo simulation on R

2012-12-04 Thread Adel ESSAFI
Hello, How can I make a monte carlo simulation on R? Regards Adel -- PhD candidate in Computer Science Address 3 avenue lamine, cité ezzahra, Sousse 4000 Tunisia tel: +216 97 246 706 (+33640302046 jusqu'au 15/6) fax: +216 71 391 166 [[alternative HTML version deleted]]

Re: [R] odd behavior of browser()

2012-12-04 Thread Duncan Murdoch
On 04/12/2012 12:54 PM, David Romano wrote: Hi everyone, I normally include a call to browser() as I'm working out the kinks in my scripts, and I am always able to step through each line by hitting Return, but for some reason, in the scripts I'm working on now, hitting Return seems to cause

Re: [R] monte carlo simulation on R

2012-12-04 Thread R. Michael Weylandt
replicate(1000, sum(rnorm(50)^2-rchisq(50, 3))) Or you know, many other things... Michael On Tuesday, December 4, 2012, Adel ESSAFI wrote: Hello, How can I make a monte carlo simulation on R? Regards Adel -- PhD candidate in Computer Science Address 3 avenue lamine, cité ezzahra,

Re: [R] Winbugs from R

2012-12-04 Thread Bob O'Hara
This is a BUGS problem, not an R problem, so would be better asked on the BUGS list (a practical hint: if it's not working through R, run the code directly in BUGS: the error reporting is better). Anyway, here BUGS manages to tell R to tell you what's wrong: variable n is not defined And looking

[R] Large loops in R

2012-12-04 Thread Charles Novaes de Santana
Dear all, I need to access data from a large matrix (48000 x 48000) and to do it I am trying to run two loops using for command. Surely it is been a very slow job. I heard that for is not the best option to perform large loops in R, but I don't really know what would be the best (fast) option.

Re: [R] Large loops in R

2012-12-04 Thread R. Michael Weylandt michael.weyla...@gmail.com
On Dec 4, 2012, at 6:47 PM, Charles Novaes de Santana charles.sant...@gmail.com wrote: Dear all, I need to access data from a large matrix (48000 x 48000) and to do it I am trying to run two loops using for command. Surely it is been a very slow job. I heard that for is not the best

[R] control point size of superscript when labeling axes with title()

2012-12-04 Thread Chris Solomon
Hi- A journal has asked me to make all of my text annotations on a figure at 10-point size. For the most part this is easy, e.g. by creating figures with: pdf(..., family='Times', pointsize=10) But where I have superscripts (or subscripts) in axis labels, the default seems to be to shrink

Re: [R] Large loops in R

2012-12-04 Thread Charles Novaes de Santana
Dear Michael, Thank you for your answer. I have 2 matrices. Each position of the matrices is a weight. And I need to calculate the following sum of differences: Considering: mat1 and mat2 - two matrices (each of them 48000 x 48000). d1 and d2 - two constant values. sum-0; for(i in 1:nrows1){

Re: [R] Large loops in R

2012-12-04 Thread Sarah Goslee
Without a reproducible example it's hard to tell for certain, but what about simply (assuming nrows2 is actually columns): sum((mat1/d1 - mat2/d2)^2) R is smart enough to understand elementwise manipulation of a matrix: you shouldn't need a loop at all. Sarah On Tue, Dec 4, 2012 at 2:27 PM,

Re: [R] Large loops in R

2012-12-04 Thread Peter Langfelder
On Tue, Dec 4, 2012 at 11:27 AM, Charles Novaes de Santana charles.sant...@gmail.com wrote: Dear Michael, Thank you for your answer. I have 2 matrices. Each position of the matrices is a weight. And I need to calculate the following sum of differences: Considering: mat1 and mat2 - two

[R] list to matrix?

2012-12-04 Thread Sam Steingold
How do I convert a list to a matrix? --8---cut here---start-8--- list(c(5, 101), c(1e+05, 46), c(15, 31), c(2e+05, 17), c(25, 19), c(3e+05, 11), c(35, 12), c(4e+05, 25), c(45, 19), c(5e+05, 16)) as.matrix(a) [,1] [1,]

Re: [R] monte carlo simulation on R

2012-12-04 Thread Suzen, Mehmet
There is a book on MC with R: Introducing Monte Carlo Methods with R by Robert/Casella: http://www.springer.com/statistics/computational+statistics/book/978-1-4419-1575-7 On 4 December 2012 19:21, Adel ESSAFI adeless...@gmail.com wrote: Hello, How can I make a monte carlo simulation on R?

Re: [R] Large loops in R

2012-12-04 Thread Charles Novaes de Santana
On Tue, Dec 4, 2012 at 8:43 PM, Peter Langfelder peter.langfel...@gmail.com wrote: On Tue, Dec 4, 2012 at 11:27 AM, Charles Novaes de Santana charles.sant...@gmail.com wrote: Dear Michael, Thank you for your answer. I have 2 matrices. Each position of the matrices is a weight. And I need

Re: [R] list to matrix?

2012-12-04 Thread Mark Lamias
Try: matrix(unlist(a), ncol=2, byrow=T) --Mark Lamias From: Sam Steingold s...@gnu.org To: r-help@r-project.org Sent: Tuesday, December 4, 2012 3:09 PM Subject: [R] list to matrix? How do I convert a list to a matrix? --8---cut

Re: [R] list to matrix?

2012-12-04 Thread R. Michael Weylandt
On Tue, Dec 4, 2012 at 8:09 PM, Sam Steingold s...@gnu.org wrote: How do I convert a list to a matrix? --8---cut here---start-8--- list(c(5, 101), c(1e+05, 46), c(15, 31), c(2e+05, 17), c(25, 19), c(3e+05, 11), c(35, 12), c(4e+05, 25),

Re: [R] Large loops in R

2012-12-04 Thread Charles Novaes de Santana
Thank you, Sarah! It is a wonderful new!!! :) Now I need to solve the other question hehe How to allocate such large matrix :) best, Charles On Tue, Dec 4, 2012 at 8:39 PM, Sarah Goslee sarah.gos...@gmail.com wrote: Without a reproducible example it's hard to tell for certain, but what about

Re: [R] Large loops in R

2012-12-04 Thread R. Michael Weylandt
On Tue, Dec 4, 2012 at 8:14 PM, Charles Novaes de Santana charles.sant...@gmail.com wrote: Error in matrix(0, 48000, 48000) : too many elements specified but I thought it was a machine limitation (and I was asking for access to a better machine in my labs...). Thanks for clarifying it. Well,

Re: [R] Large loops in R

2012-12-04 Thread Sarah Goslee
I don't think there's any reason for the calculation you're doing that you must have the whole matrix in memory, is there? Unless there's something more than what you've shown us, you're just taking the sum of elementwise operations. You can read the matrix in in manageable chunks, take the sum

[R] How to find matching columns in a matrix of lists?

2012-12-04 Thread Asis Hallab
Dear R users, I have a matrix composed of lists: m - matrix( list(), nrow=1, ncol=3 ) m[[ 1, 1 ]] - list(A, B) m[[ 1, 2 ]] - list(A, C) m[[ 1, 3 ]] - list(A, B) and want to get the sub-matrix where cells contain B. But m[ , B %in% m[ 1, ], drop=F ] as well as m[ , B %in% m[ 1, ][], drop=F ]

[R] reformatting some data

2012-12-04 Thread Charles Determan Jr
Hello, I am trying to reformat some data so that it is organized by group in the columns. The data currently looks like this: group X3.Hydroxybutyrate X3.Hydroxyisovalerate ADP 347 4 4e-04 3e-04 5e-04 353 3 5e-04

Re: [R] reformatting some data

2012-12-04 Thread Mark Lamias
It's not clear to me what it is you are attempting to do, as you switch from a very specific example to some general example with the vague terms var1 var2, and var3. It sounds like you might be trying to do something similar to what would be available in the shape package using the melt

Re: [R] reformatting some data

2012-12-04 Thread Mark Lamias
That should read the reshape package -- not the shape package.  My apologies. To: Charles Determan Jr deter...@umn.edu; r-help@r-project.org r-help@r-project.org Sent: Tuesday, December 4, 2012 4:36 PM Subject: Re: [R] reformatting some data It's not

Re: [R] monte carlo simulation on R

2012-12-04 Thread Suzen, Mehmet
There is a book on MC with R: Introducing Monte Carlo Methods with R by Robert/Casella: http://www.springer.com/statistics/computational+statistics/book/978-1-4419-1575-7 On 4 December 2012 19:38, R. Michael Weylandt michael.weyla...@gmail.com wrote: replicate(1000, sum(rnorm(50)^2-rchisq(50,

Re: [R] Large loops in R

2012-12-04 Thread arun
HI, I just wonder whether your code worked or not. set.seed(8) mat1-matrix(sample(1:80,40,replace=TRUE),ncol=8) set.seed(25) mat2-matrix(sample(1:160,40,replace=TRUE),ncol=8) #Since the dimensions are the same, m-1:5 n-1:8 sum1-0 for(i in 1:length(m)){  for(j in 1:length(n)){  

Re: [R] computing marginal values based on multiple columns?

2012-12-04 Thread Simon
Thanks to both of you! I learned something new from both of your posts :-) And you were both right, my example numbers were wrong! I accidentally computed them based on 0.25 * mean instead of 0.2 * mean. Thanks again! Simon On Wed, Dec 5, 2012 at 4:07 AM, arun smartpink...@yahoo.com wrote:

Re: [R] list to matrix?

2012-12-04 Thread arun
Hi, Try this: list1-list(c(5, 101), c(1e+05, 46), c(15, 31), c(2e+05, 17),     c(25, 19), c(3e+05, 11), c(35, 12), c(4e+05, 25),     c(45, 19), c(5e+05, 16)) res-t(sapply(list1,function(x) x)) res #    [,1] [,2]  #[1,]  5  101  #[2,] 10   46  #[3,] 15   31  

[R] How do I get internal nodes of dendograms produced by R?

2012-12-04 Thread sagnik ray choudhury
I am using R for hierarchical clustering of a number of documents. I have a distance matrix on which I have applied hclust method. When I plot the result of hclust method, I can see the dendogram plotted. What I need now is the dendogram stored as a tree in a data structure. My goal is to

Re: [R] How to find matching columns in a matrix of lists?

2012-12-04 Thread Asis Hallab
Hello, m[ , sapply(1:ncol(m), function(j) sapply(B, `%in%`, m[[1 , j]])), drop=F ] It indeed does. Thank you very much! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] reformatting some data

2012-12-04 Thread arun
Hi, Not sure whether this helps: library(reshape2) dat1-structure(list(group = c(4L, 3L, 4L, 4L, 4L, 2L), X3.Hydroxybutyrate =  c(4e-04,  5e-04, 4e-04, 6e-04, 5e-04, 7e-04), X3.Hydroxyisovalerate = c(3e-04,  3e-04, 3e-04, 3e-04, 3e-04, 4e-04), ADP = c(5e-04, 6e-04, 6e-04,  5e-04, 7e-04, 7e-04)),

Re: [R] reformatting some data

2012-12-04 Thread arun
Hi, You can also do this: dat1-structure(list(group = c(4L, 3L, 4L, 4L, 4L, 2L), X3.Hydroxybutyrate =  c(4e-04,  5e-04, 4e-04, 6e-04, 5e-04, 7e-04), X3.Hydroxyisovalerate = c(3e-04,  3e-04, 3e-04, 3e-04, 3e-04, 4e-04), ADP = c(5e-04, 6e-04, 6e-04,  5e-04, 7e-04, 7e-04)), .Names = c(group,

Re: [R] How to find matching columns in a matrix of lists?

2012-12-04 Thread arun
HI, Does this work for you?  mapply(function(x) x==B,m)   [,1]  [,2]  [,3] #[1,] FALSE FALSE FALSE #[2,]  TRUE FALSE  TRUE A.K. - Original Message - From: Asis Hallab asis.hal...@gmail.com To: r-help@r-project.org Cc: Sent: Tuesday, December 4, 2012 4:16 PM Subject: [R] How to

Re: [R] How to find matching columns in a matrix of lists?

2012-12-04 Thread Rui Barradas
Hello, Try the following. m[ , sapply(1:ncol(m), function(j) sapply(B, `%in%`, m[[1 , j]])), drop=F ] Hope this helps, Rui Barradas Em 04-12-2012 21:16, Asis Hallab escreveu: Dear R users, I have a matrix composed of lists: m - matrix( list(), nrow=1, ncol=3 ) m[[ 1, 1 ]] - list(A, B)

Re: [R] list to matrix?

2012-12-04 Thread R. Michael Weylandt
On Tue, Dec 4, 2012 at 8:17 PM, arun smartpink...@yahoo.com wrote: Hi, Try this: list1-list(c(5, 101), c(1e+05, 46), c(15, 31), c(2e+05, 17), c(25, 19), c(3e+05, 11), c(35, 12), c(4e+05, 25), c(45, 19), c(5e+05, 16)) res-t(sapply(list1,function(x) x)) Bah

[R] latticeExtra tileplot question - tiles are not all the same size, need help.

2012-12-04 Thread Ryan Flaherty
Hello, I have been creating many tileplots to try and illustrate the relative abundance of fish through space and time. My issue is that the tiles that border the plot are smaller than those in the center of the plot. In the example I've provided the effect is pretty minor (I'm hoping this will

Re: [R] list to matrix?

2012-12-04 Thread William Dunlap
No need for all this (see solutions including mine already given) -- but even without those, this is silly. An identity map is a real waste if you just want the simplification bit of sapply() -- you'd be much better just using simplify2array() You are right that simplify2array(p) does

Re: [R] partial analisys of a time series

2012-12-04 Thread Antonio Silva
Hi all Thanks for the attention and answers. I learned a lot I now I can go on my work. I also tryed to you de command window(). I thought it would be possible to select one column of an ts object, like we can do with a data.frame (plot(data[,2],data[,3]), to work. But as I saw we need to

Re: [R] control point size of superscript when labeling axes with title()

2012-12-04 Thread David Winsemius
On Dec 4, 2012, at 11:05 AM, Chris Solomon wrote: Hi- A journal has asked me to make all of my text annotations on a figure at 10-point size. For the most part this is easy, e.g. by creating figures with: pdf(..., family='Times', pointsize=10) But where I have superscripts (or

Re: [R] How to find matching columns in a matrix of lists?

2012-12-04 Thread Asis Hallab
Hi R users following this thread! I evaluated both solutions given by Rui and Arun. Both work very well. Arun's is a little faster. I did the following time measurements on a large matrix with 2 rows, labelled InterPro and GO, and 88664 columns, labelled with protein IDs. I was interested in

Re: [R] control point size of superscript when labeling axes with title()

2012-12-04 Thread Chris Solomon
Fantastic - that does the trick, David, thanks for setting me straight! Chris -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Tuesday, December 04, 2012 8:19 PM To: Chris Solomon Cc: r-help@r-project.org Subject: Re: [R] control point size of superscript

  1   2   >