[R] Fwd: Grep command

2016-05-03 Thread Steven Yen
Hi all Both \\b and $ do the job. Thanks. > x<-c("abc","def","rst","xyz","age","age2") > x [1] "abc" "def" "rst" "xyz" "age" "age2" > grep("age2\\b",x) [1] 6 > grep("age\\b",x) [1] 5 > grep("age2$",x) [1] 6 > grep("age$",x) [1] From: Jim Lemon Date: Wed, May 4, 2016 at 2:19 AM Subject: Re:

[R] Antwort: Re: selecting columns from a data frame or data table by type, ie, numeric, integer

2016-05-03 Thread G . Maubach
Hi All, Hi Carl, I am not sure if this is useful to you, but I followed your conversation and thought of you when I read this: for (i in 1:ncol(dataset)) { if(class(dataset) == "character|numeric|factor|or whatsoever") { dataset[, i] <- as.factor(dataset[, i]) } } Source: Zumel, Nina / M

Re: [R] R column assignment fails for lists

2016-05-03 Thread Bert Gunter
This is actually a bit subtle -- you need to carefully read the Help pages to see what's happening. Here's the explanation to the best of my understanding (corrections happily accepted if I've got it wrong!). First, let's simplify: > z <- data.frame(a = 1:2, b = list(a = letters[1:2], b = letters

Re: [R] R column assignment fails for lists

2016-05-03 Thread David Winsemius
> On May 3, 2016, at 4:13 PM, Yasir Suhail wrote: > > Dear R developers and users, > > Consider the object : > >> a <- data.frame(a=c(1,2), b=c(2,3), c=c("a,b","c,d"), stringsAsFactors = F) >> a$c <- strsplit(a$c, ",") > > Re-assignment works fine for columns 1 and 2, but fails for column 3.

Re: [R] Grep command

2016-05-03 Thread Omar André Gonzáles Díaz
Hi Steven, grep uses regex... so you can use this: -grep("age$",x): it says: match "a", then "g", then "e" and stop. The "$" menas until here and no more. > grep("age$",x) [1] 5 2016-05-04 1:02 GMT-05:00 Jim Lemon : > Hi Steven, > If this is just a one-off, you could do this: > > grepl("age",

Re: [R] Grep command

2016-05-03 Thread Jim Lemon
Hi Steven, If this is just a one-off, you could do this: grepl("age",x) & nchar(x)<4 returning a logical vector containing TRUE for "age" but not "age2" Jim On Wed, May 4, 2016 at 3:45 PM, Steven Yen wrote: > Dear all > In the grep command below, is there a way to identify only "age" and > no

[R] Grep command

2016-05-03 Thread Steven Yen
Dear all In the grep command below, is there a way to identify only "age" and not "age2"? In other words, I like to greb "age" and "age2" separately, one at a time. Thanks. x<-c("abc","def","rst","xyz","age","age2") x [1] "abc" "def" "rst" "xyz" "age" "age2" grep("age2",x) [1] 6 grep("age

[R] Custom data structures inside of a hash function

2016-05-03 Thread Yves S. Garret
Hello, I have the following code: http://pastebin.ca/3590201 What I'm trying to do is to create a hash map where the key is two characters and that maps to a structure of some information. The problem with the above example is that the first two keys match to the first instance of c('hello', 0),

Re: [R] R column assignment fails for lists

2016-05-03 Thread David Winsemius
> On May 3, 2016, at 4:13 PM, Yasir Suhail wrote: > > Dear R developers and users, > > Consider the object : > >> a <- data.frame(a=c(1,2), b=c(2,3), c=c("a,b","c,d"), stringsAsFactors = F) >> a$c <- strsplit(a$c, ",") You are the one who should "consider the object". Look at what strsplit(a$

Re: [R] R column assignment fails for lists

2016-05-03 Thread Jim Lemon
Hi Yasil, If you look at what happens to a[,3] after the "strsplit" it is easy: > a[,3] [1] "a,b" "c,d" Here a[,3] is two strings a$c <- strsplit(a$c, ",") > a[,3] [[1]] [1] "a" "b" [[2]] [1] "c" "d" Now a[,3] is a two element list. What R probably did was to take the first component of a[,3]

Re: [R] Unexpected scores from weighted PCA with svyprcomp()

2016-05-03 Thread Leonardo Ferreira Fontenelle
Thanks for remembering me to cc him! Thomas Lumley is the package maintainer, and he frequently answers questions in this list, but it is obviously hard for anyone to keep up with so many emails. Att, Leonardo Ferreira Fontenelle http://lattes.cnpq.br/9234772336296638 Em Ter 3 mai. 2016, às 21

[R] R column assignment fails for lists

2016-05-03 Thread Yasir Suhail
Dear R developers and users, Consider the object : > a <- data.frame(a=c(1,2), b=c(2,3), c=c("a,b","c,d"), stringsAsFactors = F) > a$c <- strsplit(a$c, ",") Re-assignment works fine for columns 1 and 2, but fails for column 3. If a is a valid object, the assignment should work. > a[,1] <- a[,1]

Re: [R] Unexpected scores from weighted PCA with svyprcomp()

2016-05-03 Thread Jeff Newmiller
Your question is a mixture of statistical and implementation (package) issues. This isn't really the right forum for "what is the statistically-correct answer" questions, and as to whether the package is correct or you are using it right would require someone familiar with that particular CONTRI

Re: [R] 3D surface plot

2016-05-03 Thread Duncan Murdoch
On 30/04/2016 1:48 PM, T.Riedle wrote: Dear R users, I am trying to generate a 3D surface plot given the inflator formula in the attached file. Now, I want to create a 3D plot showing how Delta changes with the values of Abs(B) and sigma. The other variables in the formula are constant. Delta

Re: [R] Unexpected scores from weighted PCA with svyprcomp()

2016-05-03 Thread Leonardo Ferreira Fontenelle
Is there something I could do to improve my chances of getting an answer? Leonardo Ferreira Fontenelle http://lattes.cnpq.br/9234772336296638 Em Sex 29 abr. 2016, às 23:40, Leonardo Ferreira Fontenelle escreveu: > Hello! > > I'd like to create an assets-based economic indicator using data from a

Re: [R] row names, coulmn names

2016-05-03 Thread Greg Snow
There are some packages that add labels or other attributes (units) to columns of data frames and have methods to display the labels, units, etc. One of these packages is Hmisc, see the label and unit functions. I believe that there are other packages as well. This may provide what the original

[R] Is my simulation to compute power of a multiple ordinal logistic regression right?

2016-05-03 Thread BONACHE Adrien via R-help
Good day, I was performing a power analysis of articles published in a journal of management using the pwr package in R. However, it seemed to be impossible to compute power for small, medium and large Effect Size for multiple ordinal logistic regression output. I have tried using G*power, but i

Re: [R] grep command

2016-05-03 Thread Hervé Pagès
On 05/03/2016 06:05 AM, Jeff Newmiller wrote: Isn't that just an inefficient way to do "age" == x Yep, it's an inefficient way to do which(x == "age"). H. ? -- Hervé Pagès Program in Computational Biology Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fa

Re: [R] Reading multiple tables from one .txt doc

2016-05-03 Thread William Dunlap via R-help
The following base R code does roughly what Bert suggests. It does no checking that the data is in the format you describe. The split-by-cumsum trick is a handy idiom. # lines <- readLines(yourFile), or, for this example: lines <- c("#One","X Y Z","1 2 3","4 5 6","", "#Two", "X Y

Re: [R] Fw: Generating 3Dplot in lattice package

2016-05-03 Thread William Dunlap via R-help
See if you can use is.nan() to figure out which values of B, Bmax, ..., cause the result to be NaN (not a number). One possibility is if B were always negative so abs(B)/max(B) could be negative: (negative)^(non-integer power) is NaN. Bill Dunlap TIBCO Software wdunlap tibco.com On Tue, May 3, 2

Re: [R] Reading multiple tables from one .txt doc

2016-05-03 Thread Bert Gunter
One approach would be to use ?readLines to read the lines into a character vector. You could then use indexing to remove all the blank and header (lines beginning with "image") lines. You can now find the indices of where the separate data blocks begin (they all begin with "#", right?) and then seq

Re: [R] Fw: Generating 3Dplot in lattice package

2016-05-03 Thread David Winsemius
> On May 3, 2016, at 3:54 AM, T.Riedle wrote: > > Something is wrong here. The formula > > pmin(psi/VaR,exp(((abs(B)/Bmax)^w2)*log((psi/VaR),2.718182))) > > > provides a time series. Nevertheless, the returned values are incorrect and > it produces NANs. The only thing we can conclude at th

[R] eRum 2016 conference - call for papers

2016-05-03 Thread eRum
Dear R Users, Poznan University of Economics and Business, Poznan University of Life Sciences and Polish R Users groups are organising international conference European R Users Meeting (eRum 2016)! eRum 2016 will take place between October 12th and 14th, and we already have confirmed invited s

[R] Reading multiple tables from one .txt doc

2016-05-03 Thread Mark Fingerle
Dear all, I have a .txt file which contains multiple tables and I would like to read these tables separately in order to create graphs for each one. The tables are separated by a blank line, have a variable number of lines, fixed nr. Of rows, have a header and a comment above the header (#) which

Re: [R] grep command

2016-05-03 Thread Jeff Newmiller
Isn't that just an inefficient way to do "age" == x ? -- Sent from my phone. Please excuse my brevity. On May 3, 2016 3:57:05 AM PDT, Ivan Calandra wrote: >What about? > >grep("^age$", x) > >Ivan > >-- >Ivan Calandra, PhD >Scientific Mediator >University of Reims Champagne-Ardenne >GEGENAA -

Re: [R] grep command

2016-05-03 Thread Ivan Calandra
Oh, and regarding the moderator approval, I guess it's because you're a new user to the list. Ivan -- Ivan Calandra, PhD Scientific Mediator University of Reims Champagne-Ardenne GEGENAA - EA 3795 CREA - 2 esplanade Roland Garros 51100 Reims, France +33(0)3 26 77 36 89 ivan.calan...@univ-reims.

Re: [R] grep command

2016-05-03 Thread Ivan Calandra
What about? grep("^age$", x) Ivan -- Ivan Calandra, PhD Scientific Mediator University of Reims Champagne-Ardenne GEGENAA - EA 3795 CREA - 2 esplanade Roland Garros 51100 Reims, France +33(0)3 26 77 36 89 ivan.calan...@univ-reims.fr -- https://www.researchgate.net/profile/Ivan_Calandra https://

[R] Fw: Generating 3Dplot in lattice package

2016-05-03 Thread T.Riedle
Something is wrong here. The formula pmin(psi/VaR,exp(((abs(B)/Bmax)^w2)*log((psi/VaR),2.718182))) provides a time series. Nevertheless, the returned values are incorrect and it produces NANs. From: William Dunlap Sent: 02 May 2016 20:04 To: T.Riedle Cc: r-h

[R] grep command

2016-05-03 Thread Steven Yen
Dear all In the grep command below, is there a way to identify only "age" and not "age2"? Thanks. > x<-c("abc","def","rst","xyz","age","age2") > x [1] "abc" "def" "rst" "xyz" "age" "age2" > grep("age2",x) [1] 6 > grep("age",x) # I need to grab "age" only, not "age2" [1] 5 6 Also, I post mess

[R] R 3.3.0 is released

2016-05-03 Thread Peter Dalgaard
The build system rolled up R-3.3.0.tar.gz (codename "Supposedly Educational") this morning. The list below details the changes in this release. You can get the source code from http://cran.r-project.org/src/base/R-3/R-3.3.0.tar.gz or wait for it to be mirrored at a CRAN site nearer to you. Bi

Re: [R] Use "append" in the function write.xlsx2 or write.xlsx (openxlsx package)

2016-05-03 Thread Ivan Calandra
Not sure this is what you need or the best way to do it, but you could do something along these lines: #first create a file name that depends on which file names already exist. The big thing here is list.files() but you probably need to adapt the rest to your needs: fileNumber <- list.files(p

Re: [R] Extracting rows of a data.frame by "identical"

2016-05-03 Thread Ivan Calandra
I'm not sure what you are trying to do... Have you checked what the output of d[c("b","c")] is? And what about the output of identical(d[c("b","c")],c(4,10)) ? As is, I don't see the point of going through identical(). Maybe you're looking for which() or "%in%"? If you just want to subset th