Re: [R] sum some columns for each row

2015-07-14 Thread David Winsemius
On Jul 14, 2015, at 4:49 PM, Dawn wrote: > I attached the file Well, you may have attached it, but you evidently did not read the posting guide about which filetypes are accepted by the mailserver. > including the first two rows and please help to make it > the numeric data frame. Hopeful

Re: [R] sum some columns for each row

2015-07-14 Thread Dawn
I attached the file including the first two rows and please help to make it the numeric data frame. Hopefully the following command works: dcm <- rowSums(dat1[,grep("DCM",names(dat1),fixed=T)],na.rm=T) Thank you very much! Dawn On Tue, Jul 14, 2015 at 4:36 PM, Jeff Newmiller wrote: > Well it i

Re: [R] sum some columns for each row

2015-07-14 Thread Dawn
I used two rows to test the data frame, as follows. > dat <- read.table("TOV_43_Protein_Clusters_abundance1.tab", header=TRUE,sep = "\t") > dat1 <- dat[1:2,] > str(dat1) 'data.frame':2 obs. of 44 variables: $ X : Factor w/ 1075762 levels "","POV_Cluster_101",..: 305266 625028 $ X10

Re: [R] sum some columns for each row

2015-07-14 Thread Dawn
Hi, I used a small set of data (several columns and rows) and it works fine using the following command: abc <- rowSums(test[,grep("ABC",names(test),fixed=T)],na.rm=T) But when I used the real big data table, "Error in rowSums(dat[, grep("ABC", names(dat), fixed = T)], na.rm = T) : 'x' must be

Re: [R] sum some columns for each row

2015-07-14 Thread Bert Gunter
It seems that Dawn could really benefit from spending some time with an online R tutorial or two, as she appears not to have much of a clue about R's basic data structures. Cheers, Bert Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom."

Re: [R] sum some columns for each row

2015-07-14 Thread Jeff Newmiller
Well it is pretty obvious that all of your columns have non-numeric data in them, but you are the only one who can tell which ones should have been numeric, and you are also the one who can peruse your data file in a text editor. --

Re: [R] sum some columns for each row

2015-07-14 Thread Jeff Newmiller
I suspect your data frame "dat" has non-numeric data in some of the columns that have ABC in their names. Any column of a data frame can be numeric or not, but the data frame as a unit cannot be numeric. If your data file has odd characters in done of the otherwise-numeric columns, the whole col

Re: [R] sum some columns for each row

2015-07-10 Thread Dawn
Thank you all and sorry for the data messing. It has worked! Best, Dawn On Fri, Jul 10, 2015 at 4:15 AM, Jim Lemon wrote: > Hi Dawn, > Your data are a bit messed up, but try the following: > > colSums(dat[,grep("ABC",names(dat),fixed=TRUE)],na.rm=TRUE) > colSums(dat[,grep("XYZ",names(dat),fixed

Re: [R] sum some columns for each row

2015-07-10 Thread Jim Lemon
Hi Dawn, Your data are a bit messed up, but try the following: colSums(dat[,grep("ABC",names(dat),fixed=TRUE)],na.rm=TRUE) colSums(dat[,grep("XYZ",names(dat),fixed=TRUE)],na.rm=TRUE) I'm assuming that you want to discard the NA values. Jim On Fri, Jul 10, 2015 at 6:52 AM, Rui Barradas wrote: >

Re: [R] sum some columns for each row

2015-07-09 Thread Rui Barradas
Hello, Please use ?dput to give a data example, like this it's completely unreadable. If your data.frame is named 'dat' use dput(head(dat, 30)) # paste the outut of this in your mail And don't post in html, use plain text only, like the posting guide says. Rui Barradas Em 09-07-2015 18:12

Re: [R] sum some columns for each row

2015-07-09 Thread Jeff Newmiller
Please read the Posting Guide before posting again. Pay particular attention to the guidance to post using plain text. Also use the dput function to provide your sample data so we can more accurately start from where you are starting bad give more targeted answers. You can use indexing to selec

[R] sum some columns for each row

2015-07-09 Thread Dawn
Hi, I have a big dataframe as follows 109ABC109XYZ18ABC18XYZ22XYZ23ABC25ABC25XYZ 30ABC31XYZ32ABC32XYZ34DCM34XYZ36ABC36SUR 38DCM38XYZ39DCM39SUR41DCM41SUR42DCM42SUR 46SUR52DCM64ABC64XYZ65ABC