[R] Contour

2012-07-19 Thread Akhil dua
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 draw contour for shock i.e my z matrix is shock

Re: [R] Imposing more than one condition to if

2012-07-19 Thread Santiago Guallar
Great! Thank you ever so much Rui. Santi From: Rui Barradas ruipbarra...@sapo.pt To: Santiago Guallar sgual...@yahoo.com Cc: r-help@r-project.org Sent: Wednesday, July 18, 2012 8:29 PM Subject: Re: [R] Imposing more than one condition to if Hello, You're

Re: [R] taylor expansions with real vectors

2012-07-19 Thread Petr Savicky
On Wed, Jul 18, 2012 at 06:02:27PM -0700, bilelsan wrote: Leave the Taylor expansion aside, how is it possible to compute with [R]: f(e) = e1 + e2 #for r = 1 + 1/2!*e1^2 + 1/2!*e2^2 + 1/2!*e1*e2 #for r = 2, excluding e2*e1 + 1/3!*e1^3 + 1/3!*e1^2*e2 + 1/3!*e2^2*e1 + 1/3!*e2^3 #for r = 3,

[R] Maintaining Column names while writing csv file.

2012-07-19 Thread Vincy Pyne
Dear R helpers, I have one trivial problem while writing an output file in csv format. I have two dataframes say df1 and df2 which I am reading from two different csv files. df1 has column names as date, r1, r2, r3 while the dataframe df2 has column names as date, 1w, 2w. (the dates in

Re: [R] Simple tree

2012-07-19 Thread Petr Savicky
On Wed, Jul 18, 2012 at 06:34:49PM -0700, Noah Silverman wrote: Hi, I'm looking for an easy way to setup a decision tree. This is *not* any kind of regression, but a very simple DAG with probability on each edge and a value at each node. I just need a way to input the graph and

Re: [R] double for cycle

2012-07-19 Thread cesare orsini
thank you Mr. Carlson you're right, the matrix that I used as an example does not make sense. When I built the array I was not thinking of the formula s[n]=1+s[n]+rnorm(1,mean=0,sd=1), I just wanted to give an example of the structure of the matrix that I needed. Anyway I think you have solved

Re: [R] convert deldir$delsgs to a X3D IndexedTriangleSet

2012-07-19 Thread Erdal Karaca
Oh, sorry: X3D is an interchange format for 3D scenes (s [1])... X3D's IndexedTriangleSet is a visual component to describe a complex figure to be visualized by triangles (s. [2]) I would like to triangulate a pointset (2.5D DEM consisting of xy coords and height) using deldir and convert the

[R] Finding the last value before a certain date

2012-07-19 Thread Robert Latest
Hello all, I have a dataframe that looks like this: head(df) datey 1 2010-09-27 1356 2 2010-10-04 1968 3 2010-10-11 2602 4 2010-10-17 3116 5 2010-10-24 3496 6 2010-10-31 3958 I need a function that, given any date, returns the y value corresponding to the given date or the last day

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

2012-07-19 Thread Eik Vettorazzi
Hi Vincy, have you checked names(df2) and names(df_new) because by default 'data.frame' checks the column names to ensure that they are syntactically valid variable names and 1w and 2w aren't, so an X is prepended (see ?data.frame and ?make.names). compare

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

2012-07-19 Thread Rolf Turner
On 19/07/12 18:55, Vincy Pyne wrote: Dear R helpers, I have one trivial problem while writing an output file in csv format. I have two dataframes say df1 and df2 which I am reading from two different csv files. df1 has column names as date, r1, r2, r3 while the dataframe df2 has column

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

2012-07-19 Thread Rui Barradas
Hello, Try the following. dat - read.table(text= datey 1 2010-09-27 1356 2 2010-10-04 1968 3 2010-10-11 2602 4 2010-10-17 3116 5 2010-10-24 3496 6 2010-10-31 3958 , header=TRUE, stringsAsFactors=FALSE) dat$date - as.Date(dat$date) str(dat) search - as.Date(2010-10-06)

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

2012-07-19 Thread Eik Vettorazzi
Hi Robert, how about this (assuming your data.frame is ordered by date): tmp-read.table(textConnection(datey 1 2010-09-27 1356 2 2010-10-04 1968 3 2010-10-11 2602 4 2010-10-17 3116 5 2010-10-24 3496 6 2010-10-31 3958),header=T,colClasses=c(date=Date))

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

2012-07-19 Thread Rainer Schuermann
dat - structure(list(date = structure(c(14879, 14886, 14893, 14899, 14906, 14913), class = Date), y = c(1356L, 1968L, 2602L, 3116L, 3496L, 3958L)), .Names = c(date, y), row.names = c(1, 2, 3, 4, 5, 6), class = data.frame) x - as.Date( 2010-10-06 ) getY - function( x ) { dat[ dat$date = x, 2][

Re: [R] tweaking forest plot (metafor package)

2012-07-19 Thread Viechtbauer Wolfgang (STAT)
I think Michael already gave you some really good hints. To add a bit more details to this, first of all, I suggest to use: q2 - rma(yi, vi, mods=cbind(grupo), data=qim) forest(q2, transf=transf.ztor, digits=3, alim=c(0,1), refline=.5, addfit=FALSE) so that the fitted values for that

Re: [R] mgcv: inclusion of random intercept in model - based on p-value of smooth or anova?

2012-07-19 Thread Simon Wood
Martin, I've just submitted mgcv_1.7-19 to CRAN, which includes a major upgrade of the p-value computation for random effect terms (and any other smooth term which can be penalized to zero as part of estimation). The new p-values are still conditional on the smoothing parameter/variance

Re: [R] complexity of operations in R

2012-07-19 Thread Johan Henriksson
On Wed, Jul 18, 2012 at 10:06 AM, Patrick Burns pbu...@pburns.seanet.comwrote: It looks to me like the following should do what you want: f2 - function(dotot) array(FALSE, c(dotot, 1)) What am I missing? ah, the output of this is purely a toy example. the point is that the add*()

[R] problem with using apply for dataframe

2012-07-19 Thread Marion Wenty
Dear people, I am including an example of a dataframe: mydataframe-data.frame(X=c(1:4),total_bill=c(16.99,10.34,21.01,23.68),tip=c(1.01,1.66,3.50,3.31),sex=c(Male,Male,Male,Female)) When I use the sapply function getting the information about the factors works:

[R] package installation error in unix

2012-07-19 Thread uday
Hi, Recently I have installed R in my Linux operating system , after installation I was trying to install some packages and I was getting error installed.packages(hdf5) { Package LibPath Version Priority Depends Imports LinkingTo Suggests Enhances OS_type License Archs Built} this

Re: [R] The best solver for non-smooth functions?

2012-07-19 Thread Cren
Roger Koenker-3 wrote There are obviously a large variety of non-smooth problems; for CVAR problems, if by this you mean conditional value at risk portfolio problems, you can use modern interior point linear programming methods. Further details are here:

Re: [R] The best solver for non-smooth functions?

2012-07-19 Thread Cren
Hans W Borchers wrote The most robust solver for non-smooth functions I know of in R is Nelder-Mead in the 'dfoptim' package (that also allows for box constraints). First throw out the equality constraint by using c(w1, w1, 1-w1-w2) as input. This will enlarge the domain a bit, but

Re: [R] convert deldir$delsgs to a X3D IndexedTriangleSet

2012-07-19 Thread Rolf Turner
On 19/07/12 18:36, Erdal Karaca wrote: Oh, sorry: X3D is an interchange format for 3D scenes (s [1])... X3D's IndexedTriangleSet is a visual component to describe a complex figure to be visualized by triangles (s. [2]) I would like to triangulate a pointset (2.5D DEM consisting of xy

Re: [R] The best solver for non-smooth functions?

2012-07-19 Thread Cren
Roger Koenker-3 wrote There are obviously a large variety of non-smooth problems; for CVAR problems, if by this you mean conditional value at risk portfolio problems, you can use modern interior point linear programming methods. Further details are here:

Re: [R] convert deldir$delsgs to a X3D IndexedTriangleSet

2012-07-19 Thread Erdal Karaca
Oh, I dont want anyone to do anything for me. I am just asking for hints/infos to be able to do it myself... I was hoping that someone has already done this... But anyways, I will post my solution once I have succeeded... Thanks for the support! 2012/7/19 Rolf Turner rolf.tur...@xtra.co.nz

[R] write list to ascii

2012-07-19 Thread INCOMA GfK
Dear all, apologies for this (perhaps recurrent) question but I did not found a question when searching mailing lists. How to write a list of a simple kind, e.g.: abc - list(one=(1:2), two=(1:5)) # to a file? I understand that write() co. cannot work but when I try sink(aa.txt, append=T,

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

2012-07-19 Thread Stuart Leask
(Oh, and yes I've tried setting 'inches=F', but I then get a circle correct on X axis, but too large on the Y axis.) -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Stuart Leask Sent: 18 July 2012 11:03 To: r-help@r-project.org

Re: [R] write list ascii file

2012-07-19 Thread Jim Holtman
what is that you want to do with this data after it is written? you can easily write a function using 'cat' to create any format that you want. Sent from my iPad On Jul 19, 2012, at 5:09, Skála, Zdeněk (INCOMA GfK)zdenek.sk...@gfk.com wrote: Dear all, apologies for this (perhaps recurrent)

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

2012-07-19 Thread Stuart Leask
Problem has gone away! Last night, on this computer (64-bit i7 Windows 7), setting inches=F plotted wrongly on Y. Tried it again this morning - still wrong on Y the first time, BUT repeating it - okay on Y! Repeating previous syntax, then repeating this - still okay. Odd. I will get back to

Re: [R] problem with using apply for dataframe

2012-07-19 Thread Jessica Streicher
apply(mydataframe,2,function(x){ print(x);is.factor(x)}) [1] 1 2 3 4 [1] 16.99 10.34 21.01 23.68 [1] 1.01 1.66 3.50 3.31 [1] Male Male Male Female X total_billtipsex FALSE FALSE FALSE FALSE sapply(mydataframe,function(x){

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

2012-07-19 Thread Sarah Goslee
On Thursday, July 19, 2012, Stuart Leask wrote: (Oh, and yes I've tried setting 'inches=F', but I then get a circle correct on X axis, but too large on the Y axis.) We're back to read the help. ?symbols explictly states that if inches=FALSE and the axis scales are different, then the x axis

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

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

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 install

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

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

[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] 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 yolande@gmail.com wrote: Hello, I have the following design, counts were collected at different transects, different depths and different sites at different

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] 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] 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 can do

[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] 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,

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] 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 ke...@math.montana.edu 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 ,

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:

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 down

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] 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 18 19

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

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, 2011-12-31))

[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:

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:

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

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:

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 akpbond...@gmail.com wrote: hi My inputs is min=(10,10,10,10,10)

[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 x2 y2

[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 trmesh

[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

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 erdal.karaca...@gmail.com I am trying to triangulate a point

[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

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 #with

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:

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

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 rh...@eoos.dds.nl 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)) {

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

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,

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

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 had...@rice.edu wrote: On Thu, Jul 19, 2012 at 8:02 AM, Jan van der Laan rh...@eoos.dds.nl wrote: Johan, Your 'list'

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 appear

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 gunter.ber...@gene.com

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] 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

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 19,

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 we

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), Redes

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$Patient),

Re: [R] complexity of operations in R

2012-07-19 Thread Hadley Wickham
On Thu, Jul 19, 2012 at 9:21 AM, William Dunlap wdun...@tibco.com 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

Re: [R] complexity of operations in R

2012-07-19 Thread Paul Johnson
On Thu, Jul 19, 2012 at 11:11 AM, Bert Gunter gunter.ber...@gene.com 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

[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

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 takes

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 rh...@eoos.dds.nl 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

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

[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 no

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 find the

[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|quote,

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

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

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 5

[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,

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 akpbond...@gmail.com To:

[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.

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 }

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

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 )

[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:

[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

[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

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, NA)) onenew-data.frame(keyword=gsub((NA){0,1}\\|,,one$keyword)) onenew1-data.frame(keyword=gsub((NA){0,1},,onenew$keyword))  onenew1   

[R] Fw: Removing values from a string

2012-07-19 Thread arun
- Forwarded Message - From: arun smartpink...@yahoo.com To: Abraham Mathew abmathe...@gmail.com Cc: R help r-help@r-project.org 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,

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] 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,

  1   2   >