[R] why does this simple example NOT work?

2012-07-19 Thread Martin Ivanov
Hello, I want to create and save objects in a loop, but this is precluded by the following obstacle: this part of the script fails to work: assign(x=paste("a", 1, sep=""), value=1); save(paste("a", 1, sep=""), file=paste(paste("a", 1, sep=""), ".RData", sep="")) Do you know any workaround? I a

Re: [R] Last answer

2012-07-19 Thread darnold
All, Thanks. That works. D. -- View this message in context: http://r.789695.n4.nabble.com/Last-answer-tp4637151p4637157.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman

Re: [R] Last answer

2012-07-19 Thread Rainer Schuermann
Is that what you mean: > 2 + 3 [1] 5 > .Last.value [1] 5 Rgds, Rainer (from R-intro.pdf, page 7, 2nd footnote) Original-Nachricht > Datum: Thu, 19 Jul 2012 22:12:22 -0700 (PDT) > Von: darnold > An: r-help@r-project.org > Betreff: [R] Last answer > Hi, > > In Matlab, I can

Re: [R] Last answer

2012-07-19 Thread Joshua Wiley
My apologies. I stand corrected. Thanks Michael. Josh On Thu, Jul 19, 2012 at 10:29 PM, R. Michael Weylandt wrote: > See: https://stat.ethz.ch/pipermail/r-help/2012-February/303110.html > > Michael > > On Fri, Jul 20, 2012 at 12:19 AM, Joshua Wiley wrote: >> Hi David, >> >> No, but you can st

Re: [R] Last answer

2012-07-19 Thread R. Michael Weylandt
See: https://stat.ethz.ch/pipermail/r-help/2012-February/303110.html Michael On Fri, Jul 20, 2012 at 12:19 AM, Joshua Wiley wrote: > Hi David, > > No, but you can store the results and access that. > > ## parentheses to force printing > (x <- 2 + 3) > > x > > Cheers, > > Josh > > > On Thu, Jul 1

Re: [R] Last answer

2012-07-19 Thread Joshua Wiley
Hi David, No, but you can store the results and access that. ## parentheses to force printing (x <- 2 + 3) x Cheers, Josh On Thu, Jul 19, 2012 at 10:12 PM, darnold wrote: > Hi, > > In Matlab, I can access the last computation as follows: > >>> 2+3 > > ans = > > 5 > >>> ans > > ans = >

[R] Last answer

2012-07-19 Thread darnold
Hi, In Matlab, I can access the last computation as follows: >> 2+3 ans = 5 >> ans ans = 5 Anything similar in R? David -- View this message in context: http://r.789695.n4.nabble.com/Last-answer-tp4637151.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] Truncating (rounding down) to nearest half hour.

2012-07-19 Thread Rainer Schuermann
My amateur approach: I put your data in a dataframe called t: > head( t ) Date Score 1 2008-05-01 08:58:0080 2 2008-05-01 13:31:0011 3 2008-05-01 16:35:0081 4 2008-05-01 23:20:00 152 5 2008-05-02 01:01:00 130 6 2008-05-02 03:35:00 122 Then I created a vector wit

Re: [R] Changing ungrouped cases to grouped cases

2012-07-19 Thread David L Carlson
> dtf <- read.table(text="y A B C + 0 11 2 + 0 12 1 + 1 11 2 + 0 11 2 + 1 11 2 + 1 12 1 + 0 12 2", + header=TRUE) > dtagroup <- aggregate(y~A+B+C, dtf, sum) # Gets you the groups. If you need the column/row order: > dtag

[R] Changing ungrouped cases to grouped cases

2012-07-19 Thread Christopher Desjardins
Hi, I have my data the following way: y A B C 0 11 2 0 12 1 1 11 2 0 11 2 1 11 2 1 12 1 0 12 2 . . . And so on. How can I make my data look like the following: y A B C 2 1 1 2 1 1 2 1 0 1 2 2 . . .

Re: [R] Subsetting problem data, 2

2012-07-19 Thread Rui Barradas
Hello, Sorry, forgot about that. It's trickier to write code without a dataset to test it. Try pattern <- "L[1-8][12]" and after the grep print nms to see if it's right. Rui Barradas Em 20-07-2012 00:33, Lib Gray escreveu: I'm getting this error message: nms<-names(data)[grep(vars,names(

Re: [R] Subsetting problem data, 2

2012-07-19 Thread Rui Barradas
Hello, I guess so, and I can save you some typing. vars <- sort(apply(expand.grid("L", 1:8, 1:2), 1, paste, collapse="")) Then use it and see the result. Rui Barradas Em 20-07-2012 00:00, Lib Gray escreveu: The variables are actually L11, L12, L21, L22, ... , L81, L82. Would just creating a

Re: [R] change file name from file0.1_data.RData to file1_data.Rdata

2012-07-19 Thread Rui Barradas
Hello, Follow this example. # First see the regular expression # at work without changing any disk file x <- c("file0.1_data.RData", "file0.2_data.RData") sub("^file0\\.", "file", x) # Now change them from.files <- list.files(pattern = "^file0\\.._data.Rdata$") to.files <- sub("^file0\\.", "fi

Re: [R] complexity of operations in R

2012-07-19 Thread Duncan Murdoch
On 12-07-19 4:00 PM, Jan van der Laan wrote: When the length of the end result is not known, doubling the length of the list is also much faster than increasing the size of the list with single items. f <- function(n, preallocate) { v <- if(preallocate) vector("list",n) else list() ;

Re: [R] median comparison tests

2012-07-19 Thread David L Carlson
Look at kruskalmc() in package pgirmess. -- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.o

[R] change file name from file0.1_data.RData to file1_data.Rdata

2012-07-19 Thread Soyeon Kim
Dear All, I want to change file names. I have file0.1_data.RData (I have several files whose names are file0.x_data.Rdata) I want to rename it to file1_data.RData How can I do it? Thank you for saving my time! [[alternative HTML version deleted]] __

Re: [R] a priori mean comparison/orthogonal contrast?

2012-07-19 Thread Peter Alspach
Tena koe Anna Yes: see https://stat.ethz.ch/pipermail/r-help/2006-August/111234.html which includes an excellent description on this written by Bill Venables back in 1997. HTH Peter Alspach -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org

Re: [R] A graph with a positive y-axis intercept

2012-07-19 Thread Sarah Goslee
Your question is not entirely clear to me, but I think you might want: plot(X, Y, xlim=c(0, 25), ylim=c(0, 25)) Sarah On Thu, Jul 19, 2012 at 5:31 PM, Lekgatlhamang, lexi Setlhare wrote: > Dear all, > > I have a challenge with a supposedly simple graph (a scatter). I wanted to > use R to creat

[R] A graph with a positive y-axis intercept

2012-07-19 Thread Lekgatlhamang, lexi Setlhare
Dear all,   I have a challenge with a supposedly simple graph (a scatter). I wanted to use R to create a plot/graph with a positive y-axis intercept but it does not seem to give me what I expect to see. As an example, I used the following values   > X<- c(0, 4, 8, 11) > Y<- c(8, 12, 15, 22) then

Re: [R] as.POSIXct questions

2012-07-19 Thread R. Michael Weylandt
Short answer: as.POSIXct(0, origin = ISOdatetime(1970,1,1,10,0,0, tz = "GMT")) Long answer -- as.POSIXct goes through a somewhat crazy chain of method dispatch to work, and only sometimes cares about the tz argument. For your case as.POSIXct(x) -- calls --> as.POSIXct.numeric(x) -- calls -->

[R] as.POSIXct questions

2012-07-19 Thread Jack Tanner
The following three calls all produce the same result (my machine is in EST): > as.POSIXct(0, tz="", origin=ISOdatetime(1970,1,1,10,0,0)) [1] "1970-01-01 10:00:00 EST" > as.POSIXct(0, tz="EST", origin=ISOdatetime(1970,1,1,10,0,0)) [1] "1970-01-01 10:00:00 EST" > as.POSIXct(0, tz="GMT", origin=IS

Re: [R] R packages installation error in Ubuntu

2012-07-19 Thread R. Michael Weylandt
On Thu, Jul 19, 2012 at 2:41 PM, uday wrote: > Hi, > > Recently I have installed R version 2.14.1, after installation I am trying > to install some packages and I get error message. even I tried > install.packages("Rcmdr") Why would that help? Also: don't double post. Sarah already told you how

Re: [R] Subsetting problem data, 2

2012-07-19 Thread Rui Barradas
Hello, Try the following. The data is your example of Patient A through E, but from the output of dput(). dat <- structure(list(Patient = structure(c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L), .Label = c("A", "B", "C", "D", "E"), class = "factor"), Cycle = c(1L, 2

Re: [R] Change log(J) to log(J+1) to stop log(0) from occurring in harModel

2012-07-19 Thread Joshua Ulrich
Same post on Stack Overflow (again): http://stackoverflow.com/q/11567745/271616 -- Joshua Ulrich | FOSS Trading: www.fosstrading.com On Thu, Jul 19, 2012 at 11:15 AM, cursethiscure wrote: > I think the code is part of the RTAQ package but is not included in it, as I > obtained it from > https:

[R] median comparison tests

2012-07-19 Thread Data Analytics Corp.
Hi, A client has a consumption measure on each of four products. The sample size is 75. The consumption distributions are highly skewed for each product. He would like a pairwise comparison test of the products, much like Tukey's HSD but using medians rather than means. Is there such a me

Re: [R] complexity of operations in R

2012-07-19 Thread R. Michael Weylandt
> On Thu, Jul 19, 2012 at 3:00 PM, Jan van der Laan wrote: > > When the length of the end result is not known, doubling the length of the > list is also much faster than increasing the size of the list with single > items. > > [snip] > > What causes these differences? I can imagine that the time n

Re: [R] Switching log(J) to log(J+1) to avoid log(0) in HAR-RVJ model

2012-07-19 Thread Joshua Ulrich
Cross-posted on Stack Overflow: http://stackoverflow.com/q/11567745/271616 -- Joshua Ulrich | FOSS Trading: www.fosstrading.com On Thu, Jul 19, 2012 at 12:23 PM, cursethiscure wrote: > I am working with xts dependent data, and my code is as follows (the problem > is explained throughout): > >

Re: [R] problem replacing NA's in a dataset (10% remain after removal attempt)

2012-07-19 Thread Peter Ehlers
On 2012-07-19 11:05, Julie Shoemaker wrote: Hi all, I'm attempting to gap-fill a dataset, replacing the missing values with each month's day or night median value. The problem is that my code results in some, but not all the NA's being replaced and I cannot figure out how this is possible. When

[R] Change log(J) to log(J+1) to stop log(0) from occurring in harModel

2012-07-19 Thread cursethiscure
I think the code is part of the RTAQ package but is not included in it, as I obtained it from https://r-forge.r-project.org/scm/viewvc.php/pkg/RTAQ/R/HAR_model.R?view=markup&root=blotter&sortby=author&pathrev=1028. It is not my code and I make no claim to other's good work, and apologize if I sh

[R] npindex: fitted values of the function itself?

2012-07-19 Thread Kristin
Dear list, I am using the np package. With the npindex function I estimate a semiparametric single index model using the method of Klein-Spady. P(Z=1|X) = G(X’b) I don’t have any problems to calculated the fitted values and standard errors X’b: bw = npindexbw(xdat=x, ydat=y_bi, method="kleins

Re: [R] Generating Random Numbers

2012-07-19 Thread Petr Savicky
On Thu, Jul 19, 2012 at 04:12:07AM -0700, arunkumar wrote: > hi > > My inputs is min=(10,10,10,10,10) and max=(100,100,100,100,100) > total = 300 > i have to generate 5 numbers between min and max and those numbers should > sum upto total Hi. Try the following. while (1) { x <- 10 +

[R] Fw: Removing values from a string

2012-07-19 Thread arun
- Forwarded Message - From: arun To: Abraham Mathew Cc: R help Sent: Thursday, July 19, 2012 3:58 PM Subject: Re: [R] Removing values from a string Hi, Try this: one = data.frame(keyword=c("|auto", "NA|auto|insurance|quote", "NA|auto|insurance",    "NA|ins

Re: [R] Removing values from a string

2012-07-19 Thread arun
Hi, Try this: one = data.frame(keyword=c("|auto", "NA|auto|insurance|quote", "NA|auto|insurance",    "NA|insurance", "NA|auto|insurance", "")) onenew<-data.frame(keyword=gsub("(NA){0,1}\\|","",one$keyword)) onenew1<-data.frame(keyword=gsub("(){0,1}","",onenew$keyword))  

[R] Quantile regression questions

2012-07-19 Thread Federico Weyland
Hi, everyone. I have some questions about quantile regression in R. I am running an additive quantile regression first for a complete matrix and then with some selected rows. I am doing the following: datos <-read.table("Regresion multiple.txt",header=T) Fit<-rqss(datos$campings ~datos$Cobarb

[R] problem replacing NA's in a dataset (10% remain after removal attempt)

2012-07-19 Thread Julie Shoemaker
Hi all, I'm attempting to gap-fill a dataset, replacing the missing values with each month's day or night median value. The problem is that my code results in some, but not all the NA's being replaced and I cannot figure out how this is possible. When I look at the individual line's where th

[R] a priori mean comparison/orthogonal contrast?

2012-07-19 Thread annaw
I would like to use a A priori mean comparison/orthogonal contrast test on my data. Im new to using R and I would like to know if its possible to perform this test in R and how can be done. /Anna -- View this message in context: http://r.789695.n4.nabble.com/a-priori-mean-comparison-orthogonal-

Re: [R] check whether connection can be opened

2012-07-19 Thread Berry Boessenkool
Thank you very much, Michael! That was exactly the hint I needed. I ended up using "try" as below, in case anyone happens to read this later on... Works perfectly fine. So yes, it _is_ amazing, what one can do with R ;-) Regards, Berry internet <- try(read.table("http://www...";), silent=T )

Re: [R] complexity of operations in R

2012-07-19 Thread Bert Gunter
Jan: Point taken. However, if possible, as Bill Dunlap indicated, it still may make sense to create an oversized list first and then populate what you need of it with your loop. Note that a lot of this can be finessed with lapplyand friends anyway, letting R worry about the details of creating a

Re: [R] complexity of operations in R

2012-07-19 Thread Jan van der Laan
When the length of the end result is not known, doubling the length of the list is also much faster than increasing the size of the list with single items. f <- function(n, preallocate) { v <- if(preallocate) vector("list",n) else list() ; for(i in seq_len(n)) { v[[i]] <- i

[R] R packages installation error in Ubuntu

2012-07-19 Thread uday
Hi, Recently I have installed R version 2.14.1, after installation I am trying to install some packages and I get error message. even I tried install.packages("Rcmdr") but still I am unable to fix this problem. I would be very grateful if somebody can help me to fix this problem. install.packa

Re: [R] Generating Random Numbers

2012-07-19 Thread arun
Hello, Try this: #Generate 4 random numbers. set.seed(1)  rnorm(4,60) #[1] 59.37355 60.18364 59.16437 61.59528 > sum(rnorm(4,60)) #[1] 240.7348  fifthnumber<-300-240.7348  fifthnumber #[1] 59.2652 A.K. - Original Message - From: arunkumar To: r-help@r-project.org Cc: Sent: Thu

[R] Truncating (rounding down) to nearest half hour.

2012-07-19 Thread APOCooter
I couldn't find anything in the chron or timeDate packages, and a good search yielded rounding to the nearest half hour, which I don't want. The data: structure(list(Date = structure(c(1209625080, 1209641460, 1209652500, 1209676800, 1209682860, 1209692100, 1209706980, 1209722580, 1209726300, 12

Re: [R] Removing values from a string

2012-07-19 Thread Sarah Goslee
There are a couple of ambiguities in your request, but this should get you started: > one$keyword <- gsub("NA\\|", "", one$keyword) > one$keyword <- gsub("^\\|", "", one$keyword) > one keyword 1 auto 2 auto|insurance|quote 3 auto|insurance 4insurance

Re: [R] complexity of operations in R

2012-07-19 Thread Jan van der Laan
On 07/19/2012 06:11 PM, Bert Gunter wrote: Hadley et. al: Indeed. And using a loop is a poor way to do it anyway. v <- as.list(rep(FALSE,dotot)) is way faster. -- Bert I agree that not using a loop is much faster, but I assume that the original question is about the situation where the siz

Re: [R] rcspline.problem

2012-07-19 Thread Peter Ehlers
On 2012-07-19 07:10, Bart Ferket wrote: Dear professor Harrell, I probably have the same problem as Haleh Ghaem Maralani. I am using the rms package and the rcspline.plot function to assess the relation of a continuous predictor to the log hazard function. I would like to use the "adj" stateme

[R] Removing values from a string

2012-07-19 Thread Abraham Mathew
So I have the following data frame and I want to know how I can remove all "NA" values from each string, and also remove all "|" values from the START of the string. So they should something like "auto|insurance" or "auto|insurance|quote" one = data.frame(keyword=c("|auto", "NA|auto|insurance|quot

Re: [R] finding the values to minimize sum of functions

2012-07-19 Thread Petr Savicky
On Thu, Jul 19, 2012 at 10:24:17AM -0700, Linh Tran wrote: > Hi fellow R users, > > I am desperately hoping there is an easy way to do this in R. > > Say I have three functions: > > f(x) = x^2 > f(y) = 2y^2 > f(z) = 3z^2 > > constrained such that x+y+z=c (let c=1 for simplicity). > > I want to

[R] start.val in GRM (ltm package)

2012-07-19 Thread Jeff
Can someone please give me an example of how to enter starting values for a GRM (IRT) model using the ltm package? The instructions from the ltm manual are below, but when I create either a list of the values or a matrix I get the error, "start.val not of proper type." I can find n

Re: [R] conditional increase by increment

2012-07-19 Thread Peter Ehlers
On 2012-07-19 05:56, penguins wrote: Thanks William, that works fantastically! I had a quick play with my data and have realised a potential problem in that if an individual ends the series at home it records an additional trip-no when one wasnt made. I was wondering whether you could think of a

Re: [R] complexity of operations in R

2012-07-19 Thread Jan van der Laan
On 07/19/2012 05:50 PM, Hadley Wickham wrote: On Thu, Jul 19, 2012 at 8:02 AM, Jan van der Laan wrote: The following function is faster than your g and easier to read: g2 <- function(dotot) { v <- list() for (i in seq_len(dotot)) { v[[i]] <- FALSE } } Except that you don't need

Re: [R] finding the values to minimize sum of functions

2012-07-19 Thread Joshua Wiley
Hi Linh, Here is an approach: f <- function(v) { v <- v/sum(v) (v[1]^2) + (2 * v[2]^2) + (3*v[3]^2) } (res <- optim(c(.6, .3, .1), f)) res$par/sum(res$par) This is a downright lazy way to implement the constraint. The main idea is to combine all three functions into one function that take

[R] finding the values to minimize sum of functions

2012-07-19 Thread Linh Tran
Hi fellow R users, I am desperately hoping there is an easy way to do this in R. Say I have three functions: f(x) = x^2 f(y) = 2y^2 f(z) = 3z^2 constrained such that x+y+z=c (let c=1 for simplicity). I want to find the values of x,y,z that will minimize f(x) + f(y) + f(z). I know I can use th

Re: [R] complexity of operations in R

2012-07-19 Thread Paul Johnson
On Thu, Jul 19, 2012 at 11:11 AM, Bert Gunter wrote: > Hadley et. al: > > Indeed. And using a loop is a poor way to do it anyway. > > v <- as.list(rep(FALSE,dotot)) > > is way faster. > > -- Bert > Its not entirely clear to me what we are supposed to conclude about this. I can confirm Bert's cla

Re: [R] complexity of operations in R

2012-07-19 Thread Hadley Wickham
On Thu, Jul 19, 2012 at 9:21 AM, William Dunlap wrote: > Preallocation of lists does speed things up. The following shows > time quadratic in size when there is no preallocation and linear > growth when there is, for size in the c. 10^4 to 10^6 region: Interesting, thanks! I wish there was a be

Re: [R] Subsetting problem data

2012-07-19 Thread Rui Barradas
Hello, Try the following. d <- read.csv(text=" Patient, Cycle, Variable1, Variable2 A, 1, 4, 5 A, 2, 3, 3 A, 3, 4, NA B, 1, 6, 6 B, 2, NA, 6 C, 1, 6, 5 C, 3, 2, 2 ", header=TRUE) d compl <- lapply(split(d, d$Patient), function(x) if(all(diff(x$Cycle) == 1)) x) holes <- lapply(split(d, d$Patie

Re: [R] Line chart with a double matrix

2012-07-19 Thread David L Carlson
You should include your data using dput(mymatrix) to make things easier structure(list(Label = structure(c(4L, 1L, 2L, 3L), .Label = c("de 31 a 40", "de 41 a 50", "Mayor de 51", "Menor de 30"), class = "factor"), Blogs = c(57.14, 63.83, 72.64, 62.07), Wikis = c(28.57, 61.7, 70.75, 58.62

Re: [R] Generating Random Numbers

2012-07-19 Thread Petr Savicky
On Thu, Jul 19, 2012 at 04:12:07AM -0700, arunkumar wrote: > hi > > My inputs is min=(10,10,10,10,10) and max=(100,100,100,100,100) > total = 300 > i have to generate 5 numbers between min and max and those numbers should > sum upto total Hi. If we subtract the minimum from each number, then

Re: [R] complexity of operations in R

2012-07-19 Thread Bert Gunter
Thanks, Bill, but: > system.time(z1 <-f(n=1e5,pre=TRUE)) user system elapsed 0.320.000.32 > system.time(z2 <- as.list(seq_len(1e5))) user system elapsed 0 0 0 > identical(z1,z2) [1] TRUE So the point is not to use an R level loop at all. -- Bert On Thu, Jul

Re: [R] Generating Random Numbers

2012-07-19 Thread Kjetil Halvorsen
Those restrictions you have given do not define a unique distribution! so you need to think better about what you need. For instance, if you want a uniform distribution between min and max with n=5 independent observations from that, but conditional upon sum=total. For that, you could use rejectio

Re: [R] complexity of operations in R

2012-07-19 Thread William Dunlap
Preallocation of lists does speed things up. The following shows time quadratic in size when there is no preallocation and linear growth when there is, for size in the c. 10^4 to 10^6 region: > f <- function(n, preallocate) { v <- if(preallocate)vector("list",n) else > list() ; for(i in seq_len(n

Re: [R] complexity of operations in R

2012-07-19 Thread Joshua Wiley
also rep.int() > system.time(for (i in 1:1000) x <- rep.int(FALSE, 10)) user system elapsed 0.290.020.29 > system.time(for (i in 1:1000) x <- rep(FALSE, 10)) user system elapsed 1.960.082.05 On Thu, Jul 19, 2012 at 9:11 AM, Bert Gunter wrote: > Hadley et. al

Re: [R] Boxplot names

2012-07-19 Thread S Ellison
> When i make Boxplots with a lot of boxes, the names of them > get only written down every second "column". > Since they aren't in any way ordered, you don't see anymore > to what they belong. Jessica, Another possibility if the names are long is to use abbreviated factor levels. The labels a

Re: [R] complexity of operations in R

2012-07-19 Thread Bert Gunter
Hadley et. al: Indeed. And using a loop is a poor way to do it anyway. v <- as.list(rep(FALSE,dotot)) is way faster. -- Bert On Thu, Jul 19, 2012 at 8:50 AM, Hadley Wickham wrote: > On Thu, Jul 19, 2012 at 8:02 AM, Jan van der Laan wrote: >> Johan, >> >> Your 'list' and 'array doubling' code

Re: [R] package installation error in unix

2012-07-19 Thread Sarah Goslee
The error message is here: configure: error: Can't find HDF5 The hdf5 package is an interface to the HDF5 library, so you need to install hdf5 and hdf5-devel through your package manager (yum or apt-get or whatever you use to install things on your linux distro). Or you can get it straight from t

Re: [R] Boxplot names

2012-07-19 Thread John Fox
Dear Jessica, You might try par(las=2) to rotate the tick labels to be perpendicular to the axes. I hope this helps, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Ca

Re: [R] 3-d kernel smooth by the "kde" function

2012-07-19 Thread David L Carlson
No you are not correct. The kde function estimates the density of 1 to 6 dimensions. To visualize, this try plotting the density of just the data (using density() instead of kde): plot(density(elevation$data)) rug(elevation$data) The elevations are plotted along the x-axis and their density is pl

Re: [R] complexity of operations in R

2012-07-19 Thread Hadley Wickham
On Thu, Jul 19, 2012 at 8:02 AM, Jan van der Laan wrote: > Johan, > > Your 'list' and 'array doubling' code can be written much more efficient. > > The following function is faster than your g and easier to read: > > g2 <- function(dotot) { > v <- list() > for (i in seq_len(dotot)) { > v[[

Re: [R] package installation error in unix

2012-07-19 Thread uday
Hi Thanks for reply after usinginstall.packages("hdf5") I get error {Installing package(s) into ‘/home/uday/R/x86_64-pc-linux-gnu-library/2.14’ (as ‘lib’ is unspecified) trying URL 'http://cran.revolutionanalytics.com/src/contrib/hdf5_1.6.9.tar.gz' Content type 'application/x-gzip' length 50870 b

Re: [R] write list to ascii

2012-07-19 Thread INCOMA GfK
Dear Chris, many thanks! This is just what I had in mind! (namely the 'sapply' solution). Thank you and best regards! Zdenek -Original Message- From: Chris Campbell [mailto:ccampb...@mango-solutions.com] Sent: Thursday, July 19, 2012 4:11 PM To: Skála, Zdeněk (INCOMA GfK) Cc: r-help@

Re: [R] Maintaining Column names while writing csv file.

2012-07-19 Thread arun
HI, Possibly check.names=FALSE issue. Try this: dat1<-read.table(text="   2.5a  3.6b  7.1c  7.9d   100  3  4  2    3   200  3.1  4  3  3   300  2.2  3.3  2    4   ",sep="",header=TRUE) dat1 #You can get rid of those X by either using check.names=FALSE while reading the data #wi

[R] Line chart with a double matrix

2012-07-19 Thread ramonovelar
Hello, I have a double matrix that I want to represent in a line chart. Although I have seen some examples I still don't manage to get it. My data is this (a double matrix called mymatrix) : Blogs Wikis Redes Etiq. SPC LMS Menor de 30 57.14 28.57 14.29 28.57 57.14 28.57 de 31 a 4

Re: [R] [tripack] error in trmesh

2012-07-19 Thread Erdal Karaca
Sorry, I just found this to be a common "problem" of tri.mesh: I had to "jitter" one of my first three coords in the point set: x[2] <- x[2] + 0.01 Though, that does not seem to sound clean. Is there a better way? 2012/7/19 Erdal Karaca > I am trying to triangulate a point set as follows: > >

[R] Subsetting problem data, 2

2012-07-19 Thread Lib Gray
Hello, I didn't give enough information when I sent an query before, so I'm trying again with a more detailed explanation: In this data set, each patient has a different number of measured variables (they represent tumors, so some people had 2 tumors, some had 5, etc). The problem I have is that

[R] [tripack] error in trmesh

2012-07-19 Thread Erdal Karaca
I am trying to triangulate a point set as follows: > head(cbind(x,y)) x y [1,] -78.1444 -60.4424 [2,] -78.1444 -58.4424 [3,] -78.1444 -56.4424 [4,] -78.1444 -54.4424 [5,] -76.1444 -60.4424 [6,] -76.1444 -58.4424 > length(x) [1] 5000 > tri <- tri.mesh(x, y) Fehler in tri.mesh(x, y) : error in trm

[R] [deldir] map original index of coords to describe triangles

2012-07-19 Thread Erdal Karaca
My data: > head(cbind(x,y,z)) x y z [1,] -78.1444 -60.4424 -10.09 [2,] -78.1444 -58.4424 -10.26 [3,] -78.1444 -56.4424 -10.45 [4,] -78.1444 -54.4424 -10.64 [5,] -76.1444 -60.4424 -10.19 [6,] -76.1444 -58.4424 -10.34 > tris <- deldir(x, y) > triangs <- triang.list(tris) > head(tris$delsgs) x1 y1

Re: [R] Generating Random Numbers

2012-07-19 Thread Sarah Goslee
Is this homework? runif() is one way to generate random numbers, but there are others depending on the distribution desired. And of course the fifth number is deterministic. Sarah On Thu, Jul 19, 2012 at 7:12 AM, arunkumar wrote: > hi > > My inputs is min=(10,10,10,10,10) and max=(100,100,1

Re: [R] How to get lasso fit coefficient(given penalty tuning parameter \lambda) using lars package

2012-07-19 Thread caolinii
I have this problem as well Could you please kindly let me know what s is please. Is s equals to the value of lambda? Many thanks Lini -- View this message in context: http://r.789695.n4.nabble.com/How-to-get-lasso-fit-coefficient-given-penalty-tuning-parameter-lambda-using-lars-package-tp

Re: [R] conditional increase by increment

2012-07-19 Thread penguins
Thanks William, that works fantastically! I had a quick play with my data and have realised a potential problem in that if an individual ends the series at home it records an additional trip-no when one wasnt made. I was wondering whether you could think of a way to alter it slightly so that the i

Re: [R] rcspline.problem

2012-07-19 Thread Bart Ferket
Dear professor Harrell, I probably have the same problem as Haleh Ghaem Maralani. I am using the rms package and the rcspline.plot function to assess the relation of a continuous predictor to the log hazard function. I would like to use the "adj" statement, for example using this test dataset:

[R] Generating Random Numbers

2012-07-19 Thread arunkumar1111
hi My inputs is min=(10,10,10,10,10) and max=(100,100,100,100,100) total = 300 i have to generate 5 numbers between min and max and those numbers should sum upto total Can anyone help? - Thanks in Advance Arun -- View this message in context: http://r.789695.n4.nabble.com/Generating

Re: [R] Finding the last value before a certain date

2012-07-19 Thread William Dunlap
If you need to do this for a lot of dates findInterval() will do it faster. E.g., > f <- function(dates, data) { + i <- findInterval(dates, data$date) + i[i==0] <- NA # before first data$date + data[i, ] + } > xx <- as.Date(c("2010-10-06", "2010-10-25", "2009-01-01", "201

Re: [R] Boxplot names

2012-07-19 Thread Bert Gunter
You might alternatively find the horizontal = TRUE with las=2 to be useful; e.g. dat <- data.frame(val=rnorm(100), grp=rep(apply(matrix(sample(letters,100,rep=TRUE),nr=5),2,paste,collapse=""),5)) boxplot(val~grp,horizontal=TRUE,data=dat,las=2) ## Note that las=2 might also help with horizonta

Re: [R] write list to ascii

2012-07-19 Thread William Dunlap
You will probably need to write a custom function, but it could use the built-in write.dcf() or formatDL() functions. E.g., > # options(width=50) > write.dcf(list(One=paste(1:50,collapse=" "), Two=paste(state.abb[1:5], collapse=", "))) One: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

Re: [R] complexity of operations in R

2012-07-19 Thread Jan van der Laan
Johan, Your 'list' and 'array doubling' code can be written much more efficient. The following function is faster than your g and easier to read: g2 <- function(dotot) { v <- list() for (i in seq_len(dotot)) { v[[i]] <- FALSE } } In the following line in you array doubling function

Re: [R] Boxplot names

2012-07-19 Thread Jessica Streicher
Copied the wrong lines, sry l<-rep(list(1:5),20); boxplot(l,names=sample(1:20,20)) of course. thanks for the answer . On 19.07.2012, at 16:17, Peter Ehlers wrote: > On 2012-07-19 06:58, Jessica Streicher wrote: >> When i make Boxplots with a lot of boxes, the names of them get only written >>

Re: [R] 'symbols' not plotting correct circle radii

2012-07-19 Thread Stuart Leask
You're right - easily tested by just re-sizing the graphics box - sort of counter-intuitive until I remember the clue is in the name - this generates a CIRCLE, come what may... Stuart From: Sarah Goslee [mailto:sarah.gos...@gmail.com] Sent: 19 July 2012 11:18 To: Stuart Leask Cc: r-help@r-proje

Re: [R] alternate tick labels and tick marks with lattice xyplot

2012-07-19 Thread Leah Marian
Great, Thanks! This is really helpful! On Thu, Jul 19, 2012 at 12:25 AM, ilai wrote: > Maybe I'm missing something too but from your example seems like you are > looking for > > xyplot(rnorm(12) ~ 1:12 , type="l", > scales=list(x=list(at=seq(2,12,2),labels=c(1, ' ', 3 , ' ' , 5 , ' ' ))), > par.s

Re: [R] Boxplot names

2012-07-19 Thread Peter Ehlers
On 2012-07-19 06:58, Jessica Streicher wrote: When i make Boxplots with a lot of boxes, the names of them get only written down every second "column". Since they aren't in any way ordered, you don't see anymore to what they belong. example: l<-rep(list(1:5),20); boxplot(l,names=sample(20,1:20)

Re: [R] write list to ascii

2012-07-19 Thread Chris Campbell
Dear Zdenek You could generate this file using a loop. # the data abc <- list(one=(1:2), two=(1:5)) # create a connection sink("aa.txt", append=T, split=T) # for each element in the list, print for (list_name in names(abc)) { cat(list_name,

[R] Boxplot names

2012-07-19 Thread Jessica Streicher
When i make Boxplots with a lot of boxes, the names of them get only written down every second "column". Since they aren't in any way ordered, you don't see anymore to what they belong. example: l<-rep(list(1:5),20); boxplot(l,names=sample(20,1:20)) Is there a way to show them all, or do i have

Re: [R] Entering Data Files

2012-07-19 Thread John Kane
?read.table Using my normal file path and th data as you supplied it. x <- read.csv("/home/john/rdata/ages.csv", sep = " ", header = TRUE) Change the file path to whatever yours is. Example might be x <- read.csv("C:/mydata/ages.csv", sep = " ", header = TRUE) in Windows. Note that you c

Re: [R] Upgrading on Ubuntu from 2.11.1 to 2.15.1

2012-07-19 Thread John Kane
As far as I can see those instructions are not all that helpful. The answer below, from R-sig-Debian worked very nicely for me a little over a month ago. > -Original Message- > From: marutter@gmail.com > Sent: Tue, 12 Jun 2012 16:56:16 -0400 > To: jrkrid...@inbox.com > Subject: Re: [

Re: [R] cenbox(): Changing Default x-axis Group Labels

2012-07-19 Thread John Kane
Code? Sample data? John Kane Kingston ON Canada > -Original Message- > From: rshep...@appl-ecosys.com > Sent: Wed, 18 Jul 2012 14:30:24 -0700 (PDT) > To: r-help@r-project.org > Subject: [R] cenbox(): Changing Default x-axis Group Labels > >I've looked at the lattice book and the 'R

Re: [R] expert opinion on lmer

2012-07-19 Thread Bert Gunter
This should definitely be posted on the r-sig-mixed-models list, not here. -- Bert On Thu, Jul 19, 2012 at 6:16 AM, Yolande Tra wrote: > Hello, > > I have the following design, counts were collected at different transects, > different depths and different sites at different times. Time is conti

[R] expert opinion on lmer

2012-07-19 Thread Yolande Tra
Hello, I have the following design, counts were collected at different transects, different depths and different sites at different times. Time is continuous and assumed to be random, all the others are categorical fixed where transect is nested within depth which is nested within site. I would

Re: [R] Contour

2012-07-19 Thread Jean V Adams
As Duncan Murdoch pointed out, the example data frame that you provided doesn't give very interesting results (all the shock values are zero), so I created a different shock variable for illustration. I suggest using the interp() function in the R package akima. df <- structure(list(c = 1:6, z

Re: [R] Contour

2012-07-19 Thread Duncan Murdoch
On 12-07-19 2:01 AM, Akhil dua wrote: Hello every one can any one tell me how to draw contour with this data set c zshock 1 0.45450237 0 2 0.02663337 0 3 -2.08444556 0 4 -0.12715275 0 5 0.67066360 0 6 -0.73540081 0 I want to dr

Re: [R] package installation error in unix

2012-07-19 Thread Pascal Oettli
Hello, There is a mistake. Type > install.packages("hdf5") instead of > installed.packages("hdf5") in order to install a package. Best Regards, Passcal Le 19/07/2012 17:02, uday a écrit : Hi, Recently I have installed R in my Linux operating system , after installation I was trying to in

Re: [R] problem with using apply for dataframe

2012-07-19 Thread Eik Vettorazzi
Hi Marion, as stated in the help file ?apply coerces a data.frame object into an array. Since an array has only one type of data, this coercion turns all your variables into strings (because this data type can hold all information given without loss). If it happens that your data.frame consists on

Re: [R] Upgrading on Ubuntu from 2.11.1 to 2.15.1

2012-07-19 Thread Michael Dewey
At 22:27 18/07/2012, Chet Seligman wrote: This doesn't work, what should I do? Try reposting on the r-sig-debian list. It might help to tell them what version of Ubuntu you are using and to paste in your sources.list sudo apt-get install r-base [sudo] password for cseligman: Reading pack

  1   2   >