Re: [R] Regex: Combining sub/grepl with ifelse

2015-10-09 Thread Boris Steipe
David answered most of this. Just a two short notes inline. On Oct 10, 2015, at 12:38 AM, Omar André Gonzáles Díaz wrote: > David, Boris, so thankfull for your help. Both approaches are very good. I > got this solve with David's help. > > I find very insteresting Bori's for loop. And I ne

[R] Construct a lower-triangular matrix

2015-10-09 Thread Steven Yen
Dear How do you construct a lower triangular matrix from a vector. I want to make vector a <- 1:10 into a triangular matrix 1 0 0 0 2 3 0 0 4 5 6 0 7 8 9 10 Thank you! [[alternative HTML version deleted]] __ R-help@r-project.org mailing

Re: [R] Regex: Combining sub/grepl with ifelse

2015-10-09 Thread David Winsemius
On Oct 9, 2015, at 9:38 PM, Omar André Gonzáles Díaz wrote: > David, Boris, so thankfull for your help. Both approaches are very good. I > got this solve with David's help. > > I find very insteresting Bori's for loop. And I need a little help > understanding the regex part on it. > > - The

Re: [R] Regex: Combining sub/grepl with ifelse

2015-10-09 Thread Omar André Gonzáles Díaz
David, Boris, so thankfull for your help. Both approaches are very good. I got this solve with David's help. I find very insteresting Bori's for loop. And I need a little help understanding the regex part on it. - The strsplit function: strsplit(ripley.tv$producto[i], "[^A-Z0-9-]+") I understand

[R] Problem with binomial gam{mgcv}

2015-10-09 Thread Erin Conlisk
Hello, I am having trouble testing for the significance using a binomial model in gam{mgcv}. Have I stumbled on a bug? I doubt I would be so lucky, so could someone tell me what I am doing wrong? Please see the following code: # PROBLEM USING cbind x1 <- runif

Re: [R] Regex: Combining sub/grepl with ifelse

2015-10-09 Thread David Winsemius
On Oct 9, 2015, at 4:21 PM, Boris Steipe wrote: > I think you are going into the wrong direction here and this is a classical > example of what we mean by "technical debt" of code. Rather than tell to your > regular expression what you are looking for, you are handling special cases > with red

Re: [R] [FORGED] Re: R lappy, sapply or mapply question

2015-10-09 Thread Rolf Turner
On 10/10/15 10:56, Adams, Jean wrote: You were very close. Try this. df <- data.frame(x5=dailyrecord$a, x6 = dailyrecord$e, x7 = dailyrecord$f) apply(df, 1, function(row) fun3(list1, list2, as.list(row))) There could in general be problems with this approach. The apply() function works on

Re: [R] Regex: Combining sub/grepl with ifelse

2015-10-09 Thread Boris Steipe
I think you are going into the wrong direction here and this is a classical example of what we mean by "technical debt" of code. Rather than tell to your regular expression what you are looking for, you are handling special cases with redundant code. This is ugly, brittle and impossible to maint

Re: [R] Regex: Combining sub/grepl with ifelse

2015-10-09 Thread David Winsemius
On Oct 9, 2015, at 2:48 PM, Omar André Gonzáles Díaz wrote: > Thank you, David. You put me in the right direction. > > At the end, I've used a lot of lines, to my taste, for this task. > > Is there a more elegant way, of doing this? There are conditional capture-classes in rexex in addition t

Re: [R] Help with color.scale {plotrix}

2015-10-09 Thread Kumar Mainali
Sarah, what you suggested solved the problem. Below is the code: cellcol[x<0.33 & !is.na(x)] <- color.scale(x[x<0.33 & !is.na(x)], c(1,1),c(0,1),c(0,1), xrange=c(0,0.33)) Including xrange in color.scale function makes a slight difference in my plot. I want to use the same scale to many matrices s

Re: [R] Help with color.scale {plotrix}

2015-10-09 Thread Sarah Goslee
This is the error message: > > Error in cellcol[x < 0.33] <- color.scale(x[x < 0.33], c(1, 0.8), c(0, : > > NAs are not allowed in subscripted assignments x has NA values, but is being used for subscripting. either use cellcol[!is.na(x) & x < 0.33] or specify a NA value for color.scale() an

Re: [R] R lappy, sapply or mapply question

2015-10-09 Thread Adams, Jean
You were very close. Try this. df <- data.frame(x5=dailyrecord$a, x6 = dailyrecord$e, x7 = dailyrecord$f) apply(df, 1, function(row) fun3(list1, list2, as.list(row))) Jean On Fri, Oct 9, 2015 at 3:15 PM, liqunhan--- via R-help wrote: > > > Hello, R-experts, > In R-program, I have a question a

Re: [R] Regex: Combining sub/grepl with ifelse

2015-10-09 Thread Omar André Gonzáles Díaz
Thank you, David. You put me in the right direction. At the end, I've used a lot of lines, to my taste, for this task. Is there a more elegant way, of doing this? ripley.tv$id <- sub("(.*)( [0-9]{2}[a-z]{1}[0-9]{4})(.*)", "\\2", ripley.tv$producto, ignore

Re: [R] Help with color.scale {plotrix}

2015-10-09 Thread William Dunlap
Try setting the na.color argument of color.scale to a color string, not NA. "#" (alpha = 0 is the key part) is transparent so it it might suit your needs. Bill Dunlap TIBCO Software wdunlap tibco.com On Fri, Oct 9, 2015 at 12:26 PM, Kumar Mainali wrote: > Hi Sarah, > > Thanks for the e

Re: [R] Regex: Combining sub/grepl with ifelse

2015-10-09 Thread David Winsemius
On Oct 9, 2015, at 1:50 PM, Omar André Gonzáles Díaz wrote: > David, > > this is a working case. I know that all cases for ID are not covered with my > current code. > > The question is: > > ID stars as NAs. > > 1.- How to extract 1 type of ID, and keep the rest of entries as they are. >

[R] Reformatting dataframe for use with icc()

2015-10-09 Thread Chad Danyluck
Hello, I want to determine the inter-rater reliability of ratings made from a random selection of observers and observations. I plan to use the irr package to calculate the ICC, however, my dataframe is not organized in a way that the icc() function can handle. The icc() function works with datafr

Re: [R] Regex: Combining sub/grepl with ifelse

2015-10-09 Thread Omar André Gonzáles Díaz
David, this is a working case. I know that all cases for ID are not covered with my current code. The question is: ID stars as NAs. 1.- How to extract 1 type of ID, and keep the rest of entries as they are. 2.- Then keep the first extraction, and search for second type of ID. 3.- An so on wit

Re: [R] How to install packages without internet

2015-10-09 Thread FERNANDO MANSITO CABALLERO
Thank you very much David. I will also follow your advice. I think polynom was finally successfully installed from source without mentioning it in the call under type.. Fernando On Thu, Oct 8, 2015 at 7:53 PM, David Winsemius wrote: > > On Oct 8, 2015, at 7:29 AM, Sarah Goslee wrote: > > > Don

[R] R lappy, sapply or mapply question

2015-10-09 Thread liqunhan--- via R-help
Hello, R-experts, In R-program, I have a question about the apply-family. I want to use apply-family to replace a for-loop in my R-code,But, lapply returns a list of 3 (each component is the same), sapply returns a matrix, and mapply with error message. how to use apply-family function so that

[R] for loop not working

2015-10-09 Thread mnw
Hi. I have some code which loops through raw GPS data. This initial loop calculates distance, angle, speed etc between successive coordinates as well as type of movement e.g.left, right, forward. I want to construct a second loop that goes through the movements and records 'Changes' as either '0' o

Re: [R] Attaching a pdf file to an email generated with sendmailR?

2015-10-09 Thread Michael Ashton
I seem to be able to get sendmailR to work with a text file, and maybe html is the same way...I tried this with a Pdf file and it didn't seem to work. But I will try again to be sure. Thanks for the suggestion. > On Oct 9, 2015, at 7:55 AM, Bos, Roger wrote: > > Michael, > > I use sendmailR t

[R] Time series in spatial regression model (spautolm)

2015-10-09 Thread Tobias Rüttenauer
Dear r-sig-geo team, I started working with spatial analysis some month ago, so I'm quite new (and unknowing ) in this field. However, my aim is to connect time series analysis with spatial analysis, what seems to be quite difficult (to me). The dataset I am working with a spatial polygons data f

Re: [R] Regex: Combining sub/grepl with ifelse

2015-10-09 Thread David Winsemius
On Oct 9, 2015, at 12:59 PM, Omar André Gonzáles Díaz wrote: > I need to extract an ID from the product column of my df. > > I was able to extract the ids for some scenearios, but when applying my > code for the next type of ids (there are some other combinations), the > results of my first line

Re: [R] Why can I reset directory in using setwd on desktop but not on laptop

2015-10-09 Thread WRAY NICHOLAS
> -- Original Message -- > From: WRAY NICHOLAS > To: peter dalgaard > Date: 09 October 2015 at 21:33 > Subject: Re: [R] Why can I reset directory in using setwd on desktop but > not on laptop > > > Thanks for your questions Peter > > Both machines are P

Re: [R] Help with color.scale {plotrix}

2015-10-09 Thread Sarah Goslee
Presumably you need something like cellcol[x < 0.33 & !is.na(x)] just as the error message suggests. I don't think it's a color.scale issue. On Oct 9, 2015 3:27 PM, "Kumar Mainali" wrote: > Hi Sarah, > > Thanks for the explanation. This solves my first problem. I hope somebody > will be able to a

[R] Regex: Combining sub/grepl with ifelse

2015-10-09 Thread Omar André Gonzáles Díaz
I need to extract an ID from the product column of my df. I was able to extract the ids for some scenearios, but when applying my code for the next type of ids (there are some other combinations), the results of my first line of code got NAs. ripley.tv$id <- sub("(.*)( [0-9]{2}[a-z]{1}[0-9]{4})(

Re: [R] Why can I reset directory in using setwd on desktop but not on laptop

2015-10-09 Thread peter dalgaard
> On 09 Oct 2015, at 17:58 , WRAY NICHOLAS wrote: > > Thanks Sarah I didn't realise that there was a distinction between between > asking about R per se and asking about r-studio... I shall try specifying the > path and see whether that helps Thanks, Nick The key part of the story is not ne

Re: [R] Help with color.scale {plotrix}

2015-10-09 Thread Kumar Mainali
Hi Sarah, Thanks for the explanation. This solves my first problem. I hope somebody will be able to answer my second question. Copied here from previous email >> Another question: some of my matrices have missing cells and I do not want to assign any colors to the missing cells. The following cod

Re: [R] regex - extracting 2 numbers and " from strings

2015-10-09 Thread Omar André Gonzáles Díaz
Yes, you are right. Thank you. 2015-10-08 20:07 GMT-05:00 David Winsemius : > > On Oct 8, 2015, at 4:50 PM, Omar André Gonzáles Díaz wrote: > > > David, it does work but not in all cases: > > It should work if you change the "+" to "*" in the last capture class. It > makes trailing non-digit cha

Re: [R] importing spss files without value labels

2015-10-09 Thread David Winsemius
On Oct 9, 2015, at 9:19 AM, Yongnam Kim wrote: > Hi all, > > I know how to import spss data file (.sav) to R using foreign pkg like > read.spss(file, use.value.labels = FALSE,...) but I like to use a different > pkg, in particular, memisc. Is there any corresponding way to drop the > value label

[R] importing spss files without value labels

2015-10-09 Thread Yongnam Kim
Hi all, I know how to import spss data file (.sav) to R using foreign pkg like read.spss(file, use.value.labels = FALSE,...) but I like to use a different pkg, in particular, memisc. Is there any corresponding way to drop the value labels when importing? Many thanks, [[alternative HTML v

Re: [R] Why can I reset directory in using setwd on desktop but not on laptop

2015-10-09 Thread Sarah Goslee
On Fri, Oct 9, 2015 at 11:58 AM, WRAY NICHOLAS wrote: > Thanks Sarah I didn't realise that there was a distinction between between > asking about R per se and asking about r-studio... I shall try specifying > the path and see whether that helps Thanks, Nick Yes, R-Studio is a commercial produ

[R] Revolutions blog: September 2015 roundup

2015-10-09 Thread David Smith
Since 2008, Revolution Analytics (and now Microsoft) staff and guests have written about R every weekday at the Revolutions blog: http://blog.revolutionanalytics.com and every month I post a summary of articles from the previous month of particular interest to readers of r-help. In case you mi

Re: [R] Why can I reset directory in using setwd on desktop but not on laptop

2015-10-09 Thread WRAY NICHOLAS
Thanks Sarah I didn't realise that there was a distinction between between asking about R per se and asking about r-studio... I shall try specifying the path and see whether that helps Thanks, Nick > > On 09 October 2015 at 16:51 Sarah Goslee wrote: > > > Sounds like an RStudio que

Re: [R] Why can I reset directory in using setwd on desktop but not on laptop

2015-10-09 Thread Sarah Goslee
Sounds like an RStudio question to me. Someone might be able to help, but this mailing list is for R. You should also provide sessionInfo() output when asking potentially OS-related questions. You can always specify path as part of the write.csv() or other output command; you don't need to change

Re: [R] Help with color.scale {plotrix}

2015-10-09 Thread Sarah Goslee
Hi Kumar, You're overthinking it: in RGB, colorspace, cs1 is red, cs2 is green, cs3 is blue. So if cs1=c(1,1),cs2=(c(0,1),cs3=0 (or c(0,0) because of R's recycling) the first color in the sequence is c(1, 0, 0) or red ##FF and the second color is c(1, 1, 0) #00 or yellow. Sarah On Fri,

[R] Why can I reset directory in using setwd on desktop but not on laptop

2015-10-09 Thread WRAY NICHOLAS
Hi I am running the same r routine on both my desktop and my laptop, and writing results in the form of csv files into storage folders in the respective users/documents files of both machines My desktop machine allows me to reset the directory in the course of the r programme so that I can write

Re: [R] Help with color.scale {plotrix}

2015-10-09 Thread Kumar Mainali
Hi Jim, Thank you! Your color code does work. I still do not understand how red to yellow in RGB space translates to cs1=c(1,1),cs2=(c(0,1),cs3=0. In other words, I have RGB values for red and yellow. How do I go from there to the code you sent? Another question: some of my matrices have missing

Re: [R] Attaching a pdf file to an email generated with sendmailR?

2015-10-09 Thread Bos, Roger
Michael, I use sendmailR to attached a file to an email and it does work. I remember there was something non-intuitive when I was figuring it out. I use both the attachPath and the attachName. The attachPath has the full path including the filename and the attachName just has the filename.

Re: [R] Help with color.scale {plotrix}

2015-10-09 Thread Jim Lemon
Hi Kumar, The color.scale function translates numeric values into one or more intervals of color by a linear transformation into the numeric values that specify colors. One of three color spaces (rgb, hcl and hsv) can be specified, and the endpoints can be specified as "extremes=c(," or as three ve

Re: [R] [FORGED] How to remove the grid around the plot(ca(...)) function?

2015-10-09 Thread Luca Meyer
That worked just fine. Thanks Paul! Luca 2015-10-09 0:11 GMT+02:00 Paul Murrell : > Hi > > The plot.ca() function contains explicit calls to axis(), box(), and > abline(), so, for example, ... > > plot(ca(d1), mass = c(TRUE,FALSE), xlab="", ylab="", axes=FALSE) > > ... does not work. > > One o

Re: [R] Smoth matplot

2015-10-09 Thread Jim Lemon
Hi bgnumis, This is definitely a guess at what you want to do: flatbat<-read.table(text="100.0 100.0 100.0 100.0 100. 100.0 100.0 100.0 100.54163 99.23893 100.77238 98.95058 100.2250 99.18830 100.18801 101.10791 99.61230 102.12813 99.34499 97.52805 101.8252

Re: [R] Help using "replicate()" for two commands

2015-10-09 Thread peter dalgaard
A set of curlies should help. As in > replicate(5, {y <- runif(20); mean(y)}) [1] 0.4926800 0.5356511 0.5343938 0.5313422 0.5287927 -pd BTW: sum(replicate(1,...))/1 is simpler and less error-prone written as mean(replicate(1,)) > On 09 Oct 2015, at 01:37 , Curtis Browne wrote: