[R] Inverse of FAQ 7.31.

2011-08-02 Thread Rolf Turner
Why does R think these numbers ***are*** equal? In a somewhat bizarre set of circumstances I calculated x0 - 0.03580067 x1 - 0.03474075 y0 - 0.4918823 y1 - 0.4474461 dx - x1 - x0 dy - y1 - y0 xx - (x0 + x1)/2 yy - (y0 + y1)/2 chk - yy*dx - xx*dy + x0*dy -

[R] Loops to assign a unique ID to a column

2011-08-02 Thread Chandra Salgado Kent
Dear R help, I am fairly new in data management and programming in R, and am trying to write what is probably a simple loop, but am not having any luck. I have a dataframe with something like the following (but much bigger): Dates-c(12/10/2010,12/10/2010,12/10/2010,13/10/2010,

Re: [R] Loops to assign a unique ID to a column

2011-08-02 Thread ONKELINX, Thierry
Dear Chandra, You're on the wrong track. You don't need for loops as you can do this vectorised. as.numeric(interaction(data$Groups, data$Dates, drop = TRUE)) Best regards, Thierry -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]

Re: [R] Inverse of FAQ 7.31.

2011-08-02 Thread peter dalgaard
On Aug 2, 2011, at 08:02 , Rolf Turner wrote: Why does R think these numbers ***are*** equal? In a somewhat bizarre set of circumstances I calculated x0 - 0.03580067 x1 - 0.03474075 y0 - 0.4918823 y1 - 0.4474461 dx - x1 - x0 dy - y1 - y0 xx - (x0 + x1)/2

Re: [R] Plotting problems directional or rose plots

2011-08-02 Thread Jim Lemon
On 08/02/2011 01:38 AM, kitty wrote: Hi again, I have tried playing around with the code given to me by Alan and Jim, thank you for the code but unfortunatelyI can't seem to get either of them to work... Alans does not work with the sample data and Jims is giving the error : Error in

Re: [R] Environment of a LM created in a function

2011-08-02 Thread Thaler, Thorn, LAUSANNE, Applied Mathematics
Dear Peter, Thanks for your concise answer, it works perfectly. By the way, I fully agree that data or df are not good names for data.frames and I am/was aware of that and I usually avoid those names (not consequently though I've to admit, it is too tempting ;). However, if one uses those evil

Re: [R] if function problems

2011-08-02 Thread Petr PIKAL
Hi another possibility is to use logical values properties (x 0)*x [1] -3 -2 -1 0 0 0 0 Regards Petr In addition to what David said: On Mon, Aug 1, 2011 at 6:57 PM, zoe_zhang 1987.zhan...@gmail.com wrote: Dear All, Sorry to bother I want to write a function in R using if

Re: [R] ivreg and structural change

2011-08-02 Thread Achim Zeileis
On Mon, 1 Aug 2011, Claudio Shikida (??) wrote: Hello, I am looking for some help with this question: how could I test structural breaks in a instrumental variables?s model? In principle, most of tests used in the standard linear regression model can also be transferred to the IV

Re: [R] if function problems

2011-08-02 Thread zoe_zhang
Thank you for your adding, Steve, i followed Daivd's suggection and finally got the answer. It is my careless that should put lena instead of lenx. I also tried your codes and worked well. I appreciate your help. I learnt a lot from this forum. Cheers, Zoe -- View this message in context:

[R] R CMD check problem

2011-08-02 Thread Baidya Nath Mandal
Dear friends, I am building an R package called *mypackage*. I followed every possible steps (to my understanding) for the same. I got following problem while doing *R CMD check mypackage*. * installing *source* package 'mypackage' ... ** libs cygwin warning: MS-DOS style path detected:

[R] How to 'mute' a function (like confint())

2011-08-02 Thread Remko Duursma
Dear R-helpers, I am using confint() within a function, and I want to turn off the message it prints: x - rnorm(100) y - x^1.1+rnorm(100) nlsfit - nls(y ~ g0*x^g1, start=list(g0=1,g1=1)) confint(nlsfit) Waiting for profiling to be done... 2.5%97.5% g0 0.4484198 1.143761 g1

Re: [R] Fitting ELISA measurements unknowns to 4 parameter logistic model

2011-08-02 Thread assaywiz
Try http://www.myassays.com/four-parameter-fit.assay It’s free, requires no install and pre-configured for ELISAs. Just paste and go AW -- View this message in context: http://r.789695.n4.nabble.com/Fitting-ELISA-measurements-unknowns-to-4-parameter-logistic-model-tp3252381p3711676.html

[R] Clean up a scatterplot with too much data

2011-08-02 Thread DimmestLemming
I'm working with a lot of data right now, but I'm new to R, and not very good with it, hence my request for help. What type of graph could I use to straighten out things like... http://r.789695.n4.nabble.com/file/n3711389/Untitled.png ...this? I want to see general frequencies. Should I use

Re: [R] How to 'mute' a function (like confint())

2011-08-02 Thread Prof Brian Ripley
See ?suppressMessages On Tue, 2 Aug 2011, Remko Duursma wrote: Dear R-helpers, I am using confint() within a function, and I want to turn off the message it prints: x - rnorm(100) y - x^1.1+rnorm(100) nlsfit - nls(y ~ g0*x^g1, start=list(g0=1,g1=1)) confint(nlsfit) Waiting for profiling

Re: [R] Clean up a scatterplot with too much data

2011-08-02 Thread Paul Hiemstra
Hi, One solution could be to subsample the data, or jitter the data (give it some random noise). A more elegant solution, imho, is to use a 2d histogram (3d histogram is not a good alternative, I think it is much better to use color instead of a third dimension). I don't think this is easy to

Re: [R] R-help Digest, Vol 102, Issue 2

2011-08-02 Thread fraenzi . korner
Wir sind bis am 20. August in den Ferien und werden keine e-mails beantworten. Bei dringenden Fällen melden Sie sich bei Stefanie von Felten steffi.vonfel...@oikostat.ch We are on vacation until 20. August. In urgent cases, please contact Stefanie von Felten steffi.vonfel...@oikostat.ch

Re: [R] Reorganize(stack data) a dataframe inducing names

2011-08-02 Thread Francesca
Works perfectly. Thanks. f. On 1 August 2011 18:22, jim holtman jholt...@gmail.com wrote: Try this: had to add extra names to your data since it was not clear how it was organized. Next time use 'dput' to enclose data. x - read.table(textConnection( index time key date values +

Re: [R] Clean up a scatterplot with too much data

2011-08-02 Thread Karl Ove Hufthammer
DimmestLemming wrote: I'm working with a lot of data right now, but I'm new to R, and not very good with it, hence my request for help. What type of graph could I use to straighten out things like... http://r.789695.n4.nabble.com/file/n3711389/Untitled.png Three nice alternatives:

Re: [R] R CMD check problem

2011-08-02 Thread Duncan Murdoch
On 11-08-02 5:26 AM, Baidya Nath Mandal wrote: Dear friends, I am building an R package called *mypackage*. I followed every possible steps (to my understanding) for the same. I got following problem while doing *R CMD check mypackage*. * installing *source* package 'mypackage' ... ** libs

Re: [R] R CMD check problem

2011-08-02 Thread Joshua Wiley
The cygwin warning should not be fatal. Is that what made you think there's a problem with your path? Can you upload mypackage online? Two options would be Github hosts that sort of thing or you could use a tar ball and any file hosting service. I (and possibly others more skilled) would be

Re: [R] Plotting question

2011-08-02 Thread Karl Ove Hufthammer
Andrew McCulloch wrote: I use R to draw my graphs. I have 100 points on a simple xy-plot. The points are distinguished by a third variable which is categorical with 10 levels. I have been plotting x against y and using gray scales to distinguish the level of the categorical variable for each

Re: [R] Is R the right choice for simulating first passage times of random walks?

2011-08-02 Thread Paul Menzel
Dear Dennis and Steve, Am Sonntag, den 31.07.2011, 23:32 -0400 schrieb Steve Lianoglou: […] How about trying to write the of this `f4` function below using the rcpp/inline combo. The C/C++ you will need to write looks to be quite trivial, let's change f4 to accept an x argument as a vector:

[R] Memory limit in Aggregate()

2011-08-02 Thread Guillaume
Dear all, I am trying to aggregate a table (divided in two lists here), but get a memory error. Here is the code I'm running : sessionInfo() print(paste(memory.limit() , memory.limit())) print(paste(memory.size() , memory.size())) print(paste(memory.size(TRUE) ,

[R] efficient way to reduce running time

2011-08-02 Thread Kathie
Dear R users, Would you plz tell me how to avoid this for loop blow?? I think there might be a better way to reduce running time. -- ## y1 and y2 are n*1 vectors for (k in 1:n){

[R] Standard Deviation of a matrix

2011-08-02 Thread chakri
Hello, My R knowledge could not take me any further, so this request ! I have a matrix of dimensions (1185 X 1185). I want to calculate standard deviation of entire matrix. sd function of {stats} calculates standard deviation for each row/column, giving 1 X 1185 matrix as result. I would like

[R] Using Function

2011-08-02 Thread Silvano
Hi, I have some simple statistics to calculate for a large number of variables. I created a simple function to apply to variables. I would like the variable name to be placed automatically. I tried the following function but is not working. desc = function(x){ media = mean(x,

Re: [R] Standard Deviation of a matrix

2011-08-02 Thread Paul Hiemstra
Hi! The sample below should give you what you want: M = matrix(runif(100), 10, 10) sd(as.numeric(M)) So the as.numeric command is the key. It transforms the matrix to a 1D vector. Or alternatively without using as.numeric: M = matrix(runif(100), 10, 10) M dim(M) = 100 M sd(M) Here I use the

Re: [R] Errors, driving me nuts

2011-08-02 Thread Paul Hiemstra
On 08/01/2011 08:47 PM, Matt Curcio wrote: Greetings all, I am getting this error that is driving me nuts... (not a long trip, haha) I have a set of files and in these files I want to calculate ttests on rows 'compareA' and 'compareB' (these will change over time there I want a variable

Re: [R] Standard Deviation of a matrix

2011-08-02 Thread Petr PIKAL
Hi Hi! The sample below should give you what you want: M = matrix(runif(100), 10, 10) sd(as.numeric(M)) So the as.numeric command is the key. It transforms the matrix to a 1D vector. Or alternatively without using as.numeric: M = matrix(runif(100), 10, 10) M dim(M) = 100 or

Re: [R] Standard Deviation of a matrix

2011-08-02 Thread David Winsemius
On Aug 2, 2011, at 8:48 AM, Petr PIKAL wrote: Hi Hi! The sample below should give you what you want: M = matrix(runif(100), 10, 10) sd(as.numeric(M)) So the as.numeric command is the key. It transforms the matrix to a 1D vector. Or alternatively without using as.numeric: M =

[R] Problem Installing/Uninstalling Rattle

2011-08-02 Thread adarwish
Rattle won't install properly on my Windows 7 64 bit laptop. Here is what I've tried: I've followed the instructions here: http://rattle.togaware.com/rattle-install-mswindows.html I had R installed already. I downloaded the GTK+ packages, unzipped the 32 bit one into c:\gtkwin32. I put

[R] Functions for Sum of determinants of ranges of matrix subsets

2011-08-02 Thread john james
Dear R-help list, Pls I have this problem. Suppose I have a matrix of size nxn say, generated as follows   z-matrix(rnorm(n*n,0,1),nrow=n)   I want to write a function such that for i in 1:n, I will remove the rows and columns corresponding to i (so, will be left with n-1*n-1 submatrix in each

[R] execute r-code stored in a string variable

2011-08-02 Thread Kim Lillesøe
Dear all I have a simple R question. How do I execute R-code stored in a variable? E.g if I have a variable which contains some R-code: c = reg - lm(sales$sales~sales$price) Is it possible to execute c E.g like Exec(c) I hope someone can help. Thank you Kim Lillesøe [[alternative

[R] Odp: Using Function

2011-08-02 Thread Petr PIKAL
Hi Hi, I have some simple statistics to calculate for a large number of variables. I created a simple function to apply to variables. I would like the variable name to be placed automatically. I tried the following function but is not working. desc = function(x){

Re: [R] Clean up a scatterplot with too much data

2011-08-02 Thread Dennis Murphy
In addition to the other responses (all of which I liked), a couple of other alternatives to consider are 2D density plots (see ?kde2d in the MASS package, for example) or geom_tile() in the ggplot2 package, which you can think of as a 3D histogram projected to 2D with color corresponding to

Re: [R] Clean up a scatterplot with too much data

2011-08-02 Thread Paul Hiemstra
On 08/02/2011 01:07 PM, Dennis Murphy wrote: In addition to the other responses (all of which I liked), a couple of other alternatives to consider are 2D density plots (see ?kde2d in the MASS package, for example) or geom_tile() in the ggplot2 package, which you can think of as a 3D histogram

Re: [R] Identifying US holidays

2011-08-02 Thread R. Michael Weylandt michael.weyla...@gmail.com
Now that I'm back at my computer, I'll actually suggest you do something else entirely. If you look at the code of holidayNYSE() or by calling listHolidays() of the timeDate package you'll see that there are many many functions that get every conceivable holiday directly. I'll let you pick the

Re: [R] efficient way to reduce running time

2011-08-02 Thread Dennis Murphy
Hi: Could you please provide a reproducible example? In your code, (i) n is undefined; (ii) logbp is undefined. A description of what you want to do and/or a reproducible example with an expected outcome would be useful. As the bottom of each e-mail to R-help says... PLEASE do read the

Re: [R] Identifying US holidays

2011-08-02 Thread Dimitri Liakhovitski
Thanks a lot, Michael - that's exactly what I was looking for! Dimitri On Tue, Aug 2, 2011 at 9:48 AM, R. Michael Weylandt michael.weyla...@gmail.com michael.weyla...@gmail.com wrote: Now that I'm back at my computer, I'll actually suggest you do something else entirely. If you look at the

Re: [R] Functions for Sum of determinants of ranges of matrix subsets

2011-08-02 Thread Dennis Murphy
Hi: Try this: z - matrix(rnorm(100), nrow = 10) sum(sapply(seq_len(nrow(z)), function(k) det(z[-k, -k]))) [1] 1421.06 where sapply(seq_len(nrow(z)), function(k) det(z[-k, -k])) [1] 432.11613 81.65449 516.95791 54.72775 804.32097 -643.35436 [7] -411.15932 394.18780 84.13173

Re: [R] execute r-code stored in a string variable

2011-08-02 Thread Ista Zahn
Hi Kim, You can use eval(parse(text = c)) Best, Ista On Tue, Aug 2, 2011 at 8:22 AM, Kim Lillesøe k...@dataminds.dk wrote: Dear all I have a simple R question. How do I execute R-code stored in a variable? E.g if I have a variable which contains some R-code: c = reg -

Re: [R] Memory limit in Aggregate()

2011-08-02 Thread peter dalgaard
On Aug 2, 2011, at 11:45 , Guillaume wrote: Dear all, I am trying to aggregate a table (divided in two lists here), but get a memory error. Here is the code I'm running : sessionInfo() print(paste(memory.limit() , memory.limit())) print(paste(memory.size() ,

[R] Help with aggregate syntax for a multi-column function please.

2011-08-02 Thread Michael Karol
Dear R-experts: I am using a function called AUC whose arguments are data, time, id, and dv. data is the name of the dataframe, time is the independent variable column name, id is the subject id and dv is the dependent variable. The function computes area under the curve by

[R] identifying weeks (dates) that certain days (dates) fall into

2011-08-02 Thread Dimitri Liakhovitski
Hello! I have dates for the beginning of each week, e.g.: weekly-data.frame(week=seq(as.Date(2010-04-01), as.Date(2011-12-26),by=week)) week # each week starts on a Monday I also have a vector of dates I am interested in, e.g.: july4-as.Date(c(2010-07-04,2011-07-04)) I would like to flag the

[R] matrix indexing (igraph ?)

2011-08-02 Thread Robinson, David G
I realize that matrix indexing has been addressed in various flavors, but I'm stumped and didn't find anything in the archives. It's not clear if it is an igraph issue or a more general problem. Thanks in advance for your patience. I am using igraph to read a gml file

[R] merging lists within lists via time stamp

2011-08-02 Thread tomtomme
From multiple data.frames I created two lists, one with temperature, one with gps data. With your help and lapply I managed to interpolate the timestamps of gps and temperature data. Now I want to merge/join both lists via the time-stamp, taking only times, where both lists have data. For the

Re: [R] execute r-code stored in a string variable

2011-08-02 Thread Samuel Le
Yes, you can use: eval(parse(text=c)) On the other hand I would not recommend to use c as a variable name as it is the name of a very important function in the R language to aggregate data. HTH, Samuel -Original Message- From: r-help-boun...@r-project.org

Re: [R] identifying weeks (dates) that certain days (dates) fall into

2011-08-02 Thread David Winsemius
The findInterval function should surely be tried in some form or another. On Aug 2, 2011, at 10:36 AM, Dimitri Liakhovitski wrote: Hello! I have dates for the beginning of each week, e.g.: weekly-data.frame(week=seq(as.Date(2010-04-01), as.Date(2011-12-26),by=week)) week # each week starts

Re: [R] Help with aggregate syntax for a multi-column function please.

2011-08-02 Thread Jean V Adams
Michael, The function aggregate() is not going to work for your situation. The function is applied to the individual columns of the subsetted data, not the subsetted data frame as a whole. The help file reads: Then, each of the variables (columns) in x is split into subsets of cases (rows)

Re: [R] Loops to assign a unique ID to a column

2011-08-02 Thread David L Carlson
How about this? indx - unique(cbind(Dates, Groups)) indx DatesGroups [1,] 12/10/2010 A [2,] 12/10/2010 B [3,] 13/10/2010 A [4,] 13/10/2010 B [5,] 13/10/2010 C indx - data.frame(indx, id=1:nrow(indx)) indx Dates Groups id 1 12/10/2010 A 1 2 12/10/2010

[R] vglm: warnings and errors

2011-08-02 Thread Sramkova, Anna (IEE)
Hello, I am using multinomial logit regression for the first time, and I am trying to understand the warnings and errors I get. My data consists of 200 to 600 samples with ~25 predictors (these are principal components). The response has three categories. I use the function vglm from the

Re: [R] Display/show the evaluation result of R commands automatically

2011-08-02 Thread Anthony Ching Ho Ng
R-help and Barry Thank you for your suggestions. It works, and may I ask how I am able to do the opposite (disable the call back, so that I could control when to show and suppress the output). I would like to make a function to enable/disable the callback similar to the one as follow:

Re: [R] identifying weeks (dates) that certain days (dates) fall into

2011-08-02 Thread Gabor Grothendieck
On Tue, Aug 2, 2011 at 10:36 AM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello! I have dates for the beginning of each week, e.g.: weekly-data.frame(week=seq(as.Date(2010-04-01), as.Date(2011-12-26),by=week)) week  # each week starts on a Monday I also have a vector of

Re: [R] Standard Deviation of a matrix

2011-08-02 Thread chakri
Thank you everyone for your kind input, I forgot to add that I have decimal points in my matrix ! Enclosed input file (reduced to 10 X 10 matrix), scripts and output for your suggesions: Code 1: library(stats) Matrix-read.table(test_input, head=T, sep= , dec=.) SD-sd(as.numeric(Matrix)) SD

[R] how to get the percentile of a number in a vector

2011-08-02 Thread ראובן אברמוביץ
I'm familiar with the quantile() command, but what if I have a specific number that I want to know its location in a vector? I know that in known distributions, (for example the normal distribution), there is pnorm and qnorm, but how can I do it with unknown vector? thanks in

Re: [R] Memory limit in Aggregate()

2011-08-02 Thread Guillaume
Hi Peter, Thanks for your answer. I made a mistake in the script I copied sorry ! The description of the object : listX has 3 column, listBy has 4 column, and they have 9000 rows : print(paste(ncol x , length((listX print(paste(ncol By , length((listBy print(paste(nrow ,

[R] My R code is not efficient

2011-08-02 Thread Kathie
Dear R users, I have two n*1 integer vectors, y1 and y2, where n is very very large. I'd like to compute elbp = 4^(y1) * 5^(y2) * sum_{i=0}^{max(y1, y2)} [{ (y1-i)! * (i)! * (y2-i)! }^(-1)]; that is, I need to compute elbp for each (y1, y2) pair. So I made R code like below, but I don't

[R] Extract p value from coxme object

2011-08-02 Thread Catarina Miranda
Dear R experts; I am trying to extract the p values from a coxme object (package coxme). I can see the value in the model output, but I wanted to have the result with a higher number of decimal places. I have searched the mailing list and followed equivalent suggestions for nlme/lme objects, but

Re: [R] My R code is not efficient

2011-08-02 Thread Jeff Newmiller
?expand.grid --- Jeff Newmiller The . . Go Live... DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded

Re: [R] how to get the percentile of a number in a vector

2011-08-02 Thread David Winsemius
On Aug 2, 2011, at 10:14 AM, ראובן אברמוביץ wrote: I'm familiar with the quantile() command, but what if I have a specific number that I want to know its location in a vector? I know that in known distributions, (for example the normal distribution), there is pnorm and qnorm,

Re: [R] Standard Deviation of a matrix

2011-08-02 Thread Nordlund, Dan (DSHS/RDA)
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of chakri Sent: Tuesday, August 02, 2011 6:31 AM To: r-help@r-project.org Subject: Re: [R] Standard Deviation of a matrix Thank you everyone for your kind input, I forgot to

Re: [R] how to get the percentile of a number in a vector

2011-08-02 Thread R. Michael Weylandt michael.weyla...@gmail.com
Would this work for you? if you want to know where the i-th element falls percentage-wise in the distribution of a vector: sum(x = x[i])/length(x) This could be turned into a function: pEmpirical - function(i,x) { if (length(i) 1) return(apply(as.matrix(i), 1, pEmpirical,x)) r = sum(x

Re: [R] SSOAP chemspider

2011-08-02 Thread Benton, Paul
Has anyone got SSOAP working on anything besides KEGG? I just tried another 3 SOAP servers. Both the WSDL and constructing the .SOAP call. Again the perl and ruby interface worked without any hitches. Paul library(SSOAP)

Re: [R] how to get the percentile of a number in a vector

2011-08-02 Thread Jean V Adams
Does this help? x - c(3, 8, 5, 2, 9, 33, 21) # the 43rd percentile quantile(x, 0.43) # the proportion of the distribution that is less than 7 mean(x7) Jean `·.,, (((? `·.,, (((? `·.,, (((? Jean V. Adams Statistician U.S. Geological Survey Great Lakes Science Center 223 East Steinfest

Re: [R] Memory limit in Aggregate()

2011-08-02 Thread peter dalgaard
On Aug 2, 2011, at 17:10 , Guillaume wrote: Hi Peter, Thanks for your answer. I made a mistake in the script I copied sorry ! The description of the object : listX has 3 column, listBy has 4 column, and So what is the contents of listBy? If they are all factors with 100 levels, then

Re: [R] Help with aggregate syntax for a multi-column function please.

2011-08-02 Thread Dennis Murphy
Hi: Another way to do this is to use one of the summarization packages. The following uses the plyr package. The first step is to create a function that takes a data frame as input and outputs either a data frame or a scalar. In this case, the function returns a scalar, but if you want to carry

[R] lattice: index plot

2011-08-02 Thread Thaler, Thorn, LAUSANNE, Applied Mathematics
Dear all, How can I make an index plot with lattice, that is plotting a vector simply against its particular index in the vector, i.e. something similar to y - rnorm(10) plot(y) I don't want to specify the x's manually, as this could become cumbersome when having multiple panels. I tried

Re: [R] Loops to assign a unique ID to a column

2011-08-02 Thread Bert Gunter
Whoa! 1. First and most important, there is very likely no reason you need to do this. R can handle multiple groupings automatically in fitting and plotting without creating artificial labels of the sort you appear to want to create. Please read an Intro to R and/or get help to see how. 2. The

Re: [R] identifying weeks (dates) that certain days (dates) fall into

2011-08-02 Thread Dennis Murphy
Hi: You could try the lubridate package: library(lubridate) week(weekly$week) week(july4) [1] 27 27 week function (x) yday(x)%/%7 + 1 environment: namespace:lubridate which is essentially Gabor's code :) HTH, Dennis On Tue, Aug 2, 2011 at 7:36 AM, Dimitri Liakhovitski

Re: [R] Inserting column in between -- better way?

2011-08-02 Thread peter dalgaard
On Aug 1, 2011, at 20:50 , David L Carlson wrote: Actually Sara's method fails if the insertion is after the first or before the last column: x - data.frame(A=1:3, B=1:3, C=1:3, D=1:3, E=1:3) newcol - 4:6 cbind(x[,1], newcol, x[,2:ncol(x)]) Sarah (sic) is on the right track, just lose

[R] density plot for weighted data

2011-08-02 Thread r student
I'm trying to create a density plot using census data, where the weights don't sum to 1. plot(density(oh$FINCP,weights=oh$PWGTP)) Warning message: In density.default(oh$FINCP, weights = oh$PWGTP) : sum(weights) != 1 -- will not get true density How would I go about doing this? Thanks!

Re: [R] identifying weeks (dates) that certain days (dates) fall into

2011-08-02 Thread Dimitri Liakhovitski
Thanks a lot, everyone! Dimitri On Tue, Aug 2, 2011 at 12:34 PM, Dennis Murphy djmu...@gmail.com wrote: Hi: You could try the lubridate package: library(lubridate) week(weekly$week) week(july4) [1] 27 27 week function (x) yday(x)%/%7 + 1 environment: namespace:lubridate which is

Re: [R] lattice: index plot

2011-08-02 Thread Peter Ehlers
Does xyplot(y ~ seq_along(y), xlab = Index) do what you want? Peter Ehlers On 2011-08-02 09:07, Thaler, Thorn, LAUSANNE, Applied Mathematics wrote: Dear all, How can I make an index plot with lattice, that is plotting a vector simply against its particular index in the vector, i.e.

Re: [R] density plot for weighted data

2011-08-02 Thread David Winsemius
On Aug 2, 2011, at 12:51 PM, r student wrote: I'm trying to create a density plot using census data, where the weights don't sum to 1. plot(density(oh$FINCP,weights=oh$PWGTP)) Warning message: In density.default(oh$FINCP, weights = oh$PWGTP) : sum(weights) != 1 -- will not get true

[R] Data frame to matrix - revisited

2011-08-02 Thread Jagz Bell
Hi, I've tried to look through all the previous related Threads/posts but can't find a solution to what's probably a simple question.   I have a data frame comprised of three columns e.g.:   ID1 ID2 Value a b 1 b d 1 c a 2 c e 1 d a 1 e d 2   I'd like to convert the data to a matrix i.e.:    a b

Re: [R] Memory limit in Aggregate()

2011-08-02 Thread Guillaume
Hi Peter, Yes I have a large number of factors in the listBy table. Do you mean that aggregate() creates a complete cartesian product of the by columns ? (and creates combinations of values that do not exist in the orignial by table, before removing them when returning the aggregated table?)

Re: [R] Inserting column in between -- better way?

2011-08-02 Thread Bert Gunter
Thanks for this Peter: Sarah (sic) is on the right track, just lose the commas so that you don't drop to a vector: x - data.frame(A=1:3, B=1:3, C=1:3, D=1:3, E=1:3) newcol - 4:6 cbind(x[1], newcol, x[2:ncol(x)])  A newcol B C D E 1 1      4 1 1 1 1 2 2      5 2 2 2 2 3 3      6 3 3 3

Re: [R] density plot for weighted data

2011-08-02 Thread David Winsemius
On Aug 2, 2011, at 1:11 PM, r student wrote: Like below? plot(density(oh$FINCP,weights=oh$PWGTP/sum(oh$PWGTP))) I don't understand why you are asking for approval. You are the one with the data and know where they came from. We have none of that background. -- David. On Tue, Aug 2,

Re: [R] Data frame to matrix - revisited

2011-08-02 Thread Jean V Adams
Jagz, Assuming that your data frame is called df, try this ... tapply(df$Value, list(df$ID1, df$ID2), mean) Jean `·.,, (((º `·.,, (((º `·.,, (((º Jean V. Adams Statistician U.S. Geological Survey Great Lakes Science Center 223 East Steinfest Road Antigo, WI 54409 USA 715-627-4317,

Re: [R] Inserting column in between -- better way?

2011-08-02 Thread peter dalgaard
On Aug 2, 2011, at 19:17 , Bert Gunter wrote: Thanks for this Peter: Sarah (sic) is on the right track, just lose the commas so that you don't drop to a vector: x - data.frame(A=1:3, B=1:3, C=1:3, D=1:3, E=1:3) newcol - 4:6 cbind(x[1], newcol, x[2:ncol(x)]) A newcol B C D E 1 1

Re: [R] Memory limit in Aggregate()

2011-08-02 Thread peter dalgaard
On Aug 2, 2011, at 19:09 , Guillaume wrote: Hi Peter, Yes I have a large number of factors in the listBy table. Do you mean that aggregate() creates a complete cartesian product of the by columns ? (and creates combinations of values that do not exist in the orignial by table, before

Re: [R] density plot for weighted data

2011-08-02 Thread r student
Like below? plot(density(oh$FINCP,weights=oh$PWGTP/sum(oh$PWGTP))) On Tue, Aug 2, 2011 at 10:06 AM, David Winsemius dwinsem...@comcast.net wrote: On Aug 2, 2011, at 12:51 PM, r student wrote: I'm trying to create a density plot using census data, where the weights don't sum to 1.

[R] Extract names from vector according to their values

2011-08-02 Thread Sverre Stausland
Dear helpers, I can create a vector with the priority of the packages that came with R, like this: installed.packages()[,Priority]-my.vector my.vector base boot class cluster codetools base recommended recommended recommended recommended compiler

Re: [R] Data frame to matrix - revisited

2011-08-02 Thread Dennis Murphy
Hi: Here are a couple of ways. Since your data frame does not contain a 'c' in ID2, we redefine the factor to give it all five levels rather than the observed four: df - read.table(textConnection( + ID1 ID2 Value + a b 1 + b d 1 + c a 2 + c e 1 + d a 1 + e d 2), header = TRUE) str(df) str(df)

Re: [R] Extract names from vector according to their values

2011-08-02 Thread David Winsemius
On Aug 2, 2011, at 2:21 PM, Sverre Stausland wrote: Dear helpers, I can create a vector with the priority of the packages that came with R, like this: installed.packages()[,Priority]-my.vector my.vector base boot class cluster codetools base

Re: [R] Extract names from vector according to their values

2011-08-02 Thread Jean V Adams
Sverre, Try this: my.list - split(names(my.vector), my.vector) my.list$base my.list$recommended Jean `·.,, (((º `·.,, (((º `·.,, (((º Jean V. Adams Statistician U.S. Geological Survey Great Lakes Science Center 223 East Steinfest Road Antigo, WI 54409 USA From: Sverre Stausland

Re: [R] Extract names from vector according to their values

2011-08-02 Thread Dennis Murphy
Hi: One more possibility: names(my.vector[grep('recommended', my.vector)]) [1] Matrix boot class clustercodetools [6] foreignKernSmooth latticeMASS Matrix [11] mgcv nlme nnet rpart spatial [16] survival names(my.vector[grep('base',

[R] Need to compute density as done by panel.histogram

2011-08-02 Thread Sébastien Bihorel
Hi, This might be a simple problem but I don't know how to calculate a random variable density the way panel.histogram does it before it creates the actual density rectangles. The documentation says that it uses the density function but the actual code suggests that the hist.constructor function

[R] 3D Bar Graphs in ggplot2?

2011-08-02 Thread wwreith
Does anyone know how to create a 3D Bargraph using ggplot2/qplot. I don't mean 3D as in x,y,z coordinates. Just a 2D bar graph with a 3D shaped bard. See attached excel file for an example. Before anyone asks I know that 3D looking bars don't add anything except prettiness.

Re: [R] density plot for weighted data

2011-08-02 Thread Thomas Lumley
On Wed, Aug 3, 2011 at 5:11 AM, r student student...@gmail.com wrote: Like below? plot(density(oh$FINCP,weights=oh$PWGTP/sum(oh$PWGTP))) Yes If you are doing lots of analyses with weighted data you might want to look at the survey package. It also has a density estimator, in svysmooth(),

Re: [R] 3D Bar Graphs in ggplot2?

2011-08-02 Thread Brian Diggs
On 8/2/2011 11:39 AM, wwreith wrote: Does anyone know how to create a 3D Bargraph using ggplot2/qplot. I don't mean 3D as in x,y,z coordinates. Just a 2D bar graph with a 3D shaped bard. See attached excel file for an example. It is not possible. Before anyone asks I know that 3D looking

Re: [R] 3D Bar Graphs in ggplot2?

2011-08-02 Thread Duncan Murdoch
On 11-08-02 2:39 PM, wwreith wrote: Does anyone know how to create a 3D Bargraph using ggplot2/qplot. I don't mean 3D as in x,y,z coordinates. Just a 2D bar graph with a 3D shaped bard. See attached excel file for an example. Before anyone asks I know that 3D looking bars don't add anything

[R] How to find the parameter of a power function to fit simulation data to it for the tail?

2011-08-02 Thread Paul Menzel
Dear R folks, having simulation data in a vector n2off, I know that they should be similar to a power function f [1], f(n) = n^(-1/r), r ∈ ℕ\{0}, and I want to find the value for r best fitting the simulation data. Furthermore I know that this is only true for big n, that means n2off(n) ~ f(n) ⇔

Re: [R] Inverse of FAQ 7.31.

2011-08-02 Thread Rolf Turner
Thanks to Peter Dalgaard and to Baptiste Auguie (off-list) for the insights they provided. cheers, Rolf turner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

[R] Calculate mean ignore null

2011-08-02 Thread Jeffrey Joh
I have the following: Tout = c(., ., + -51.0, -9.6, -9.6, -9.6, -9.6, -9.6, -9.6, + -9.6, -9.5, -9.5, -9.6, -9.5, -9.6, -9.6, + -9.5, -9.4, -9.3, -9.3, -9.3, -9.2, -9.0, + -9.0, -8.9, -8.9, -8.9) How can I take the mean while ignoring the null values? I

Re: [R] Calculate mean ignore null

2011-08-02 Thread R. Michael Weylandt michael.weyla...@gmail.com
Are you sure it doesn't? na.rm=T works for me, so I think your problem is elsewhere. Specifically, the example given below consists of 27 character strings, not numbers, so there' so surprise R doesn't want to give you a mean -- to R, it's as logical as asking for the average of a and Q5 Try

Re: [R] Help with R

2011-08-02 Thread Gavin Simpson
On Thu, 2011-07-28 at 11:58 -0400, Sarah Goslee wrote: Hi Mark, On Thu, Jul 28, 2011 at 10:44 AM, m...@statcourse.com wrote: 1. How can I plot the entire tree produced by rpart? What does plot() not do that you are expecting? Not do any labelling... ;-) text(tree) where `tree` is

[R] Wrong values when projecting LatLong in UTM

2011-08-02 Thread Colin Bergeron
Hi R helpers, I tried to convert a list of LatLong coordinates (in DD format) into UTM zone 11 NAD 27. I first tried this from PBSmapping: library(PBSmapping) LatLong-cbind(c(56.85359, 56.85478),c(-118.4109, -118.4035)) colnames(LatLong)-c(X,Y) attr(LatLong, projection) - UTM attr(LatLong,

[R] xlsx error

2011-08-02 Thread Andrew Winterman
Hey All, I'm trying to use the xlsx package to read a series of excel spreadsheets into R, but my code is failing at the first step. I setwd into my the directory with the spreadsheets, and, as a test ask for the first one: read.xlsx(file = Argentina Final.xls, sheetIndex = 1) I promptly

Re: [R] [Rd] example package for devel newcomers

2011-08-02 Thread Alexandre Aguiar
Em Segunda 01 Agosto 2011, você escreveu: Is there a preferred language you would like to use in your package development? I randomly downloaded packages until I found some that helped me along my way, and might be able to help you pick one. If you are just looking at building a package of R

  1   2   >