search for: colsplit

Displaying 17 results from an estimated 17 matches for "colsplit".

2012 Sep 27
4
Colsplit, removing parts of a string
Hi, I am using colsplit (package = reshape) to split all strings in a column according to the same patterns. Here an example: library(reshape2) df1 <- data.frame(x=c("str1_name2", "str3_name5")) df2 <- data.frame(df1, colsplit(df1$x, pattern = "_", names=c("str","name&...
2008 Jun 13
1
help with colsplit (reshape)
...1 1 10 103 5.1 5 -1 1 1 10 104 6.1 6 -2 1 0 11 105 Using Hadley's JSS article "Reshaping Data with the reshape Package" as a guide, I tried the following: M.Data <- melt(Data, id="pid") M.Data2 <- cbind(M.Data, colsplit(M.Data$variable, split = ".", names = c("treatment", "time"))) but this gave a warning and resulted in head(M.Data2) pid variable value treatment time NA. NA..1 NA..2 NA..3 NA..4 1 1 predA -1 NA NA NA NA NA NA NA 2 2 predA -...
2012 May 05
2
creating a new column assigning values of other columns
...,"secs","act")) xlig <- read.table("lig.txt", sep = ',', col.names=c("ok","time","secs","lig")) w<- merge(xact, xlig, by = c("time" ,"secs"), all = TRUE, sort=F) require(reshape) z <- cbind(w, colsplit(w$time, split=" ", names=c("date", "clock"))) zh<-cbind(z, colsplit(z$clock, split=":", names=c("h","m","s"))) zhd<- cbind(zh, colsplit(zh$date, split="/", names=c("d","mo","y"))) nig...
2012 Apr 30
1
Subtract days to dates in POSIXct format
Hello, I'm having problems working with date values in POSIXct format. Here is what I got (eg.lig attached): x <- read.table("eg.txt", sep = ',', col.names=c("ok","time","secs","lig")) # it gives time as factor z <- cbind(x,colsplit(x$time, split="\\s", names=c("date", "clock"))) zh<-cbind(z,colsplit(z$clock,split=":",names=c("h","m","s"))) zn <- subset(zh, zh$lig<= 5 & zh$h<8?|?zh$h>=22) # nighttime zn$timepos<-as.POSIXct(zn$time,tz=&q...
2009 Jul 20
2
data frame from list of lists with unequal lengths
...;, c("D", "E", "F"), "A", "C", : arguments imply differing number of rows: 1, 2, 3 How can I create a data frame from the unequal length vectors that result from strsplit(my.df$v1)? Am I going about this the wrong way? I have also tried to use colsplit{reshape} without success. Thank you for any advice you can offer. I hope the answer to this question is not too obvious.
2013 Mar 11
0
splitting column into two
...645,94,+,10 ?chr1,565369,565404,565371 565372,217,+,8 ?chr1,565463,565541,565480 565481,1214,+,15 ?chr1,565653,565697,565662 565663,1031,+,28 ?chr1,565861,565922,565883 565884,316,+,12 ",sep=",",header=TRUE,stringsAsFactors=FALSE) library(reshape2) dat2<-with(dat1,{cbind(dat1[,-4],colsplit(V4,pattern=" ",names=c("peak_start","peak_end")))}) ?dat2 #???? V1???? V2???? V3?? V5 V6? V7 peak_start peak_end #1? chr1 564563 564598 1336? + 134???? 564588?? 564589 #2? chr1 564620 564649?? 94? +? 10???? 564644?? 564645 #3? chr1 565369 565404? 217? +?? 8???? 565371?...
2011 Oct 25
2
extract data for specific levels factor
Dear all, I'm trying to analyze data with the following structure: ind cat tx age 40.2 por fol peq vh 35 41.9 por fol med vh 35 68.9 por fol preov vh 35 71.5 por fol peq ser 37 67.5 por fol med ser 37 76.9 por fol preov ser 37 78.7 por fol peq otr 37 78.3 por fol med otr 37 82.1 por fol
2010 Oct 26
4
divide column in a dataframe based on a character
Hello, If I have a dataframe: example(data.frame) zz<-c("aa_bb","bb_cc","cc_dd","dd_ee","ee_ff","ff_gg","gg_hh","ii_jj","jj_kk","kk_ll") ddd <- cbind(dd, group = zz) and I want to divide the column named group by the "_", how would I do this? so instead of the first row being x
2011 Aug 27
1
Overdispersed GLM
Hi all, I have the following data: rep1_treat rep2_treat rep1_control rep2_control 2 3 4 5 100 20 98 54 0 1 2 3 23 32 27
2011 Oct 06
3
Wide to long form conversion
I have some data 'myData' in wide form (attached at the end), and would like to convert it to long form. I wish to have five variables in the result: 1) Subj: factor 2) Group: between-subjects factor (2 levels: s / w) 3) Reference: within-subject factor (2 levels: Me / She) 4) F: within-subject factor (2 levels: F1 / F2) 5) J: within-subject factor (2 levels: J1 / J2) As this is the
2008 May 19
1
reshape a wide data frame from wide to a long format with metadata columns
Hello R users and developers, I have a general question about reshaping a wide data frame using the "reshape" command. I have a data frame consisting of 108 columns that I would like to convert to a long table and remove the metadata (embedded in the column names of the wide table) to new metadata columns in the long format. #example data frame. NOTE column names contain metadata::
2011 May 22
2
Convert dataframe with two factors from wide to long format
I know how to convert a simple dataframe from wide to long format with one varying factor. However, for a dataset with two factors like the following, Subj T1_Cond1 T1_Cond2 T2_Cond1 T2_Cond2 1 0.125869 4.108232 1.099392 5.556614 2 1.427940 2.170026 0.120748 1.176353 How to elegantly convert to a long form as Subj Time Cond Value 1 1 1 0.125869 1
2012 Jul 21
4
rhsape2 bug?
All, I believe I am running the latest version of rshape2 (1.2.1). But this code: library(reshape2) tmp <- melt(smiths, id.vars=1:2, measure.vars=c("age","weight","height"), variable.name="myvars", value.name="myvals" ) names(tmp) Produces this output: > names(tmp) [1] "subject" "time"
2010 Jul 19
3
Reshaping data
Dear All, I have some data in the following shape: ID begin_t1 end_t1 begin_t2 end_t2 Thomas 11/03/04 13/05/06 04/02/07 16/05/08 ... ... ... ... ... Jens 24/01/02 23/05/03 07/06/03 14/11/05 I would like to reshape this data to have the following form: ID Begin_Time End_Time Thomas 11/03/04 13/05/06 Thomas 04/02/07 16/05/08 ... ... ... Jens 24/01/02 23/05/03 Jens
2009 Sep 25
7
Spliting columns, strings or reg exp returning substrings
Currently as the first column in a data frame I have string values in the format xx_yy - I want to create a new column with just the substring xx (for each row in turn). Three possible ways to do this might be (1) split the string by '_' using strsplit and paste the first of the resulting variables into a new column, but I have been unable to do this for each row of my data frame in turn
2011 Jan 20
4
How to reshape wide format data.frame to long format?
Dear list, I need to convert this data.frame > names(codesM) [1] "key" "AMR.pa1.M" "AMR.pa2.M" "AMR.pa3.M" "AMR.pa4.M" [6] "AMR.pa5.M" "AMR.pa6.M" "AMR.pa7.M" "AMR.pa8.M" "AMR.pa9.M" [11] "AMR.pa10.M" "AMR.ta1.M" "AMR.ta2.M" "AMR.ta3.M"
2012 Jun 28
6
Help
Dear all, I need some help on plotting multiple boxplots on one figure. I have three matrix A, B and C. Each of them is a 1000 by 10 matrix. The 10 columns of all three matrix correspond to the 10 values of the same parameter, say k=1, ..., 10. I want to make a plot where x axis represents different values of k. For each k value, I want to plot three boxplots, one on top of another. For