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

2016-04-29 Thread Carl Sutton via R-help
Thank you Bill Dunlap.  So simple I never tried that approach. Tried dozens of others though, read manuals till I was getting headaches, and of course the answer was simple when one is competent.   Learning, its a struggle, but slowly getting there. Thanks again  Carl Sutton CPA On Friday

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

2016-04-29 Thread Giorgio Garziano
Hi, I was able to replicate the solution as suggested by William in case of data.frame class, not in case of data.table class. In case of data.table, I had to do some minor changes as shown below. library(data.table) a <- 1:10 b <- c("a","b","c","d","e","f","g","h","i","j") c <- seq(1.1, .2, len

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

2016-04-29 Thread William Dunlap via R-help
> dt1[ vapply(dt1, FUN=is.numeric, FUN.VALUE=NA) ] a c 1 1 1.1 2 2 1.0 ... 10 10 0.2 Bill Dunlap TIBCO Software wdunlap tibco.com On Fri, Apr 29, 2016 at 9:19 AM, Carl Sutton via R-help < r-help@r-project.org> wrote: > Good morning RGuru's > I have a data frame of 575 columns. I wan

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

2016-04-29 Thread Carl Sutton via R-help
Good morning RGuru's I have a data frame of 575 columns.  I want to extract only those columns that are numeric(double) or integer to do some machine learning with.  I have searched the web for a couple of days (off and on) and have not found anything that shows how to do this.   Lots of ways to

Re: [R] selecting columns based on partial names

2014-06-19 Thread Chris Dolanc
Thank you. That worked. On 19-Jun-2014 3:24 PM, Uwe Ligges wrote: On 19.06.2014 23:50, Chris Dolanc wrote: Hello, I have a data frame with > 5000 columns and I'd like to be able to make subsets of that data frame made up of certain columns by using part of the column names. I've had a surpri

Re: [R] selecting columns based on partial names

2014-06-19 Thread Jim Lemon
On Thu, 19 Jun 2014 02:50:20 PM Chris Dolanc wrote: > Hello, > > I have a data frame with > 5000 columns and I'd like to be able to make > subsets of that data frame made up of certain columns by using part of > the column names. I've had a surprisingly hard time finding something > that works

Re: [R] selecting columns based on partial names

2014-06-19 Thread Uwe Ligges
On 19.06.2014 23:50, Chris Dolanc wrote: Hello, I have a data frame with > 5000 columns and I'd like to be able to make subsets of that data frame made up of certain columns by using part of the column names. I've had a surprisingly hard time finding something that works by searching online.

[R] selecting columns based on partial names

2014-06-19 Thread Chris Dolanc
Hello, I have a data frame with > 5000 columns and I'd like to be able to make subsets of that data frame made up of certain columns by using part of the column names. I've had a surprisingly hard time finding something that works by searching online. For example, lets say I have a data fram

Re: [R] Selecting columns whose names contain "mutated" except when they also contain "non" or "un"

2012-04-27 Thread Paul Miller
Greg Snow <538...@gmail.com> > Subject: Re: [R] Selecting columns whose names contain "mutated" except when > they also contain "non" or "un" > To: "Paul Miller" > Cc: r-help@r-project.org > Received: Thursday, April 26, 2012, 1:55 PM > S

Re: [R] Selecting columns whose names contain "mutated" except when they also contain "non" or "un"

2012-04-27 Thread Martin Maechler
> David Winsemius > on Mon, 23 Apr 2012 12:16:39 -0400 writes: > On Apr 23, 2012, at 12:10 PM, Paul Miller wrote: >> Hello All, >> >> Started out awhile ago trying to select columns in a >> dataframe whose names contain some variation of the word >> "mutant"

Re: [R] Selecting columns whose names contain "mutated" except when they also contain "non" or "un"

2012-04-26 Thread Greg Snow
Sorry I took so long getting back to this, but the paying job needs to take priority. The regular expression "(? wrote: > Hi Greg, > > This is quite helpful. Not so good yet with regular expressions in general or > Perl-like regular expressions. Found the help page though, and think I was > able

Re: [R] Selecting columns whose names contain "mutated" except when they also contain "non" or "un"

2012-04-25 Thread peter dalgaard
On Apr 24, 2012, at 19:15 , Rui Barradas wrote: > > Has anyone realized that both 'non' and 'un' end with the same letter? The > only one we really need to check? > > (tmp <- c('mutation','nonmutated','unmutated','verymutated','other')) > > i1 <- grepl("muta", tmp) > i2 <- grepl("nmuta", tmp)

Re: [R] Selecting columns whose names contain "mutated" except when they also contain "non" or "un"

2012-04-25 Thread Paul Miller
Hello Dr. Winsemius, There was a non-numeric column. Thanks for helping me to see the obvious. Paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guid

Re: [R] Selecting columns whose names contain "mutated" except when they also contain "non" or "un"

2012-04-24 Thread Rui Barradas
Hello, Greg Snow wrote > > Here is a method that uses negative look behind: > >> tmp <- c('mutation','nonmutated','unmutated','verymutated','other') >> grep("(? [1] 1 4 > > it looks for muta that is not immediatly preceeded by un or non (but > it would matc

Re: [R] Selecting columns whose names contain "mutated" except when they also contain "non" or "un"

2012-04-24 Thread David Winsemius
On Apr 24, 2012, at 9:40 AM, Paul Miller wrote: Hi Greg, This is quite helpful. Not so good yet with regular expressions in general or Perl-like regular expressions. Found the help page though, and think I was able to determine how the code works as well as how I would select only instan

Re: [R] Selecting columns whose names contain "mutated" except when they also contain "non" or "un"

2012-04-24 Thread Paul Miller
Hi Greg, This is quite helpful. Not so good yet with regular expressions in general or Perl-like regular expressions. Found the help page though, and think I was able to determine how the code works as well as how I would select only instances where "muta" is preceeded by either "non" or "un".

Re: [R] Selecting columns whose names contain "mutated" except when they also contain "non" or "un"

2012-04-23 Thread Greg Snow
Here is a method that uses negative look behind: > tmp <- c('mutation','nonmutated','unmutated','verymutated','other') > grep("(? wrote: > Hello All, > > Started out awhile ago trying to select columns in a dataframe whose names > contain some variation of the word "mutant" using code like: > > n

Re: [R] Selecting columns whose names contain "mutated" except when they also contain "non" or "un"

2012-04-23 Thread Paul Miller
Hi Bert, Yes, code like: x <- names(yourdataframe) grepl("muta",x) & !grepl("nonmuta|unmuta",x) works perfectly. Thanks very much for your help. Paul --- On Mon, 4/23/12, Bert Gunter wrote: > From: Bert Gunter > Subject: Re: [R] Selecting columns who

Re: [R] Selecting columns whose names contain "mutated" except when they also contain "non" or "un"

2012-04-23 Thread Bert Gunter
, > > Paul > > > --- On Mon, 4/23/12, David Winsemius wrote: > >> From: David Winsemius >> Subject: Re: [R] Selecting columns whose names contain "mutated" except when >> they also contain "non" or "un" >> To: "Paul Mil

Re: [R] Selecting columns whose names contain "mutated" except when they also contain "non" or "un"

2012-04-23 Thread David Winsemius
x27;t you? -- David. Thanks, Paul --- On Mon, 4/23/12, David Winsemius wrote: From: David Winsemius Subject: Re: [R] Selecting columns whose names contain "mutated" except when they also contain "non" or "un" To: "Paul Miller" Cc: r-help@r-project.

Re: [R] Selecting columns whose names contain "mutated" except when they also contain "non" or "un"

2012-04-23 Thread Bert Gunter
Below. -- Bert On Mon, Apr 23, 2012 at 9:10 AM, Paul Miller wrote: > Hello All, > > Started out awhile ago trying to select columns in a dataframe whose names > contain some variation of the word "mutant" using code like: > > names(KRASyn)[grep("muta", names(KRASyn))] > > The idea then would be

Re: [R] Selecting columns whose names contain "mutated" except when they also contain "non" or "un"

2012-04-23 Thread Paul Miller
Hello Dr. Winsemius, Unfortunately, I also have terms like "krasmutated". So simply selecting words that start with "muta" won't work in this case. Thanks, Paul --- On Mon, 4/23/12, David Winsemius wrote: > From: David Winsemius > Subject: Re: [R] Select

Re: [R] Selecting columns whose names contain "mutated" except when they also contain "non" or "un"

2012-04-23 Thread David Winsemius
On Apr 23, 2012, at 12:10 PM, Paul Miller wrote: Hello All, Started out awhile ago trying to select columns in a dataframe whose names contain some variation of the word "mutant" using code like: names(KRASyn)[grep("muta", names(KRASyn))] The idea then would be to add together the various

[R] Selecting columns whose names contain "mutated" except when they also contain "non" or "un"

2012-04-23 Thread Paul Miller
Hello All, Started out awhile ago trying to select columns in a dataframe whose names contain some variation of the word "mutant" using code like: names(KRASyn)[grep("muta", names(KRASyn))] The idea then would be to add together the various columns using code like: KRASyn$Mutant_comb <- rowSum

Re: [R] selecting columns

2011-02-15 Thread Phil Spector
Clayton - From your explanation, it sounds like you want to create a new file removing the "Location" variable, and all the variables that have the string "Ambient" or "Name" in their names. Suppose that your data frame is called mydata, and you wish to create a reduced csv file called "myda

[R] selecting columns

2011-02-15 Thread Clayton Dorrity
I need help. I have very big .csv files with many unnecessary columns. From the original .csv files I would like to create a new .csv file with just the columns I need. For example: The original column heading are: Date, Time, Location, Sensor Name, Sensor Serial, Ambient Temp, IR Temp, Sensor

Re: [R] selecting columns based on values of two variables

2009-09-06 Thread Dimitris Rizopoulos
probably you're looking for subset(capdist, ida %in% c("DEN","SWD","FIN") & idb %in% c("DEN","SWD","FIN")) I hope it helps. Best, Dimitris Thomas Jensen wrote: Dear R-list, I am having troubles selecting rows from a very large data-set containing distances between capitals. The struc

[R] selecting columns based on values of two variables

2009-09-06 Thread Thomas Jensen
Dear R-list, I am having troubles selecting rows from a very large data-set containing distances between capitals. The structure of the data-set looks like this: numaida numbidb kmdist midist 12 USA 20 CAN 731