[R] Saving run time in loop

2011-04-19 Thread vincent.deluard
Hi r users, I am trying to compute the "moving variance" of a large matrix. I now use a loop but I am looking for a faster solution. Here is a sample of the code. Source= matrix(rnorm(400),ncol=100) variances= matrix(rep(NA,4*100),ncol=100) for (i in 1:80) {variances[,i]=apply(Source[,i:(i+80)],

[R] How to check if a value of a variable is in a list

2011-04-19 Thread Frederik Lang
Hi all, I am working with some social network analysis in R and ran into a problem I just cannot solve. Each observation in my data consists of a respondent, some characteristics and up to five friends. The problem is that all of these five friends might no show up later as a respondent (observa

[R] counting values in multiple columns

2011-04-19 Thread Yosub Jung
Hello, I have a table that has 2000 rows and 8 columns. The headings of columns are: yearjel.code.1jel.code.2jel.code.3jel.code.4jel.code.5jel.code.6 jel.code.7. Under each column, there are either numbers or blank spaces corresponding to the given year. For instance, my 10th row is:10198382428243

Re: [R] Axes Alignment Problem for Multiple Plots

2011-04-19 Thread Barbaglia, Guido (ESA)
Dear Matthieu, thanks for your clarification! Basically, what I need to do is to plot different series on the same chart using different types of plot (lines, barplot, ...) and it is fundamental that the various charts have the same reference system. I hope that someone in the list is able

Re: [R] Simple question about symbols()

2011-04-19 Thread David Winsemius
On Apr 19, 2011, at 10:51 PM, murilofm wrote: Thanks for the answer; I see that col=c("blue","red")[inv$c+1] creates a vector of "red" and "blue" associated with the binnary c. But still I got everything red. If you want tested solution, submit test data. -- View this message in context:

Re: [R] Simple question about symbols()

2011-04-19 Thread murilofm
Thanks for the answer; I see that col=c("blue","red")[inv$c+1] creates a vector of "red" and "blue" associated with the binnary c. But still I got everything red. -- View this message in context: http://r.789695.n4.nabble.com/Simple-question-about-symbols-tp3461676p3462013.html Sent from the R he

[R] trouble with library(FrF2)

2011-04-19 Thread Fred Schenkelberg
Hi, I'm trying to use commands in FrF2 and once I install FrF2 and use the console command of library(FrF2) it loads required packages and ends with: Loading Tcl/Tk interface ... > then when I enter another command (only got to DATA<-read.table without an enter or more text) I get a non-res

[R] Ranked Boxplot generates an extra category?

2011-04-19 Thread Karmatose
Hi folks, Any time I try to plot my dependent variable as a ranked value against my predictor, R generates an additional category which precedes my actual predictors. So if I have Sex as my predictor, my categories are an unnamed category, M, and F. The unnamed category always has a box with the h

Re: [R] Ranked Boxplot generates an extra category?

2011-04-19 Thread Karmatose
Update: SOLVED Checking my levels revealed a "" in addition to every actual category. I went to my data sheet and deleted all of the blank spaces below my data, saved, reloaded my data sheet and the problem was solved :-) -- View this message in context: http://r.789695.n4.nabble.com/Ranked-Box

[R] [R-pkgs] glmnet_1.6 uploaded to CRAN

2011-04-19 Thread Trevor Hastie
We have submitted glmnet_1.6 to CRAN This version has an improved convergence criterion, and it also uses a variable screening algorithm that dramatically reduces the time to convergence (while still producing the exact solutions). The speedups in some cases are by a factors of 20 to 50, depending

[R] What to do with positive likelihoods

2011-04-19 Thread Turchin, Michael
Hi all, I'll preface this with saying I've gone through the archives, and am still in need of some help. I've been using this likelihood model with mean = 0 and s.d. = sqrt( (c + ( 1 / N1 ) + ( 1 / N2 ) ) * x * ( 1 - x )), where c is a genetic drift parameter (usually very small, like between

Re: [R] Source Code File For an Object

2011-04-19 Thread Duncan Murdoch
On 19/04/2011 5:18 PM, rivercode wrote: Is there anyway to query an object to find its source code file ? Created object F from file F.r, can object F tell me this ? In general, no. For functions you can if the "keep.source" option was active when it was sourced. Duncan Murdoch __

Re: [R] Simple question about symbols()

2011-04-19 Thread Ben Bolker
murilofm gmail.com> writes: > > I'm new to R and i'm having some trouble with a bubble chart. > Basically I have 3 series (a,b,c), but the third one is a binnary variable > (assumes only 0 or 1 to the entire data). > How can I use these binnary information to make 2 different colours in a > bubb

[R] Simple question about symbols()

2011-04-19 Thread murilofm
I'm new to R and i'm having some trouble with a bubble chart. Basically I have 3 series (a,b,c), but the third one is a binnary variable (assumes only 0 or 1 to the entire data). How can I use these binnary information to make 2 different colours in a bubble chart?. I.e., I'm using this code: sym

Re: [R] splom, plotmath: how to add three lines of information with alignment?

2011-04-19 Thread baptiste auguie
Hi, You may want to wait advice from someone who actually understands (the labyrinth that is) lattice's help for splom, but the following might be a start. I didn't understand what values you actually wanted displayed in the lower triangle panels, so I made up some random ones in a 3x3 matrix of 3

Re: [R] splom, plotmath: how to add three lines of information with alignment?

2011-04-19 Thread Marius Hofert
Dear Baptiste, there is one tricky part left: how can I create a matrix with the grid.table() objects as output? Is this possible? If not, maybe one can try to work with panel.splom (which can address single panels and thus call info() for each row-column index pair (i,j)), but I'm not sure if th

[R] Source Code File For an Object

2011-04-19 Thread rivercode
Is there anyway to query an object to find its source code file ? Created object F from file F.r, can object F tell me this ? Thanks, Chris -- View this message in context: http://r.789695.n4.nabble.com/Source-Code-File-For-an-Object-tp3461566p3461566.html Sent from the R help mailing list arch

Re: [R] Simple question

2011-04-19 Thread Peter Ehlers
Seconded. Peter Ehlers On 2011-04-19 14:11, Marc Schwartz wrote: On Apr 19, 2011, at 4:08 PM, Rolf Turner wrote: On 20/04/11 07:19, Steven Wolf wrote: [...snip...] It sounds to me like you don't understand lists. If you are going to use R you really should understand them. They are a w

Re: [R] Simple question

2011-04-19 Thread peter dalgaard
On Apr 19, 2011, at 21:56 , David Winsemius wrote: > > On Apr 19, 2011, at 3:19 PM, Steven Wolf wrote: > >> I am trying to convert a string to a vector, and I'm stuck! >> >> >> >> Suppose you have a string of numbers (string) that you want to convert to a >> vector (vec). I am able to split

Re: [R] Axes Alignment Problem for Multiple Plots

2011-04-19 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of mat > Sent: Tuesday, April 19, 2011 1:59 PM > To: John Kane > Cc: r-help@r-project.org > Subject: Re: [R] Axes Alignment Problem for Multiple Plots > > Ok, I can replicate your

Re: [R] Simple question

2011-04-19 Thread Marc Schwartz
On Apr 19, 2011, at 4:08 PM, Rolf Turner wrote: > On 20/04/11 07:19, Steven Wolf wrote: >> I am trying to convert a string to a vector, and I'm stuck! >> >> >> >> Suppose you have a string of numbers (string) that you want to convert to a >> vector (vec). I am able to split the string turning

Re: [R] Simple question

2011-04-19 Thread Rolf Turner
On 20/04/11 07:19, Steven Wolf wrote: I am trying to convert a string to a vector, and I'm stuck! Suppose you have a string of numbers (string) that you want to convert to a vector (vec). I am able to split the string turning it into a list by using strsplit, but this makes a list, which I ca

Re: [R] Overlaying images at nodes of phylogenetic tree

2011-04-19 Thread Greg Snow
A couple of possibilities: The rasterImage function (in the graphics package) The my.symbols and ms.image functions in the TeachingDemos package. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -Original Message- > Fr

Re: [R] splom, plotmath: how to add three lines of information with alignment?

2011-04-19 Thread baptiste auguie
Hi, This is always a challenge with expressions vs calls, etc. grid.table expects an input that can be coerced into a matrix of unevaluated expressions. This seems to work, info <- function(a,b){ grid.table(c(bquote(alpha==.(a)), bquote(beta==.(b))), parse=TRUE, # parse labels as e

Re: [R] Axes Alignment Problem for Multiple Plots

2011-04-19 Thread mat
Ok, I can replicate your problem, with following code: dat <- 1:10 barplot(dat, beside=TRUE,ylim=c(0,100)); par()$usr; par(new=T); plot(dat, ylim=c(0,100), type="l"); par()$usr; So it looks like even if you specify yourself ylim, the resulting effective ylim (usr[3:4] ) will be d

Re: [R] Way OT: Anyone know where to get data on relationship between education and salary

2011-04-19 Thread Thomas Lumley
>> I'm sorry for the way OT post, but here goes.  I'm an informatics >> specialist, and R user.  My wife is a secondary school maths teacher. >> The first place to look for this sort of information in the US is the Statistical Abstract of the United States [which is, sadly, scheduled to be a victi

Re: [R] problem reading csv file

2011-04-19 Thread David Winsemius
Not attached. You might succeed if you rename the file with a .txt extension and re-post. Almost surely an encoding issue. We may need your session Info to get "locale". -- David On Apr 19, 2011, at 2:47 PM, Petr Pikal wrote: Dear all I have several files which claim to be *.csv (one att

Re: [R] problem reading csv file

2011-04-19 Thread Uwe Ligges
On 19.04.2011 20:47, Petr Pikal wrote: Dear all I have several files which claim to be *.csv (one attached, maybe it will come through). Can you provide the file on some webspace or send it to me privately, I will take a look tomorrow then. Uwe Ligges They can be read to Open Office wit

[R] doSMP package works better than perfect, at least sometimes.

2011-04-19 Thread Seeliger . Curt
Some might have noticed that REvolution Computing released the doSMP package to the general public about a month and a half ago, which allows multiple cores to be accessed for parallel computation in R. Some of our physical habitat calculations were taking an extraordinary amount of time to c

Re: [R] Simple question

2011-04-19 Thread David Winsemius
On Apr 19, 2011, at 3:19 PM, Steven Wolf wrote: I am trying to convert a string to a vector, and I'm stuck! Suppose you have a string of numbers (string) that you want to convert to a vector (vec). I am able to split the string turning it into a list by using strsplit, but this makes a

Re: [R] splom, plotmath: how to add three lines of information with alignment?

2011-04-19 Thread Marius Hofert
Dear guys, I'm almost there... how can I fix the final problems? Cheers, Marius PS: the "info" function is the one I will then try to call within splom... library(lattice) library(gridExtra) ## trial 1 info <- function(a,b){ grid.table(as.expression(substitute(expression(alpha==alph, be

[R] cr.setup & predict with se.fit

2011-04-19 Thread apeer
Hello, I've recently started using the rms package to fit some continuation ratio models using cr.setup. The package runs beautifully and I'm getting good fits with my data, however, I'm having trouble getting plots of the predicted mean values of y in relation to predictor variables with confide

[R] Simple question

2011-04-19 Thread Steven Wolf
I am trying to convert a string to a vector, and I'm stuck! Suppose you have a string of numbers (string) that you want to convert to a vector (vec). I am able to split the string turning it into a list by using strsplit, but this makes a list, which I can't seem to access the way that I'd lik

[R] problem reading csv file

2011-04-19 Thread Petr Pikal
Dear all I have several files which claim to be *.csv (one attached, maybe it will come through) . They can be read to Open Office without much problem, however I can not read them into R. I tried read.table("H2O.CSV", sep=",", dec=".") V1 1 ˙ţ1 2 3 > read.table("H2O.CSV", sep=",", dec=".", s

Re: [R] A small problem with PDF manuals

2011-04-19 Thread Duncan Murdoch
On 19/04/2011 3:14 PM, apjawor...@mmm.com wrote: Hello, I am not sure if I have done something wrong or something changed between 12.2.2 and 2.13.0, but I just installed R-2.13.0 from CRAN install executable on 64 bit Windows 7 Pro and when I try "Help>Manuals (in PDF)>An Introduction to R" I ge

[R] A small problem with PDF manuals

2011-04-19 Thread apjaworski
Hello, I am not sure if I have done something wrong or something changed between 12.2.2 and 2.13.0, but I just installed R-2.13.0 from CRAN install executable on 64 bit Windows 7 Pro and when I try "Help>Manuals (in PDF)>An Introduction to R" I get the following Error: 'doc\manual\R-intro.pd

[R] Subsetting a data frame by dropping correlated variables

2011-04-19 Thread Rita Carreira
Hello R Users! I have a data frame that has many variables, some with missing observations, and some that are correlated with each other. I would like to subset the data by dropping one of the variables that is correlated with another variable that I will keep int he data frame. Alternatively,

Re: [R] Robustbase source question

2011-04-19 Thread kv
Thank you very much Peter, Best, -- View this message in context: http://r.789695.n4.nabble.com/Robustbase-source-question-tp3459966p3461263.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://sta

Re: [R] Axes Alignment Problem for Multiple Plots

2011-04-19 Thread John Kane
What is Coredata(Z0)? It would be very useful. as the posting guidelines suggest to supply working code and sample data. --- On Tue, 4/19/11, Barbaglia, Guido (ESA) wrote: > From: Barbaglia, Guido (ESA) > Subject: [R] Axes Alignment Problem for Multiple Plots > To: "r-help@r-project.org" > C

Re: [R] simple user input

2011-04-19 Thread Greg Snow
If you don't need the web browser part then look at the tkexamp function in the TeachingDemos package. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-h

[R] Axes Alignment Problem for Multiple Plots

2011-04-19 Thread Barbaglia, Guido (ESA)
Dear all, I'm trying to plot, in the same window, two different series, using barplot() for the first one and plot() for the second. What happens is that the second chart has a different axes origin, therefore the final plot is wrong. This piece of code shows the differences between the val

Re: [R] Markov transition matrices , missing transitions for certain years

2011-04-19 Thread Chris Stubben
To keep the table dimensions the same, try changing the columns to factors... boxes$y97<-factor(boxes$y97, 1:4) boxes$y98<-factor(boxes$y98, 1:4) boxes$y99<-factor(boxes$y99, 1:4) ... > table(boxes$y98, boxes$y97) 1 2 3 4 1 1 0 1 0 2 0 0 0 0 3 0 0 0 0 4 1 0 0 1 > table(boxes$y99,

Re: [R] How to program with colleagues

2011-04-19 Thread Smith, Dale
a. Check out Roxygen. b. Use version control. You will not regret it. Thanks, Dale Smith, Ph.D. Senior Financial Quantitative Analyst Risk & Compliance Fiserv. 107 Technology Park Norcross, GA 30092 Direct NYC: 212-419-3242 Mail: dale.sm...@fiserv.com www.fiserv.com -Original Message- F

Re: [R] How to program with colleagues

2011-04-19 Thread Barry Rowlingson
On Tue, Apr 19, 2011 at 6:20 PM, Alaios wrote: > b. Could you please suggest me an easy way to exchange the R code with my > colleagues. I know about these version systems but unfortunately they look > pretty bizarre to me. Nothing looks more bizarre than a project that isn't using version co

Re: [R] How to program with colleagues

2011-04-19 Thread Seeliger . Curt
Alex writes: > Dear all, > ... > a. Do you know if there is any system that can convert our R scripts > to html pages with some nice dependency graphs (which functions calls which). > > b. Could you please suggest me an easy way to exchange the R code > with my colleagues. I know about these ver

[R] How to program with colleagues

2011-04-19 Thread Alaios
Dear all, my colleagues and I have to write some R code for some of our projects. I would like to ask you help to organize us a little. a. Do you know if there is any system that can convert our R scripts to html pages with some nice dependency graphs (which functions calls which). b. Could you

Re: [R] A question regarding RFreak

2011-04-19 Thread James Shaw
Dr. Ligges: Thank you for the prompt reply. I am sorry that I did not include my code. I submitted my post as I was running to a meeting and did not have time to provide more detail. Given the information you provided, I was able to access the coefficient vector. -- Jim 2011/4/19 Uwe Ligges

Re: [R] Robustbase source question

2011-04-19 Thread Peter Ehlers
On 2011-04-19 02:45, kv wrote: Dear All, in the sources of robustbase, there appears a function called rPsort() (say l253 of qn_sn.c). I could not find its source in the robustbase package and a google search yields too many unrelated response. Can anyone point to its source ? It's not in robu

Re: [R] Matching Problem: Want to match to data.frame with inexact matching identifier (one identifier has to be in the range of the other).

2011-04-19 Thread Christoph Jäckel
Hi together, I found a solution to my problem that works for me and performs reasonable well in my opinion. Instead of looping through both datasets, I decided to replicate each row in d2 from Min_Month to Max_Month and then use the match-function. Here is the code (I changed the original example

Re: [R] Prediction interval with GAM?

2011-04-19 Thread Simon Wood
> Is it possible to estimate prediction interval using GAM? I looked > through ?gam, - The easiest and most general way is by posterior simulation. Here's an example... ## Prediction interval example for Gamma GAM library(mgcv) ## simulate some data... f <- function(x) (0.2 * x^11 * (10 *

Re: [R] Data frame with 3 columns to matrix

2011-04-19 Thread Michael Bach
David Winsemius writes: > On Apr 19, 2011, at 8:16 AM, Michael Bach wrote: > >> David Winsemius writes: >> >>> Perhaps but only if the third row of your example was incorrectly >>> constructed: dta <- rd.txt(" x y z >>> 1 1.00 5 0.5 >>> 2 1.02 5 0.7 >>> 3 1.04 7 0.1 >>> 4 1.06 9 0.4")

Re: [R] Reducing dimension of a list object

2011-04-19 Thread Ivan Calandra
Hi, Would unlist() do what you want? unlist(lis3) [1] 4 1 8 HTH, Ivan Le 4/19/2011 17:32, Bogaso Christofer a écrit : Hi all, I generally use the Reduce() function to reduce the dimension of list object. However in my current session I have few objects which are actually list of list of list..

[R] Reducing dimension of a list object

2011-04-19 Thread Bogaso Christofer
Hi all, I generally use the Reduce() function to reduce the dimension of list object. However in my current session I have few objects which are actually list of list of list..(say n step). If I reduce their dimension then I have call Reduce() function many times. Therefore my question is, is there

Re: [R] str() on a data frame with 600 variables

2011-04-19 Thread Greg Snow
An alternative that you may find interesting is the TkListView function in the TeachingDemos package. This opens a separate window and shows the list structure there with options for scrolling and expanding/collapsing sublists. You will probably need to be a little patient while the display bu

Re: [R] cut & histogram

2011-04-19 Thread David Winsemius
On Apr 19, 2011, at 10:32 AM, Santosh wrote: Dear Rxperts, Below is a small sample of values (cut short due to space considerations while posting).. I was wondering if it is possible to construct boundaries (or intervals) based on the distribution of points. Is it anything similar to b

Re: [R] Power Analysis

2011-04-19 Thread Marc Schwartz
On Apr 19, 2011, at 8:43 AM, Schatzi wrote: > "Inter ocular data" > Quite amusing :) > Thank you for the help. For some reason I was thinking that I could get the > n values for the combined test, but that doesn't make sense as there could > be an infinite number of combinations of n values. > Tha

[R] Prediction in gamlss package

2011-04-19 Thread IhorB
Hello! I've just build one-inflated beta regression model using package GAMLSS. It all worked very nicely but now I want to make prediction using it. I use typical function predict() give all necessary arguments (my new data is in data frame and all relevant columns have same names as before). Unf

[R] cut & histogram

2011-04-19 Thread Santosh
Dear Rxperts, Below is a small sample of values (cut short due to space considerations while posting).. I was wondering if it is possible to construct boundaries (or intervals) based on the distribution of points. Is it anything similar to boundary detection of distributions? x1 <- c(0.00,0.25,0.

Re: [R] SQLDF syntax

2011-04-19 Thread new2R
Thank you very much. Its working. -- View this message in context: http://r.789695.n4.nabble.com/SQLDF-syntax-tp3458919p3460448.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mail

Re: [R] print.raw - but convert ASCII?

2011-04-19 Thread Matt Shotwell
On Tue, 2011-04-19 at 03:14 -0400, Duncan Murdoch wrote: > On 11-04-18 9:51 PM, Matt Shotwell wrote: > > Does anyone know if there is a simple way to print raw vectors, such > > that ASCII characters are printed for bytes in the ASCII range, and > > their hex representation otherwise? rawToChar doe

Re: [R] How to get the tuning parameter lamda in storey's qvalue package

2011-04-19 Thread Uwe Ligges
Just load the package and type qvalue so you will see what the underlying R code is. You will find some parts of the code may be worth to be improved, hence time to contribute to the package. Uwe Ligges On 19.04.2011 07:53, Chee Chen wrote: Dear All, In Storey's estimator of the proport

Re: [R] Odp: Data frame with 3 columns to matrix

2011-04-19 Thread Petr PIKAL
Hi Michael Bach napsal dne 19.04.2011 14:21:13: > Petr PIKAL writes: > > > Hi > > > > r-help-boun...@r-project.org napsal dne 19.04.2011 09:46:47: > > > >> Dear R Users, > >> > >> Lets assume I have this data frame: > >> > >> x y z > >> 1 1.00 5 0.5 > >> 2 1.02 5 0.7 > >> 3 1.04 7 0.

Re: [R] Power Analysis

2011-04-19 Thread Schatzi
"Inter ocular data" Quite amusing :) Thank you for the help. For some reason I was thinking that I could get the n values for the combined test, but that doesn't make sense as there could be an infinite number of combinations of n values. Thanks again for the replies. -- View this message in conte

Re: [R] Data frame with 3 columns to matrix

2011-04-19 Thread David Winsemius
On Apr 19, 2011, at 8:16 AM, Michael Bach wrote: David Winsemius writes: Perhaps but only if the third row of your example was incorrectly constructed: dta <- rd.txt(" x y z 1 1.00 5 0.5 2 1.02 5 0.7 3 1.04 7 0.1 4 1.06 9 0.4") #rd.txt() is a combo fn of read.table and textConnection

Re: [R] factor analysis - constraints

2011-04-19 Thread peter dalgaard
On Apr 19, 2011, at 13:58 , Robert Ruser wrote: > Dear R Users, > I'm wondering how is it possible to get |factor loadings| <1 in factor > analysis model (factanal) performing maximum-likelihood estimation. Is > it caused by some constraints? If so, what kind of constraints are > placed and when

Re: [R] Way OT: Anyone know where to get data on relationship between education and salary

2011-04-19 Thread Gene Leynes
This is an amazing website which would definitely have what you want, probably in many ways. *http://www.gapminder.org/* There are a wealth of data sources, and the GUI is very intuitive and interesting. I encourage you to view a few samples to get an idea of what you can do with the "trendanalyi

Re: [R] Odp: Data frame with 3 columns to matrix

2011-04-19 Thread Michael Bach
Petr PIKAL writes: > Hi > > r-help-boun...@r-project.org napsal dne 19.04.2011 09:46:47: > >> Dear R Users, >> >> Lets assume I have this data frame: >> >> x y z >> 1 1.00 5 0.5 >> 2 1.02 5 0.7 >> 3 1.04 7 0.1 >> 4 1.06 9 0.4 >> >> x and y columns are sorted and the values not necessari

Re: [R] Error is assocplot

2011-04-19 Thread Uwe Ligges
On 14.04.2011 14:37, suparna mitra wrote: Hello, I have a contingency table showing relation between two datasets. I tried to see association among them with the assocplot, but it shows error. mosaicplot of the same data worked perfectly. Can anyone please help me. Perhaps, given you spec

Re: [R] Which should I use? system.file() path.package() find.package()

2011-04-19 Thread Uwe Ligges
On 19.04.2011 05:19, Kevin Wright wrote: For a package that I am creating, I have some files in the "inst" directory. In the package man pages, I want to have R code that accesses these files. As of R-2.13.0, it looks like I can use any of: system.file() path.package() find.package() There a

Re: [R] Data frame with 3 columns to matrix

2011-04-19 Thread Michael Bach
David Winsemius writes: > Perhaps but only if the third row of your example was incorrectly constructed: >> dta <- rd.txt(" x y z > 1 1.00 5 0.5 > 2 1.02 5 0.7 > 3 1.04 7 0.1 > 4 1.06 9 0.4") > #rd.txt() is a combo fn of read.table and textConnection > >> mat <- matrix(NA, ncol=NROW(dta)+1,

Re: [R] Several factors same levels

2011-04-19 Thread peter dalgaard
On Apr 19, 2011, at 10:57 , dereksloan wrote: > This is probably very simple but I'm new to R so apologies for being stupid. > > I have some data with No coded as 0 and yes coded as 1. > > e.g. > > id sex alcohol smoker > 1 M 01 > 2 F 10 > 3 M 00 >

Re: [R] A question regarding RFreak

2011-04-19 Thread Uwe Ligges
On 18.04.2011 23:41, James Shaw wrote: I am using robreg.evol (part of the RFreak package) to fit models via least trimmed squares (LTS) regression and am encountering the following error message when attempting to access the coefficients: Error in fit1$coef : $ operator not defined for this S

Re: [R] Several factors same levels

2011-04-19 Thread Dimitris Rizopoulos
one way is the following: DF <- data.frame(id = 1:6, sex = gl(2, 3, labels = c("M", "F")), x = sample(0:1, 6, TRUE), y = sample(0:1, 6, TRUE), z = rnorm(6)) f <- function (x) { if (all(unique(x) %in% 0:1)) factor(x, levels = 0:1, labels = c("No", "Yes")) else

[R] factor analysis - constraints

2011-04-19 Thread Robert Ruser
Dear R Users, I'm wondering how is it possible to get |factor loadings| <1 in factor analysis model (factanal) performing maximum-likelihood estimation. Is it caused by some constraints? If so, what kind of constraints are placed and when (during the estimation or after)? Robert _

Re: [R] rownames in an apply function

2011-04-19 Thread Santosh Srinivas
Thanks. On Tue, Apr 19, 2011 at 5:16 PM, Gabor Grothendieck wrote: > On Tue, Apr 19, 2011 at 6:59 AM, santosh wrote: >> Dear Group, >> >> I am doing an apply function on a zoo object. I need the rownames to >> be passed to the function. >> Any suggestions on how to accomplish this? >> >> Here is

[R] RHmm, mixture of gaussians, memory could not be "read" error

2011-04-19 Thread Xirisx
Hi, I'm trying to fit a hidden Markov model (mixture of Gaussians) to stock prices (Open, High, Low, Close) data. Here's my code: #First download the data with package TTR library(TTR) n <- 200 data <- getYahooData("GOOG", strftime(as.POSIXlt(Sys.time() - n*24*3600),format="%Y%m%d")) keep <- c

[R] SPDEP Package, neighbours list for Moran's I on large grid dataset

2011-04-19 Thread Laurent Jégou
Hello list members, i'd like to calculate the Moran I on a large dataset, a 8640x3432 grid of values. When i try to create the neighbours list with the cell2nb function, on such a scale, R works for several hours and seems to crash. I'm using the last version (2.13), 64 bits, on a mac pro with 4go

Re: [R] Entire part of number

2011-04-19 Thread Ivan Calandra
Nice example, I forgot about negative numbers... Thanks Ivan Le 4/19/2011 12:17, (Ted Harding) a écrit : trunc(-1.5) # [1] -1 floor(-1.5) # [1] -2 Ted. On 19-Apr-11 09:57:43, Ivan Calandra wrote: By the way, is there any difference between trunc() and floor()? x<- c(1.05, 1.95, 2

[R] combining n imputed dataset

2011-04-19 Thread wiplash
Hi, I'm using the library MICE to make multiple imputations. I'can pool the results to show how the predicted values fit, but how to combine the five imputed datasets? I take the mean? for exemple : x1<-complete(imp) x2<-complete(imp, 2) x3<-complete(imp, 3) x4<-complete(imp, 4) x5<-complete(

[R] Prediction interval with GAM?

2011-04-19 Thread yosuke kimura
Hello, Is it possible to estimate prediction interval using GAM? I looked through ?gam, ?predict.gam etc and the mgcv.pdf Simon Wood. I found it can calculate confidence interval but not clear if I can get it to calculate prediction interval. I read "Inference for GAMs is difficult and somewhat

[R] Several factors same levels

2011-04-19 Thread dereksloan
This is probably very simple but I'm new to R so apologies for being stupid. I have some data with No coded as 0 and yes coded as 1. e.g. id sex alcohol smoker 1 M 01 2 F 10 3 M 00 I realise I can covert the numerical variable back to a factor by f

Re: [R] rownames in an apply function

2011-04-19 Thread Gabor Grothendieck
On Tue, Apr 19, 2011 at 6:59 AM, santosh wrote: > Dear Group, > > I am doing an apply function on a zoo object. I need the rownames to > be passed to the function. > Any suggestions on how to accomplish this? > > Here is the code I am using > > tmp <- > structure(c(611.55, 611.55, 611.55, 611.55,

Re: [R] Define ylim in lattice plot based upon panel function output

2011-04-19 Thread Sébastien Bihorel
Dear Deepayan, Thank you for pointing out those functions. They will be helpful to me. If you don't mind, I may get back to you on that topic if I cannot find a way to apply them to my actual problem (the example I gave was just for illustration). This problem is more complex and involves multiple

Re: [R] rownames in an apply function

2011-04-19 Thread santosh
Thanks David. Is there a way of explicitly passing the rowname since I need it in the function. On Apr 19, 4:19 pm, David Winsemius wrote: > On Apr 19, 2011, at 6:59 AM, santosh wrote: > > > > > > > > > > > > > Dear Group, > > > I am doing an apply function on a zoo object. I need the rownames to

Re: [R] rownames in an apply function

2011-04-19 Thread David Winsemius
On Apr 19, 2011, at 6:59 AM, santosh wrote: Dear Group, I am doing an apply function on a zoo object. I need the rownames to be passed to the function. Any suggestions on how to accomplish this? Here is the code I am using tmp <- structure(c(611.55, 611.55, 611.55, 611.55, 611.55, 520, 520,

Re: [R] zero fill empty cell in data.frame

2011-04-19 Thread Kenn Konstabel
On Tue, Apr 19, 2011 at 1:45 PM, Rolf Turner wrote: > On 19/04/11 21:39, Simone Gabbriellini wrote: >> >> Hello List, >> >> I have a data frame like: >> >>        V130    V131    V132    V133    V134    V135    V136 >> 1       0               0               0.9             0 >> 0.9             0

Re: [R] Data frame with 3 columns to matrix

2011-04-19 Thread David Winsemius
On Apr 19, 2011, at 3:46 AM, Michael Bach wrote: Dear R Users, Lets assume I have this data frame: x y z 1 1.00 5 0.5 2 1.02 5 0.7 3 1.04 7 0.1 4 1.06 9 0.4 x and y columns are sorted and the values not necessarily integers. z values are not sorted. Now I would like to create a matri

[R] rownames in an apply function

2011-04-19 Thread santosh
Dear Group, I am doing an apply function on a zoo object. I need the rownames to be passed to the function. Any suggestions on how to accomplish this? Here is the code I am using tmp <- structure(c(611.55, 611.55, 611.55, 611.55, 611.55, 520, 520, 520, 520, 520, 425, 425, 425, 432.2, 432.2, 337,

[R] Odp: Data frame with 3 columns to matrix

2011-04-19 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 19.04.2011 09:46:47: > Dear R Users, > > Lets assume I have this data frame: > > x y z > 1 1.00 5 0.5 > 2 1.02 5 0.7 > 3 1.04 7 0.1 > 4 1.06 9 0.4 > > x and y columns are sorted and the values not necessarily integers. z > values are not sorte

Re: [R] zero fill empty cell in data.frame

2011-04-19 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 19.04.2011 12:02:31: > On 04/19/2011 07:39 PM, Simone Gabbriellini wrote: > > Hello List, > > > > I have a data frame like: > > > >V130 V131 V132 V133 V134 V135 V136 > > 1 0 0 0.9 0 0.9 0 0 > > 2 0

Re: [R] zero fill empty cell in data.frame

2011-04-19 Thread Rolf Turner
On 19/04/11 21:39, Simone Gabbriellini wrote: Hello List, I have a data frame like: V130V131V132V133V134V135V136 1 0 0 0.9 0 0.9 0 0 2 0 0 0

Re: [R] Markov transition matrices , missing transitions for certain years

2011-04-19 Thread Rolf Turner
Make two assumptions: (1) The initial state probability distribution (``ispd'') is *NOT* a function of the transition probability matrix (``tpm''). (2) The boxes are stochastically independent of each other. Both of these assumptions may be dubious. The second assumption is the crucial one

Re: [R] From nested loop to mclapply

2011-04-19 Thread Alaios
Dear Allan, thank you very much for your answer. If I got it right your idea is a: create first all the i,j combinations and then b. use mclapply (parallel version of lapply). so I wrote some draft and run three experiments: # code require('multicore') sr<-matrix(data=NA,ncol=256,nrow=256) su

Re: [R] Entire part of number

2011-04-19 Thread Ted Harding
trunc(-1.5) # [1] -1 floor(-1.5) # [1] -2 Ted. On 19-Apr-11 09:57:43, Ivan Calandra wrote: > By the way, is there any difference between trunc() and floor()? > > x <- c(1.05, 1.95, 2.5, 3.51) > trunc(x) > [1] 1 1 2 3 > floor(x) > [1] 1 1 2 3 > identical(trunc(x), floor(x)) > > Ivan > >

[R] Error message in package:bayesSurv. Why?

2011-04-19 Thread David Foreman
Dear folks, I have been struggling to create what I fondly imagined would be a straightforward adaptation of the package's example to my own dataset, which looks at incidence of depression following the birth of initial and up to 3 subsequent children (4 children in all, with all subjects having a

Re: [R] zero fill empty cell in data.frame

2011-04-19 Thread Jim Lemon
On 04/19/2011 07:39 PM, Simone Gabbriellini wrote: Hello List, I have a data frame like: V130V131V132V133V134V135V136 1 0 0 0.9 0 0.9 0 0 2 0 0

Re: [R] Entire part of number

2011-04-19 Thread Ivan Calandra
By the way, is there any difference between trunc() and floor()? x <- c(1.05, 1.95, 2.5, 3.51) trunc(x) [1] 1 1 2 3 floor(x) [1] 1 1 2 3 identical(trunc(x), floor(x)) Ivan Le 4/19/2011 11:46, Rolf Turner a écrit : On 19/04/11 21:30, barbara.r...@uniroma1.it wrote: What is the function to ha

Re: [R] zero fill empty cell in data.frame

2011-04-19 Thread Dimitris Rizopoulos
you could try something along these lines: DF <- data.frame(V1 = c(0, 0.9, " ", 0.8, 0.1, 0), V2 = c(0.9, " ", 0.8, 0.7, " ", 1)) DF sapply(DF, function (x) as.numeric(gsub("(^ +)|( +$)", "0", x))) I hope it helps. Best, Dimitris On 4/19/2011 11:39 AM, Simone Gabbriellini wrote: H

Re: [R] SQLDF syntax

2011-04-19 Thread Gabor Grothendieck
On Mon, Apr 18, 2011 at 6:34 PM, new2R wrote: > Hi, > > I am new to R and trying to migrate from SAS. I am trying to use sqldf to > create a new table from existed table and change some of the columns. I have > table called DataOld with columns commodity, rate and total and I am trying > to create

Re: [R] Entire part of number

2011-04-19 Thread Rolf Turner
On 19/04/11 21:30, barbara.r...@uniroma1.it wrote: What is the function to have the entire part of a number? [[alternative HTML version deleted]] I'm not quite sure what you mean, but perhaps you want "floor()". cheers, Rolf Turner

  1   2   >