Re: [R] how to compute a vector of min values ?

2012-04-06 Thread peter dalgaard
On Apr 6, 2012, at 00:25 , ikuzar wrote: Hi, I'd like to know how to get a vector of min value from many vectors without making a loop. For example : v1 = c( 1, 2, 3) v2 = c( 2, 3, 4) v3 = c(3, 4, 5) df = data.frame(v1, v2, v3) df v1 v2 v3 1 1 2 3 2 2 3 4 3 3 4 5

[R] Legend based on levels of a variable

2012-04-06 Thread Kumar Mainali
I have a bivariate plot of axis2 against axis1 (data below). I would like to use different size, type and color for points in the plot for the point coming from different region. For some reasons, I cannot get it done. Below is my code. col - rep(c(blue, red, darkgreen), c(16, 16, 16)) ## Choose

[R] Time series - year on year growth rate

2012-04-06 Thread jpm miao
Hello, Is there a function in R that calculates the year-on-year growth rate of some time series? In EView the function is @pchy. Thanks, miao [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

Re: [R] Fisher's LSD multiple comparisons in a two-way ANOVA

2012-04-06 Thread Jinsong Zhao
On 2012-04-05 10:49, Richard M. Heiberger wrote: Here is your example. The table you displayed in gigawiz ignored the two-way factor structure and interpreted the data as a single factor with 6 levels. I created the interaction of a and b to get that behavior. ## your example, with data stored

Re: [R] Legend based on levels of a variable

2012-04-06 Thread Petr PIKAL
Hi I have a bivariate plot of axis2 against axis1 (data below). I would like to use different size, type and color for points in the plot for the point coming from different region. For some reasons, I cannot get it done. Below is my code. col - rep(c(blue, red, darkgreen), c(16, 16,

[R] Hi: Help Using Spreadsheets

2012-04-06 Thread Petr PIKAL
Hi Hello, I am a new user of R and I am trying to use the data I am reading from a spreadsheet. I installed the xlsReadWrite package and I am able to read data from this files, but how can I assign the colums into values? E.g: as I read a spreadsheet like this one: Maybe with

Re: [R] Legend based on levels of a variable

2012-04-06 Thread mlell08
He provided data, yet in an inconvenient way at the bottom of his post. Kumar, please use dput() to provide data to the list, because its much easier to import: dput(data)## name data is made up by me structure(list(Region = structure(c(2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L,

Re: [R] how to do piecewise linear regression in R?

2012-04-06 Thread Petr PIKAL
Hi Your post is rather screwed. [R] how to do piecewise linear regression in R? Maybe segmented? Regards Petr Dear all, I want to do piecewise CAPM linear regression in R: RRiskArb−Rf = (1−δ)[αMktLow+βMktLow(RMkt−Rf)] + δ[αMkt High +βMkt High(RMkt −Rf )] where

Re: [R] Time series - year on year growth rate

2012-04-06 Thread Berend Hasselman
On 06-04-2012, at 10:27, jpm miao wrote: Hello, Is there a function in R that calculates the year-on-year growth rate of some time series? In EView the function is @pchy. This might do what you need pchy - function(x) { if(!is.ts(x)) stop(x is not a timeseries) x.freq -

Re: [R] Legend based on levels of a variable

2012-04-06 Thread Petr PIKAL
Thanks, anyway, using build-in R features is preferable for colours with(data, plot(axis1, axis2, col= c(red, blue, green)[as.numeric(data$Region)])) legend(topright, legend=levels(data$Region), fill= c(red, blue, green)) although sometimes can be preferable to get advantage of grid graphic

Re: [R] Help with gsub function or a similar function

2012-04-06 Thread Sarah Goslee
You don't provide a reproducible example, or even str(), but I'd guess you need to match ^15 instead of just 15. Sarah On Apr 5, 2012, at 10:38 PM, ieatnapalm era...@tulane.edu wrote: Hey, sorry if this has been addressed before, but I'm really new to R and having trouble with the gsub

Re: [R] integrate function - error -integration not occurring with last few rows

2012-04-06 Thread Navin Goyal
Apologies for the lengthy code. I tried a simple (and shorter) piece of code (pasted below) and it still gives me the same error for last few rows. Is this a bug or am I doing something totally wrong? Could anyone please provide some help/pointers ? PS. beta0 was fixed to 0.001 in the previous

Re: [R] integrate function - error -integration not occurring with last few rows

2012-04-06 Thread Navin Goyal
Apologies for the lengthy code. I tried a simple (and shorter) piece of code (pasted below) and it still gives me the same error for last few rows. Is this a bug or am I doing something totally wrong? Could anyone please provide some help/pointers ? PS. beta0 was fixed to 0.001 in the previous

Re: [R] Legend based on levels of a variable

2012-04-06 Thread windmagics_lsl
I think there may 3 legends should be added in your plot the argument col, pch and pt.cex should be in the same length with legend, but the objects col, pch and cex you defined former have 16*3 length. I guess the follow codes may work col - rep(c(blue, red, darkgreen), c(16, 16, 16)) ## Choose

[R] R generated means are different from the boxplot!

2012-04-06 Thread Jhope
Hi R-listers, 1) I am having trouble understanding why the means I have calculated from Aeventexhumed (A, B, and C) are different from the means showing on the boxplot I generated (see attached). I have added the script as to how my data is organized. 2) Also when I went through the data

Re: [R] R generated means are different from the boxplot!

2012-04-06 Thread Liviu Andronic
Hello On Fri, Apr 6, 2012 at 10:35 AM, Jhope jeanwaij...@gmail.com wrote: Hi R-listers, 1) I am having trouble understanding why the means I have calculated from Aeventexhumed (A, B, and C) are different from the means showing on the boxplot I generated (see attached).  I have added the

[R] DESCRIPTION FILE in R Manuals

2012-04-06 Thread Axel Urbiz
Dear List, In building a package on a Mac, all the steps performed (build, check, install) seem to be working fine (no warning messages or errors). The manual for the package is created and everything looks good except for the fact that the header of the document is not showing the info on the

Re: [R] R generated means are different from the boxplot!

2012-04-06 Thread Petr PIKAL
Hi Hi R-listers, 1) I am having trouble understanding why the means I have calculated from Aeventexhumed (A, B, and C) are different from the means showing on the boxplot I generated (see attached). I have added the script as to how my data is organized. Maybe the difference is that

Re: [R] reclaiming lost memory in R

2012-04-06 Thread Ramiro Barrantes
Thank you for your feedback. I think the problem is that, when nlme runs, it hangs when iterating. I have a timeout of 5 minutes so that is how I get it to stop on the few cases where it goes over. However, I think the memory doesn't get cleared up properly. Please let me know if you have

Re: [R] reclaiming lost memory in R

2012-04-06 Thread Liviu Andronic
On Fri, Apr 6, 2012 at 2:21 PM, Ramiro Barrantes ram...@precisionbioassay.com wrote: Please let me know if you have any other suggestions or clues. See this older post by Brian [1] and check ?Memory-limits. Otherwise, I remember someone suggesting that even if R releases the memory internally,

[R] read multiaple files within one folder

2012-04-06 Thread Amen
Suppose we have files in one folder file1.bin, file2.bin, ... , and 1460slice(file) with dim of 720 * 360 in directory C:\\PHD\\Climate Data\\Wind\\ and we want to read them and make a loop to go from 1 to 4 and take the average, then from 4 to 8 and so on till 1460. in the end we will get 365

Re: [R] Adding text for written comments to bottom of graphs

2012-04-06 Thread Paul Miller
Hi Baptiste, Thanks for your help with this. Sorry for being slow to express my appreciation. I had intended to put some more time into tweaking the graphs before responding. Recently have been reading Hadley Wickham's ggplot2 book and have also located some materials on the knitr package.

Re: [R] DESCRIPTION FILE in R Manuals

2012-04-06 Thread Duncan Murdoch
On 12-04-06 8:03 AM, Axel Urbiz wrote: Dear List, In building a package on a Mac, all the steps performed (build, check, install) seem to be working fine (no warning messages or errors). The manual for the package is created and everything looks good except for the fact that the header of the

[R] Missing CRAN Mirror

2012-04-06 Thread Tyler Rinker
Hello R community, This isn't a technical question about R: I have used http://lib.stat.cmu.edu/R/CRAN/ as my mirror for some time now. As of a few days now I don't seem to be able to use this mirror. The link from CRAN to this repository does not work either. Does anyone know the fate of

Re: [R] integrate function - error -integration not occurring with last few rows

2012-04-06 Thread Berend Hasselman
On 06-04-2012, at 13:14, Navin Goyal wrote: Apologies for the lengthy code. I tried a simple (and shorter) piece of code (pasted below) and it still gives me the same error for last few rows. Is this a bug or am I doing something totally wrong? Could anyone please provide some

Re: [R] read multiaple files within one folder

2012-04-06 Thread jim holtman
Why didn't seem to be right? Are there error messages? I assume you have at least 6GB of real memory since you single copy of Testarray requires 3GB. Is your already in a 'binary' file? If so, why are you defining your matrix as numeric? Should you be using 'array(0L, dim = c(1460, 720,

Re: [R] integrate function - error -integration not occurring with last few rows

2012-04-06 Thread Navin Goyal
Thank you so much for your help Berend. I did not see that my code had a typo and it was thus wrongly written ( I overlooked the i that was supposed to be actually 1) instead of for (q in *1*:length(comb1$ID)) I had it as for (q in *i*:length(comb1$ID)) It works correctly as

Re: [R] read multiaple files within one folder

2012-04-06 Thread Amen
firstly , thanks a lot. yes the files are already binarys. (there are 360 binary files ,each file has dim of 720 *360 files) in one folder of what I am trying to do is to take the average of each 4 files and finally got 40 files to a new folder . the error message is Error in Testarray[i, , ]

[R] Changing grid defaults

2012-04-06 Thread Brett Presnell
I'm trying to use the vcd package to produce mosaic plots for my class notes, written in Sweave and using the LaTeX's beamer document class. For projecting the notes in class, I use a dark background with light foreground colors. It's easy enough to change the defaults for R's standard graphics

[R] multiple values in one column

2012-04-06 Thread John D. Muccigrosso
I have some data files in which some fields have multiple values. For example first last sex major John Smith M ANTH Jane DoeF HIST,BIOL What's the best R-like way to handle these data (Jane's major in my example), so that I can do things like summarize the other fields by

Re: [R] multiple values in one column

2012-04-06 Thread Mark Grimes
John I have to deal with this kind of thing too for my class. # Some functions # for ad$Full.name = Mark Grimes get.first.name - function(cell){ x-unlist(strsplit(as.character(cell), )) return(x[1]) } get.last.name - function(cell){

Re: [R] Missing CRAN Mirror

2012-04-06 Thread David Winsemius
On Apr 6, 2012, at 9:45 AM, Tyler Rinker wrote: Hello R community, This isn't a technical question about R: I have used http://lib.stat.cmu.edu/R/CRAN/ as my mirror for some time now. As of a few days now I don't seem to be able to use this mirror. The link from CRAN to this repository

[R] How to get the confidence interval of area under then time dependent roc curve

2012-04-06 Thread 何湘湘
It is possible to calculate the c-index for time dependent outcomes (such as disease) using the survivalROC package in R. My question is : is it possible to produce a p-value for the c-index that is calculated (at a specific point in time)?How to get the confidence interval of area under then

Re: [R] multiple values in one column

2012-04-06 Thread Ashish Agarwal
How about reading lines and separating out cases having more than one major? For cases having more than one major, process the data to create duplicate rows - one for each major On Fri, Apr 6, 2012 at 8:39 PM, John D. Muccigrosso intern...@muccigrosso.org wrote: I have some data files in which

Re: [R] Help Using Spreadsheets

2012-04-06 Thread Pedro Henrique
Hi, Petr, Thanks for answering. Yes, I do read the file with the read.xls command but I do not know how to read it into an object. I read the R-into document chapter of objects, but I is still not clear for me how to transform this kind of data into an object. Regards, Lämarao -

Re: [R] Best way to do temporal joins in R?

2012-04-06 Thread Edith Mertz
Hi, I'm new to R-help mailing list and novice in R, so pls excuse 'silly questions' and obvious blunders. I have the same problem as Jon Greenberg (just different data) and have been trying to use the code given above, but with some difficulty. Pls Help? My data: Table 1 (TideH.csv) Date

[R] Multivariate Multilevel Model: is R the right software for this problem

2012-04-06 Thread Eiko Fried
Hello, I've been trying to answer a problem I have had for some months now and came across multivariate multilevel modeling. I know MPLUS and SPSS quite well but these programs could not solve this specific difficulty. My problem: 9 correlated dependent variables (medical symptoms; categorical,

[R] Execution speed in randomForest

2012-04-06 Thread Jason Caroline Shaw
I am using the randomForest package. I have found that multiple runs of precisely the same command can generate drastically different run times. Can anyone with knowledge of this package provide some insight as to why this would happen and whether there's anything I can do about it? Here are

Re: [R] Best way to do temporal joins in R?

2012-04-06 Thread Edith Mertz
Found the blunder, last line should have been: TideH$dt - as.chron(paste(TideH$Date, TideH$Time), %Y%m%d %H%M%S) After this I did: Fix - read.csv(Fix times.csv) Fix[,Station] - as.character(Fix[,Station]) Fix[,Date] - as.Date(Fix[,Date],format=%d/%m/%Y) Fix[,Time] - as.character(Fix[,Time])

Re: [R] Changing grid defaults

2012-04-06 Thread ilai
You might want to check out package {tikzDevice} and it's documentation. In essence you turn your R plots to tikz-pgf so they can be naturally incorporated into a beamer presentation. Colors, bg, fonts etc. can now be controlled in your main latex doc. I find it much more convenient, and nicer

[R] Order sapply

2012-04-06 Thread MSousa
Good Afternoon, I have the following code, but it seems that something must be doing wrong, because it is giving the results I want. The idea is to create segments while the value of Commutation is less than 1000. for example, from the small set of data below text= val_user posv

[R] Sincere inquiry about “subscript out of bounds” error in R

2012-04-06 Thread 卢永芳
Hello£¬experts I am working on a simulation of effect of artificial selection on certain population in Animal Breeding.I am new beginner in coding. I have already build a matrix A(500*500) based on this code A-matrix(,500,500) for(i in 1:500){ for(j in 1:500){ ifelse(i==j,A[i,j]-1,A[i,j]-0) } }

Re: [R] Imputing missing values using LSmeans (i.e., population marginal means) - advice in R?

2012-04-06 Thread Jenn Barrett
Thanks Andy. I did read that posting, but didn't find that it answered my questions. Ok - so I've confirmed that I can use popMeans in the doBy package to obtain the LSmeans as described in my e-mail below; however, the output has me puzzled. Recall that my data consists of counts at various

Re: [R] Order sapply

2012-04-06 Thread R. Michael Weylandt
On Fri, Apr 6, 2012 at 10:27 AM, MSousa ricardosousa2...@clix.pt wrote: Good Afternoon,   I have the following code, but it seems that something must be doing wrong, because it is giving the results I want. Didn't someone else have that problem just a few weeks ago? :-P Michael The idea is

Re: [R] Multivariate Multilevel Model: is R the right software for this problem

2012-04-06 Thread Andrew Miles
I recommend looking at chapter 6 of Paul Allison's Fixed Effects Regression Models. This chapter outlines how you can use a structural equation modeling framework to estimate a multi-level model (a random effects model). This approach is slower than just using MLM software like lmer() in the

Re: [R] indexing in a function doesn't work?

2012-04-06 Thread Benjamin Caldwell
Josh Apologies I haven't responded earlier. This looks great - I ended up doing what I needed done piece-by-piece because of a looming deadline, but understanding this code and your suggestions below will be a weekend project. Many thanks for all your help. * * Best Ben On Tue, Apr 3, 2012 at

Re: [R] avoiding for loops

2012-04-06 Thread R. Michael Weylandt
Usually you can just use cor() and it will do all the possibilities directly: x - matrix(rnorm(100), ncol = 10) cor(x) But that works on the columns, so you'll need to transpose things if you want all possible row combinations: cor(t(x)) Hope this helps, Michael On Fri, Apr 6, 2012 at 9:57 AM,

Re: [R] Sincere inquiry about “subscript out of bounds” error in R

2012-04-06 Thread jim holtman
You need to do some basic debugging by putting options(error=utils::recover) in your startup of R (or just type it in) so that when the error occurs you get control at the point of the error and can examine all the variable. You have some incorrect data that is causing the subscript error, so

Re: [R] Execution speed in randomForest

2012-04-06 Thread jim holtman
Are you looking at the CPU or the elapsed time? If it is the elapsed time, then also capture the CPU time to see if it is different. Also consider the use of the Rprof function to see where time is being spent. What else is running on the machine? Are you doing any paging? What type of system

[R] resampling syntax for caret package

2012-04-06 Thread Juliet Hannah
Max and List, Could you advise me if I am using the proper caret syntax to carry out leave-one-out cross validation. In the example below, I use example data from the rda package. I use caret to tune over a grid and select an optimal value. I think I am then using the optimal selection for

Re: [R] Best way to do temporal joins in R?

2012-04-06 Thread jim holtman
check out the 'sqldf' package. In http://code.google.com/p/sqldf/#Example_4._Join there is an example of a temporal join. Maybe this will work for you. On Fri, Apr 6, 2012 at 9:56 AM, Edith Mertz mertz...@gmail.com wrote: Found the blunder, last line should have been: TideH$dt -

Re: [R] Help Using Spreadsheets

2012-04-06 Thread jim holtman
You might want to re-read the Intro to R and the section on dataframes. Your spreadsheet is read into R as a dataframe which is very similar to an Excel spreadsheet. Exactly what problem are you having with it? Is it trying to access the data? 2012/4/6 Pedro Henrique lama...@superig.com.br:

[R] Converting data frame to its object results in matrix of strings

2012-04-06 Thread Noah Silverman
Hi, I have a rather large data frame (500 x 5000) that I want to convert to a proper xts object. I am able to properly generate an xts object with the correct time index. However, all of my numerical values are now strings. b - as.xts(a[,2:dim(a)[2]],

Re: [R] Order sapply

2012-04-06 Thread Sarah Goslee
On Fri, Apr 6, 2012 at 10:27 AM, MSousa ricardosousa2...@clix.pt wrote: Good Afternoon,   I have the following code, but it seems that something must be doing wrong, because it is giving the results I want. Assuming you don't really mean that, you can use order() and/or sort() to put it back

Re: [R] Fisher's LSD multiple comparisons in a two-way ANOVA

2012-04-06 Thread Richard M. Heiberger
Interpreting contrasts for a two-way interaction in the presence of a significant three-way interaction is dangerous. They might not be interpretable. I would start by examining the interaction2wt plot (in the HH package) interaction2wt(activity ~ pH + I + f, data=yourdataframe) Look at the

Re: [R] Sincere inquiry about “subscript out of bounds” error in R

2012-04-06 Thread Henrik Bengtsson
str() is your number one friend in R. Do str(A) and str(A2) after allocating the matrices and you'll be surprised. My $.02 /Henrik On Fri, Apr 6, 2012 at 7:35 AM, 卢永芳 sswwss...@126.com wrote: Hello,experts I am working on a simulation of effect of artificial selection on certain population

Re: [R] How do I get a rough quick utility plot of a time series?

2012-04-06 Thread Hurr
I believe I have made this posting simple enough to understand. The sample time-series has only 10 times. SimpleTS() is the R function to contain the call to do the plot. SimpleTS - function() { titleline - readLines(SimpleTS.dta, n=1) print(titleline) dta - read.table(SimpleTS.dta, skip

[R] Saving multiple plots using tiff function

2012-04-06 Thread John S
Dear R experts, I am trying to save three plots using tiff graphics devices; however the following code only produces two files (Rplot002.tif and Rplot003.tif) showing figures 1 and 3. Here is a simplified ex code tiff(filename =Rplot%03d.tif,width=24,height=20,units=cm,res=300, pointsize=10,

Re: [R] Saving multiple plots using tiff function

2012-04-06 Thread John S
Sorry forgot to mention that I am using windows 7 and R session info R version 2.15.0 (2012-03-30) Platform: i386-pc-mingw32/i386 (32-bit Thanks, John On Fri, Apr 6, 2012 at 2:17 PM, John S john.smith...@gmail.com wrote: Dear R experts, I am trying to save three plots using tiff graphics

[R] Bayesian 95% Credible interval

2012-04-06 Thread Gyanendra Pokharel
Hi all, I have the data from the posterior distribution for some parameter. I want to find the 95% credible interval. I think t.test(data) is only for the confidence interval. I did not fine function for the Bayesian credible interval. Could some one suggest me? Thanks [[alternative HTML

Re: [R] multiple values in one column

2012-04-06 Thread Nutter, Benjamin
This is a function I use for these kinds of situations. Assuming the delimiter within the column is consistent and the spelling is consistent, it is pretty useful. The function returns a vector of 0/1 values, 1 if the text in level is found, 0 otherwise. var=the variable level=The value of

Re: [R] Bayesian 95% Credible interval

2012-04-06 Thread Brunero Liseo
This is a function I use when the posterior is unimodal I do not remember but I think I found it somewhere in the web brunero hpd-function(x,p){ #generate an hpd set of level p, based #on a sample x from the posterior dx-density(x) md-dx$x[dx$y==max(dx$y)] px-dx$y/sum(dx$y) pxs--sort(-px)

[R] filling the matrix row by row in the order from lower to larger elements

2012-04-06 Thread Dimitri Liakhovitski
Hello, everybody! I have a matrix input (see example below) - with all unique entries that are actually unique ranks (i.e., start with 1, no ties). I want to assign a value of 100 to the first row of the column that contains the minimum (i.e., value of 1). Then, I want to assign a value of 100 to

Re: [R] multiple values in one column

2012-04-06 Thread John D. Muccigrosso
On Apr 6, 2012, at 9:09 AM, John D. Muccigrosso wrote: I have some data files in which some fields have multiple values. For example first last sex major John Smith M ANTH Jane DoeF HIST,BIOL What's the best R-like way to handle these data (Jane's major in my

Re: [R] multiple values in one column

2012-04-06 Thread Sarah Goslee
To the best of my knowledge, you can't skip step #2, at least not with using much more complicated work-arounds like including a gsub() step within the call to table, and to everything else you do with those data. Computers are generally better at dealing with normalized data, which is what

Re: [R] Converting data frame to its object results in matrix of strings

2012-04-06 Thread R. Michael Weylandt
Try this: x - xts(as.character(1:10), Sys.Date() + 0:9) storage.mode(x) - double Michael On Fri, Apr 6, 2012 at 1:13 PM, Noah Silverman noahsilver...@ucla.edu wrote: Hi, I have a rather large data frame (500 x 5000) that I want to convert to a proper xts object. I am able to properly

Re: [R] filling the matrix row by row in the order from lower to larger elements

2012-04-06 Thread ilai
I maybe missing something but this seems like an indexing problem which doesn't require a loop at all. Something like this maybe? (input-matrix(c(5,1,3,7,2,6,4,8),nc=2)) output - matrix(0,max(input),2) output[input[,1],1] - 100 output[input[,2],2] - 100 output Cheers On Fri, Apr 6, 2012 at

Re: [R] How do I get a rough quick utility plot of a time series?

2012-04-06 Thread R. Michael Weylandt
This still isn't reproducible -- when I said use dput() I meant it. x - data.frame(x = 1:5, y = letters[1:5], z = factor(sample(1:3,5, TRUE))) # complicated dput(x) # Easy to copy and paste. Also, what package is the linearizeTime function from? I'm having trouble finding it on CRAN. If you can

Re: [R] Changing grid defaults

2012-04-06 Thread Paul Murrell
Hi On 7/04/2012 2:43 a.m., Brett Presnell wrote: I'm trying to use the vcd package to produce mosaic plots for my class notes, written in Sweave and using the LaTeX's beamer document class. For projecting the notes in class, I use a dark background with light foreground colors. It's easy

Re: [R] Multivariate Multilevel Model: is R the right software for this problem

2012-04-06 Thread Andrew Miles
I recommend looking at chapter 6 of Paul Allison's *Fixed Effects Regression Models*. This chapter outlines how you can use a structural equation modeling framework to estimate a multi-level model (a random effects model). This approach is slower than just using MLM software like lmer() in the

Re: [R] How do I get a rough quick utility plot of a time series?

2012-04-06 Thread Hurr
linearizeTime() is from the restof my own code and the rest if my code is not small. That is why I gave you the printout and the code line that produced it. The printout at the end of SimpleTS() is this: [1] `Simple Time Series monoMn SBP DBP HRT 1 1057366710 117 53 54 2 1057369636 108

Re: [R] filling the matrix row by row in the order from lower to larger elements

2012-04-06 Thread Carl Witthoft
I think the OP wants to fill values in an arbitrarily large matrix. Now, first of all, I'd like to know what his real problem is, since this seems like a very tedious and unproductive matrix to produce. But in the meantime, since he also left out important information, let's assume the input

[R] RE filling the matrix row by row in the order from lower to larger elements

2012-04-06 Thread Carl Witthoft
Apologies -- I meant to translate that code (which is what the OP provided, albeit in longer form) into a *apply one-liner. -- Sent from my Cray XK6 Quidvis recte factum, quamvis humile, praeclarum. __ R-help@r-project.org mailing list

[R] how to control exact positions of axis

2012-04-06 Thread Maxim
Hi, I have to plot a heat map and next to it a lineplot. Unfortunately the scale is not the same between the two plots (as the heatmap data is binned). My problem is, that despite the fact the plotted areas (marked by the heatmap and box of the the default line plot) are essentially very

Re: [R] filling the matrix row by row in the order from lower to larger elements

2012-04-06 Thread Carl Witthoft
Ok, how's this: Rgames foo [,1] [,2] [,3] [,4] [1,]361 16 [2,] 10 14 125 [3,] 117 159 [4,]84 132 Rgames sapply(1:4,FUN=function(k){ foo[k,which(foo==k,arr.ind=T)[2]]-100;return(foo)})-bar Rgames bar [,1] [,2] [,3] [,4] [1,]3

Re: [R] filling the matrix row by row in the order from lower to larger elements

2012-04-06 Thread Dimitri Liakhovitski
Yes, that's correct - my matrix has N rows. Thank you very much, Carl. This works great: input-as.matrix(data.frame(a=c(5,1,3,7),b=c(2,6,4,8))) result-input N-nrow(input) for (k in 1:N){ foo - which (input == k,arr.ind=T) result[k,foo[2]] -100 } result[result !=100]-0 Dimitri On Fri, Apr

Re: [R] how to control exact positions of axis

2012-04-06 Thread mlell08
Hello, the graphical parameters xaxs and yaxs are for you. par(xaxs=i) Regards! __ 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

[R] system command and Perl confusion

2012-04-06 Thread Maxim
Hello, I'm having a question related to the system command within R: I try to evoke a perl script from within R with something like system(paste('perl myscript.pl', some parameters ,sep= ) This works just fine as long as I do not use any additionally installed Perl module, as this leads to a

Re: [R] filling the matrix row by row in the order from lower to larger elements

2012-04-06 Thread ilai
On Fri, Apr 6, 2012 at 4:02 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: This works great: Really ? surprising given it is the EXACT same for-loop as in your original problem with counter i replaced by k and reorder to matrix[!100]- 0 instead of matrix(0)[i]- 100 You didn't

Re: [R] integrate function - error -integration not occurring with last few rows

2012-04-06 Thread Peter Ehlers
On 2012-04-06 07:19, Navin Goyal wrote: Thank you so much for your help Berend. I did not see that my code had a typo and it was thus wrongly written ( I overlooked the i that was supposed to be actually 1) instead of for (q in *1*:length(comb1$ID)) I had it as for (q in

Re: [R] How do I get a rough quick utility plot of a time series?

2012-04-06 Thread Hurr
A friend of mine added plot code to the function SimpleTS() as follows but it misses the single point between two missing points: SimpleTS - function() { fileStg - C:/ad/dta/TryRRead/Rcode/SHIYU/SimpleTS.dta titleline - readLines(fileStg, n=1) print(titleline) dta -

Re: [R] Legend based on levels of a variable

2012-04-06 Thread Kumar Mainali
Thank you every body for your suggestion. It does help. On Fri, Apr 6, 2012 at 2:37 AM, windmagics_lsl shfu_...@163.com wrote: I think there may 3 legends should be added in your plot the argument col, pch and pt.cex should be in the same length with legend, but the objects col, pch and cex

Re: [R] system command and Perl confusion

2012-04-06 Thread Nathan McIntyre
This reads like a PATH problem. Specify the absolute path to the perl you want use: /usr/bin/perl or /opt/local/bin/perl. It looks like you already have Statistics::Descriptive thru MacPorts; you can use system(paste(/opt/local/bin/perl myscript.pl, ..., sep = )). If you plan on using the Mac OS

[R] Find sequence in vector

2012-04-06 Thread ens
a-sample(1:6,100,replace=T) a [1] 2 4 3 4 5 1 3 2 4 3 6 6 2 6 2 1 5 5 3 4 6 1 6 6 3 4 6 6 4 4 5 4 6 5 6 3 4 5 6 3 4 1 6 6 6 4 2 1 1 3 1 5 3 2 2 6 2 5 [59] 2 6 1 6 1 1 6 4 4 2 2 3 4 5 6 1 6 4 6 1 5 1 1 2 1 3 4 4 6 3 1 4 1 1 1 5 5 2 4 6 5 1 which(a=3) [1] 1 3 6 7 8 10 13 15 16