Re: [R] Opening package manual from within R

2011-08-24 Thread Prof Brian Ripley
On Tue, 23 Aug 2011, Tyler Rinker wrote: Simple question but searching rseek did not yield the results I wanted. Question: Is there a way to open a help manual for a package from within R. For instance I would like to type a function in r for the tm package and R would open that PDF as

[R] Efficient way to Calculate the squared distances for a set of vectors to a fixed vector

2011-08-24 Thread Wei Wu
I am pretty new to R. So this may be an easy question for most of you.   I would like to calculate the squared distances of a large set (let's say 2) of vectors (let's say dimension of 5) to a fixed vector.   Say I have a data frame MY_VECTORS with 2 rows and 5 columns, and one 5x1

Re: [R] Error message: object of type 'closure' is not subsettable

2011-08-24 Thread Newbie
I think I have found my problem, but I dont know how to correct it. I have found an old post saying that it might be a problem if the starting values are evaluated at Inf (see link here http://r.789695.n4.nabble.com/Help-about-nlminb-function-td3089048.html) But how can I run nlminb without the

Re: [R] Efficient way to Calculate the squared distances for a set of vectors to a fixed vector

2011-08-24 Thread Daniel Malter
Let's say your fixed vector is x, and y is the list of vectors that you want to create the squared distance to x with, then: x-c(1:5) y-list() y[[1]]-sample(c(1:5),5) y[[2]]-sample(c(1:5),5) y[[3]]-sample(c(1:5),5) y distances-lapply(y,function(a,b) crossprod(a-b), b=x) #lapply goes over the

Re: [R] Efficient way to Calculate the squared distances for a set ofvectors to a fixed vector

2011-08-24 Thread Enrico Schumann
You could do something like this: # data nrows - 2L ncols - 5L myVec - array(rnorm(nrows * ncols), dim = c(nrows, ncols)) y - rnorm(ncols) temp - t(myVec) - y result - colSums(temp * temp) # check all.equal(as.numeric(crossprod(myVec[1L, ] - y)), result[1L]) #... (And don't use a

Re: [R] Easier ways to create .Rd files?

2011-08-24 Thread Philippe Grosjean
On 24/08/11 01:55, Jonathan Greenberg wrote: R-helpers: Are there any ways to auto-generate R-friendly (e.g. will pass a compilation check) .Rd files given a set of .R code? How about GUIs that help properly format the .Rd files? Thanks! I want a basic set of .Rd files that I can update as I

Re: [R] Efficient way to Calculate the squared distances for a set ofvectors to a fixed vector

2011-08-24 Thread Tsjerk Wassenaar
Hi Wei Wu, What about: x - matrix(rnorm(2*5),ncol=5) y - rnorm(5) distances - rowSums((x-y)**2) Cheers, Tsjerk On Wed, Aug 24, 2011 at 8:43 AM, Enrico Schumann enricoschum...@yahoo.de wrote: You could do something like this: # data nrows - 2L ncols - 5L myVec -

[R] Autocorrelation using library(tseries)

2011-08-24 Thread Vincy Pyne
Dear R list I am trying to understand the auto-correlation concept. Auto-correlation is the self-correlation of random variable X with a certain time lag of say t. The article http://www.mit.tut.fi/MIT-3010/luentokalvot/lk10-11/MDA_lecture16_11.pdf; (Page no. 9 and 10) gives the methodology

[R] Passing a large amount of parameters to a function

2011-08-24 Thread Eran Eidinger
Hello, I have a function with a long list of parameters (of different types, numeric and string) myFunc -function(p1, p2, p3, p4, p5...etc) { do.something(p1,p2,) } I want to loop over this to provide a different set of parameters to the list every time. for (ii in 1:N) {

Re: [R] Passing a large amount of parameters to a function

2011-08-24 Thread Dimitris Rizopoulos
You could use something like the following: paramsList - list(p1 = 1:10, p2 = -5:5, p3 = 5, p4 = 8) params - unlist(as.relistable(paramsList)) myFunc - function (params) { params - relist(params, skeleton = paramsList) p1 - params$p1 p2 - params$p2 p3 - params$p3 p4 -

Re: [R] Efficient way to Calculate the squared distances for a set ofvectors to a fixed vector

2011-08-24 Thread Tsjerk Wassenaar
Yes, sorry, so the distance is colSums((t(x)-y)**2) (I knew that) :S Tsjerk On Wed, Aug 24, 2011 at 9:19 AM, Enrico Schumann enricoschum...@yahoo.de wrote: R will subtract the vector columnwise from the matrix (so the vectors need be the columns). x - matrix(0, nrow = 10L, ncol = 5L) y -

Re: [R] Error: evaluation nested too deeply: infinite recursion / options(expressions=)?

2011-08-24 Thread qinmao
I think you have change options(expression = default_value) you can input the command options()in Rconsole And check the value of the expression. and change the value to 100. Hope you over this problem. -- View this message in context:

[R] setMethods/setGeneric problem when R CMD CHECK'ing a package

2011-08-24 Thread Jonathan Greenberg
R-helpers: I'm trying to build a package, but I'm a bit new to the whole S3/S4 methods concept. I'm trying to add a new definition of the zoo function as.yearmon, but I'm getting the following error when it gets to this point during a package install: *** R CMD INSTALL STARStools * installing

Re: [R] Easier ways to create .Rd files?

2011-08-24 Thread Jonathan Greenberg
Thanks Kevin! Got started with roxygen tonight! Cheers! On Tue, Aug 23, 2011 at 6:28 PM, Kevin Wright kw.s...@gmail.com wrote: I like the roxygen2 package for combining code and documentation.  If you use Emacs + ESS, it will even create much of the roxygen code for you (and auto-revise it

Re: [R] matrix into vector with vertex names

2011-08-24 Thread joe j
Hi Gabor, Thanks. I will try to figure out the solution you suggest. I found out about melt() from a discussion forum; it seems to me that melt()$value is similar to c(), and when I modified the script as below it 'seems' to be running faster. Anyway in the end I only needed to use a smaller

Re: [R] setMethods/setGeneric problem when R CMD CHECK'ing a package

2011-08-24 Thread Uwe Ligges
On 24.08.2011 10:30, Jonathan Greenberg wrote: R-helpers: I'm trying to build a package, but I'm a bit new to the whole S3/S4 methods concept. I'm trying to add a new definition of the zoo function as.yearmon, but I'm getting the following error when it gets to this point during a package

Re: [R] Autocorrelation using library(tseries)

2011-08-24 Thread Prof Brian Ripley
Your understanding is wrong. For a start, there is no function acf() in package tseries: it is in stats. And the autocorrelation at lag one is not the correlation omitting the first and last values: it uses the mean and variance estimated from the whole series and divisor n. Have you

Re: [R] Efficient way to Calculate the squared distances for a set ofvectors to a fixed vector

2011-08-24 Thread Prof Brian Ripley
On Wed, 24 Aug 2011, Tsjerk Wassenaar wrote: Yes, sorry, so the distance is colSums((t(x)-y)**2) (I knew that) :S Did you know that ** is deprecated (and almost undocumented), so your readers can hardly be expected to understand that? Please use the documented operator ^ . Tsjerk On

Re: [R] Bug or feature? sum(c(a, b, c)) != (a + b + c)

2011-08-24 Thread Karl Ove Hufthammer
Thomas Lumley wrote: So it looks as though sum(c(...)) is somwhow independent of the order of its arguments, which implies that the summation it does is not quite the addition corresponding to +. I now feel out of my depth, so hope someone else knows/can find the truth about this! sum()

Re: [R] spectral analysis

2011-08-24 Thread Petr PIKAL
Is there anything in R similar to spectogram command in matlab? As I do not use matlab I can not know what spectogram does. What is wrong with fft or spectrum functions? Regards Petr On Tue, Aug 23, 2011 at 10:20 AM, Petr PIKAL petr.pi...@precheza.cz wrote: Hi Hi all, I am

Re: [R] setMethods/setGeneric problem when R CMD CHECK'ing a package

2011-08-24 Thread Uwe Ligges
On 24.08.2011 11:09, Jonathan Greenberg wrote: Hmm, so I moved the function call to the same file as the methods call, and placed it above the method in the file -- but I'm getting the same error. Is there something odd about as.yearmon in the zoo package that it might not be getting defined

[R] boxplot from mean and SD data

2011-08-24 Thread Alejandro González
Dear all, I have a dataset of 3 categorical factors, the mean and the standard deviation of each value. I want to use these values to plot a boxplot, grouped by each of the 3 categorical factors (24 boxplots in total). I don't have a clue on how to do the boxplot from mean and SD data already

[R] Odp: boxplot from mean and SD data

2011-08-24 Thread Petr PIKAL
Hi Dear all, I have a dataset of 3 categorical factors, the mean and the standard deviation of each value. I want to use these values to plot a boxplot, grouped by each of the 3 categorical factors (24 boxplots in total). I don't have a clue on how to do the boxplot from mean and SD

Re: [R] obtaining p-values for lm.ridge() coefficients (package 'MASS')

2011-08-24 Thread Liviu Andronic
Dear Michael Thank you for your pointers. On Tue, Aug 23, 2011 at 4:05 PM, Michael Friendly frien...@yorku.ca wrote: First, you should be using rms::ols, as Design is old. Good to know. I've always wondered why Design and rms, in many cases, were providing similar functions and (upon cursory

Re: [R] obtaining p-values for lm.ridge() coefficients (package 'MASS')

2011-08-24 Thread Liviu Andronic
The attachment seems to have been dropped, so I'm pasting the code below. Sorry for that Liviu On Wed, Aug 24, 2011 at 1:44 PM, Liviu Andronic landronim...@gmail.com wrote: Second, penalty in ols() is not the same as the ridge constant in lm.ridge, but rather a penalty on the log likelihood.  

Re: [R] setMethods/setGeneric problem when R CMD CHECK'ing a package

2011-08-24 Thread Jonathan Greenberg
Hmm, so I moved the function call to the same file as the methods call, and placed it above the method in the file -- but I'm getting the same error. Is there something odd about as.yearmon in the zoo package that it might not be getting defined as a generic function? If so, how would I go about

[R] identify connected cells in a cellular automaton

2011-08-24 Thread matpops
Hello, I’m working on a simulation using a cellular automata. The scenario is: Each cell represent a land plot. Each plot can have 3 different states: -The owner is a private individual (P) -The owner is a company ( C) -The land is abandoned/not used (A) The first year

[R] gofCopula() function

2011-08-24 Thread Deniz SIGIRLI
Hi all, I'm trying to use gofCopula() function in copula package. But I'm always (trying different data sets) getting the same p value for Cramer-von Mises statistic. I'm using: g-gumbelCopula(1.653, dim = 2)gofCopula(g, x, N = 1000, method = itau,simulation = pb) c-claytonCopula(1.306, dim =

[R] hide row and column-names in cat()

2011-08-24 Thread Tim Haering
Dear list, to prepare data as input for a stand-alone groundwater model I use the cat() function to print data. I want to print a table with print() or cat() but without the row- and column-names. Is this possible? Here a small example my.df - rbind(c(Nr,FraSand,FraSilt,FraClay,pH), c(,

Re: [R] hide row and column-names in cat()

2011-08-24 Thread Dimitris Rizopoulos
try function write.matrix() from package MASS, e.g., library(MASS) write.matrix(my.df) I hope it helps. Best, Dimitris On 8/24/2011 1:46 PM, Tim Haering wrote: Dear list, to prepare data as input for a stand-alone groundwater model I use the cat() function to print data. I want to print a

[R] How to use mvrnorm?

2011-08-24 Thread maaariiianne
Dear R community! I would like to simulate distributions based on a polynomial model. It consists of 96 values and I want to randomly select new normaly distributed values around the modeled values. Furthermore, each value should be correlated with the previous one. Is it correct to therefore use

[R] Scatter plots, linear regression in ggplot2

2011-08-24 Thread ashz
Hi, Based on some modification that I did to the R Cookbook Graphs Scatterplots code, link:http://wiki.stdout.org/rcookbook/Graphs/Scatterplots%20(ggplot2) I have some questions and I will appreciate a help: - How do I change the legend title? - How can I change the for each linear

[R] R (stats) newcomer.... help!

2011-08-24 Thread geigercounter120
Hi all, I hope that i've posted this in the correct place. if not, please accept my apologies (where should this go?) I have carried out experimental removal of bivalves at 2 intertidal shores. Bivalves were removed by raking of surface sediments. I wish compare the biomass values of for a total

[R] Change color in forest.rma (metafor)

2011-08-24 Thread Paola Tellaroli
My script is the following: library(metafor) yi-c(-0.1, 0.2, 0.3, 0.4) sei-c(0.4, 0.2, 0.6, 0.1) vi-sei^2 studi-c(A, B, C, D) eventi.c-c(10, 5, 7, 6) n.c-c(11, 34, 25, 20) eventi.a-c(2, 7, 6, 5) n.a-c(11, 35, 25, 15) dfs-rma(yi, vi, method=DL) dfs windows(height=6, width=10, pointsize=10)

[R] library REEMtree = Error in estRE[toString(uniqueID[i]), 1] : incorrect number of dimensions

2011-08-24 Thread Ubuntu Diego
Hi List, I'm having this problem when trying to use the PREDICT function. Here is a way to reproduce the error library(REEMtree) data(simpleREEMdata) REEMresult-REEMtree(Y~D+t+X, data=simpleREEMdata, random=~1|ID/D) predict(REEMresult, simpleREEMdata, id =

Re: [R] R (stats) newcomer.... help!

2011-08-24 Thread Ben Bolker
geigercounter120 geigercounter120 at yahoo.co.uk writes: Hi all, I hope that i've posted this in the correct place. if not, please accept my apologies (where should this go?) I have carried out experimental removal of bivalves at 2 intertidal shores. Bivalves were removed by raking of

Re: [R] Scatter plots, linear regression in ggplot2

2011-08-24 Thread Ista Zahn
Hi, Have you looked at the documentation at http://had.co.nz/ggplot2/ ? You will find the answers to your questions there. On Wed, Aug 24, 2011 at 7:46 AM, ashz a...@walla.co.il wrote: Hi, Based on some modification that I did to the R Cookbook Graphs Scatterplots code,

Re: [R] Odp: boxplot from mean and SD data

2011-08-24 Thread peter dalgaard
On Aug 24, 2011, at 13:18 , Petr PIKAL wrote: Hi Dear all, I have a dataset of 3 categorical factors, the mean and the standard deviation of each value. I want to use these values to plot a boxplot, grouped by each of the 3 categorical factors (24 boxplots in total). I don't have a

[R] debugging functions in R

2011-08-24 Thread Eran Eidinger
Hi, I am not sure if this is the right list to ask this question (though I did not find a more appropriate one). I've started using R a month ago, and small scripts work fine. However, when I start writing more complex code, it gets messy. 1. Is there any way to debug normally, with breakpoints?

Re: [R] Change color in forest.rma (metafor)

2011-08-24 Thread Bernd Weiss
Am 24.08.2011 07:50, schrieb Paola Tellaroli: My script is the following: library(metafor) yi-c(-0.1, 0.2, 0.3, 0.4) sei-c(0.4, 0.2, 0.6, 0.1) vi-sei^2 studi-c(A, B, C, D) eventi.c-c(10, 5, 7, 6) n.c-c(11, 34, 25, 20) eventi.a-c(2, 7, 6, 5) n.a-c(11, 35, 25, 15) dfs-rma(yi, vi,

[R] silently testing for data from another package for .Rd examples

2011-08-24 Thread Michael Friendly
In an .Rd example for a package, I want to use data from another package, but avoid loading the entire package and avoid errors/warnings if that other package is not available. If I don't care about loading the other package, I can just do: if (require(ElemStatLearn, quietly=TRUE)) {

Re: [R] debugging functions in R

2011-08-24 Thread Liviu Andronic
On Wed, Aug 24, 2011 at 4:20 PM, Eran Eidinger e...@taykey.com wrote: Hi, I am not sure if this is the right list to ask this question (though I did not find a more appropriate one). I've started using R a month ago, and small scripts work fine. However, when I start writing more complex

Re: [R] debugging functions in R

2011-08-24 Thread Justin Haynes
Another great tool is debugonce() wrap your function name in it and then execute your function call. debugonce(my.function) out-my.function(df) And you'll be brought into the same interactive browser. (its Vi if im not mistaken which can take a little getting used to.) Justin On Wed, Aug

[R] THX-- How to use 'switch' with strings containing spaces?

2011-08-24 Thread Mauricio Cornejo
Richard, Thanks for your observation and tip. My apologies that the 'expr' seemed undefined.  That was intentional on my part as I only wanted to show the form of the non-working code.  Let me be clearer by updating the code with what I actually type at the command line.  The code below does

Re: [R] debugging functions in R

2011-08-24 Thread Eran Eidinger
Wow, thanks Justin and Liviu, DebugOnce and browser. great! Eran On Wed, Aug 24, 2011 at 5:34 PM, Justin Haynes jto...@gmail.com wrote: Another great tool is debugonce() wrap your function name in it and then execute your function call. debugonce(my.function) out-my.function(df) And

Re: [R] debugging functions in R

2011-08-24 Thread jim holtman
Also check out the 'debug' package On Wed, Aug 24, 2011 at 10:59 AM, Eran Eidinger e...@taykey.com wrote: Wow, thanks Justin and Liviu, DebugOnce and browser. great! Eran On Wed, Aug 24, 2011 at 5:34 PM, Justin Haynes jto...@gmail.com wrote: Another great tool is debugonce() wrap your

Re: [R] THX-- How to use 'switch' with strings containing spaces?

2011-08-24 Thread jim holtman
?switch If you read the help page, you will see that if the EXPR evaluates to a character string, then is matches on the names of the elements; 'x[1]' is not a name, it is a value. You want to probably use 'match' match(Choice 2, x) [1] 2 On Wed, Aug 24, 2011 at 10:52 AM, Mauricio Cornejo

[R] Function rank() for data frames (or multiple vectors)?

2011-08-24 Thread Sebastian Bauer
Hello, I'd like to rank rows of a data frame similar to what rank() does for vectors. However, ties should be broken by columns that I specify. If it is not possible to break a ties (because the row data is essentially the same), I'd like to have the same flexibility that rank() offers. Is

Re: [R] THX-- How to use 'switch' with strings containing spaces?

2011-08-24 Thread Daniel Nordlund
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Mauricio Cornejo Sent: Wednesday, August 24, 2011 7:53 AM To: Richard M. Heiberger Cc: r-help@r-project.org Subject: [R] THX-- How to use 'switch' with strings containing

[R] Help: find the index of the minimum of entries

2011-08-24 Thread Chee Chen
Dear All, I would like to ask a question on how to find the index of the minimum of entries of a numeric vector, without using loops or user defined functions. Suppose we have a vector: a - c(3,1,2) then, min(a) = 1 and its index is 2. Target: how to get the index of this minimum? How to get

Re: [R] THX-- How to use 'switch' with strings containing spaces?

2011-08-24 Thread S Ellison
Your code example doesn't work because x[3]='My 3rd choice' is not a valid named parameter assignment for a function, and that is because x[3] is not a valid name for a function argument. The _content_ of x[3] might be, but argument names aren;t parsed in this context (and indeed only would

Re: [R] Help: find the index of the minimum of entries

2011-08-24 Thread R. Michael Weylandt
which.min() more generally which(a==min(a)) Michael Weylandt On Wed, Aug 24, 2011 at 12:03 PM, Chee Chen chee.c...@yahoo.com wrote: Dear All, I would like to ask a question on how to find the index of the minimum of entries of a numeric vector, without using loops or user defined

Re: [R] R.oo modify an object inside another classes method

2011-08-24 Thread Ben qant
I didn't see an answer to this and I THINK I sorted it out myself so I thought I'd post it for anyone who is interested (in using it or correcting it): My original question: Can someone show me how to modify one (R.oo) class's object inside another (R.oo) class's method? Is that possible with

Re: [R] Help: find the index of the minimum of entries

2011-08-24 Thread Henrique Dallazuanna
Try which.min(a) On Wed, Aug 24, 2011 at 1:03 PM, Chee Chen chee.c...@yahoo.com wrote: Dear All, I would like to ask a question on how to find the index of the minimum of entries of a numeric vector, without using loops or user defined functions. Suppose we have a vector: a - c(3,1,2)

Re: [R] silently testing for data from another package for .Rd examples

2011-08-24 Thread Yihui Xie
.packages(all = TRUE) will give you a list of all available packages without really loading them like require(). Regards, Yihui -- Yihui Xie xieyi...@gmail.com Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Wed, Aug

Re: [R] Easier ways to create .Rd files?

2011-08-24 Thread Yihui Xie
To avoid a possible confusion, please note it is roxygen2 rather than roxygen; both are packages on CRAN, but roxygen2 is an improved version and under maintenance; I guess the development of the original roxygen package has stopped. Emacs+ESS helps a whole lot in writing documentation! I really

Re: [R] Change color in forest.rma (metafor)

2011-08-24 Thread Viechtbauer Wolfgang (STAT)
Thank you, Bernd, for looking into this. Yes, at the moment, the color of the summary estimate for models without moderators is hard-coded (as black). I didn't think people may want to change that. I guess I was wrong =) A dirty solution for the moment is to add: addpoly(dfs, efac=6, row=-1,

Re: [R] silently testing for data from another package for .Rd examples

2011-08-24 Thread Uwe Ligges
Actually it is recommended to test for the availability of a valid package with find.package(), particularly in this case where the name of the package is already know. Best, Uwe On 24.08.2011 18:29, Yihui Xie wrote: .packages(all = TRUE) will give you a list of all available packages

Re: [R] Function rank() for data frames (or multiple vectors)?

2011-08-24 Thread David Winsemius
On Aug 24, 2011, at 11:09 AM, Sebastian Bauer wrote: Hello, I'd like to rank rows of a data frame similar to what rank() does for vectors. However, ties should be broken by columns that I specify. If it is not possible to break a ties (because the row data is essentially the same), I'd

[R] data manipulation and summaries with few million rows

2011-08-24 Thread Juliet Hannah
I have a data set with about 6 million rows and 50 columns. It is a mixture of dates, factors, and numerics. What I am trying to accomplish can be seen with the following simplified data, which is given as dput output below. head(myData) mydate gender mygroup id 1 2012-03-25 F

[R] How to do cross validation with glm?

2011-08-24 Thread Andra Isan
Hi All, I have a fitted model called glm.fit which I used glm and data dat is my data frame pred= predict(glm.fit, data = dat, type=response) to predict how it predicts on my whole data but obviously I have to do cross-validation to train the model on one part of my data and predict on the

Re: [R] Function rank() for data frames (or multiple vectors)?

2011-08-24 Thread Sebastian Bauer
Hi! I'd like to rank rows of a data frame similar to what rank() does for vectors. However, ties should be broken by columns that I specify. If it is not possible to break a ties (because the row data is essentially the same), I'd like to have the same flexibility that rank() offers. Is

Re: [R] How to do cross validation with glm?

2011-08-24 Thread Prof Brian Ripley
What you describe is not cross-validation, so I am afraid we do not know what you mean. And cv.glm does 'prediction for the hold-out data' for you: you can read the code to see how it does so. I suspect you mean you want to do validation on a test set, but that is not what you actually

Re: [R] How to do cross validation with glm?

2011-08-24 Thread Andra Isan
Hi, Thanks for the reply. What I meant is that, I would like to partition my dat data (a data frame) into training and testing data and then evaluate the performance of the model on test data. So, I thought cross validation is the natural choice to see how the prediction works on the hold-out

Re: [R] data manipulation and summaries with few million rows

2011-08-24 Thread Dennis Murphy
Hi Juliet: Here's a Q D solution: # (1) plyr f - function(d) length(unique(d$mygroup)) - 1 ddply(myData, .(id), f) id V1 1 1 0 2 2 2 3 3 1 4 4 0 # (2) data.table myDT - data.table(myData, key = 'id') myDT[, list(nswitch = length(unique(mygroup)) - 1), by = 'id'] If one can switch

Re: [R] Function rank() for data frames (or multiple vectors)?

2011-08-24 Thread David Winsemius
On Aug 24, 2011, at 1:11 PM, Sebastian Bauer wrote: Hi! I'd like to rank rows of a data frame similar to what rank() does for vectors. However, ties should be broken by columns that I specify. If it is not possible to break a ties (because the row data is essentially the same), I'd like to

Re: [R] data manipulation and summaries with few million rows

2011-08-24 Thread Juliet Hannah
Thanks Dennis! I'll check this out. Just to clarify, I need the total number of switches/changes regardless of if that state had occurred in the past. So A-A-B-A, would have 2 changes: A to B and B to A. Thanks again. On Wed, Aug 24, 2011 at 1:28 PM, Dennis Murphy djmu...@gmail.com wrote: Hi

Re: [R] Function rank() for data frames (or multiple vectors)?

2011-08-24 Thread Sebastian Bauer
Hi! in R? Basically, what I need is a mixture of order() and rank(). While the former allows to specify multiple vectors, it doesn't provide the flexibility of rank() such that I can specify what happens if ties can not be broken. An example of this simple problem would clarify this greatly.

Re: [R] How to do cross validation with glm?

2011-08-24 Thread Frank Harrell
What is your sample size? I've had trouble getting reliable estimates using simple data splitting when N 20,000. Note that the following functions in the rms package facilitates cross-validation and bootstrapping for validating models: ols, validate, calibrate. Frank Andra Isan wrote: Hi,

Re: [R] Function rank() for data frames (or multiple vectors)?

2011-08-24 Thread David Winsemius
On Aug 24, 2011, at 1:37 PM, Sebastian Bauer wrote: Hi! in R? Basically, what I need is a mixture of order() and rank(). While the former allows to specify multiple vectors, it doesn't provide the flexibility of rank() such that I can specify what happens if ties can not be broken. An

[R] read.table truncated data?

2011-08-24 Thread zhenjiang xu
Hi R users, I was using read.table to read a file. The data.fame looked alright, but I found not all rows are read by the read.table. What's wrong with it? It didn't give me any warning or error messages. Why the data are truncated? Thanks. $ wc -l all/isoform_exp.diff 42847 all/isoform_exp.diff

[R] Help: convert entry of a list into a matrix

2011-08-24 Thread Chee Chen
Dear All, As always, I appreciate all your help. I would like to know the easiest way to convert each of the homogeneous elements of a numeric list into a matrix. Each element of this list is also a list such that when displayed, looks like a 2-by-3 matrix , I would like to convert each of them

Re: [R] read.table truncated data?

2011-08-24 Thread Sarah Goslee
Hi, On Wed, Aug 24, 2011 at 2:18 PM, zhenjiang xu zhenjiang...@gmail.com wrote: Hi R users, I was using read.table to read a file. The data.fame looked alright, but I found not all rows are read by the read.table. What's wrong with it? It didn't give me any warning or error messages. Why the

Re: [R] Help: convert entry of a list into a matrix

2011-08-24 Thread R. Michael Weylandt
I'm not sure I understand your question: a[[2]] is a matrix. a - list(matrix(1:6,2),matrix(5:10,2)) is.matrix(a[[2]]) TRUE x = a[[2]] is.matrix(x) TRUE x+2 [,1] [,2] [,3] [1,] 7 9 11 [2,] 810 12 a[[2]] + 2 [,1] [,2] [,3] [1,] 7 9 11 [2,] 810 12 What

Re: [R] Help: convert entry of a list into a matrix

2011-08-24 Thread R. Michael Weylandt
Rereading your email, still not sure what the question is -- perhaps you could give a better code example to illustrate the difference between a[[2]] and mat1 -- but, since you mentioned briefly lists of lists, have you looked at unlist(, recursive = F)? If applied to a list of lists, it won't

Re: [R] silently testing for data from another package for .Rd examples

2011-08-24 Thread Michael Friendly
On 8/24/2011 12:40 PM, Uwe Ligges wrote: Actually it is recommended to test for the availability of a valid package with find.package(), particularly in this case where the name of the package is already know. Best, Uwe Thanks. So I guess the idiom I'm looking for is

[R] Model selection and model efficiency - Search for opinions

2011-08-24 Thread Arnaud Mosnier
Hi, In order to find the best models I use AIC, more specifically I calculate Akaike weights then Evidence Ratio (ER) and consider that models with a ER 2 are equally likely. But the same problem remain each time I do that. I selected the best models from a set of them, but I don't know if those

[R] Column of probabilities

2011-08-24 Thread Jim Silverton
Hi all, I have a vector xm say: xm = c(1,2,3,4,5,5,5,6,6) I want to return a vector with the corresponding probabilities based on the amount of times the numbers occurred. For example, I should get the following vector for xm: prob.xm = c(1/9, 1/9, 1/9, 1/9, 3/9, 3/9, 3/9, 2/9, 2/9) Any help

Re: [R] Column of probabilities

2011-08-24 Thread Jean V Adams
Try this: prob.xm - (table(xm)/length(xm))[match(xm, sort(unique(xm)))] Jean Jim Silverton wrote on 08/24/2011 02:31:05 PM: Hi all, I have a vector xm say: xm = c(1,2,3,4,5,5,5,6,6) I want to return a vector with the corresponding probabilities based on the amount of times the numbers

Re: [R] Column of probabilities

2011-08-24 Thread R. Michael Weylandt
If your numbers are all positive integers, this should work: (tabulate(xm)[xm])/length(xm) it can be put into a function for ease of use: probVec - function(x) {(tabulate(x)[x])/length(x)} You'll have some trouble if you have non-positive integers or non-integers. Let me know if you need to

Re: [R] Model selection and model efficiency - Search for opinions

2011-08-24 Thread Bert Gunter
1. As this is not really appropriate for R, I suggest replies be private. 2. You might try posting on various statistical forums, e.g. on http://stats.stackexchange.com/ -- Cheers, Bert On Wed, Aug 24, 2011 at 12:15 PM, Arnaud Mosnier a.mosn...@gmail.com wrote: Hi, In order to find the best

Re: [R] Opening package manual from within R

2011-08-24 Thread Tyler Rinker
Apparently my request to view the help pages is not a popular method among R users for gaining information. for me these pages are very helpful so I will follow up to completed this thread for future searchers. First thanks fo Prof. Brian Ripley. Your idea was spot on what I was looking

[R] Append a value to a vector

2011-08-24 Thread Claudio Zanettini
This should be easy but it does not work I have 3 vectors*(activeT,inactT, activeR)*, the idea is that if the last value in inactT is higher than the last in activeT this value has to be append in active T and the last value in another vector call activeR has to be repeated. (at the bottom you can

Re: [R] Append a value to a vector

2011-08-24 Thread Jean V Adams
Claudio Zanettini wrote on 08/24/2011 03:04:39 PM: This should be easy but it does not work I have 3 vectors*(activeT,inactT, activeR)*, the idea is that if the last value in inactT is higher than the last in activeT this value has to be append in active T When you say this value which one

Re: [R] Column of probabilities

2011-08-24 Thread David Winsemius
On Aug 24, 2011, at 3:31 PM, Jim Silverton wrote: Hi all, I have a vector xm say: xm = c(1,2,3,4,5,5,5,6,6) I want to return a vector with the corresponding probabilities based on the amount of times the numbers occurred. For example, I should get the following vector for xm: prob.xm =

Re: [R] Append a value to a vector

2011-08-24 Thread Jean V Adams
I'm still a little confused about lastV and lastI. The code you provide uses lastV, but your description seems to refer to lastI. Test out this code and see if it is doing what you want it to do. lastI lastA activeT activeR if(lastI lastA) { activeT - c(activeT, lastI)

Re: [R] Append a value to a vector

2011-08-24 Thread Claudio Zanettini
Thank you, this work fine, and is not contorted like mine:) In this case lastV=LastI but depending on the data that I obtain lastV can be = LastA. Any way it works very good:) Thank you very much :) PS: but I still do not understand what was wrong in the script that I used, It was not very

[R] Boxplot orders

2011-08-24 Thread Phoebe Jekielek
Hi there, I have length data of an organism over the year and I want to make a boxplot. I get the boxplot just fine but the months are all out of order. In the data set they are in order from Jan-Dec...how can I fix this problem? Thanks so much in advance!! Phoebe [[alternative HTML

[R] Howto convert Linear Regression data to text

2011-08-24 Thread ashz
Dear all, How can I covert lm data to text in the form of y=ax+b, r2 and how do I calculate R-squared(r2)? Thanks. Code: x=18:29 y=c(7.1,7,7.7,8.2,8.8,9.7,9.9,7.1,7.2,8.8,8.7,8.5) res=lm(y~x) -- View this message in context:

[R] unused argument(s) (Header = True) help!

2011-08-24 Thread shardman
Hi, I'm really new to R so I aoplogise if this is a stupid question. I'm trying to import data from a .txt file into R using the read.table command, the headers for the data columns are already in the text file so I add Header = True after the file location. The problem is I keep getting the

Re: [R] Replacing NAs in one variable with values of another variable

2011-08-24 Thread StellathePug
Thank you Dan and Ista! Both of you are correct, I should have used NA rather than NA in my example. So the correct code should be: X -as.data.frame(matrix(c(9, 6, 1, 3, 9, NA, NA,NA,NA,NA, 6, 4, 3,NA, NA, NA, 5, 4, 1, 3), ncol=2)) names(X)-c(X1,X2)

[R] ddply from plyr package - any alternatives?

2011-08-24 Thread AdamMarczak
Hello everyone, I was asked to repost this again, sorry for any inconvenience. I'm looking replacement for ddply function from plyr package. Function allows to apply function by category stored in any column/columns. Regular loops or lapplys slow down greatly because my unique combination count

Re: [R] R (stats) newcomer.... help!

2011-08-24 Thread geigercounter120
Many thanks for your response. unfortunately, it appears that I'm the closest thing in the vicinity to a local expert (chilling times indeed...), but i will certainly look at the booklist in terms of the number of data points, we have: two shores, three treatments, three replicates of each

Re: [R] Controling R from MS Access

2011-08-24 Thread lowman
answered my own question, just use the call shell function in vb woohoo -- View this message in context: http://r.789695.n4.nabble.com/Controling-R-from-MS-Access-tp2719751p3766037.html Sent from the R help mailing list archive at Nabble.com. __

[R] df of numerator and denominator

2011-08-24 Thread martinas
hello I need to know the dfn and dfd of my Anova. But in the Anova output there is only Df. Is this the dfn or the dfd? and how do I get both of it in R? Thanks for any answers -- View this message in context: http://r.789695.n4.nabble.com/df-of-numerator-and-denominator-tp3765526p3765526.html

Re: [R] Controling R from MS Access

2011-08-24 Thread lowman
Hello did you happen to figure this out? I am just learning about using R, i have a whack of fish data in MSAccess...and i want to take whatever functions access is limited by with stats, and then call R to do them i know the package RODBC works great to read data from your mdb, but i want to

[R] Regression by factor using sapply

2011-08-24 Thread elh
Apologies for the elementary nature of the question (yes, I'm another newbie)... I'd like to perform a multiple regression on a single data set containing a representation of energy consumption and temperatures containing account number, usage (KWh), heating degree days (HDD) and cooling degree

[R] Append a value to a vector

2011-08-24 Thread heverkuhn
This should be easy but it does not work I have 3 vectors*(activeT,inactT, activeR)*, the idea is that if the last value in inactT is higher than the last in activeT this value has to be append in active T and the last value in another vector call activeR has to be repeated. (at the bottom you can

[R] as.numeric() and POSIXct format

2011-08-24 Thread Agustin Lobo
Hi! I'm confused by this: as.numeric(as.POSIXct(518400,origin=2001-01-01)) [1] 978822000 I guess the problem is that as.numeric() assumes a different origin, but cannot find any default origin. How can I get back the seconds from the POSIXct format? In other words, which the inverse

[R] help with by command

2011-08-24 Thread amalka
Hello, I am a new user of R, and I'd be grateful if someone could help me with the following: I would like to compute the mean of variable trust in dataframe foo, but separately for each level of variable V2. That is, I'd like to compute the mean of trust at each level of V2. I have done this:

  1   2   >