Re: [R] multi-platform equivalent of x11() ?

2012-03-06 Thread peter dalgaard
On Mar 7, 2012, at 08:13 , Paul Johnson wrote: > I want to write an R help example that throws up 2 graphs in separate > windows, for comparison. In Linux I plot one, then run > > x11() > > to spawn a new on-screen device. > > Is there some generic equivalent so I can write an example that wil

[R] how to see inbuilt function(cor.test) & how to get p-value from t-value(test of significance) ?

2012-03-06 Thread sagarnikam123
i can see source code of function > cor function (x, y = NULL, use = "everything", method = c("pearson", "kendall", "spearman")) { na.method <- pmatch(use, c("all.obs", "complete.obs", "pairwise.complete.obs", "everything", "na.or.complete"))

[R] constant function

2012-03-06 Thread Chris Waggoner
Is it possible to define a constant function (for example the zero function) in R? I found the following unsatisfying hack to create the "seven function": constant <- stepfun( x = -100:100, y = rep(7, 201) ) This is mathematically unsatisfying because the domain is artificially restricte

Re: [R] Convert Numeric (20090101) to Date

2012-03-06 Thread peter dalgaard
On Mar 7, 2012, at 02:42 , jim holtman wrote: > forgot what you asked for: > >> format(x, format = "%d-%m-%Y") > [1] "01-01-2009" I don't think that was quite what was asked for. Original question was to convert something read as numeric to a date. For that, you need to first convert to a cha

Re: [R] pulling out 1 country and 1 wave

2012-03-06 Thread Petr PIKAL
Hi > Petr, > > > > wvs.a[,362] > > > ### wvs.a this is data set. > > ###,362 is location of year of wave. > > > table(wvs.a[,362]) > > > norway <- wvs.a[which(wvs.a[,362] == "2005"), ] > > ### i am renaming dataset 'norway' > > ### the year of the wave in question is '2005.' > > > dim

[R] multi-platform equivalent of x11() ?

2012-03-06 Thread Paul Johnson
I want to write an R help example that throws up 2 graphs in separate windows, for comparison. In Linux I plot one, then run x11() to spawn a new on-screen device. Is there some generic equivalent so I can write an example that will work for Windows and Mac users as well? If there is none, don'

Re: [R] pulling out 1 country and 1 wave

2012-03-06 Thread Nicole Marie Ford
Petr, > wvs.a[,362] ### wvs.a this is data set. ###,362 is location of year of wave. > table(wvs.a[,362]) > norway <- wvs.a[which(wvs.a[,362] == "2005"), ] ### i am renaming dataset 'norway' ### the year of the wave in question is '2005.' > dim(norway) thanks, nicole. =)) does this

Re: [R] Demographic Variables in AIDS (Demand System)

2012-03-06 Thread Arne Henningsen
Dear xiaodao On 7 March 2012 05:19, xiaodao wrote: > I am using aidsEst( ) in "micEconAids" package to estimate Demand system. > But I would like to add more demographic variables in demand system. How can > I add those information? > > for example: > mydata<-data.frame(p1,p2,p3,p4, >            

Re: [R] pulling out 1 country and 1 wave

2012-03-06 Thread Petr PIKAL
Hi > wvs.a[,362] Error: object 'wvs.a' not found > table(wvs.a[,362]) Error in table(wvs.a[, 362]) : object 'wvs.a' not found > norway <- wvs.a[which(wvs.a[,362] == "2005"), ] Error: object 'wvs.a' not found > dim(norway) Error: object 'norway' not found > I get errors with all your commands and

Re: [R] pulling out 1 country and 1 wave

2012-03-06 Thread Nicole Marie Ford
sorry here is the .tiff - Original Message - From: "Nicole Marie Ford" To: "r-help" Sent: Tuesday, March 6, 2012 11:08:43 PM Subject: pulling out 1 country and 1 wave Hello. I am trying to pull out one country from a time series of 5 waves. For example I need Norway from the 5th wave

[R] Demographic Variables in AIDS (Demand System)

2012-03-06 Thread xiaodao
Hi all, I am using aidsEst( ) in "micEconAids" package to estimate Demand system. But I would like to add more demographic variables in demand system. How can I add those information? for example: mydata<-data.frame(p1,p2,p3,p4, s1,s2,s3,s4,

[R] Where do I report CRAN mirror problems?

2012-03-06 Thread Robert King
Where should I report mirror problems? There doesn't seem to be anywhere on http://cran.r-project.org/mirrors.html listing contact emails for mirror admins. There is some problem with the debian binaries on http://cran.ms.unimelb.edu.au output from my apt-get update says: W: Failed to fetch http

Re: [R] pulling out 1 country and 1 wave

2012-03-06 Thread Nicole Marie Ford
I have done the following to pull out the wave but now need to pull out the country form there... but I am not sure how to do that without messing it up? wvs.a[,362] table(wvs.a[,362]) norway <- wvs.a[which(wvs.a[,362] == "2005"), ] dim(norway) - Original Message - From: "Nicole Marie

[R] pulling out 1 country and 1 wave

2012-03-06 Thread Nicole Marie Ford
Hello. I am trying to pull out one country from a time series of 5 waves. For example I need Norway from the 5th wave. This is new to me. Typically, I work with country specific surveys. data = norway I have attached a .tiff of the codebook showing the variable names for Norway and the wa

[R] confidence intervals in dotplots in a for loop

2012-03-06 Thread Byerly, Mike M (DFG)
# I have some population estimates and confidence intervals for various size classes # of animals captured with two gear types. I'd like to plot the estimates along with # the 90 and 95% CI's by size class for each gear type. # The data can be read in as: estimates <- c(67.42,30.49,32.95,

[R] [R-pkgs] sparsenet: a new package for sparse model selection

2012-03-06 Thread Trevor Hastie
We have put a new package sparsenet on CRAN. Sparsenet fits regularization paths for sparse model selection via coordinate descent, using a penalized least-squares framework and a non-convex penalty. The package is based on our JASA paper Rahul Mazumder, Jerome Friedman and Trevor Hastie: Spars

Re: [R] Convert Numeric (20090101) to Date

2012-03-06 Thread jim holtman
forgot what you asked for: > format(x, format = "%d-%m-%Y") [1] "01-01-2009" On Tue, Mar 6, 2012 at 8:40 PM, jim holtman wrote: > try this: > >> x <- as.POSIXct("20090101", format = "%Y%m%d") >> x > [1] "2009-01-01 EST" >> > > > On Tue, Mar 6, 2012 at 7:38 PM, RHelpPlease > wrote: >> Hi there

Re: [R] Convert Numeric (20090101) to Date

2012-03-06 Thread jim holtman
try this: > x <- as.POSIXct("20090101", format = "%Y%m%d") > x [1] "2009-01-01 EST" > On Tue, Mar 6, 2012 at 7:38 PM, RHelpPlease wrote: > Hi there, > Does it exist where R can convert a numeric date (20090101) to a "proper" > date format?  (Ideally dd-mm-) > > Original data (in this case)

[R] Convert Numeric (20090101) to Date

2012-03-06 Thread RHelpPlease
Hi there, Does it exist where R can convert a numeric date (20090101) to a "proper" date format? (Ideally dd-mm-) Original data (in this case) is in .DAT format. I read the multi-column data with the read.fwf function, where I specified the column width for the eight digit date (example abo

Re: [R] Table into a list

2012-03-06 Thread Thomas Coquet
Hello, Thanks to all for your answers. The solution given by R. Michael was perfect ! Thank you very much, that helped a lot ! Thomas On Tue, Feb 28, 2012 at 11:50 AM, Alemtsehai Abate wrote: > Perhaps, the following does it as well. > > (d <- data.frame(x1=letters[2*1:4 - 1], x2=letters[2*1:4]))

Re: [R] help with time data - R weird behaviour across machines

2012-03-06 Thread Prof Brian Ripley
What timezones are you and your colleague in? "2011-03-27 01:00:01" does not exist in some timezones, e.g. Europe/London. As ?as.POSIXlt explains, you can expect such non-existent inputs to give NA. And from ?Sys.timezone: Note that except on Windows, the operation of time zones is an

[R] help with time data - R weird behaviour across machines

2012-03-06 Thread Tiago Marques
Hello list, I was hoping I could get some help on something which is really giving me a headache. I am using R version 2.14.1 (2011-12-22) (Platform: x86_64-pc-mingw32/x64 (64-bit)) An object which is supposed to have times has a few elements listed as not times but NA's > ls() [1] "todelet

Re: [R] times series trellis plot

2012-03-06 Thread Gabor Grothendieck
On Tue, Mar 6, 2012 at 11:14 AM, Stefan Luedtke wrote: > I spent some more time to understand the examples .. it helped a bit. > > But there is still one issue. > > Taking example data (my first on, hope it is not confusing ;-)  ) like: > > > library(latticeExtra) > library(zoo) > > > #  example D

Re: [R] how to run system command

2012-03-06 Thread Henrik Bengtsson
On Tue, Mar 6, 2012 at 11:49 AM, William Dunlap wrote: >> system("cmd.exe /c date /T", intern=TRUE) > [1] "Tue 03/06/2012 " To avoid messing with "cmd.exe /c", you can use shell(), e.g. > res <- shell("date /T", intern=TRUE) > res [1] "Tue 03/06/2012 " > > Bill Dunlap > Spotfire, TIBCO Softwar

Re: [R] Scale parameter in Weibull distribution

2012-03-06 Thread FU-WEN LIANG
Thanks for your advise, David. I did read the help for survreg and using the followings to calculate. survreg's scale =1/(rweibull shape) survreg's intercept = log(rweibull scale) However, the scale in rweibull has been transformed by exp(betaX's). In my case, the baseline hazard for T is 0

[R] How to eliminate for next loops in this script

2012-03-06 Thread Walter Anderson
I needed to compute a complicated cross tabulation to show weighted means and standard deviations and the only method I could get that worked uses a series of nested for next loops. I know that there must be a better way to do so, but could use some assistance pointing the way. Here is my working

[R] Obtain Log-Likelihood for ml.nbc (COUNT)

2012-03-06 Thread Michael Stegh
Dear List, I normally try to solve this kind of problems by myself but I am running out of time and have no idea where to start. So I hope you might excuse this rather basic question. I'm trying to fit a Canonical Negative Binomial model using the ml.nbc function from the COUNT package. This

Re: [R] Scale parameter in Weibull distribution

2012-03-06 Thread David Winsemius
On Mar 6, 2012, at 5:53 PM, FU-WEN LIANG wrote: Hi all, I'm trying to generate a Weibull distribution including four covariates in the model. Here is the code I used: T = rweibull(200, shape=1.3, scale=0.004*exp(-(-2.5*b1+2.5*b2+0.9*x1-1.3*x2)/1.3)) C = rweibull(n, shape=1.5, scale=0.008)

[R] Scale parameter in Weibull distribution

2012-03-06 Thread FU-WEN LIANG
Hi all, I'm trying to generate a Weibull distribution including four covariates in the model. Here is the code I used: T = rweibull(200, shape=1.3, scale=0.004*exp(-(-2.5*b1+2.5*b2+0.9*x1-1.3*x2)/1.3)) C = rweibull(n, shape=1.5, scale=0.008) #censoring time time = pmin(T,C) #observed time is m

Re: [R] Extracting data from a zoo by date

2012-03-06 Thread Gabor Grothendieck
On Tue, Mar 6, 2012 at 3:06 PM, Mago84 wrote: > Dear all, > > I know that it is a silly question, but I have a zoo object like this: > >                    valor1  valor2 > 01/02/08 36.7381 17.0097 > 01/03/08 36.9296 16.8331 > 01/04/08 35.6934 16.3539 > 01/07/08 35.3539 16.3791 > 01/08/08 36.3811

Re: [R] Numerical Inversion of Cumulative Distribution Function

2012-03-06 Thread David Winsemius
On Mar 6, 2012, at 1:47 PM, Gildas Mazo wrote: Dear R users, Given a user-defined cumulative distribution function F, I want to compute F^{-1}(x). Isn't this quantile()? (But pay attention to the type some say to use type=1.) Alternatively: If q = CDF(x) then generate a matrix

Re: [R] How to apply two parameter function in data frame

2012-03-06 Thread David L Carlson
Try this. > set.seed(123) > a <- sample(letters[1:4], 250, replace=TRUE) > b <- sample(letters[1:4], 250, replace=TRUE) > c <- sample(letters[1:4], 250, replace=TRUE) > d <- sample(letters[1:4], 250, replace=TRUE) > e <- sample(letters[1:4], 250, replace=TRUE) > df <- data.frame(a, b, c, d, e) > r

Re: [R] Reshape question

2012-03-06 Thread David Winsemius
On Mar 6, 2012, at 3:00 PM, David Perlman wrote: I have a data frame in wide format. There are six variables that represent two factors in long format 3x2, Valence and Temperature: head(dpts) File Subj Time Group PainNeg.hot PainNeg.warm SociNeg.hot SociNeg.warm Positiv.hot

[R] Winbugs

2012-03-06 Thread yushimito
I have a problem with Winbugs. The code is executed perfectly, the only problem is that the stats option isn't available (grey color) and i don't know how to make it work. Maybe if i run the winbugs throug R i will be able to get stats results? -- View this message in context: http://r.789695.

[R] Extracting data from a zoo by date

2012-03-06 Thread Mago84
Dear all, I know that it is a silly question, but I have a zoo object like this: valor1 valor2 01/02/08 36.7381 17.0097 01/03/08 36.9296 16.8331 01/04/08 35.6934 16.3539 01/07/08 35.3539 16.3791 01/08/08 36.3811 16.9340 01/09/08 37.9220 17.6655 The na

[R] Exclusion restriction criterion

2012-03-06 Thread saqlain raza
Hello, I am in search of any command or package that can be used for exclusion of some variable estimates from one model but not from the other. I am using MNP package for data analysis and want the result in the form of unequal number of covariates for each model choice.   Saqlain RAZA PhD Stud

Re: [R] index instead of loop?

2012-03-06 Thread Ben quant
Hello, In case anyone is interested in a faster solution for lots of columns. This solution is slower if you only have a few columns. If anyone has anything faster, I would be interested in seeing it. ### some mockup data z.dates = c("2007-03-31","2007-06-30","2007-09-30","2007-12-31","2008-03-3

Re: [R] sourcearg function is there a better way already built into R

2012-03-06 Thread Bert Gunter
?pmatch ?switch _may_ be of use... But if the file calls it Fe and you want to label it "Iron," then you'll need some sort of explicit dictionary. -- Bert On Tue, Mar 6, 2012 at 12:57 PM, Robert Sandefur wrote: > List and Jim: > > My solution works to my satisfaction so perhaps I should not ha

Re: [R] sourcearg function is there a better way already built into R

2012-03-06 Thread Robert Sandefur
List and Jim: My solution works to my satisfaction so perhaps I should not have not ask. The problem was basically this: 1. I receive a CSV file containing assays on various chemical elements. The names of these fields are inconsistent in terms of spelling, length and case. 2. As an example I wo

[R] Fitting difference models in R (nls, nlme)

2012-03-06 Thread Journals
I wish to fit a dynamical model in R and I am running in a problem that requires some of your wisdom to solve. For SAS users I am searching for the equivalent of the retain statement. For people that want to read complicated explanations to help me: I have a system of two equations written as d

Re: [R] sourcearg function is there a better way already built into R

2012-03-06 Thread Robert Sandefur
List and Jim -Original Message- From: jim holtman [mailto:jholt...@gmail.com] Sent: Tuesday, March 06, 2012 09:47 To: Robert Sandefur Cc: r-help@r-project.org Subject: Re: [R] sourcearg function is there a better way already built into R The basic question is what do you want the functio

[R] How to apply two parameter function in data frame

2012-03-06 Thread jon waterhouse
I know this is something simple that I cannot do because I do not yet "think" in R. I have a data frame has a variable participation (a factor), and several other factors. I want a chisq test (no contingency tables) for participation vs all of the other factors. In SPSS I would do: CROSSTABS

[R] Reshape question

2012-03-06 Thread David Perlman
I have a data frame in wide format. There are six variables that represent two factors in long format 3x2, Valence and Temperature: > head(dpts) File Subj Time Group PainNeg.hot PainNeg.warm SociNeg.hot SociNeg.warm Positiv.hot Positiv.warm Errors 1 WB101_1_1_dp.txt 1011 MN

Re: [R] how to run system command

2012-03-06 Thread William Dunlap
> system("cmd.exe /c date /T", intern=TRUE) [1] "Tue 03/06/2012 " Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of sagarnikam123 > Sent: Tuesday, March 06, 2012 5:49 AM >

Re: [R] Numerical Inversion of Cumulative Distribution Function

2012-03-06 Thread Dimitris Rizopoulos
Check function uniroot(). I hope it helps. Best, Dimitris On 3/6/2012 7:47 PM, Gildas Mazo wrote: Dear R users, Given a user-defined cumulative distribution function F, I want to compute F^{-1}(x). How is that possible with R? Best Regards, -- Dimitris Rizopoulos Assistant Professor De

Re: [R] split array into groups by value

2012-03-06 Thread pavlo
Rui and Dimitris, thank you much, both approaches work great! (although rle won me, I had a feeling something like that had to exist) -- View this message in context: http://r.789695.n4.nabble.com/split-array-into-groups-by-value-tp4448578p4451048.html Sent from the R help mailing list archive at

[R] Numerical Inversion of Cumulative Distribution Function

2012-03-06 Thread Gildas Mazo
Dear R users, Given a user-defined cumulative distribution function F, I want to compute F^{-1}(x). How is that possible with R? Best Regards, -- Gildas Mazo PhD student MISTIS team at INRIA Grenoble, France [[alternative HTML version deleted]] __

[R] Classification tree - Uniform vertical spacing of the nodes

2012-03-06 Thread Nathalia Machado
Hello everyone! I'm working with Decision tree and I have doubt about one of the arguments of "plot.rpart" function: When we use "uniform=F", the vertical spacing of nodes will be proportional to the error in the fit. But, I want to build a scale next my classif tree to show it. So, how could I

Re: [R] LOESS confidence interval

2012-03-06 Thread Bert Gunter
As I have seen no response to your post 1. I am in no sense an expert on loess, so caveat emptor. 2. AFAICS, you just need to read the seq() Help file carefully. I do not know how to tell you how to use seq() more clearly than it already does, and so will not attempt to do so. You might ge

Re: [R] closing file with close(file) *silently*

2012-03-06 Thread Prof Brian Ripley
On 06/03/2012 17:53, Federico Calboli wrote: Hi All, I am writing a function that reads a file in myfile = file('myfile.raw', 'rb') . . . . . close(myfile) No matter what, I get the warning Warning message: closing unused connection 3 (myfile.raw) Since the whole thing is in a function, I'd

Re: [R] Add number series to data frame

2012-03-06 Thread Petr Savicky
On Tue, Mar 06, 2012 at 09:32:37AM -0800, syrvn wrote: > Hi Sarah, > > thanks a lot for this peace of code. > > Is it possible to give the second sequence of "B" in your second example > (data frame b) > the numbers 6, 7 and 8 instead of 1, 2 and 3 again? In my real data I have > more columns th

Re: [R] Label rows of table by factor level for groups of factors

2012-03-06 Thread Sarah Goslee
On Tue, Mar 6, 2012 at 1:32 PM, O'Hanlon, Simon J wrote: > Ah! > > Thanks. > > I had already made vector x2 previously and then went and changed it for some > reason, which was why I didn't notice the error (because the subsequent code > was able to run regardless). Sorry about that. > > so x2 s

Re: [R] Windows - **Paste commands only** issue

2012-03-06 Thread Duncan Murdoch
On 06/03/2012 1:02 PM, Robert Baer wrote: In following a thread on this mailing list, I encounter an apparent issue with **Edit | Paste commands only** in the Windows R-GUI. Reproducible steps: Go to (using IE?): http://www.r-bloggers.com/select-operations-on-r-data-frames/ Find the section en

Re: [R] closing file with close(file) *silently*

2012-03-06 Thread Sarah Goslee
On Tue, Mar 6, 2012 at 1:20 PM, Federico Calboli wrote: > On 6 Mar 2012, at 18:01, Sarah Goslee wrote: > >> The help for warning offers some suggestions. > > none that seem to work though. Where's your reproducible example of this? "Doesn't seem to work" is unanswerable. > F > > > >> >> Sarah >>

Re: [R] Label rows of table by factor level for groups of factors

2012-03-06 Thread Sarah Goslee
Well, if you can get this to run your version of R is markedly\ different than mine. > #Start of code > > x1=c(rep(0:1,6)) > x2=c(rep(c(1,1,0,0)6)) Error: unexpected numeric constant in "x2=c(rep(c(1,1,0,0)6" > x3=c(rep(1,6),rep(0,6)) On Tue, Mar 6, 2012 at 1:23 PM, O'Hanlon, Simon J wrote: >

Re: [R] closing file with close(file) *silently*

2012-03-06 Thread Federico Calboli
On 6 Mar 2012, at 18:01, Sarah Goslee wrote: > The help for warning offers some suggestions. none that seem to work though. F > > Sarah > > On Tue, Mar 6, 2012 at 12:53 PM, Federico Calboli > wrote: >> Hi All, >> >> I am writing a function that reads a file in >> >> myfile = file('myfile

Re: [R] Label rows of table by factor level for groups of factors

2012-03-06 Thread Sarah Goslee
One possible approach is to use unique() to get the list of distinct combinations, cbind() an identifying variable to that list, then use merge() to join it to your existing data frame. But I'm not seeing how you are getting four unique combinations. Given your sample data (with the missing comma

Re: [R] Help on reshape function

2012-03-06 Thread David Winsemius
On Mar 6, 2012, at 12:45 PM, R. Michael Weylandt wrote: You'll need to use the cast() function but I can't say more unless you can provide more specifics. I believe Hadley's website has more documentation than the package: http://had.co.nz/reshape/ in reshape2 Hadley did away with cast() and

Re: [R] TXT-file with R to SPS-file

2012-03-06 Thread David Winsemius
On Mar 6, 2012, at 12:39 PM, Nordlund, Dan (DSHS/RDA) wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Aims Sent: Tuesday, March 06, 2012 9:00 AM To: r-help@r-project.org Subject: [R] TXT-file with R to SPS-file Hey, for

Re: [R] times series trellis plot

2012-03-06 Thread Stefan Luedtke
I spent some more time to understand the examples .. it helped a bit. But there is still one issue. Taking example data (my first on, hope it is not confusing ;-) ) like: library(latticeExtra) library(zoo) # example Data timeVect1=seq(as.Date("1990-01-01"), as.Date("2010-12-31"), by="day"

Re: [R] how to run system command

2012-03-06 Thread Sarah Goslee
On Tue, Mar 6, 2012 at 8:48 AM, sagarnikam123 wrote: > i used it on windows system, but giving error like > >> e <- system("date", intern=TRUE) > Error in system("date", intern = TRUE) : 'date' not found If you type date at a windows command line does it work? You can't use system() to run syste

[R] Label rows of table by factor level for groups of factors

2012-03-06 Thread O'Hanlon, Simon J
Dear useRs, I am sure this is a fairly simple problem, but I just cannot get my head around it. I have a dataframe which contains several factor variables. I can use table() to tell me how many different combinations there are of these variables. What I should like to do is to add a column to

Re: [R] how to used regular expression while reading file

2012-03-06 Thread Sarah Goslee
You could perhaps set the comment.char argument of read.table() to "@". More generally, you can use scan() and process the lines within R. On Tue, Mar 6, 2012 at 8:41 AM, sagarnikam123 wrote: > i have file as in txt format > > @ATTRIBUTE f1996 REAL > @ATTRIBUTE f1997 REAL > @ATTRIBUTE f1998 REAL

Re: [R] how to run system command

2012-03-06 Thread sagarnikam123
i used it on windows system, but giving error like > e <- system("date", intern=TRUE) Error in system("date", intern = TRUE) : 'date' not found -- View this message in context: http://r.789695.n4.nabble.com/how-to-run-system-command-tp4449597p4449906.html Sent from the R help mailing list archi

Re: [R] closing file with close(file) *silently*

2012-03-06 Thread Sarah Goslee
The help for warning offers some suggestions. Sarah On Tue, Mar 6, 2012 at 12:53 PM, Federico Calboli wrote: > Hi All, > > I am writing a function that reads a file in > > myfile = file('myfile.raw', 'rb') > . > . > . > . > . > close(myfile) > > No matter what, I get the warning > > Warning mess

[R] Windows - **Paste commands only** issue

2012-03-06 Thread Robert Baer
In following a thread on this mailing list, I encounter an apparent issue with **Edit | Paste commands only** in the Windows R-GUI. Reproducible steps: Go to (using IE?): http://www.r-bloggers.com/select-operations-on-r-data-frames/ Find the section entitled 'Duplicate row names' Copy the foll

[R] how to used regular expression while reading file

2012-03-06 Thread sagarnikam123
i have file as in txt format @ATTRIBUTE f1996 REAL @ATTRIBUTE f1997 REAL @ATTRIBUTE f1998 REAL @ATTRIBUTE f1999 REAL @ATTRIBUTE f2000 REAL @ATTRIBUTE class {-1,1} @DATA 2.080750,1.099070,0.927763,1.029080,-0.130763,1.265460,-0.43 1.109460,0.786453,0.445560,-0.146323,-0.996316,0.555759,0.29 -0.676

Re: [R] index instead of loop?

2012-03-06 Thread Rui Barradas
Hello, > Just looking at this, but it looks like ix doesn't exist: >sapply(1:length(inxlist), function(i) if(length(ix[[i]])) > fin1[ix[[i]], tkr + 1] <<- ua[i, tkr]) > > Trying to sort it out now. Right, sorry. I've changed the name from 'ix' to 'inxlist' to make it more readable just

Re: [R] frequency count by row

2012-03-06 Thread R. Michael Weylandt
Or perhaps faster but less general: rowSums(mydata != 0) Michael On Tue, Mar 6, 2012 at 12:56 PM, Sarah Goslee wrote: > A reproducible example would be helpful, but lacking that > here's some untested code. If your data frame has NA values, > those will also need to be dealt with. > > apply(myd

Re: [R] frequency count by row

2012-03-06 Thread Sarah Goslee
A reproducible example would be helpful, but lacking that here's some untested code. If your data frame has NA values, those will also need to be dealt with. apply(mydata, 1, function(x)sum(x != 0)) Sarah On Tue, Mar 6, 2012 at 12:03 PM, mari681 wrote: > I feel this is a very easy thing but I'

[R] closing file with close(file) *silently*

2012-03-06 Thread Federico Calboli
Hi All, I am writing a function that reads a file in myfile = file('myfile.raw', 'rb') . . . . . close(myfile) No matter what, I get the warning Warning message: closing unused connection 3 (myfile.raw) Since the whole thing is in a function, I'd like to avoid unecessary noise for the user, a

[R] milanoR

2012-03-06 Thread Andrea Spano
Good afternoon, MilanoR.net is proud to announce the first MilanoR meeting on Tuesday 8th May 2012 at 18:00. Venue: Fiori Oscuri Bistrot Via Fiori Oscuri 3 IT-20122 Milano www.fiorioscuri.it Agenda: Introduction Andrea Spano' Quantdie Srl Past, present and future of R Stefano Iacus, Departmen

Re: [R] Help on reshape function

2012-03-06 Thread R. Michael Weylandt
You'll need to use the cast() function but I can't say more unless you can provide more specifics. I believe Hadley's website has more documentation than the package: http://had.co.nz/reshape/ Michael On Tue, Mar 6, 2012 at 9:34 AM, mails wrote: > Hey Michael, > > thanks for your help. I think t

[R] frequency count by row

2012-03-06 Thread mari681
I feel this is a very easy thing but I've never done it before and it is getting frustrating. I have a big data.frame (1445846 rows, 15 col) that looks like this: V1 V2 V3 V4 V5 1home sisterbrother chair 0 2cat

Re: [R] times series trellis plot

2012-03-06 Thread R. Michael Weylandt
Type at your console: library(lattice) example(xyplot.zoo) I think the second and third do what you were asking. Otherwise, please describe in more detail what you mean about "add other variables to each panel" -- how do you want these displayed and what sort of variables are they? On Tue, Mar 6

Re: [R] Add number series to data frame

2012-03-06 Thread syrvn
Hi Sarah, thanks a lot for this peace of code. Is it possible to give the second sequence of "B" in your second example (data frame b) the numbers 6, 7 and 8 instead of 1, 2 and 3 again? In my real data I have more columns than only those two and sometimes the are sorted differently so that colu

Re: [R] TXT-file with R to SPS-file

2012-03-06 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Aims > Sent: Tuesday, March 06, 2012 9:00 AM > To: r-help@r-project.org > Subject: [R] TXT-file with R to SPS-file > > Hey, > > for a statistical analysis I have to work with so

Re: [R] Help on reshape function

2012-03-06 Thread mails
Hey Michael, thanks for your help. I think the reshape2 library works much better than the normal reshape function. However, I still cannot retransform my data.frame into wide format once used melt function to transform it into long format. How do I get it back to wide format? The documentation, u

Re: [R] Add number series to data frame

2012-03-06 Thread Sarah Goslee
I'd just sort them first, if you want consecutive numbers for each value. (It would have been nice to specify that in the original question.) If you need for some reason to put them back in order, you can always cbind(1:nrow(x), x) before sorting, to get an index to sort on after you're done. As

Re: [R] Using ddply within a function by argument transfer

2012-03-06 Thread Fredrik Karlsson
Dear list, A follow up on this thread - the solution I ended up with does indeed involve "parse()". However, it does the job, and it is more efficient than what I came up with in my other attempts. suspicious.vowels <- function(data,factors,vowelcolumn,f1,f2) { for(currfac in c(factors,vowel

Re: [R] 632 estimator using boot package

2012-03-06 Thread Jin Minming
Thanks a lot. I have changed the calculation method by using optimism defined by Efron. The results from using boot and rms packages are quite close now. Jim --- On Tue, 6/3/12, Frank Harrell wrote: > From: Frank Harrell > Subject: Re: [R] 632 estimator using boot package > To: r-help@r-pro

[R] Importing name/value formatted data

2012-03-06 Thread Karl Ove Hufthammer
Hi! Does anybody know about an R function for importing paired name/value data, where each pair is separated by a fixed string (e.g., a semi-colon), and within each pair a different delimeter is used (e.g., an equals sign). Example: x="FirstName=John;LastName=Doe;Age=75;\nFirstName=Jane;LastNa

[R] LOESS confidence interval

2012-03-06 Thread F.Hassan
Dear all, I'm trying to construct confidence intervals for a LOWESS estimation (by not using bootstrapping). I have checked previous posts and other material online and I understand that the main procedure is: my.count<- seq(...) fit<- loess (y ~ x, data=z) pred<- pred(fit, my.count

[R] TXT-file with R to SPS-file

2012-03-06 Thread Aims
Hey, for a statistical analysis I have to work with some micro dates in SPSS. I only have txt-files though (any further details concerning the format or something like that, I don´t have. I can only see a lot of numbers when I open it). On the same page I found another Download especially for R.

Re: [R] Help in matrix

2012-03-06 Thread arunkumar1111
Thanks so much it worked very well - Thanks in Advance Arun -- View this message in context: http://r.789695.n4.nabble.com/Help-in-matrix-tp4449622p4450560.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.or

Re: [R] evaluate String

2012-03-06 Thread Lucas
PERFECT Thank you so much. Lucas. 2012/3/6 R. Michael Weylandt > eval(parse(text = STRING)) > > but you often don't need to do this. A somewhat canonical quote in the > R-world: > > If the answer is parse() you should usually rethink the question. > -- Thomas Lumley, R-help (February 2005) > >

Re: [R] evaluate String

2012-03-06 Thread R. Michael Weylandt
eval(parse(text = STRING)) but you often don't need to do this. A somewhat canonical quote in the R-world: If the answer is parse() you should usually rethink the question. -- Thomas Lumley, R-help (February 2005) Michael On Tue, Mar 6, 2012 at 10:06 AM, Lucas wrote: > Hello to everyone. > > I

Re: [R] Add number series to data frame

2012-03-06 Thread Sarah Goslee
Here's one possible approach. It assumes that a$name is a factor, as it is in your example, but does not require that each sequence has a unique value (see second example). > a <- data.frame(name = c(rep("A", 3), rep("B", 5), rep("C", 10))) > data.frame(name=a, val=unlist(sapply(rle(as.numeric(a[,

Re: [R] Why aren't row names in a data frame unique?

2012-03-06 Thread William Dunlap
S+ does allow duplicates in the row names if you ask for them to be allowed (with data.frame(..., dup.row.names=TRUE) or attr(df, "dup.row.names") <- TRUE). They were allowed because bootstrappers were sampling the rows of data.frames with replacement and it turned out that a fair bit of time was

[R] Add number series to data frame

2012-03-06 Thread syrvn
Hi, Is there a simple way of doing the following in R? a <- data.frame(name = c(rep("A", 3), rep("B", 5), rep("C", 10))) > a name 1 A 2 A 3 A 4 B 5 B 6 B 7 B 8 B 9 C 10C 11C 12C 13C 14C 15C 16C 17C 18C Do some fancy R c

Re: [R] sourcearg function is there a better way already built into R

2012-03-06 Thread jim holtman
The basic question is what do you want the function to do. It seems convoluted and I am not sure exactly what you are giving it as input and what you expect as output. Not exactly sure of what the 'sink' and 'source' are supposed to do. So "tell me what you want to do, not how you want to do it".

[R] evaluate String

2012-03-06 Thread Lucas
Hello to everyone. In MATLAB you can find a function that executes a text string. I have not find it in R. Does anyone knows a similiar function in R, i think a valuable tool. Thank you. Lucas. [[alternative HTML version deleted]] __ R-help@r-

Re: [R] evaluate String

2012-03-06 Thread David Winsemius
On Mar 6, 2012, at 10:24 AM, Lucas wrote: PERFECT Thank you so much. If by 'execute' you meant translate a name for a function then you should also look at do.call. -- David. Lucas. 2012/3/6 R. Michael Weylandt eval(parse(text = STRING)) but you often don't need to do this. A som

Re: [R] Help on reshape function

2012-03-06 Thread Liaw, Andy
Just using the reshape() function in base R: df.long = reshape(df, varying=list(names(df)[4:7]), direction="long") This also gives two extra columns ("time" and "id") can can be dropped. Andy > -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.

[R] sourcearg function is there a better way already built into R

2012-03-06 Thread Robert Sandefur
Hi list: I work with a lot of laboratory analytical data and I often have inconsistent names of files and variables within those files so I wrote this sourcearg function to facilitate handling file and variable names as both character and R names. The source of the function is given below s

Re: [R] index instead of loop?

2012-03-06 Thread Ben quant
Unfortunately, your solution is does not scale well. (Tough for you to test this without my real data.) If ua is my data and rd1 are my report dates (same as the code below) and I use more columns, it appears that your solution slows considerably. Remember I have ~11k columns in my real data, so

Re: [R] PLS predict

2012-03-06 Thread Bjørn-Helge Mevik
Thomas Möckel writes: > I have a question about understanding PLS. If I use the predict function of R > than it seems to me the function only uses the last latent variable to model > new Y values. But should the function not use all latent variables to model > new Y´s? It should, and it definite

Re: [R] PLS Error message

2012-03-06 Thread Bjørn-Helge Mevik
Thomas Möckel writes: > I work with hyperspectral remote sensing data and I try to built a pls > model with this data. I already built the model but if I try to > calculate the RMSEP and R2 with a test data set I get the following > error message: > > Error: variable 'subX' was fitted with typ

Re: [R] index instead of loop?

2012-03-06 Thread Ben quant
I think this is what you meant: z.dates = c("2007-03-31","2007-06-30","2007-09-30","2007-12-31","2008-03-31","2008-06-30","2008-09-30","2008-12-31") nms = c("A","B","C","D") # these are the report dates that are the real days the data was available rd1 = matrix(c("20070514","20070814","20071115",

Re: [R] index instead of loop?

2012-03-06 Thread Ben quant
Just looking at this, but it looks like ix doesn't exist: sapply(1:length(inxlist), function(i) if(length(ix[[i]])) fin1[ix[[i]], tkr + 1] <<- ua[i, tkr]) Trying to sort it out now. Ben On Mon, Mar 5, 2012 at 7:48 PM, Rui Barradas wrote: > Hello, > > > > > Mar 05, 2012; 8:53pm — by Ben

  1   2   >