Re: [R] Problem when creating matrix of values based on covariance matrix

2012-08-12 Thread R. Michael Weylandt
On Sun, Aug 12, 2012 at 7:52 PM, R. Michael Weylandt wrote: > I am not sure if this is a general/fixed bias in the spearman > estimator or if it's just a function of the covMat I randomly chose. > Prof. Dalgaard and many others on this list must know. To somewhat answer myself, I restricted my at

Re: [R] Direct Method Age-Adjustment to Complex Survey Data

2012-08-12 Thread Thomas Lumley
On Sat, Aug 11, 2012 at 5:53 AM, Anthony Damico wrote: > Hi everyone, my apologies in advance if I'm overlooking something simple in > this question. I am trying to use R's survey package to make a direct > method age-adjustment to some complex survey data. I have played with > postStratify, cal

Re: [R] named character question

2012-08-12 Thread Joshua Wiley
Hi Erin, The first element of the character vector is a string. You cannot extract specifically characters from a string; try something like ?nchar or perhaps better use regular expressions to extract things between commas after two characters (or whatever logical rule accurately gets the zip co

Re: [R] named character question

2012-08-12 Thread R. Michael Weylandt
It's best if you make these things available to us using dput() in the future. You're probably looking for the substr() function. Since _strings_ (not characters) in R are "primitive" (Not in the primitive/internal sense: just in the primordial sense) you can't subset them with the brackets opera

[R] compile fails with x86_64-alpine-linux-uclibc-gcc

2012-08-12 Thread nobody
hello, i am trying to build R on alpine/gentoo with uclibc and it fails with the following error msg: connections.c: In function 'Rconn_fgetc': connections.c:3184:11: error: expected identifier before '(' token connections.c:3186:15: error: expected identifier before '(' token make[3]: *** [conn

[R] named character question

2012-08-12 Thread Erin Hodgess
Dear R People: Here is a goofy question: I want to extract the zip code from an address and here is my work so far: > add1 results.formatted_address "200 W Rosamond St, Houston, TX 77076, USA" > add1[1][32:36] NA NA NA NA NA > str(add1) Named chr "200 W Rosamond

Re: [R] if else elseif for data frames

2012-08-12 Thread R. Michael Weylandt
On Sun, Aug 12, 2012 at 8:07 PM, Sachinthaka Abeywardana wrote: > The thing is I have about 10 cases. I saw the ifelse statement Note that there is no "ifelse" statement: there is only nested if/else of forms if else if else if else > but was > wondering if

Re: [R] if else elseif for data frames

2012-08-12 Thread David Winsemius
On Aug 12, 2012, at 5:43 PM, Sachinthaka Abeywardana wrote: Hi all, It seems like I cannot use normal 'if' for data frames. What would be the best way to do the following. if data$col1='high' data$col2='H' else if data$col1='Neutral' data$col2='N' else if data$col='low' data$col2='

Re: [R] if else elseif for data frames

2012-08-12 Thread Jeff Newmiller
Maybe the cut function? ?cut --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Pl

Re: [R] if else elseif for data frames

2012-08-12 Thread jim holtman
You might look at the 'recode' that is part of the 'car' package. You can also setup a dataframe with two columns; one with the current value and one with the new value you want, then you can use 'merge' or 'match' to create your new column. If you have provided some sample data, I could have pro

[R] insufficient backgrounds in linear algebra - was Simple question about formulae in R!?

2012-08-12 Thread S Ellison
> This whole discussion, of course, raises the (OT!) issue >of the widespread misuse of linear modeling by those with insufficient >background in linear algebra to understand the points S. Ellison > discusses. ... but does not necessarily claim to comprehend. There's still Peter Dalgaard's 'ortho

Re: [R] if else elseif for data frames

2012-08-12 Thread arun
Hi, Try this: dat1<-data.frame(col1=c(rep("high",3),rep("Neutral",3),rep("low",4)))  dat1$col2<-ifelse(dat1$col1=="high",dat1$col2<-"H",ifelse(dat1$col1=="Neutral",dat1$col2<-"N","L")) dat1   col1 col2 1 high    H 2 high    H 3 high    H 4  Neutral    N 5  Neutral    N 6  Neutral   

Re: [R] if else elseif for data frames

2012-08-12 Thread Sachinthaka Abeywardana
The thing is I have about 10 cases. I saw the ifelse statement but was wondering if there was a cleaner method of doing it. The coding will get really messy when I write all 10 cases. Cheers, Sachin On Mon, Aug 13, 2012 at 11:04 AM, arun wrote: > Hi, > Try this: > dat1<-data.frame(col1=c(rep("h

Re: [R] Problem when creating matrix of values based on covariance matrix

2012-08-12 Thread R. Michael Weylandt
On Sun, Aug 12, 2012 at 1:46 PM, Boel Brynedal wrote: > A clarification - yes, calculating the pearson covariance does give > the expected results. I dont fully understand why yet, but many thanks > for this help! I'm not sure that the spearman correlation is an appropriate estimator for the cova

[R] if else elseif for data frames

2012-08-12 Thread Sachinthaka Abeywardana
Hi all, It seems like I cannot use normal 'if' for data frames. What would be the best way to do the following. if data$col1='high' data$col2='H' else if data$col1='Neutral' data$col2='N' else if data$col='low' data$col2='L' else #chuch a warning? Note that col2 was not an existin

Re: [R] How to overlay a global map on a filled contour?

2012-08-12 Thread Ray Brownrigg
On 08/10/12 11:01, Cable, Sam B Civ USAF AFMC AFRL/RVBXI wrote: > Duncan, > > I agree that my second code doesn't make sense. Sorry for the red herring. > I was grasping at straws. > > My first code, however, differs from your suggestion only in that I am > asking for a rectangular projection, A

Re: [R] How to write % in pie chart?

2012-08-12 Thread jim holtman
check out the 'plotrix' package: floating.pie & pie.labels On Sun, Aug 12, 2012 at 1:00 AM, Manish Gupta wrote: > HI, > > I am plotting one pie chart and need to write % inside it. How can i write % > inside it as show in figure below. > > http://r.789695.n4.nabble.com/file/n4640078/pie_chart.png

[R] Web scrabing - getURL with delay

2012-08-12 Thread Kasper Christensen
Hi R people. Im currently trying to construct a piece of R-code that can retrieve a list of webpages I have stored as a csv file and save the content of the webpages into separate txt files. I want to retrieve a total number of 6000 threads posted at a forum, to try to build/train a classifier tha

Re: [R] translating HTML character entities to accented characters

2012-08-12 Thread David L Carlson
This may work for your needs with a little fine tuning. Special and accented characters can be represented in HTML with a character name or a numeric value. For example, " can be represented as " or as " and it appears from your example that both are used. I've attached a dput(HTMLChars) to the end

Re: [R] Using R as Shared Library

2012-08-12 Thread Thorsten Jolitz
Dirk Eddelbuettel writes: > On 12 August 2012 at 07:56, Michael Weylandt wrote: > | On Aug 12, 2012, at 6:09 AM, Thorsten Jolitz > | wrote: > | > Thorsten Jolitz writes: > | > Let me reformulate my question (since I managed to make 'native' calls > | > to C functions in libR by now): > | > I s

Re: [R] Problem when creating matrix of values based on covariance matrix

2012-08-12 Thread Boel Brynedal
A clarification - yes, calculating the pearson covariance does give the expected results. I dont fully understand why yet, but many thanks for this help! 2012/8/12 Boel Brynedal : > Thanks for these replies. > @Peter - are these methods only suitable for pearson covariances? That > would def expla

Re: [R] replacing a character string

2012-08-12 Thread David Winsemius
On Aug 10, 2012, at 7:18 AM, toehanus wrote: I am working on modifying a REDCap survey. The data dictionary column for the response field has the following value. 1, Strongly disagree | 2, Disagree | 3, Agree | 4, Strongly Agree | 5, Don't Know | 6, Refuse to Answer | 7, Not Applicable

Re: [R] Problem when creating matrix of values based on covariance matrix

2012-08-12 Thread Boel Brynedal
Thanks for these replies. @Peter - are these methods only suitable for pearson covariances? That would def explain my issues. Sorry for my ignorance, but I would highly appreciate an explanation. My original covariance matrix is calculated using spearman as well (which is suitable for the data). @M

Re: [R] Stopping all code execution when ANY error occurs (OR error handling without try/tryCatch)

2012-08-12 Thread Rui Barradas
Hello, Something like this? x <- 1:5 # vector with more than one element # warning, execution continues if(x == 2) print(2) else print("No!") ow <- options(warn = 2) # all warnings are now errors # error, else clause not executed if(x == 2) print(2) else print("No!") options(ow) # reset defa

Re: [R] replacing a character string

2012-08-12 Thread Rui Barradas
Hello, I believe I don't understand your problem. Is this your input datum? x <- "1, Strongly disagree | 2, Disagree | 3, Agree | 4, Strongly Agree | 5, Don't Know | 6, Refuse to Answer | 7, Not Applicable" If so the following will do it: (search <- paste("(", 1:7, ",)", sep = "")) (replace

Re: [R] compile fails with x86_64-alpine-linux-uclibc-gcc

2012-08-12 Thread nobody
On 11 August 2012 12:55, nobody wrote: > hello, > > i am trying to build R on alpine/gentoo and it fails with the following > error msg: > > connections.c: In function 'Rconn_fgetc': > connections.c:3184:11: error: expected identifier before '(' token > connections.c:3186:15: error: expected ident

Re: [R] choosing multiple columns

2012-08-12 Thread David Winsemius
On Aug 11, 2012, at 6:01 AM, Ista Zahn wrote: On Sat, Aug 11, 2012 at 8:51 AM, Sachinthaka Abeywardana wrote: I should have mentioned that I do not know the number index of the columns, but regardless, thanks for the responses Right, so use my first method. This does not depend on the pos

Re: [R] length of variable in mlogit

2012-08-12 Thread R. Michael Weylandt
Hi Lee, I've finally had time to look at this: If you look at ?mlogit.data you'll see that choice must be "the variable indicating the choice made: it can be either a logical vector, a numerical vector with 0 where the alternative is not chosen, a factor with level 'yes' when the alternative is

Re: [R] Using R as Shared Library

2012-08-12 Thread Dirk Eddelbuettel
On 12 August 2012 at 07:56, Michael Weylandt wrote: | On Aug 12, 2012, at 6:09 AM, Thorsten Jolitz wrote: | > Thorsten Jolitz writes: | > Let me reformulate my question (since I managed to make 'native' calls | > to C functions in libR by now): | > I still wonder whats 'in there' in libR - only

[R] Index Values in NbClust

2012-08-12 Thread eliza botto
Dear All,i applied "NbClust", to my data to find optimum number of clusters, and got following resultsNow, i don't know how to read these results. more precisely, i would like to know, how to see which method is more precise for my data considering these index values.your help is needed...thank

Re: [R] Error in if-command

2012-08-12 Thread arun
HI, Your second function works: fun2<-function(y){  if(y==2){  print("yes")}  else {print("no")}}  fun2(3) #[1] "no"  fun2(4) #[1] "no"  fun2(2) #[1] "yes" But, in the first case, it is a vector. So, you can use: fun3<-function(y){  numbers1<-c(4,5,9,11,17)  if(y %in% numbers1){  print("yes")}  

Re: [R] What's wrong with my code?

2012-08-12 Thread stephenxqy
Thanks! Date: Sun, 12 Aug 2012 07:42:12 -0700 From: ml-node+s789695n4640093...@n4.nabble.com To: stephen...@hotmail.com Subject: RE: What's wrong with my code? stephenxqy wrote Yes, missing * is the problem. Thank you a lot. Do you mean I need to incorporate all expression of Rg0sq,

Re: [R] Error in if-command

2012-08-12 Thread arun
HI, Try ifelse  fun1<-function(y){  ifelse(y==c(4,5,9,11,17),"yes","no")  } > fun1(9) #[1] "no"  "no"  "yes" "no"  "no" A.K. - Original Message - From: Dominic Roye To: r-help@r-project.org Cc: Sent: Sunday, August 12, 2012 6:12 AM Subject: [R] Error in if-command Hello everybody,

Re: [R] What's wrong with my code?

2012-08-12 Thread Berend Hasselman
stephenxqy wrote > > Yes, missing * is the problem. Thank you a lot. Do you mean I need to > incorporate all expression of Rg0sq, Rg etc. into the final Pfit function? > Not necessarily. For example in function Pexv you evaluate Rg(L,b) 5 times. You can also do this evaluating Rg(L,b) once and

Re: [R] Using R as Shared Library

2012-08-12 Thread Michael Weylandt
On Aug 12, 2012, at 6:09 AM, Thorsten Jolitz wrote: > Thorsten Jolitz writes: > > Let me reformulate my question (since I managed to make 'native' calls > to C functions in libR by now): > I still wonder whats 'in there' in libR - only the core C functions, or > all the functions written in

Re: [R] Error in if-command

2012-08-12 Thread Michael Weylandt
Take a look at ?ifelse Cheers, Michael On Aug 12, 2012, at 3:12 AM, Dominic Roye wrote: > Hello everybody, > > I don't understand what I'm doing wrong. But it isn't possible that each > element of the if-condition is tested for each vector element? > > y <- c(1:20) >> y > [1] 1 2 3 4 5

Re: [R] Changing character into date

2012-08-12 Thread Berry Boessenkool
Another helfpul function is strptime Berry -- View this message in context: http://r.789695.n4.nabble.com/Changing-character-into-date-tp4640079p4640088.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing l

Re: [R] What's wrong with my code?

2012-08-12 Thread stephenxqy
Yes, missing * is the problem. Thank you a lot. Do you mean I need to incorporate all expression of Rg0sq, Rg etc. into the final Pfit function? Qiuyang Date: Sat, 11 Aug 2012 21:18:03 -0700 From: ml-node+s789695n4640077...@n4.nabble.com To: stephen...@hotmail.com Subject: Re: What's wrong wit

Re: [R] Using R as Shared Library

2012-08-12 Thread Thorsten Jolitz
Thorsten Jolitz writes: Let me reformulate my question (since I managed to make 'native' calls to C functions in libR by now): I still wonder whats 'in there' in libR - only the core C functions, or all the functions written in R itself too? And what packages are included? -- cheers, Thorsten

[R] Error in if-command

2012-08-12 Thread Dominic Roye
Hello everybody, I don't understand what I'm doing wrong. But it isn't possible that each element of the if-condition is tested for each vector element? y <- c(1:20) > y [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 > if (y == c(4,5,9,11,17)) { print("yes") } else { print("no

Re: [R] Problem when creating matrix of values based on covariance matrix

2012-08-12 Thread peter dalgaard
On Aug 11, 2012, at 16:17 , Boel Brynedal wrote: > cov8=cov(sample8,method='spearman') There's your problem. I'm surprised that nobody seems to have picked up on this, but Spearman covariances are of the ranks, not of the data. Try method="pearson". -- Peter Dalgaard, Professor, Center for S

Re: [R] Problem when creating matrix of values based on covariance matrix

2012-08-12 Thread Michael Dewey
At 15:17 11/08/2012, Boel Brynedal wrote: Hi, I want to simulate a data set with similar covariance structure as my observed data, and have calculated a covariance matrix (dimensions 8368*8368). So far I've tried two approaches to simulating data: rmvnorm from the mvtnorm package, and by using t

[R] Different cluster orderings from cutree() and cut.dendrogram()

2012-08-12 Thread Milan Bouchet-Valat
Hi! I just discovered that cutree() and cut.dendrogram() do not assign the same cluster numberings when called on the same tree. More specifically, cutree() assigns cluster numbers by order of appearance in the data, while cut.dendrogram() sorts clusters by height (see example below). I guess this

Re: [R] Changing character into date

2012-08-12 Thread Rui Barradas
Hello, There are two or three simple ways. x <- c("2012-08-09 22:23:00", "2012-08-09 22:24:00") #1st: dates without times as.Date(x) [1] "2012-08-09" "2012-08-09" #2nd: dates and times and time zones. #Too big for axis tick marks? as.POSIXct(x) [1] "2012-08-09 22:23:00 BST" "2012-08-09 22:2

Re: [R] "Masked by GlobalEnv"

2012-08-12 Thread Uwe Ligges
On 12.08.2012 04:54, Ashok Parmar wrote: hello everyone, i am getting problems in graph plotting. When i attach file after adding color attributes in my data set. i got problem of "GlobalEnv" and masked the followings. Like this attach(machm) The following object(s) are masked _by_ '.Global

Re: [R] How to write % in pie chart?

2012-08-12 Thread Hasan Diwan
Post yer code and I'd be happy to take a look. On Aug 11, 2012 10:57 PM, "Manish Gupta" wrote: > HI, > > I am plotting one pie chart and need to write % inside it. How can i write > % > inside it as show in figure below. > > http://r.789695.n4.nabble.com/file/n4640078/pie_chart.png > > Regards >