Re: [R] permutations in R

2009-03-13 Thread Daniel Viar
Try this: > # Taken from combinations(gtools) > # library(gregmisc) > # Function permutations > fn_perm_list <- + function (n, r, v = 1:n) + { +if (r == 1) + matrix(v, n, 1) +else if (n == 1) + matrix(v, 1, r) +else { + X <- NULL + for (i in 1:n) X <- rbind(X, c

[R] permutations in R

2009-03-13 Thread onyourmark
Hi. Does anyone know of a function which will take as input a number n (or a set of n letters) and will give out, one at a time, the permutations of n (or of those n letters) as a vector? So that I can use the permutations one at a time. And such that it will exhaust all the permutations with no r

[R] Is it normal that normalize.loess does not tolerate a single NA value?

2009-03-13 Thread Emmanuel Levy
Dear all, I have been using normalize.loess and I get the following error message when my matrix contains NA values: > my.mat = matrix(nrow=100, ncol=4, runif(400) ) > my.mat[1,1]=NA > my.mat.n = normalize.loess(my.mat, verbose=TRUE) Done with 1 vs 2 in iteration 1 Done with 1 vs 3 in iteration 1

Re: [R] How to combine xtable and minipage with Sweave ?

2009-03-13 Thread Paul Johnson
On Fri, Mar 13, 2009 at 12:17 PM, Duncan Murdoch wrote: > On 3/13/2009 12:07 PM, Ptit_Bleu wrote: >> >> Thanks Dieter for the link. > > You can use \includegraphics explicitly yourself, and avoid the automatic > code generated by Sweave.  For example, > > <>= > curve(f, from = 1, to = 5) > @ > >

[R] Build function from model formula

2009-03-13 Thread Corey Dow-Hygelund
Hi fellow R-users, I am (attempting) to take a formula object, and convert it into a function which I can feed into optim. Basically, I have several functions that fit the formula object to data, and analyze the results. The next step would be to combine the fitting function coefficient results

Re: [R] Help with Function!

2009-03-13 Thread Paul Johnson
On Fri, Mar 13, 2009 at 6:28 PM, Lars Bishop wrote: > Dear All, > > I need to write 'n' functions on 'm' variables. The functions should be > constructed according to the values of an (nxm) matrix of '1/0' values as > follows. For example, > > if row1 is equal to ,say [1 0  ...0 0] then f1 <-

[R] Help with Function!

2009-03-13 Thread Lars Bishop
Dear All, I need to write 'n' functions on 'm' variables. The functions should be constructed according to the values of an (nxm) matrix of '1/0' values as follows. For example, if row1 is equal to ,say [1 0 ...0 0] then f1 <- (1+x1) if row 2 is equal to, say [1 1 1 0...0 1] then f2 <-(1+x1)

Re: [R] Using format to add leading zeroes

2009-03-13 Thread jim holtman
use sprintf: > sprintf("%04d",15) [1] "0015" On Fri, Mar 13, 2009 at 6:17 PM, Jonathan Greenberg wrote: > I have a numerical vector which contains a (poorly) formatted time column, > which, in theory, should be HHMM, but was distributed as an integer, so, for > 12:15 am, it is saved as "15" (e.

Re: [R] Question on summing rows within nested variable

2009-03-13 Thread jim holtman
If you want zero if only one variable: > DF2 sid pid slope 1 1.1 1.1 2 2 1.1 4.1 3 3 1.1 5.1 2 4 2.1 5.1 3 5 3.2 1.2 2 6 3.2 1.7 3 > tapply(DF2$slope, DF2$sid, function(x) if(length(x) == 1) 0 else mean(x)) 1.1 2.1 3.2 2.33 0.00 2.50 > On Fri,

Re: [R] Question on summing rows within nested variable

2009-03-13 Thread David Winsemius
DF2 <- read.table(textConnection("sidpidslope + 1.11.12 + 1.14.13 + 1.15.12 + 2.15.13 + 3.21.22 + 3.21.73"), header = TRUE) > tapply(DF2$slope, as.factor(DF2$pid), mean) 1.1 1.2 1.7 4.

Re: [R] Using format to add leading zeroes

2009-03-13 Thread David Winsemius
If you have a function that just works on one item at a time then sapply will cure that hormonal deficiency. It will even let you forward arguments to ... if such are allowed: > sapply(vec, "+", 1) [1] 2 3 4 5 6 > vec [1] 1 2 3 4 5 > sapply(vec, "+", 1) [1] 2 3 4 5 6 -- David Winsemius, MD

[R] Question on summing rows within nested variable

2009-03-13 Thread Vedula, Satyanarayana
Hi, I was hoping someone could help figure out how to write code for R to do the below. I have data that looks like below. Variables, sid and pid are strings, slope is numeric. I need R to get me the mean of slopes for all pid's nested within each sid if there are more than one pid's nested wi

[R] Ever see Process R exited abnormally with code 4?

2009-03-13 Thread Paul Johnson
I'm on a Windows XP student's computer. When we get busy and start running R stuff, it hangs at random with the hour glass showing, but the system's cpu is not running at 100%. We sit and watch for a while, and then try alt-ctl-delete to kill the not responding program. In this case, I'm able to

[R] Using format to add leading zeroes

2009-03-13 Thread Jonathan Greenberg
I have a numerical vector which contains a (poorly) formatted time column, which, in theory, should be HHMM, but was distributed as an integer, so, for 12:15 am, it is saved as "15" (e.g. HHMM = 0015 with the zeroes stripped). I'm trying to use this in conjunction with strptime, but I'm thinki

[R] More basic equivalent of TukeyHSD

2009-03-13 Thread Janet Rosenbaum
This is a simple question, but I'm going on the supposition that the only stupid question is the one not asked. 1. I have many sets of 5 proportions that are different from each other (prop.test), and want to know which proportions are different from each other. In other words, I want the equiva

Re: [R] Output Data Formatting Question

2009-03-13 Thread jim holtman
I don't know why sprintf does not work for you. Here is something close; you will have to work on the spacing but the formating in sprintf lets you specify the field size: > sprintf("%2s %-20s%6d%14.5f", "7", "WORD", 5550, 3.14158) [1] " 7 WORD 5550 3.14158" > On Fri, Mar

Re: [R] transforming a matrix

2009-03-13 Thread David Winsemius
Am I correct in thinking that you actually want a function that will take the three row matrix Ystart <- matrix(c(1:3, 34,-56,27), ncol=2) and return the 4 column matrix offered? As it is I see no way that we could know what rule you wanted to apply to that four row X matrix to get the 9

[R] Mixed model help!

2009-03-13 Thread Martín Quiroga
Hi everyone! I am a biologist from Argentina and have to solve this problem. I have an insect population obtained from 10 different nests and need to know its sex ratio. But as I cannot ensure insects independence I need to run a model where I can include the variable “nest” as with a random effect

Re: [R] different outcomes using read.table vs read.csv

2009-03-13 Thread Jason Rupert
Without data it is a bit difficult. However, you may want to check out the following: library(prob) That is from: http://finzi.psych.upenn.edu/R/R-devel/archive/26683.html It allows you to diff the data.frames, so you can see what is missing. This should allow you to find out what rows are

[R] Output Data Formatting Question

2009-03-13 Thread Jason Rupert
Within R I need to reformat my data so that the output looks like the following: " 7 WORDS 5550 3.14159 -6. 6." Previous folks were doing this by hand, but I would like to have a formula do it. That is, (a) 7 (place holder) on second column, then a spac

Re: [R] different outcomes using read.table vs read.csv

2009-03-13 Thread Barry Rowlingson
2009/3/13 jatwood : > Good Afternoon > I have noticed results similar to the following several times as I have used > R over the past several years. > My .csv file has a header row and 3073 rows of data. > >> rskreg<-read.table('D:/data/riskregions.csv',header=T,sep=",") >> dim(rskreg) > [1] 2722  

[R] different outcomes using read.table vs read.csv

2009-03-13 Thread jatwood
Good Afternoon I have noticed results similar to the following several times as I have used R over the past several years. My .csv file has a header row and 3073 rows of data. > rskreg<-read.table('D:/data/riskregions.csv',header=T,sep=",") > dim(rskreg) [1] 2722 13 > rskreg<-read.csv('D:/dat

Re: [R] search for string insider a string

2009-03-13 Thread Gabor Grothendieck
That might be done by splitting the string into the portion before dtest, the portion from dtest to the number but not including it, the number and the rest. The s<- line splits it up into a list and the next line reforms it into a character matrix replacing NULL list items with NA: > library(gsub

Re: [R] Sorting rows of a matrix independent of each other

2009-03-13 Thread Wacek Kusnierczyk
Gabor Grothendieck wrote: > There is aaply in the plyer package that does not > require a transpose: > > aaply(test, 1, sort) > what about a yaaply? vQ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

[R] transforming a matrix

2009-03-13 Thread Dimitri Szerman
Hello, I have a matrix such as > X = matrix(c(1:4,29,32,56,-45), ncol=2) and I want one like > Y=matrix(c( 1 , 34 , 1 , 34 , 2 , -56 , 1 , 34 , 3 , 27 , 1 , 34 , 1 , 34 , 2 , -56 , 2 , -56 , 2 , -56 , 3 , 27 , 2 , -56 , 1 , 34 , 3 , 27 , 2 , -56 , 3 , 27 , 3 , 27 , 3 , 27 ), ncol=4, byrow=T) Ho

Re: [R] Fourier Analysis Help

2009-03-13 Thread Murray Cooper
Just a word of caution. Having done a lot of work with 24 hour blood pressure and ecg recordings, these series are seldom stationary which presents problems with spectral analysis. I don't know what your ultimate goal is, but in my work I found it often better to work with subsets, of the serie

Re: [R] malformed plot symbols in lattice pdf

2009-03-13 Thread Dieter Menne
Mark Wilkinson gmail.com> writes: > I'm using panel.polygon inside a custom panel function to generate > filled polygons for an xyplot. Everything is as expected until I > specify a value < 1 for alpha to fill with a semi-transparent color > and output to pdf. The plot symbols appear malformed.

Re: [R] Overlay plot: boxplot and stripchart

2009-03-13 Thread David Winsemius
It seems almost too simple. Check to see if stripchart has an add= or other argument that lets you overlay charts. It does, so try this: boxplot(x$earned ~ x$movie) stripchart(x$earned ~ x$movie, vertical=T,data=x, method="jitter", add=TRUE, pch=19) -- David Winsemius On Mar 13, 2009, at

[R] malformed plot symbols in lattice pdf

2009-03-13 Thread Mark Wilkinson
Hi, I'm using panel.polygon inside a custom panel function to generate filled polygons for an xyplot. Everything is as expected until I specify a value < 1 for alpha to fill with a semi-transparent color and output to pdf. The plot symbols appear malformed. Am I doing something wrong here? Tha

[R] Running Ztest on r

2009-03-13 Thread avideh yesharim
hello, I would like to obtain a coefficient correlation between residuals and their expected value. in order to do that I need to run a z.test but non of the command available do not work, Im using z.score(x) or scores(x, type=z) commands . my R version is R 2.8.1 GUI 1.27 Tiger build 32-bit (5

Re: [R] search for string insider a string

2009-03-13 Thread Tan, Richard
That works. I want the position just for the purpose of my later manual check. Thanks a lot Gabor. -Original Message- From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] Sent: Friday, March 13, 2009 2:18 PM To: Tan, Richard Cc: r-help@r-project.org Subject: Re: [R] search for str

Re: [R] Fourier Analysis Help

2009-03-13 Thread stephen sefick
Have you done any homework. help.search() or ... spectrum will produce a spectrum and fft is the underlying function. On Fri, Mar 13, 2009 at 2:46 PM, Vittorio Colagrande wrote: > Dear R-help members, > > To whom it may concern, our research group is conducting a study to evaluate > the predic

[R] Overlay plot: boxplot and stripchart

2009-03-13 Thread Aldi Kraja
Hi, I have a data.frame of this kind: x obs movie earned rating 1P1 3.2xx 2P1 4.2xx 3P1 5.2xx 4P1 6.2xx 5P2 3.5xx 6P2 6.5xx 7P2 7.5xx 8P2 4.5xx 9P2 4.5xx 10 P3 4.8

Re: [R] Sorting rows of a matrix independent of each other

2009-03-13 Thread Gabor Grothendieck
There is aaply in the plyer package that does not require a transpose: aaply(test, 1, sort) On Fri, Mar 13, 2009 at 11:14 AM, Kevski wrote: > > Oh, this seemed so simple (and I'm sure the answer will be, as usual, so > thanks in advance for enlightening me). I need to sort each row of a matrix >

Re: [R] Sorting rows of a matrix independent of each other

2009-03-13 Thread Wacek Kusnierczyk
David Winsemius wrote: >> Now I just need the resulting matrix: >> 2 8 9 >> 4 6 7 >> 1 3 5 > > > > > On Mar 13, 2009, at 1:26 PM, Wacek Kusnierczyk wrote: > >> Kevski wrote: >>> Oh, this seemed so simple (and I'm sure the answer will be, as >>> usual, so >>> thanks in advance for enlightening me).

Re: [R] Windows binary version of DPpackage

2009-03-13 Thread Dieter Menne
Debabrata Midya commerce.nsw.gov.au> writes: > 2. Is there any possibility to have a copy of Windows binary of > DPpackage in the near future in the site http://www.cran.r-project.org/? > I contacted Alejandro (now Conception/Chile), and he will upload a new version this weekend, with his

[R] Hierarchical Bayesian Modeling in R

2009-03-13 Thread Kiran BM
Hi Friends, I'm trying to model the consumer decisions (Click-Through Rate and Conversion) in Search Engine Advertising using a hierarchical Bayesian binary logit. The input data is the weekly CTRs and Avg. Position for each search keyword. CTR is modeled as (for each keyword i and week j): Pij =

[R] Fourier Analysis Help

2009-03-13 Thread Vittorio Colagrande
Dear R-help members, To whom it may concern, our research group is conducting a study to evaluate the predictive value of 24 hour blood pressure variability. We are looking for an R routine that performs a fast Fourier transform spectral analysis (with an output of the approximation function o

Re: [R] Unable to run smoother in qplot() or ggplot() - complains about knots

2009-03-13 Thread Christopher David Desjardins
Thanks for the reply. I'll look into this. Chris On Mar 13, 2009, at 8:31 AM, hadley wickham wrote: On Thu, Mar 12, 2009 at 5:37 PM, Christopher David Desjardins wrote: I get the following error when I run qplot() qplot(grade, read,data = hhm.long.m, geom = c("point", "smooth")) Error in sm

Re: [R] How to find maximum values on the density function of arandom variable

2009-03-13 Thread David Winsemius
In discrete math, first differences are the analogues of first derivatives and second differences are the analogues of second derivatives. (I thought I learned this in Knuth, vol 1 25 years ago, but I cannot find it, so maybe it was in some the time series stuff I read 20 years ago). So a

Re: [R] search for string insider a string

2009-03-13 Thread Gabor Grothendieck
Try this. We use regexpr to get the positions and strapply puts the values in list s. The unlist statement converts NULL to NA and simplifies the list, s, to a numeric vector. For more info on strapply see http://gsubfn.googlecode.com library(gsubfn) # strapply x <- c"test1", "bcdtestblabla2.

Re: [R] Matrix Construction; Subdiagonal

2009-03-13 Thread Paul Smith
On Wed, Mar 11, 2009 at 11:49 PM, Sundar Dorai-Raj wrote: > Does this help? > > A <- matrix(0, 6, 6) > vec <- 1:5 > A[row(A) == col(A) + 1] <- vec Maybe, more simply: A <- matrix(0, 6, 6) vec <- 1:5 diag(A[-1,]) <- vec Paul __ R-help@r-project.org ma

Re: [R] Sorting rows of a matrix independent of each other

2009-03-13 Thread Kevski
Got the answer: > t(apply(test,1,sort)) I had played with the apply fn at one point, but noticed the results were not quite right. Wrapping it in t was the trick! Thanks! Now to use the nicely sorted rows in my "real" problem at hand... Cheers, Kev- -- View this message in context: http://w

Re: [R] How to find maximum values on the density function of arandom variable

2009-03-13 Thread guox
Thanks for your ideas. I would like to find all possible maximums - "mountains" on a graph of a given density function but I have no ideas. In calculus, there is a general approach for a given function f(x): Find derivative of f(x) and estimate all zeros of f'(x). These zeros give us locations of m

Re: [R] Sorting rows of a matrix independent of each other

2009-03-13 Thread Paul Smith
On Fri, Mar 13, 2009 at 5:26 PM, Wacek Kusnierczyk wrote: >> Oh, this seemed so simple (and I'm sure the answer will be, as usual, so >> thanks in advance for enlightening me). I need to sort each row of a matrix >> independent of the others. For example, >> >    apply(matrix, 1, sort) t(apply(te

Re: [R] Sorting rows of a matrix independent of each other

2009-03-13 Thread David Winsemius
Now I just need the resulting matrix: 2 8 9 4 6 7 1 3 5 On Mar 13, 2009, at 1:26 PM, Wacek Kusnierczyk wrote: Kevski wrote: Oh, this seemed so simple (and I'm sure the answer will be, as usual, so thanks in advance for enlightening me). I need to sort each row of a matrix independent o

Re: [R] Sorting rows of a matrix independent of each other

2009-03-13 Thread Wacek Kusnierczyk
Kevski wrote: > Oh, this seemed so simple (and I'm sure the answer will be, as usual, so > thanks in advance for enlightening me). I need to sort each row of a matrix > independent of the others. For example, > > apply(matrix, 1, sort) vQ __ R-he

Re: [R] How to combine xtable and minipage with Sweave ?

2009-03-13 Thread Duncan Murdoch
On 3/13/2009 12:07 PM, Ptit_Bleu wrote: Thanks Dieter for the link. In fact it may be a problem with R. The .tex created with R for the table put \begin{table}[ht] and \end{table}\ between \begin{minipage} and \end{minipage} (see below) If I manually change these positions, according to your li

Re: [R] How to find maximum values on the density function of arandom variable

2009-03-13 Thread David Winsemius
If you are trying to build your own function then presumably you do not want the global maximum, since that is trivially returned by max. So what do you really want? Is this a programming question or just a general statistics question? If you want to search along a (specific) sequence for l

Re: [R] Save the elements of an atomic vector to a text fil

2009-03-13 Thread johnhj
Thank you all, I did it with "write.table"... greetings, johnh johnhj wrote: > > Hii, > > I will save the elements of the vector median<-with(x, tapply(V3, grup, > median)). The output of this vector is: > > 25 50 75 100 125 150 175 200 225 250 275 300 325 350 375 > 40

[R] how to add labels to existing plot for the subset of data

2009-03-13 Thread Xin Shi
Dear: I am trying to plot x against y for a particular subset of data, say z=1, and labelling data by another variable say, k. My data are: y<-c(69.7, 82.3, 66.3, 107.3, 90.1, 63.7, 82, 74.4, 61.7, 93.4, 73.4, NA, NA, 70.7, 67.7, NA, NA) x<-c(71.2, 82.6, 67.4, 107.1, 90.5, 66.7, 83.9, 73.9, 61

[R] Sorting rows of a matrix independent of each other

2009-03-13 Thread Kevski
Oh, this seemed so simple (and I'm sure the answer will be, as usual, so thanks in advance for enlightening me). I need to sort each row of a matrix independent of the others. For example, > test <- matrix(c(8,7,1,2,6,5,9,4,3),nrow=3) > test [,1] [,2] [,3] [1,]829 [2,]76

Re: [R] print median and sd...

2009-03-13 Thread johnhj
Ok, sorry... here is my code so far... x <-read.table(file="D:/output.txt") x$grup <- 25*rep(1:144, each=5) median<-with(x, tapply(V3, grup, median)) sd<-with(x, tapply(V3, grup, sd)) I will plot to types of graph. One graph with the median values for example with the "plot()" function,

Re: [R] Selecting / creating unique colours for behavioural / transitional data

2009-03-13 Thread Alexis Gabadinho
Hi Ross, If you really need 15 colors, maybe you can use the Set3 palette provided by RColorBrewer (this is the one used by TraMineR up to 12 states) and add yourself 3 more colors ? For example (you can mix the hexadecimal color numbers from the RColorBrewer palette and real color names in

[R] More basic equivalent of TukeyHSD

2009-03-13 Thread Janet
This is a simple question, but I'm going on the supposition that the only stupid question is the one not asked. 1. I have many sets of 5 proportions that are different from each other (prop.test), and want to know which proportions are different from each other. In other words, I want t

Re: [R] How to find maximum values on the density function of arandom variable

2009-03-13 Thread guox
Yes, a random variable, discrete or continuous one, should associate with a probability space and a measurable space. I thought that graph of density(rv) below could give us an example of a density function. I am very sorry for confusing you. My question is how to find/estimate maximum values of a

Re: [R] Selecting / creating unique colours for behavioural / transitional data

2009-03-13 Thread Ross Culloch
Hi Alexis, In my opinion you are nothing short of genius! That worked a treat, i thought it would be something simple, but i could not find the script or an example anywhere!!! That was a massive help and has salvaged my day! :clap: Thanks very much to everyone else that helped, it was much app

Re: [R] Selecting / creating unique colours for behavioural / transitional data

2009-03-13 Thread Alexis Gabadinho
Hi Ross, If you really need 15 colors, maybe you can use the Set3 palette provided by RColorBrewer (this is the one used by TraMineR up to 12 states) and add yourself 3 more colors ? For example (you can mix the hexadecimal color numbers from the RColorBrewer palette and real color names in

[R] search for string insider a string

2009-03-13 Thread Tan, Richard
Hi, sorry if it is a too stupid question, but how do I a string search in R: I have a dataframe A with A$test like: test1 bcdtestblabla2.1bla cdtestblablabla3.88blabla and I want to search for string that start with 'dtest' and ends with number and return the location of that substring and th

Re: [R] Cross-validation -> lift curve

2009-03-13 Thread Gene Leynes
This may be somewhat useful, but I might have more later. http://florence.acadiau.ca/collab/hugh_public/index.php?title=R:CheckBinFit (the code below is copied from the URL above) CheckBinFit <- function(y,phat,nq=20,new=T,...) { if(is.factor(y)) y <- as.double(y) y <- y-mean(y) y[y>0

Re: [R] How to combine xtable and minipage with Sweave ?

2009-03-13 Thread Ptit_Bleu
Thanks Dieter for the link. In fact it may be a problem with R. The .tex created with R for the table put \begin{table}[ht] and \end{table}\ between \begin{minipage} and \end{minipage} (see below) If I manually change these positions, according to your link, there is no more error ... but the ta

Re: [R] How to color certain area under curve

2009-03-13 Thread Vincent Goulet
I did similar things with polygon(). Le mar. 10 mars à 13:30, g...@ucalgary.ca a écrit : For a given random variable rv, for instance, rv = rnorm(1000), I plot its density curve and calculate some quantiles: plot(density(rv)) P10P50P90 = = quantile(rv,probs = c(10,50,90)/100) I would like to co

Re: [R] [R-SIG-Finance] Problem with RBloomberg (not the usual one)

2009-03-13 Thread Sergey Goriatchev
Hi, Kent Thank you for that! I'll pass the info to our systems administrator, he is the only one who is allowed to do things like that. Have a nice weekend! Best, Serge On Fri, Mar 13, 2009 at 15:32, Voss, Kent wrote: > Sergey, > > Sorry I missed your post earlier.  I had this same problem and

Re: [R] Save the elements of an atomic vector to a text fil

2009-03-13 Thread David Winsemius
?cat On Mar 13, 2009, at 10:59 AM, johnhj wrote: Hii, I will save the elements of the vector median<-with(x, tapply(V3, grup, median)). The output of this vector is: 25 50 75 100 125 150 175 200 225 250 275 300 325 350 375 400 425 450 475 500 17.8 17.8 17.5 17.8 17

Re: [R] How to combine xtable and minipage with Sweave ?

2009-03-13 Thread Dieter Menne
Ptit_Bleu yahoo.fr> writes: > Concerning the point 3, I'm a bit lost. Is it a problem of place to put the > table and the graph side by side (my english is quite as low as my skills in > Latex) ? > I tried with \begin{minipage}{0.45\textwidth} instead of 0.7 and I put > "//tiny" but no success.

Re: [R] Save the elements of an atomic vector to a text fil

2009-03-13 Thread Usuario R
Hi, take a look to ?write.table regards 2009/3/13 johnhj > > Hii, > > I will save the elements of the vector median<-with(x, tapply(V3, grup, > median)). The output of this vector is: > > 25 50 75 100 125 150 175 200 225 250 275 300 325 350 375 > 400 425 450 475 500 > 17

Re: [R] Save the elements of an atomic vector to a text fil

2009-03-13 Thread jim holtman
'str(x)' would help. I assume that this is a named list, so this might plot it for you: plot(names(x), x) On Fri, Mar 13, 2009 at 10:59 AM, johnhj wrote: > > Hii, > > I will save the elements of the vector median<-with(x, tapply(V3, grup, > median)). The output of this vector is: > >  25   50  

Re: [R] print median and sd...

2009-03-13 Thread jim holtman
Can you provide a reproducible example with the data so that we understand what you are working with. Need to see what the structure of 'x' and 'median' are. On Fri, Mar 13, 2009 at 8:35 AM, johnhj wrote: > > Hii Jholtman, > > I will make a graph of the median values and not to print to the cons

Re: [R] [R-SIG-Finance] Problem with RBloomberg (not the usual one)

2009-03-13 Thread Voss, Kent
Sergey, Sorry I missed your post earlier. I had this same problem and I reinstalled the DDE Server and Excel Add-In, rebooted and it fixed it. I thought they were already installed as I could pull down data in Excel from Bloomberg, but reinstalling them fixed my R problem. You can find the d

Re: [R] Selecting / creating unique colours for behavioural / transitional data

2009-03-13 Thread Olivier Delaigue
> library(colorRamps) > image(matrix(1:150, 10), col = blue2green2red(15)) Regards, Olivier Delaigue Ross Culloch wrote: > > Dear all, > > This seems like a simple problem but i've searched the help files and > tried various options but failed, so apologies in advance for asking what > i'm s

[R] Save the elements of an atomic vector to a text fil

2009-03-13 Thread johnhj
Hii, I will save the elements of the vector median<-with(x, tapply(V3, grup, median)). The output of this vector is: 25 50 75 100 125 150 175 200 225 250 275 300 325 350 375 400 425 450 475 500 17.8 17.8 17.5 17.8 17.7 17.6 17.7 17.6 17.8 17.7 17.6 17.7 17.8 17.7 17.8 17.

Re: [R] Using package ROCR

2009-03-13 Thread LIMONIKA
> library(ROCR) > library(randomForest) > plot(results,significant) Error in as.double(x) : cannot coerce type 'S4' to vector of type 'double' After try with all the possibilities, it shows same error in simpleaffy data plot for the results. please someone guide me wiener30 wrote: > > I

Re: [R] print median and sd...

2009-03-13 Thread johnhj
Hii Jholtman, I will make a graph of the median values and not to print to the console. I tried to plot with: plot(V3 ~ grup, data = median) ?? but I get an error message. I also tried to print the output of median<-with(x, tapply(V3, grup, median)) to a text file with the X and Y Koordinates

Re: [R] Is there any difference between <- and =

2009-03-13 Thread Alan Zaslavsky
thanks for your supportive comments! by that time r programs will be scanned directly from your head, i suppose, and the intelligent scanner will as gladly take <- as it will =, so the problem will rather vanish. Yes, and maybe the scanner will be more intelligent than the programmer so when th

Re: [R] updating packages?

2009-03-13 Thread ronggui
Maybe they are loaded, use search() to see if they are. If yes, then use detach() to unload them first. Best 2009/3/13 : > I am trying to update the packages that I have installed but I get the > following warning messages: > > package 'tseries' successfully unpacked and MD5 sums checked > Warn

Re: [R] code to find all distinct subsets of size r from a set of size n

2009-03-13 Thread David Winsemius
If your subsets are to be taken from the rows of a dataframe, df, and the size is r, then something like this could satisfy: apply(combn(nrow(df), r), 2, function(x) df[x, ]) (Although these are not really permutations as I understand that term.) -- David Winsemius On Mar 13, 2009, at 8:35 A

[R] updating packages?

2009-03-13 Thread rkevinburton
I am trying to update the packages that I have installed but I get the following warning messages: package 'tseries' successfully unpacked and MD5 sums checked Warning: cannot remove prior installation of package 'tseries' bundle 'forecasting' successfully unpacked and MD5 sums checked Warning: c

[R] updating packages?

2009-03-13 Thread rkevinburton
I am trying to update the packages that I have installed but I get the following warning messages: package 'tseries' successfully unpacked and MD5 sums checked Warning: cannot remove prior installation of package 'tseries' bundle 'forecasting' successfully unpacked and MD5 sums checked Warning: c

Re: [R] Is there any difference between <- and =

2009-03-13 Thread Wacek Kusnierczyk
Alan Zaslavsky wrote: > I would argue that this is a matter of preference and the arguments on > "principle" for one side or another are not particularly compelling. indeed; i have argued (i think...) for treating them as equals, the vhoice being a matter of taste. > When the "=" was introduce

Re: [R] Time-Ordered Clustering

2009-03-13 Thread Prew, Paul
Dear Ingmar, Thank you for your reply, I hope I answer your question --- A couple specific applications I have in mind: * We work with customers to reduce energy consumption from use of hot water. Baseline data was gathered at several locations by attaching a temperature sensor downstream from

Re: [R] R multiline expression grief

2009-03-13 Thread Wacek Kusnierczyk
Gabor Grothendieck wrote: > On Fri, Mar 13, 2009 at 10:11 AM, Wacek Kusnierczyk > wrote: > >> Gabor Grothendieck wrote: >> >>> If all your code has semicolons you could write a program that >>> puts each statement on one line based on the semicolons and >>> then passing it through R will r

Re: [R] Is there any difference between <- and =

2009-03-13 Thread Alan Zaslavsky
I would argue that this is a matter of preference and the arguments on "principle" for one side or another are not particularly compelling. When the "=" was introduced for assignment, an argument was made that name=value function arguments are also implicitly a kind of assignment. While Duncan

Re: [R] R multiline expression grief

2009-03-13 Thread Gabor Grothendieck
On Fri, Mar 13, 2009 at 10:11 AM, Wacek Kusnierczyk wrote: > Gabor Grothendieck wrote: >> If all your code has semicolons you could write a program that >> puts each statement on one line based on the semicolons and >> then passing it through R will reformat it in a standard way. >> See Rtidy.bat

Re: [R] R multiline expression grief

2009-03-13 Thread Ted Harding
On 13-Mar-09 12:55:35, Paul Suckling wrote: > Dear all. > After much grief I have finally found the source of some weird > discrepancies in results generated using R. It turns out that this is > due to the way R handles multi-line expressions. Here is an example > with R version 2.8.1: > > ---

Re: [R] R multiline expression grief

2009-03-13 Thread Wacek Kusnierczyk
Gabor Grothendieck wrote: > If all your code has semicolons you could write a program that > puts each statement on one line based on the semicolons and > then passing it through R will reformat it in a standard way. > See Rtidy.bat in the batchfiles distribution for the reformatting part: > http:/

Re: [R] Selecting / creating unique colours for behavioural / transitional data

2009-03-13 Thread Ross Culloch
Hi Kingsford, Thanks yet again for your help! I have tried this, and once again i have failed! I have put the code that i've used below (i'm sure you'll note some bad practice) if that is any use to help explain where i'm going wrong, it seems to run fine and feeds back just what you noted it wou

Re: [R] Selecting / creating unique colours for behavioural / transitional data

2009-03-13 Thread Ross Culloch
Hi Hadley, Many thanks for your post. You're not wrong - i'm certainly finding it challenging, but i assumed it was because i was making some basic errors. My data are 15 types of behaviour, e.g. resting, alert, locomotion, etc. so i need to use 15 colours to tell each appart in a barplot which

Re: [R] How to combine xtable and minipage with Sweave ?

2009-03-13 Thread Ptit_Bleu
Hello Dieter, And thank you for the corrections. Concerning the point 3, I'm a bit lost. Is it a problem of place to put the table and the graph side by side (my english is quite as low as my skills in Latex) ? I tried with \begin{minipage}{0.45\textwidth} instead of 0.7 and I put "//tiny" but no

Re: [R] Selecting / creating unique colours for behavioural / transitional data

2009-03-13 Thread Kingsford Jones
On Fri, Mar 13, 2009 at 7:19 AM, Ross Culloch wrote: > > Many thanks yet again for your reply, thanks for that method, i gave it a go > and i checked 'mycols' and sure enough it had selected the chosen colours > and listed their names, but when i used it for making the graph warnigs > informed me

Re: [R] Unable to run smoother in qplot() or ggplot() - complains about knots

2009-03-13 Thread hadley wickham
On Thu, Mar 12, 2009 at 5:37 PM, Christopher David Desjardins wrote: > I get the following error when I run qplot() > > qplot(grade, read,data = hhm.long.m, geom = c("point", "smooth")) > > Error in smooth.construct.cr.smooth.spec(object, data, knots) : >  x has insufficient unique values to suppo

Re: [R] R multiline expression grief

2009-03-13 Thread Gabor Grothendieck
If all your code has semicolons you could write a program that puts each statement on one line based on the semicolons and then passing it through R will reformat it in a standard way. See Rtidy.bat in the batchfiles distribution for the reformatting part: http://batchfiles.googlecode.com On Fri,

Re: [R] R multiline expression grief

2009-03-13 Thread Wacek Kusnierczyk
jim holtman wrote: > > >> if (1 == 1) {print (TRUE) >> > + } else {print (FALSE)} > [1] TRUE > > > so the parse knows that the initial 'if' is not complete on the single line. > ... and likewise the original code could be rewritten as f <- { a + b + c } vQ __

Re: [R] Selecting / creating unique colours for behavioural / transitional data

2009-03-13 Thread Ross Culloch
Hi Oliver, Thanks very much for your reply. I have tried your script, but when the script for the graph runs it comes up with several error messages repeating that 'supplied colour is not numeric or character' Olivier Delaigue wrote: > >> library(colorRamps) >> image(matrix(1:150, 10), col =

Re: [R] R multiline expression grief

2009-03-13 Thread Paul Suckling
I get it. Thanks everyone for the feedback. Now that I understand how it works, my comment would be that this system is dangerous since it makes it difficult to read the code and easy to make errors when typing it. I recognise that this is something so fundamental that it is unlikely to be changed

Re: [R] code to find all distinct subsets of size r from a set of size n

2009-03-13 Thread Kingsford Jones
For permutations a couple of options are 'permutations' in package gtools, and 'urnsamples' in package prob hth, Kingsford Jones On Fri, Mar 13, 2009 at 6:35 AM, Dale Steele wrote: > I'm doing a permutation test and need to efficiently generate all > distinct subsets of size r from a set of size

Re: [R] Selecting / creating unique colours for behavioural / transitional data

2009-03-13 Thread hadley wickham
> Thanks for the reply - some of the sets/palettes in the RColorBrewer are > ideal, but the problem with the problem i have is that they only go up to 12 > colours, and i need 15 colours - so i assume the only thing i can do is > create my own palette, but i'm having limited success in trying to wo

Re: [R] R multiline expression grief

2009-03-13 Thread Wacek Kusnierczyk
Paul Suckling wrote: <...> > > # R-script... > > r_parse_error <- function () > { > <...> > f <- a > + b > + c; > } > > <...> > f 1 > > > As far as I am concerned f should hav

Re: [R] Selecting / creating unique colours for behavioural / transitional data

2009-03-13 Thread Ross Culloch
Many thanks yet again for your reply, thanks for that method, i gave it a go and i checked 'mycols' and sure enough it had selected the chosen colours and listed their names, but when i used it for making the graph warnigs informed me that the supplied colour in not numeric or character. Ross

Re: [R] cor.test(x,y)

2009-03-13 Thread Sarah Goslee
Did you read the help for cor.test? Test statistics, references looks pretty complete to me. If the descriptions are too terse, then the references given would be the next step. Sarah Excerpted from ?cor.test If 'method' is '"pearson"', the test statistic is based on Pearson's pro

Re: [R] R multiline expression grief

2009-03-13 Thread Thomas Lumley
On Fri, 13 Mar 2009, Paul Suckling wrote: Dear all. After much grief I have finally found the source of some weird discrepancies in results generated using R. It turns out that this is due to the way R handles multi-line expressions. Here is an example with R version 2.8.1: ---

  1   2   >