search for: col3

Displaying 20 results from an estimated 194 matches for "col3".

Did you mean: col
2006 Mar 16
3
Did I use "step" function correctly? (Is R's step() function reliable?)
Hi all, I put up an exhaustive model to use R's "step" function: ------------------------ mygam=gam(col1 ~ 1 + col2 + col3 + col4 + col2 ^ 2 + col3 ^ 2 + col4 ^ 2 + col2 ^ 3 + col3 ^ 3 + col4 ^ 3 + s(col2, 1) + s(col3, 1) + s(col4, 1) + s(col2, 2) + s(col3, 2) + s(col4, 2) + s(col2, 3) + s(col3, 3) + s(col4, 3) + s(col2, 4) + s(col3, 4) + s(col4, 4) + s(col2, 5) + s(col3, 5) + s(col4, 5) + s(col2, 6) + s(col3, 6) +...
2018 Feb 25
3
include
Thank you Jim, I read the data as you suggested but I could not find K1 in col1. rbind(preval,mydat) Col1 Col2 col3 1 <NA> <NA> <NA> 2 X1 <NA> <NA> 3 Y1 <NA> <NA> 4 K2 <NA> <NA> 5 W1 <NA> <NA> 6 Z1 K1 K2 7 Z2 <NA> <NA> 8 Z3 X1 <NA> 9 Z4 Y1 W1 On Sat, Feb 24, 2018 at 6:18 PM, Jim Lemon <drjimlemon a...
2018 Feb 25
0
include
Hi Val, My fault - I assumed that the NA would be first in the result produced by "unique": mydat <- read.table(textConnection("Col1 Col2 col3 Z1 K1 K2 Z2 NA NA Z3 X1 NA Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE) val23<-unique(unlist(mydat[,c("Col2","col3")])) napos<-which(is.na(val23)) preval<-data.frame(Col1=val23[-napos], Col2=NA,col3=NA) mydat<-rbind(preval,mydat) mydat[is.na(mydat)]<-&qu...
2018 Feb 25
2
include
HI Jim and all, I want to put one more condition. Include col2 and col3 if they are not in col1. Here is the data mydat <- read.table(textConnection("Col1 Col2 col3 K2 X1 NA Z1 K1 K2 Z2 NA NA Z3 X1 NA Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE) The desired out put would be Col1 Col2 col3 1 X1 0 0 2 K1 0 0 3 Y1 0 0 4...
2018 Feb 25
2
include
Sorry , I hit the send key accidentally here is my complete message. Thank you Jim and all, I got it. I have one more question on the original question What does this "[-1] " do? preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3")]))[-1], Col2=NA,col3=NA) mydat <- read.table(textConnection("Col1 Col2 col3 Z1 K1 K2 Z2 NA NA Z3 X1 NA Z4 Y1 W1"),header = TRUE) preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3")]))[-1], Col2=NA,col3=NA)...
2018 Feb 25
0
include
...problems so we can help you work on your specific weaknesses and become self-sufficient? -- Sent from my phone. Please excuse my brevity. On February 25, 2018 7:55:55 AM PST, Val <valkremk at gmail.com> wrote: >HI Jim and all, > >I want to put one more condition. Include col2 and col3 if they are >not >in col1. > >Here is the data >mydat <- read.table(textConnection("Col1 Col2 col3 >K2 X1 NA >Z1 K1 K2 >Z2 NA NA >Z3 X1 NA >Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE) > >The desired out put would be > > Col1 Col2 col3 &gt...
2018 Feb 25
0
include
hi Val, Your problem seems to be that the data are read in as a factor. The simplest way I can think of to get around this is: mydat <- read.table(textConnection("Col1 Col2 col3 Z1 K1 K2 Z2 NA NA Z3 X1 NA Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE) preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3")]))[-1], Col2=NA,col3=NA) rbind(preval,mydat) mydat[is.na(mydat)]<-"0" Jiim On Sun, Feb 25, 2018 at 11:05 AM, Val &lt...
2013 Jan 11
3
split & rbind (cast) dataframe
Hi, I would like to split dataframe based on one colum and want to connect the two dataframes by rows (like rbind). Here a small example: # The orgininal dataframe df1 <- data.frame(col1 = c("A","A","B","B"),col2 = c(1:4), col3 = c(1:4)) # The datafame how it could look like df2 <- data.frame(A.col2 = c(1,2), A.col3 = c(1,2), B.col2 = c(3,4), B.col3 = c(3,4)) I think I already did a similar procedure sometime ago with the cast() command from reshape-package but I cant remember correctly... ...maybe someone can point...
2010 Oct 11
2
Split rows depending on time frame
Hi, I have the following data frame, where col2 is a startdate and col3 an enddate COL1 COL2 COL3 A 40462 40482 B 40462 40478 The above timeframe of 3 weeks I would like to splits it in weeks like this COL1 COL2 COL3 COL4 A 40462 40468 1 A 40469 40475 1 A...
2018 Feb 24
0
include
Thank you Jim and all, I got it. I have one more question on the original question What does this "[-1] " do? preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3")]))[-1], Col2=NA,col3=NA) mydat <- read.table(textConnection("Col1 Col2 col3 Z1 K1 K2 Z2 NA NA Z3 X1 NA Z4 Y1 W1"),header = TRUE) preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3")]))[-1], Col2=NA,col3=NA)...
2018 Feb 24
3
include
...;> >> why I am getting this? >> >> >> On Sat, Feb 24, 2018 at 12:17 AM, Jim Lemon <drjimlemon at gmail.com> wrote: >> >>> Hi Val, >>> Try this: >>> >>> preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3")]))[-1], >>> Col2=NA,col3=NA) >>> rbind(preval,mydat) >>> >>> Jim >>> >>> On Sat, Feb 24, 2018 at 3:34 PM, Val <valkremk at gmail.com> wrote: >>>> Hi All, >>>> >>>> I am reading a file as follow,...
2013 Jun 11
1
mapply on multiple data frames
Hi all- I am wondering about using the mapply function to multiple data frames. Specifically, I would like to do a t-test on a subset of multiple data frames. All data frames have the same structure. Here is my code so far: f<-function(x,y) { test<-t.test(x$col1[x$col3=="num",],v$col2[x$col3=="num",],paired=T,alternative="greater") out<-test$p.value return(out) } all_nums<-list(num1,num2,num3,num4) all_dfs<-list(df1,df2,df3,df4) mapply(f,all_dfs,all_nums) This tells me that $ operator is invalid for atomic vectors. I h...
2018 Feb 24
2
include
Hi All, I am reading a file as follow, mydat <- read.table(textConnection("Col1 Col2 col3 Z2 NA NA Z3 X1 NA Z4 Y1 W1"),header = TRUE) 1. "NA" are missing should be replace by 0 2. value that are in COl2 and Col3 should be included in col1 before they appear in col2 and col3. So the output data looks like as follow, X1 0 0 Y1 0 0 W1 0 0 Z2 0 0 Z3 X1 0 Z4 Y...
2010 Jul 26
4
using string variable as order() function argument
Hello, In my script I would like to use a loop, which sorts the dataframe according to different columns, pointed by the string variable. id col1 col2 col3 1 10 0 4 8 2 11 1 2 2 3 12 0 8 3 4 13 0 5 5 Usually the order() function can be used like this: sorted = mytable**[order(column3) , ] which results in properly sorted table: ** id col1 col2 col3 2 11 1 2 2 3 12 0 8...
2010 Jul 24
2
union data in column
Is there any function/way to merge/unite the following data GENEID col1 col2 col3 col4 G234064 1 0 0 0 G234064 1 0 0 0 G234064 1 0 0 0 G234064 0 1 0...
2017 Jun 21
4
selecting dataframe columns based on substring of col name(s)
Suppose I have the following sort of dataframe, where each column name has a common structure: prefix, followed by a number (for this example, col1, col2, col3 and col4): d = data.frame( col1=runif(10), col2=runif(10), col3=runif(10),col4=runif(10)) What I haven't been able to suss out is how to efficiently 'extract/manipulate/play with' columns from the data frame, making use of this common structure. Suppose, for example, I want to &...
2012 Mar 19
5
Output formatting in Latex and R
I am working on Latex and R and using following code. <<echo=FALSE>>= infile<-read.table("test.txt",sep="\t") Col3 <- unique(infile[,3]) LCol3 <- length(Col3) for (i in 1:LCol3) { print(paste("Column", Col3[i])) print(infile[infile[,3]==Col3[i],-3]) } @ I am getting following output. 1] "Column C" V1 V2 V4 1 A B D 2 X T K [1] "Column Z" V1 V2 V4 3 Z U M 4 E V R 5 Z U M [...
2008 Aug 20
3
vector operation using regexpr?
...strings. The first columns is a simple character. I want to get the index of that character in the second column and use it to extract the item from the third column. I can do this using a scalar method. But I'm not finding a vector method. An example is below. col1 col2 col3 'L' 'MAIL ' 'PLOY' What I want to do with the above is find the index of col1 in col2 (4) and then use it to extract the character from col3 ('Y'). I could do the last part if I could get the index in a vector fashion. So, the shorter question is, ho...
2006 Dec 14
5
Better way to change the name of a column in a dataframe?
...7 [2,] 6 8 4 10 7 1 [3,] 7 5 1 3 1 8 [4,] 10 6 5 4 9 2 and I want to correct or otherwise change the name of one of the columns, I can do so with > dimnames(frame)[[2]][which(dimnames(frame)[[2]]=="cmlo3")] <- "col3" which renames the offending column: > frame col1 col2 col3 col4 col5 col6 [1,] 3 10 2 6 5 7 [2,] 6 8 4 10 7 1 [3,] 7 5 1 3 1 8 [4,] 10 6 5 4 9 2 This seems cumbersome and not very intuitive. How can...
2018 Feb 24
2
include
...nique(preval),mydat) x2 <- x1[is.na(x1)] <- 0 x2 but I got this, [1] 0 why I am getting this? On Sat, Feb 24, 2018 at 12:17 AM, Jim Lemon <drjimlemon at gmail.com> wrote: > Hi Val, > Try this: > > preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3")]))[-1], > Col2=NA,col3=NA) > rbind(preval,mydat) > > Jim > > On Sat, Feb 24, 2018 at 3:34 PM, Val <valkremk at gmail.com> wrote: > > Hi All, > > > > I am reading a file as follow, > > > > mydat <- read.table(textConnection("Col1...