[R] irregular splits in dataframe

2012-08-21 Thread Sapana Lohani
Hello everyone, My dataframe (Soil Type) looks something like this Granitic Hills 16-20 PZ Loamy Upland 16-20 PZ Sandy Loam Upland 12-16 PZ / Sandy Loam, Deep 12-16 PZ Loamy Upland 12-16 PZ / Sandy Loam Upland 12-16 PZ Loamy Upland 16-20 PZ I want to separate them at /, but when there is just

Re: [R] Iterative sampling with restrictions

2012-08-21 Thread PIKAL Petr
Hi why not shuffle your values by x - 1:60 x - sample(x, 60) and then add groups groups - rep(paste(g,1:3, sep=), each=20) If you want you can suffle also groups. Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf

Re: [R] Doubt in relation with packaging

2012-08-21 Thread Eva Prieto Castro
Thank you, Michael and Rui. I think I will adjust namespaces file. Cheers, Eva --- El mar, 21/8/12, R. Michael Weylandt michael.weyla...@gmail.com escribió: De: R. Michael Weylandt michael.weyla...@gmail.com Asunto: Re: [R] Doubt in relation with packaging Para: Rui Barradas

Re: [R] The difference between chisq.test binom.test and pbinom

2012-08-21 Thread Tal Galili
Dear Peter, Your explanation makes perfect sense, thank you. With regards, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |

Re: [R] Iterative sampling with restrictions

2012-08-21 Thread Daniel Nordlund
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of David A. Kim Sent: Monday, August 20, 2012 9:17 PM To: r-help@r-project.org Subject: [R] Iterative sampling with restrictions Hi all, I'm working on a seemingly trivial

Re: [R] colorful plot

2012-08-21 Thread nooshin bahar
Hello guys, I want to increase contrast of colors in my matrix plot. Nooshin- as.matrix(matrix(sample(c(0.02,0.01,0.003,0.001,0.0001,0.0005,0.0004,0.00013),2401,replace=TRUE),ncol=49), row.names=1, header=TRUE) filled.contour(Nooshin, main=Permeability) Nooshin_matrix -

Re: [R] colorful plot

2012-08-21 Thread Jessica Streicher
filled.contour(Nooshin, main=Permeability,color.palette=rainbow) filled.contour(Nooshin, main=Permeability,color.palette=terrain.colors) filled.contour(Nooshin, main=Permeability,color.palette=topo.colors) not quite sure what to do with the heat map, but it has a col attribute. On 21.08.2012, at

Re: [R] irregular splits in dataframe

2012-08-21 Thread jim holtman
try this: x - scan(text = Granitic Hills 16-20 PZ + Loamy Upland 16-20 PZ + Sandy Loam Upland 12-16 PZ / Sandy Loam, Deep 12-16 PZ + Loamy Upland 12-16 PZ / Sandy Loam Upland 12-16 PZ + Loamy Upland 16-20 PZ, what = '', sep = '\n') Read 5 items x [1] Granitic Hills 16-20 PZ [2] Loamy Upland

Re: [R] Changing line length in Sweave output works for numeric, but not for character vectors

2012-08-21 Thread Enrico Schumann
Hi Simon try strwrap(test) regards, Enrico Am 20.08.2012 23:03, schrieb Simon Kiss: Hi there: I'm preparing a report in RStudio 0.96.330 on a Mac OS. I'm running R 2.15.0 I understand from Ross Ihaka's document (http://www.stat.auckland.ac.nz/~stat782/downloads/Sweave-customisation.pdf)

[R] reexpr transform nonumeric values to numeric

2012-08-21 Thread PIKAL Petr
Dear all I have got this kind of data temp - structure(c(1L, 1L, 1L, 1L, 1L, 16L, 6L, 6L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 11L, 10L, 16L, 16L, 16L, 21L, 16L, 16L, 16L, 1L, 1L, 1L, 16L, 16L, 16L, 16L, 1L, 1L, 7L, 3L, 1L, 1L, 1L, 1L, 3L, 3L, 1L, 1L, 1L, 4L, 10L,

Re: [R] irregular splits in dataframe

2012-08-21 Thread Noia Raindrops
How about this? read.table(text = Granitic Hills 16-20 PZ Loamy Upland 16-20 PZ Sandy Loam Upland 12-16 PZ / Sandy Loam, Deep 12-16 PZ Loamy Upland 12-16 PZ / Sandy Loam Upland 12-16 PZ Loamy Upland 16-20 PZ, header = FALSE, sep = /, fill = TRUE, na.strings = , strip.white = TRUE) ##

Re: [R] reexpr transform nonumeric values to numeric

2012-08-21 Thread Noia Raindrops
Use backreference: as.numeric(gsub(^(.*)-$, -\\1, as.character(temp))) -- Noia Raindrops noia.raindr...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

Re: [R] reexpr transform nonumeric values to numeric

2012-08-21 Thread PIKAL Petr
Thank you I knew that somebody can use power of gsub better than myself. Petr -Original Message- From: Noia Raindrops [mailto:noia.raindr...@gmail.com] Sent: Tuesday, August 21, 2012 12:33 PM To: PIKAL Petr Cc: r-help Subject: Re: [R] reexpr transform nonumeric values to numeric

Re: [R] What makes R different from other programming languages?

2012-08-21 Thread Alexandre Aguiar
cbe...@tajo.ucsd.edu escreveu: This rather unlikely linguistic cocktail would probably never have been prepared by computer scientists, yet the language has become surprisingly popular. A linguist that is a good friend once observed that language is both expression and a modeller of how we

Re: [R] radarchart axis scaling

2012-08-21 Thread Jean V Adams
Mitra, Try this ... # provide the data you want to plot, and the desired range mydat - c(3.34, 3.28, 1.37, 1.12, 3.52, 4.07, 3.66) myrange - c(0, 5) # create a data frame with the max and min as the first two rows mydf - data.frame(rbind(max=myrange[2], min=myrange[1], mydat)) # create a radar

[R] Entering a table

2012-08-21 Thread Thomas
I'm trying to enter a frequency table manually so that I can run a goodness of fit test (I only have the frequencies, I don't have the raw data). So for example, let's say I want to re-create the HorseKicks table: library(vcd) data(HorseKicks) str(HorseKicks) 'table' int [1:5(1d)] 109 65

Re: [R] colorful plot

2012-08-21 Thread Jose Iparraguirre
Hi Nooshin, Have you tried the RColorBrewer package? After loading the package, the following gives you the whole array of available colour palletes. display.brewer.all(n=NULL, type=all, select=NULL, exact.n=TRUE) Then, you can add to your code something like this (I'm using palette Set3

[R] elasticnet iteration problem

2012-08-21 Thread Nico Met
Dear all, I am trying to iterate an elastic net regression method on a matrix 1) Each column of the matrix ( nxp) will act as a response (y) and rest of the variables (columns) which means p-1 will act as predictor set 2) i want to store selected variables as matrix I wrote a code. Please help

[R] Cox Proportional Hazards

2012-08-21 Thread Nanthinee Jeevanandam
I have run this model for my data set on insect survival time for different temperature treatments in R. I understand the Wald statistic reports on whether the variable makes a difference to the model but there is also a p-value so i am not sure whther to report the Wald statistic. I have pasted

[R] Trace values in the function ca.jo()

2012-08-21 Thread Rmillan
Hi all R users, I'm trying to replicate the same results that are given in a published article after been granted the same data that the authors use. I'm having problems to determine the cointegration rank of my data set using the Johnasen's trace test. This trace test is already programmed in

Re: [R] irregular splits in dataframe

2012-08-21 Thread arun
Hi, Try this: dat1 - readLines(textConnection(Granitic Hills 16-20 PZ  Loamy Upland 16-20 PZ  Sandy Loam Upland 12-16 PZ / Sandy Loam, Deep 12-16 PZ  Loamy Upland 12-16 PZ / Sandy Loam Upland 12-16 PZ  Loamy Upland 16-20 PZ))  dat3-strsplit(dat1,/)  

Re: [R] reexpr transform nonumeric values to numeric

2012-08-21 Thread arun
HI, Try this: as.numeric(gsub(^([0-9].[0-9]{1,4})-$,-\\1,temp)) #or as.numeric(gsub(^([[:digit:]].[[:digit:]]{1,4})-$,-\\1,temp)) #or as.numeric(gsub(^([[:digit:]]..*{1,4})-$,-\\1,temp)) #or as.numeric(gsub(^(.*.[[:digit:]]{1,4})-$,-\\1,temp)) A.K. - Original Message - From: PIKAL Petr

[R] R-package FunctSNP

2012-08-21 Thread ltrotta
Hy everyone, I am new in R so I will pose a simple question that I cannot find out reading tutorials. I would like to install the R-package FunctSNP by file.zip because it´s in the archive (http://ftp.sunet.se/pub/lang/CRAN/src/contrib/Archive/FunctSNP/) but It doesn´t work, I think some

Re: [R] irregular splits in dataframe

2012-08-21 Thread arun
Hi, Slight modification to my earlier code to make it more simple. dat1 - readLines(textConnection(Granitic Hills 16-20 PZ  Loamy Upland 16-20 PZ  Sandy Loam Upland 12-16 PZ / Sandy Loam, Deep 12-16 PZ  Loamy Upland 12-16 PZ / Sandy Loam Upland 12-16 PZ  Loamy Upland 16-20 PZ))

Re: [R] Entering a table

2012-08-21 Thread Noia Raindrops
Try this: table(nDeaths = rep(0:4, c(109, 65, 22, 3, 1))) ## or as.table(array(c(109L, 65L, 22L, 3L, 1L), dimnames = list(nDeaths = 0:4))) -- Noia Raindrops noia.raindr...@gmail.com __ R-help@r-project.org mailing list

Re: [R] Trace values in the function ca.jo()

2012-08-21 Thread Michael Weylandt
This is somewhat technical and I'd advise you post to R-Sig-Finance and cc the package maintainer, Dr Pfaff, directly. Use maintainer(urca) to get his email. Cheers, Michael On Aug 21, 2012, at 4:48 AM, Rmillan emiln_leifs...@hotmail.com wrote: Hi all R users, I'm trying to replicate the

Re: [R] Changing line length in Sweave output works for numeric, but not for character vectors

2012-08-21 Thread Simon Kiss
Hi: I'm not sure how to do 1, but I also tried strwrap() and that worked OK. Although it's not pretty. But it'll do. Simon On 2012-08-20, at 5:52 PM, Yihui Xie wrote: Two possible solutions: 1. Redefine the LaTeX environment so it allows wrapping (see listings for example); 2. Manually

Re: [R] reexpr transform nonumeric values to numeric

2012-08-21 Thread PIKAL Petr
Thanks I new that gsub shall be involved somehow, but the key is to use backreference -\\1. Regards Petr -Original Message- From: arun [mailto:smartpink...@yahoo.com] Sent: Tuesday, August 21, 2012 2:51 PM To: PIKAL Petr Cc: R help Subject: Re: [R] reexpr transform nonumeric

Re: [R] Entering a table

2012-08-21 Thread Thomas
I've no idea why, but both seemed to work perfectly. I'll work through the help files to see if I can figure it out. Thank you! Thomas On 21 Aug 2012, at 14:03, Noia Raindrops wrote: Try this: table(nDeaths = rep(0:4, c(109, 65, 22, 3, 1))) ## or as.table(array(c(109L, 65L, 22L, 3L, 1L),

[R] define subset argument for function lm as variable?

2012-08-21 Thread Rainer M Krug
Hi I want to do a series of linear models, and would like to define the input arguments for lm() as variables. I managed easily to define the formula arguments in a variable, but I also would like to have the subset in a variable. My reasoning is, that I have the subset in the results object.

Re: [R] define subset argument for function lm as variable?

2012-08-21 Thread Joshua Wiley
Hi Rainer, You could try: subs - expression(dead==FALSE recTreat==FALSE) lme(formula, subset = eval(subs)) Not tested, but something along those lines should work. Cheers, Josh On Tue, Aug 21, 2012 at 7:44 AM, Rainer M Krug r.m.k...@gmail.com wrote: Hi I want to do a series of linear

Re: [R] define subset argument for function lm as variable?

2012-08-21 Thread Bert Gunter
?? I do not groc what you mean. ... subset == subs would work fine in your lm call. So unless someone else does get it, you may need to elaborate. In general, ?substitute, ?bquote, and ?quote are useful to avoid immediate evaluation of calls, but I don't know if that's relevant to what you want

[R] Error: ReadItem: unknown type 98, perhaps written by later version of R

2012-08-21 Thread Aldi Kraja
Hi, I am running a large number of jobs (thousands) in parallel (linux OS 64bit), R version 2.14.1 (2011-12-22), Platform: x86_64-redhat-linux-gnu (64-bit). Up to yesterday everything ran fine with jobs in several blocks (block1, block2 etc) of submission. They are sent to an LSF platform to

Re: [R] define subset argument for function lm as variable?

2012-08-21 Thread Rainer M Krug
On 21/08/12 16:57, Bert Gunter wrote: ?? I do not groc what you mean. ... subset == subs would work fine in your lm call. So unless someone else does get it, you may need to elaborate. OK - here is an example: dat - data.frame( ctl =

Re: [R] define subset argument for function lm as variable?

2012-08-21 Thread Eik Vettorazzi
Hi Rainer, I got an error while replicating your data.frame construction. But this worked for me ctl = c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt = c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) dat - data.frame( group = gl(2,10,20, labels=c(Ctl,Trt)), weight =

Re: [R] Inserting superscripts in free-format text line

2012-08-21 Thread Brian Kriegler
All of these suggestions are great. Let me add one other dimension. Suppose I want to add curly quotations, italicize, underline, or bold some of the words. I can get this to work: plot(-15:15,15:-15, pch=NA) text(x=0, y=5,

[R] Fwd: Re: R-package FunctSNP

2012-08-21 Thread ltrotta
- Messaggio inoltrato da ltro...@mappi.helsinki.fi - Data: Tue, 21 Aug 2012 17:13:34 +0300 Da: ltro...@mappi.helsinki.fi Oggetto: Re: [R] R-package FunctSNP A: Steve Friedman skfgla...@gmail.com Cc: r-help@r-project.org I did it, but It can´t find the library.

Re: [R] Unable to reference variable created in dataframe

2012-08-21 Thread slavrenz
Wow, sometimes writing it all out does really help to see the issue. I now see that I need to run the log command before splitting my data into a subset, or it won't see the newly created variable. My code now runs without issue. Thanks for everyone who took the time to read this and/or help. I

Re: [R] define subset argument for function lm as variable?

2012-08-21 Thread Rainer M Krug
On 21/08/12 17:35, Eik Vettorazzi wrote: Hi Rainer, I got an error while replicating your data.frame construction. But this worked for me ctl = c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt = c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) dat - data.frame( group = gl(2,10,20,

Re: [R] R-package FunctSNP

2012-08-21 Thread Steve Friedman
Did you download the zip file to your computer? Next install from zip file. On Aug 21, 2012 9:06 AM, ltro...@mappi.helsinki.fi wrote: Hy everyone, I am new in R so I will pose a simple question that I cannot find out reading tutorials. I would like to install the R-package FunctSNP by

Re: [R] Unable to reference variable created in dataframe

2012-08-21 Thread slavrenz
That simple code works for me as well, but for some reason my actual code still isn't working. Here is exactly what I'm doing: - The code for importing my data is: /Bridges = read.csv(file = C:/R/Bridges.RData.csv, head=TRUE, sep=,)/ - Within my group of highway bridges, I have defined a

Re: [R] define subset argument for function lm as variable?

2012-08-21 Thread Joshua Wiley
What is wrong with what I suggested initially? subst - expression(trt 0) lm(weight ~ group, data=dat, subset=eval(subst)) ?? On Tue, Aug 21, 2012 at 8:41 AM, Rainer M Krug r.m.k...@gmail.com wrote: On 21/08/12 17:35, Eik Vettorazzi wrote: Hi Rainer, I got an error while replicating your

[R] apply question

2012-08-21 Thread Chet Seligman
This works, where zz is a dataframe: for(i in 1:nrow(zz)) { zzz[i,1]-paste(zz[i,1],zz[i,2],sep=_) } I would like to use apply to concatentate two columns of text along with a separator. How? Chet [[alternative HTML version deleted]]

Re: [R] define subset argument for function lm as variable?

2012-08-21 Thread Rainer M Krug
On 21/08/12 17:54, Joshua Wiley wrote: What is wrong with what I suggested initially? subst - expression(trt 0) lm(weight ~ group, data=dat, subset=eval(subst)) That it does not work? ctl = c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt =

Re: [R] define subset argument for function lm as variable?

2012-08-21 Thread Eik Vettorazzi
Josh's solution should be fine. just one more note, trt0 may not work as intended since trt is a factor in your example. Just check subset(dat,trt0) wich is just 'dat'. Am 21.08.2012 17:41, schrieb Rainer M Krug: On 21/08/12 17:35, Eik Vettorazzi wrote: Hi Rainer, I got an error while

Re: [R] define subset argument for function lm as variable?

2012-08-21 Thread Rainer M Krug
Sorry - it is working as suggested by Joshua. Thanks a lot and sorry for the horrible confusion and examples, Rainer On 21/08/12 18:12, Rainer M Krug wrote: On 21/08/12 17:54, Joshua Wiley wrote: What is wrong with what I suggested initially? subst - expression(trt 0) lm(weight ~ group,

Re: [R] apply question

2012-08-21 Thread Jeff Newmiller
What is wrong with utilizing the vectorized nature of paste? zz[[1]] - paste(zz[[1]],zz[[2]],sep=_) --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics:

Re: [R] apply question

2012-08-21 Thread R. Michael Weylandt
You don't need loops or apply with paste since it's vectorized: x - data.frame(n = 1:5, l = letters[1:5], stringsAsFactors = FALSE) paste(x[,1], x[,2], sep = _) Cheers, Michael On Tue, Aug 21, 2012 at 10:57 AM, Chet Seligman chet.selig...@gmail.com wrote: This works, where zz is a dataframe:

Re: [R] apply question

2012-08-21 Thread Bert Gunter
... or using the handy with() with(x,paste(n,l,sep=_)) Slightly greater clarity and robustness, perhaps... -- Bert On Tue, Aug 21, 2012 at 9:24 AM, R. Michael Weylandt michael.weyla...@gmail.com wrote: You don't need loops or apply with paste since it's vectorized: x - data.frame(n = 1:5, l

Re: [R] patchDVI: how to pass encoding of the .Rnw file?

2012-08-21 Thread Duncan Murdoch
On 12-08-19 3:47 PM, Marius Hofert wrote: Dear Duncan, I recently asked a question concerning patchDVI on r-help, see , | https://stat.ethz.ch/pipermail/r-help/2012-August/321780.html ` Unfortunately, no one could help. I was wondering if you know a solution to the above problem. Any

Re: [R] Inserting superscripts in free-format text line

2012-08-21 Thread Peter Ehlers
On 2012-08-21 08:28, Brian Kriegler wrote: All of these suggestions are great. Let me add one other dimension. Suppose I want to add curly quotations, italicize, underline, or bold some of the words. I can get this to work: plot(-15:15,15:-15, pch=NA) text(x=0, y=5,

[R] Sequence detection longer than a certain value

2012-08-21 Thread inti luna
Hello, I have 2 variable: one is an id sequence from 1:1000 and the other is variable with real values VI from -15.0 to 20.0 and I want to detect id values that have indicator values less than a certain threshold, for example (x=1) BUT that are in sequence equal or longer than 5. For instance,

[R] ncdf - writing variable to a file

2012-08-21 Thread m p
Hello, I have a problem writing a variable to an existing file. Below is a part of my script and how it fails. I can't find create.var.ncdf in help Thanks for any help. Mark nc - open.ncdf(ncname, readunlim=FALSE, write=TRUE ) missing - 1.e+30 xdim - nc$dim[[west_east]] ydim -

Re: [R] Sequence detection longer than a certain value

2012-08-21 Thread Bert Gunter
z - rle(VI1) gets you most of the way there. ?rle will tell you what z is so that you can then use it to go the rest of the way. -- Bert On Tue, Aug 21, 2012 at 10:54 AM, inti luna ilunal...@gmail.com wrote: Hello, I have 2 variable: one is an id sequence from 1:1000 and the other is

Re: [R] Sequence detection longer than a certain value

2012-08-21 Thread Rui Barradas
Hello, Try the following d - read.table(text= id VI 1 -10 2 -4 3 5 4 -2 5 -5 6 -3 7 -2 8 -1 9 4 10 8 , header = TRUE) fun - function(n, thres){ r - rle(!d$VI thres) inx - which(!r$values r$lengths = n) csum - cumsum(r$lengths) from - ifelse(inx == 1, 1, csum[inx - 1] +

Re: [R] Sequence detection longer than a certain value

2012-08-21 Thread Bert Gunter
Rui: It's much simpler than you propose, which is why I left it to the OP. Just use the results of rle to create a logical vector to index id. For example, the solution for the OP's example becomes : (d is the data frame containing id and VI) with(d,{ + z - rle(VI 1) + vals - with(z,values

Re: [R] ncdf - writing variable to a file

2012-08-21 Thread Peter Ehlers
On 2012-08-21 11:02, m p wrote: Hello, I have a problem writing a variable to an existing file. Below is a part of my script and how it fails. I can't find create.var.ncdf in help You probably want 'create.ncdf'. Peter Ehlers Thanks for any help. Mark nc - open.ncdf(ncname,

[R] Retrieve autocorrelation-corrected errors from gls (nlme) or gamm (mgcv)

2012-08-21 Thread Daniel Malter
Hi, In the example below, I am modeling the dependent variable Y as a function of X when the errors are autoregressive at the first lag. There is a number of ways/functions with which to model this. arima (tseries), gls (nlme), and gamm should produce similar results in the simulated example

[R] Sweave: R chunk inside caption?

2012-08-21 Thread Alexander Shenkin
Hi Folks, I'm surprised, but I didn't find this question addressed anywhere. I'd like to generate a LaTeX caption with R code. I've tried the code below, but I get the following TeX error: ! Argument of \@caption has an extra }. inserted text \par l.21 } Any thoughts? Perhaps

Re: [R] Sequence detection longer than a certain value

2012-08-21 Thread inti luna
Thanks a lot, it works very well! Inti 2012/8/21 Rui Barradas ruipbarra...@sapo.pt Hello, Try the following d - read.table(text= id VI 1 -10 2 -4 3 5 4 -2 5 -5 6 -3 7 -2 8 -1 9 4 10 8 , header = TRUE) fun - function(n, thres){ r - rle(!d$VI thres) inx -

[R] Regular Expressions in grep

2012-08-21 Thread Dr. Holger van Lishaut
Dear r-help members, I have a number in the form of a string, say: a--01020.909200 I'd like to extract 1020. as well as .9092 Front-grep(pattern=[1-9]+[0-9]*\\., value=TRUE, x=a, fixed=FALSE) End-grep(pattern=\\.[0-9]*[1-9]+, value=TRUE, x=a, fixed=FALSE) However, both strings give

Re: [R] Sweave: R chunk inside caption?

2012-08-21 Thread Marc Schwartz
On Aug 21, 2012, at 2:03 PM, Alexander Shenkin ashen...@ufl.edu wrote: Hi Folks, I'm surprised, but I didn't find this question addressed anywhere. I'd like to generate a LaTeX caption with R code. I've tried the code below, but I get the following TeX error: ! Argument of \@caption

Re: [R] Regular Expressions in grep

2012-08-21 Thread Bert Gunter
grep() returns the matches. You want regexpr() and regmatches() -- Bert On Tue, Aug 21, 2012 at 12:24 PM, Dr. Holger van Lishaut h.v.lish...@gmx.de wrote: Dear r-help members, I have a number in the form of a string, say: a--01020.909200 I'd like to extract 1020. as well as .9092

Re: [R] Regular Expressions in grep

2012-08-21 Thread Noia Raindrops
'grep' does not change strings. Use 'gsub' or 'regmatches': # gsub Front - gsub(^.*?([1-9][0-9]*\\.).*?$, \\1, a) End - gsub(^.*?(\\.[0-9]*[1-9]).*?$, \\1, a) # regexpr and regmatches (R = 2.14.0) Front - regmatches(a, regexpr([1-9][0-9]*\\., a)) End - regmatches(a, regexpr(\\.[0-9]*[1-9], a))

Re: [R] Regular Expressions in grep

2012-08-21 Thread R. Michael Weylandt
You're misreading the docs: from grep, value: if ‘FALSE’, a vector containing the (‘integer’) indices of the matches determined by ‘grep’ is returned, and if ‘TRUE’, a vector containing the matching elements themselves is returned. Since there's a match somewhere

Re: [R] Sweave: R chunk inside caption?

2012-08-21 Thread Yihui Xie
This is a LaTeX question. I'll be surprised if \caption{} allows arbitrary LaTeX environments inside it. Perhaps it is irrelevant, but you can make it more compact with the fig.cap option in knitr; see an example at https://github.com/yihui/knitr-examples/blob/master/019-fig-caption.Rnw

[R] make check fails two tests on RHEL 6 build

2012-08-21 Thread Bennet Fauber
I am installing R 2.15.1 onto RHEL 6, using gcc 4.7.0 with Intel MKL 10.3.7 and the following environment: export BLAS_LIBS=-Wl,--start-group /usr/caen/intel-12.1/mkl/lib/intel64/libmkl_gf_lp64.a /usr/caen/intel-12.1/mkl/lib/intel64/libmkl_sequential.a

[R] About matrix manipulation

2012-08-21 Thread Thiago Gonçalves-Souza
Dear list, I'm trying to create a matrix by combining the sites that species occur in a new matrix with species as rows and sites as columns. The main matrix is mat: mat - as.data.frame(cbind(sp1=c(rep(0, 5), rep(1, 5)),sp2=sample(c(rep(0, 6),rep(1, 4))), fac=c(rep(a, 3), rep(b, 3),rep(c, 4

Re: [R] Cox Proportional Hazards

2012-08-21 Thread David Winsemius
On Aug 21, 2012, at 3:40 AM, Nanthinee Jeevanandam wrote: I have run this model for my data set on insect survival time for different temperature treatments in R. I understand the Wald statistic reports on whether the variable makes a difference to the model but there is also a p-value so i am

[R] Estimating and predicting using segmented Package

2012-08-21 Thread Yunkai Huang
Hello, Any one who can help me with the problems regrarding segmented regression. 1.When I run the code as following: library(segmented) n -100 S-200 x1 - seq(-0.99,0.99,length=29) MSEPtrm-matrix(0,S,1) MAEtrm-matrix(0,S,1) TRM-matrix(0,S,length(x1)) for (s in seq(1:S)){ set.seed(123*s+123)

[R] R CMD build error with data files

2012-08-21 Thread Christian Hennig
Dear list, I want to update my prabclus package which I haven't done for quite a while. In the previous version, I had .dat files in my data subdirectory, which I read using .R files. Now R CMD check gives me a warning that .dat files are no longer accepted there. So I changed my

Re: [R] make check fails two tests on RHEL 6 build

2012-08-21 Thread Bennet Fauber
As a follow-up to my prior post, if I remove --with-blas --with-lapack, then the stats test passes: ... Testing examples for package ‘stats’ comparing ‘stats-Ex.Rout’ to ‘stats-Ex.Rout.save’ ... OK ... Perhaps this is now a question about building R with the Intel MKL libraries instead of one

[R] Combining imputed datasets for analysis using Factor Analysis

2012-08-21 Thread Conrad Zygmont
Dear R users and developers, I have a dataset containing 34 variables measured in a survey, which has some missing items. I would like to conduct a factor analysis of this data. I tested mi, Amelia, and MissForest as alternative packages in order to impute the missing data. I now have 5

Re: [R] make check fails two tests on RHEL 6 build

2012-08-21 Thread Marc Schwartz
On Aug 21, 2012, at 3:39 PM, Bennet Fauber ben...@umich.edu wrote: As a follow-up to my prior post, if I remove --with-blas --with-lapack, then the stats test passes: ... Testing examples for package ‘stats’ comparing ‘stats-Ex.Rout’ to ‘stats-Ex.Rout.save’ ... OK ... Perhaps this is

Re: [R] About matrix manipulation

2012-08-21 Thread Rui Barradas
Hello, Try the following. library(reshape2) # Don't need 'cbind' mat - data.frame(sp1=c(rep(0, 5), rep(1, 5)), sp2=sample(c(rep(0, 6),rep(1, 4))), fac=c(rep(a, 3), rep(b, 3), rep(c, 4))) mat.new - matrix (c(0, 1, 1, 1, 1, 1), nrow=2, ncol=3) rownames(mat.new) - c(sp1, sp2)

[R] (Slight) calculation discrepancy in escalc (metafor package)

2012-08-21 Thread Stephen Ban
Hello, I recently started using the metafor package (version 1.6-0) in R (2.15.1, 64-bit Windows 7) and noticed that I was getting slightly different values when I manually calculated the standardized mean difference versus what escalc was giving me. Here's a very simple example:

[R] Irregular splits in dataframe

2012-08-21 Thread Sapana Lohani
Hello, Re framing my previous question, my dataframe (Soil Type) looks something like below. I want the code to find / first and split the string into 2 or 3 depending on the number of /. I don't want to specify the number of columns after split. How can I do that ? Granitic Hills 16-20 PZ

Re: [R] Regular Expressions in grep

2012-08-21 Thread arun
HI, Try this: gsub(^-\\d(\\d{4}.).*,\\1,a) #[1] 1020. gsub(^.*(.\\d{5}).,\\1,a) #[1] .90920 A.K. - Original Message - From: Dr. Holger van Lishaut h.v.lish...@gmx.de To: r-help@r-project.org r-help@r-project.org Cc: Sent: Tuesday, August 21, 2012 3:24 PM Subject: [R] Regular

Re: [R] Inserting superscripts in free-format text line

2012-08-21 Thread David Winsemius
On Aug 21, 2012, at 10:39 AM, Peter Ehlers wrote: On 2012-08-21 08:28, Brian Kriegler wrote: All of these suggestions are great. Let me add one other dimension. Suppose I want to add curly quotations, italicize, underline, or bold some of the words. I can get this to work:

Re: [R] Irregular splits in dataframe

2012-08-21 Thread David Winsemius
On Aug 21, 2012, at 3:24 PM, Sapana Lohani wrote: Hello, Re framing my previous question, my dataframe (Soil Type) looks something like below. I want the code to find / first and split the string into 2 or 3 depending on the number of /. I don't want to specify the number of columns

Re: [R] (Slight) calculation discrepancy in escalc (metafor package)

2012-08-21 Thread Viechtbauer Wolfgang (STAT)
The pooled standard deviation is calculated exactly how you describe it. There are, however, two differences between your approach and the way escalc() computes the SMD and corresponding sampling variance: 1) Instead of the equation for approximating the correction factor (J), escalc() uses

Re: [R] make check fails two tests on RHEL 6 build

2012-08-21 Thread Prof Brian Ripley
On 21/08/2012 22:46, Marc Schwartz wrote: On Aug 21, 2012, at 3:39 PM, Bennet Fauber ben...@umich.edu wrote: As a follow-up to my prior post, if I remove --with-blas --with-lapack, then the stats test passes: ... Testing examples for package ‘stats’ comparing ‘stats-Ex.Rout’ to