[R] Ask for help - how to change WHIRR.117.csv to WHIRR_117.csv

2012-09-25 Thread s.s.m. fauzi
Hi,
I have a script below.

dat <- read.table(file="pt.csv", header=T, sep=",", row.names=1,
col.names=1)
dat
for(which_col in seq_len(ncol(dat)))
{
  subset_data <- dat[,which_col:ncol(dat)]
  file_name <- sprintf('%s.csv', colnames(dat)[which_col])
  write.csv(subset_data, file_name)
  message(sprintf('Saving %s', file_name))
}

dput(head(dat))

structure(list(WHIRR.25 = c(0L, 0L, 0L, 0L, 0L, 0L), WHIRR.28 = c(0L,
0L, 1L, 0L, 0L, 0L), WHIRR.55 = c(0L, 0L, 0L, 0L, 0L, 0L), WHIRR.61 = c(0L,
0L, 1L, 0L, 0L, 0L), WHIRR.76 = c(0L, 0L, 0L, 0L, 0L, 0L), WHIRR.87 = c(0L,
0L, 0L, 0L, 0L, 0L), WHIRR.92 = c(0L, 0L, 0L, 0L, 0L, 0L), WHIRR.115 =
c(0L,
0L, 0L, 0L, 0L, 0L), WHIRR.117 = c(0L, 0L, 0L, 0L, 0L, 0L)), .Names = c(
"WHIRR.25",
"WHIRR.28", "WHIRR.55", "WHIRR.61", "WHIRR.76", "WHIRR.87", "WHIRR.92",
"WHIRR.115", "WHIRR.117"), row.names = c("Adrian Cole", "Alison Wong",
"Andrei Savu", "Bruno Dumon", "Edward J. Yoon", "Eugene Koontz"
), class = "data.frame")

The script is able to save the file in the directory, but with the
following name:
WHIRR.25.csv
WHIRR.28.csv
WHIRR.55.csv
WHIRR.61.csv
WHIRR.76.csv
WHIRR.87.csv
WHIRR.92.csv
WHIRR.115.csv
WHIRR.117.csv

My first question is:
How can I change or convert the name above to WHIRR_25.csv, WHIRR_28.csv,
WHIRR_55.csv, etc?

My second question is:
The last column which is WHIRR.177.csv is not properly created, the output
for the last column is as below:

   X1
1   0
2   0
3   0
4   0
5   0
6   0
7   0
8   0
9   0
10  0
11  0
12  0
13  0
14  1
15  0

Suppose, the last column should be properly created like this, as below:

  WHIRR.117
Adrian Cole 0
Alison Wong   0
Andrei Savu0
Bruno Dumon  0
Edward J. Yoon   0
Eugene Koontz   0
Jakob Homan  0
Kelvin Kakugawa 0
Kirk True 0
Lars George0
Soren Macbeth0
Stu Hood0
Tibor Kiss   0
Tom White 1
Unassigned0

Appreciate your thought...

[[alternative HTML version deleted]]

__
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-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Write table with data in other .csv template

2012-09-25 Thread s.s.m. fauzi
Hi Jeff,
I got it...Thank you for your help!



On Wed, Sep 26, 2012 at 11:53 AM, s.s.m. fauzi  wrote:

> Hi Jeff,
> Do I need to call the .csv template to perform this operation?
>
> Shukor
>
>
> On Wed, Sep 26, 2012 at 11:50 AM, Jeff Newmiller  > wrote:
>
>> Perhaps you might try
>>
>> template[ , names(tbl) ] <- tbl
>>
>> where I have used tbl instead of table, for reasons previously mentioned.
>>
>> ---
>> Jeff NewmillerThe .   .  Go
>> Live...
>> DCN:Basics: ##.#.   ##.#.  LiveGo...
>>   Live:   OO#.. Dead: OO#..  Playing
>> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
>> /Software/Embedded Controllers)   .OO#.   .OO#.  rocks
>> ...1k
>>
>> -------
>> Sent from my phone. Please excuse my brevity.
>>
>> "s.s.m. fauzi"  wrote:
>>
>> >Hi Jeff,
>> >Thank you for the respond.
>> >
>> >I'm not really familiar with cbind.
>> >
>> >Anyway, there is a duplication in my input and the template, and I want
>> >to
>> >preserve the column order.
>> >
>> >Shukor
>> >
>> >On Wed, Sep 26, 2012 at 11:30 AM, Jeff Newmiller
>> >wrote:
>> >
>> >> Thanks for posting dput data, but I don't understand your question.
>> >>
>> >> are you familiar with cbind?
>> >> Is there duplication of column names in your input table and
>> >template? Are
>> >> they always duplicated in the template? What characteristics of the
>> >> template are you trying to preserve? Column order?
>> >>
>> >> Other:
>> >> Don't post HTML email.
>> >> The name "table" is defined in the base package, so using it as a
>> >data
>> >> name can lead to confusion and inability to perform fundamental
>> >operations.
>> >>
>>
>> >---
>> >> Jeff Newmiller    The .   .  Go
>> >Live...
>> >> DCN:Basics: ##.#.   ##.#.  Live
>> >> Go...
>> >>   Live:   OO#.. Dead: OO#..
>> >Playing
>> >> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
>> >> /Software/Embedded Controllers)   .OO#.   .OO#.
>> >rocks...1k
>> >>
>>
>> >---
>> >> Sent from my phone. Please excuse my brevity.
>> >>
>> >> "s.s.m. fauzi"  wrote:
>> >>
>> >> >Hi,
>> >> >
>> >> >I have a table with data, as below:
>> >> >
>> >> >dput(table):
>> >> >
>> >> >structure(list(Adrian.Cole = c(0L, 0L, 0L, 0L, 0L, 0L), Alison.Wong
>> >=
>> >> >c(0L, 0L, 0L, 0L, 0L, 0L), Andrei.Savu = c(0L, 0L, 0L, 0L, 0L, 0L),
>> >> >Bruno.Dumon = c(0L, 0L, 0L, 0L, 0L, 0L), Edward.J..Yoon = c(0L, 0L,
>> >0L,
>> >> >0L, 0L, 0L), Eugene.Koontz = c(0L, 0L, 0L, 0L, 0L,
>> >> >0L), Jakob.Homan = c(0L, 0L, 0L, 0L, 0L, 0L), Kelvin.Kakugawa =
>> >> >c(0L, 0L, 0L, 0L, 0L, 0L), Kirk.True = c(0L, 0L, 0L, 0L, 0L, 0L
>> >> >  ), Lars.George = c(0L, 0L, 1L, 0L, 0L, 0L), Soren.Macbeth = c(0L,
>> >0L,
>> >> >1L, 0L, 0L, 0L), Stu.Hood = c(0L, 0L, 0L, 0L, 0L, 0L),
>> >> >  Tibor.Kiss = c(0L, 0L, 0L, 0L, 0L, 0L), Tom.White = c(0L, 0L, 1L,
>> >0L,
>> >> >0L, 0L), Unassigned = c(0L, 0L, 0L, 0L, 0L, 0L
>> >> >)), .Names = c("Adrian.Cole", "Alison.Wong",
>> >> >"Andrei.Savu", "Bruno.Dumon", "Edward.J..Yoon", "Eugene.Koontz",
>> >> >"Jakob.Homan",
>> >> >"Kelvin.Kakugawa", "Kirk.True", "Lars.George", "Soren.Macbeth",
>> >> >"Stu.Hood",
>> >> >"Tibor.Kiss", "Tom.White", "Unassigned"), row.names = c("Adrian
>> >Cole",
>> >> >"Alison Wong", "Andrei Savu", "Bruno Dumon", "Edward J. Yoon

Re: [R] Write table with data in other .csv template

2012-09-25 Thread s.s.m. fauzi
Hi Jeff,
Do I need to call the .csv template to perform this operation?

Shukor

On Wed, Sep 26, 2012 at 11:50 AM, Jeff Newmiller
wrote:

> Perhaps you might try
>
> template[ , names(tbl) ] <- tbl
>
> where I have used tbl instead of table, for reasons previously mentioned.
> ---
> Jeff NewmillerThe .   .  Go Live...
> DCN:Basics: ##.#.   ##.#.  LiveGo...
>   Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
> /Software/Embedded Controllers)   .OO#.   .OO#.  rocks
> ...1k
> ---
> Sent from my phone. Please excuse my brevity.
>
> "s.s.m. fauzi"  wrote:
>
> >Hi Jeff,
> >Thank you for the respond.
> >
> >I'm not really familiar with cbind.
> >
> >Anyway, there is a duplication in my input and the template, and I want
> >to
> >preserve the column order.
> >
> >Shukor
> >
> >On Wed, Sep 26, 2012 at 11:30 AM, Jeff Newmiller
> >wrote:
> >
> >> Thanks for posting dput data, but I don't understand your question.
> >>
> >> are you familiar with cbind?
> >> Is there duplication of column names in your input table and
> >template? Are
> >> they always duplicated in the template? What characteristics of the
> >> template are you trying to preserve? Column order?
> >>
> >> Other:
> >> Don't post HTML email.
> >> The name "table" is defined in the base package, so using it as a
> >data
> >> name can lead to confusion and inability to perform fundamental
> >operations.
> >>
>
> >---
> >> Jeff NewmillerThe .   .  Go
> >Live...
> >> DCN:Basics: ##.#.   ##.#.  Live
> >> Go...
> >>   Live:   OO#.. Dead: OO#..
> >Playing
> >> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
> >> /Software/Embedded Controllers)   .OO#.   .OO#.
> >rocks...1k
> >>
>
> >---
> >> Sent from my phone. Please excuse my brevity.
> >>
> >> "s.s.m. fauzi"  wrote:
> >>
> >> >Hi,
> >> >
> >> >I have a table with data, as below:
> >> >
> >> >dput(table):
> >> >
> >> >structure(list(Adrian.Cole = c(0L, 0L, 0L, 0L, 0L, 0L), Alison.Wong
> >=
> >> >c(0L, 0L, 0L, 0L, 0L, 0L), Andrei.Savu = c(0L, 0L, 0L, 0L, 0L, 0L),
> >> >Bruno.Dumon = c(0L, 0L, 0L, 0L, 0L, 0L), Edward.J..Yoon = c(0L, 0L,
> >0L,
> >> >0L, 0L, 0L), Eugene.Koontz = c(0L, 0L, 0L, 0L, 0L,
> >> >0L), Jakob.Homan = c(0L, 0L, 0L, 0L, 0L, 0L), Kelvin.Kakugawa =
> >> >c(0L, 0L, 0L, 0L, 0L, 0L), Kirk.True = c(0L, 0L, 0L, 0L, 0L, 0L
> >> >  ), Lars.George = c(0L, 0L, 1L, 0L, 0L, 0L), Soren.Macbeth = c(0L,
> >0L,
> >> >1L, 0L, 0L, 0L), Stu.Hood = c(0L, 0L, 0L, 0L, 0L, 0L),
> >> >  Tibor.Kiss = c(0L, 0L, 0L, 0L, 0L, 0L), Tom.White = c(0L, 0L, 1L,
> >0L,
> >> >0L, 0L), Unassigned = c(0L, 0L, 0L, 0L, 0L, 0L
> >> >)), .Names = c("Adrian.Cole", "Alison.Wong",
> >> >"Andrei.Savu", "Bruno.Dumon", "Edward.J..Yoon", "Eugene.Koontz",
> >> >"Jakob.Homan",
> >> >"Kelvin.Kakugawa", "Kirk.True", "Lars.George", "Soren.Macbeth",
> >> >"Stu.Hood",
> >> >"Tibor.Kiss", "Tom.White", "Unassigned"), row.names = c("Adrian
> >Cole",
> >> >"Alison Wong", "Andrei Savu", "Bruno Dumon", "Edward J. Yoon",
> >"Eugene
> >> >Koontz"), class = "data.frame")
> >> >
> >> >> dim(table)
> >> >[1] 15 15
> >> >> names(table)
> >> >[1] "Adrian.Cole" "Alison.Wong" "Andrei.Savu"
> >"Bruno.Dumon"
> >> >"Edward.J..Yoon"  "Eugene.Koontz"   "Jakob.Homan"
> >"Kelvin.Kakugawa"
> >> > [9] "Kirk.True"

Re: [R] Write table with data in other .csv template

2012-09-25 Thread s.s.m. fauzi
Hi Jeff,
Thank you for the respond.

I'm not really familiar with cbind.

Anyway, there is a duplication in my input and the template, and I want to
preserve the column order.

Shukor

On Wed, Sep 26, 2012 at 11:30 AM, Jeff Newmiller
wrote:

> Thanks for posting dput data, but I don't understand your question.
>
> are you familiar with cbind?
> Is there duplication of column names in your input table and template? Are
> they always duplicated in the template? What characteristics of the
> template are you trying to preserve? Column order?
>
> Other:
> Don't post HTML email.
> The name "table" is defined in the base package, so using it as a data
> name can lead to confusion and inability to perform fundamental operations.
> ---
> Jeff NewmillerThe .   .  Go Live...
> DCN:Basics: ##.#.   ##.#.  Live
> Go...
>   Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
> /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
> -------
> Sent from my phone. Please excuse my brevity.
>
> "s.s.m. fauzi"  wrote:
>
> >Hi,
> >
> >I have a table with data, as below:
> >
> >dput(table):
> >
> >structure(list(Adrian.Cole = c(0L, 0L, 0L, 0L, 0L, 0L), Alison.Wong =
> >c(0L, 0L, 0L, 0L, 0L, 0L), Andrei.Savu = c(0L, 0L, 0L, 0L, 0L, 0L),
> >Bruno.Dumon = c(0L, 0L, 0L, 0L, 0L, 0L), Edward.J..Yoon = c(0L, 0L, 0L,
> >0L, 0L, 0L), Eugene.Koontz = c(0L, 0L, 0L, 0L, 0L,
> >0L), Jakob.Homan = c(0L, 0L, 0L, 0L, 0L, 0L), Kelvin.Kakugawa =
> >c(0L, 0L, 0L, 0L, 0L, 0L), Kirk.True = c(0L, 0L, 0L, 0L, 0L, 0L
> >  ), Lars.George = c(0L, 0L, 1L, 0L, 0L, 0L), Soren.Macbeth = c(0L, 0L,
> >1L, 0L, 0L, 0L), Stu.Hood = c(0L, 0L, 0L, 0L, 0L, 0L),
> >  Tibor.Kiss = c(0L, 0L, 0L, 0L, 0L, 0L), Tom.White = c(0L, 0L, 1L, 0L,
> >0L, 0L), Unassigned = c(0L, 0L, 0L, 0L, 0L, 0L
> >)), .Names = c("Adrian.Cole", "Alison.Wong",
> >"Andrei.Savu", "Bruno.Dumon", "Edward.J..Yoon", "Eugene.Koontz",
> >"Jakob.Homan",
> >"Kelvin.Kakugawa", "Kirk.True", "Lars.George", "Soren.Macbeth",
> >"Stu.Hood",
> >"Tibor.Kiss", "Tom.White", "Unassigned"), row.names = c("Adrian Cole",
> >"Alison Wong", "Andrei Savu", "Bruno Dumon", "Edward J. Yoon", "Eugene
> >Koontz"), class = "data.frame")
> >
> >> dim(table)
> >[1] 15 15
> >> names(table)
> >[1] "Adrian.Cole" "Alison.Wong" "Andrei.Savu" "Bruno.Dumon"
> >"Edward.J..Yoon"  "Eugene.Koontz"   "Jakob.Homan" "Kelvin.Kakugawa"
> > [9] "Kirk.True"   "Lars.George" "Soren.Macbeth"   "Stu.Hood"
> > "Tibor.Kiss"  "Tom.White"   "Unassigned"
> >
> >What I want to do is to embed/write this table to other big .csv
> >template,
> >and save it with other name.
> >
> >dput(template)
> >
> >structure(list(Adrian.Cole = c(0L, 0L, 0L, 0L, 0L, 0L), Alison.Wong =
> >c(0L, 0L, 0L, 0L, 0L, 0L), Andrei.Savu = c(0L, 0L, 0L, 0L, 0L, 0L),
> >Bruno.Dumon = c(0L, 0L, 0L, 0L, 0L, 0L), Edward.J..Yoon = c(0L, 0L, 0L,
> >0L, 0L, 0L), Eugene.Koontz = c(0L, 0L, 0L, 0L, 0L,
> >0L), Jakob.Homan = c(0L, 0L, 0L, 0L, 0L, 0L), Kelvin.Kakugawa =
> >c(0L, 0L, 0L, 0L, 0L, 0L), Kirk.True = c(0L, 0L, 0L, 0L, 0L, 0L
> >  ), Lars.George = c(0L, 0L, 0L, 0L, 0L, 0L), Soren.Macbeth = c(0L, 0L,
> >0L, 0L, 0L, 0L), Stu.Hood = c(0L, 0L, 0L, 0L, 0L, 0L),
> >  Tibor.Kiss = c(0L, 0L, 0L, 0L, 0L, 0L), Tom.White = c(0L, 0L, 0L, 0L,
> >0L, 0L), Unassigned = c(0L, 0L, 0L, 0L, 0L, 0L
> >   ), David.Alves = c(0L, 0L, 0L, 0L, 0L, 0L), Patrick.Hunt = c(0L, 0L,
> >0L, 0L, 0L, 0L), Sebastian.Schoenherr = c(0L, 0L, 0L,
> >0L, 0L, 0L), Roman.Valls = c(0L, 0L, 0L, 0L, 0L, 0L), Pavel.Yaskevich =
> >c(0L, 0L, 0L, 0L, 0L, 0L), Karel.Vervaeke = c(0L, 0L, 0L, 0L, 0L,
> >  0L), Shay.Banon = c(0L, 0L, 0L, 0L, 0L, 0L), Hyunsik.Choi = c(0L, 0L,
> >0L, 0L, 0L, 0L), Joey.Hung. = c(0L, 0L, 0L, 0L, 0L, 0L
> >   ), Tommaso.Teofili = c(0L, 0L, 0L, 0L, 0L, 0L), Jeff.Hammerbacher. =
> >c(0L, 0L, 0L, 0L, 0L, 0L), Andrew.Purtell. = c(0L, 0L, 0L, 0L,
> >0L, 0L)

[R] Write table with data in other .csv template

2012-09-25 Thread s.s.m. fauzi
Hi,

I have a table with data, as below:

dput(table):

structure(list(Adrian.Cole = c(0L, 0L, 0L, 0L, 0L, 0L), Alison.Wong =
c(0L, 0L, 0L, 0L, 0L, 0L), Andrei.Savu = c(0L, 0L, 0L, 0L, 0L, 0L),
Bruno.Dumon = c(0L, 0L, 0L, 0L, 0L, 0L), Edward.J..Yoon = c(0L, 0L, 0L,
0L, 0L, 0L), Eugene.Koontz = c(0L, 0L, 0L, 0L, 0L,
0L), Jakob.Homan = c(0L, 0L, 0L, 0L, 0L, 0L), Kelvin.Kakugawa =
c(0L, 0L, 0L, 0L, 0L, 0L), Kirk.True = c(0L, 0L, 0L, 0L, 0L, 0L
), Lars.George = c(0L, 0L, 1L, 0L, 0L, 0L), Soren.Macbeth = c(0L, 0L,
1L, 0L, 0L, 0L), Stu.Hood = c(0L, 0L, 0L, 0L, 0L, 0L),
Tibor.Kiss = c(0L, 0L, 0L, 0L, 0L, 0L), Tom.White = c(0L, 0L, 1L, 0L,
0L, 0L), Unassigned = c(0L, 0L, 0L, 0L, 0L, 0L
)), .Names = c("Adrian.Cole", "Alison.Wong",
"Andrei.Savu", "Bruno.Dumon", "Edward.J..Yoon", "Eugene.Koontz",
"Jakob.Homan",
"Kelvin.Kakugawa", "Kirk.True", "Lars.George", "Soren.Macbeth", "Stu.Hood",
"Tibor.Kiss", "Tom.White", "Unassigned"), row.names = c("Adrian Cole",
"Alison Wong", "Andrei Savu", "Bruno Dumon", "Edward J. Yoon", "Eugene
Koontz"), class = "data.frame")

> dim(table)
[1] 15 15
> names(table)
 [1] "Adrian.Cole" "Alison.Wong" "Andrei.Savu" "Bruno.Dumon"
  "Edward.J..Yoon"  "Eugene.Koontz"   "Jakob.Homan" "Kelvin.Kakugawa"
 [9] "Kirk.True"   "Lars.George" "Soren.Macbeth"   "Stu.Hood"
 "Tibor.Kiss"  "Tom.White"   "Unassigned"

What I want to do is to embed/write this table to other big .csv template,
and save it with other name.

dput(template)

structure(list(Adrian.Cole = c(0L, 0L, 0L, 0L, 0L, 0L), Alison.Wong =
c(0L, 0L, 0L, 0L, 0L, 0L), Andrei.Savu = c(0L, 0L, 0L, 0L, 0L, 0L),
Bruno.Dumon = c(0L, 0L, 0L, 0L, 0L, 0L), Edward.J..Yoon = c(0L, 0L, 0L,
0L, 0L, 0L), Eugene.Koontz = c(0L, 0L, 0L, 0L, 0L,
0L), Jakob.Homan = c(0L, 0L, 0L, 0L, 0L, 0L), Kelvin.Kakugawa =
c(0L, 0L, 0L, 0L, 0L, 0L), Kirk.True = c(0L, 0L, 0L, 0L, 0L, 0L
), Lars.George = c(0L, 0L, 0L, 0L, 0L, 0L), Soren.Macbeth = c(0L, 0L,
0L, 0L, 0L, 0L), Stu.Hood = c(0L, 0L, 0L, 0L, 0L, 0L),
Tibor.Kiss = c(0L, 0L, 0L, 0L, 0L, 0L), Tom.White = c(0L, 0L, 0L, 0L,
0L, 0L), Unassigned = c(0L, 0L, 0L, 0L, 0L, 0L
), David.Alves = c(0L, 0L, 0L, 0L, 0L, 0L), Patrick.Hunt = c(0L, 0L,
0L, 0L, 0L, 0L), Sebastian.Schoenherr = c(0L, 0L, 0L,
0L, 0L, 0L), Roman.Valls = c(0L, 0L, 0L, 0L, 0L, 0L), Pavel.Yaskevich =
c(0L, 0L, 0L, 0L, 0L, 0L), Karel.Vervaeke = c(0L, 0L, 0L, 0L, 0L,
0L), Shay.Banon = c(0L, 0L, 0L, 0L, 0L, 0L), Hyunsik.Choi = c(0L, 0L,
0L, 0L, 0L, 0L), Joey.Hung. = c(0L, 0L, 0L, 0L, 0L, 0L
), Tommaso.Teofili = c(0L, 0L, 0L, 0L, 0L, 0L), Jeff.Hammerbacher. =
c(0L, 0L, 0L, 0L, 0L, 0L), Andrew.Purtell. = c(0L, 0L, 0L, 0L,
0L, 0L), Johan.Oskarsson = c(0L, 0L, 0L, 0L, 0L, 0L), Erik.Frey = c(0L,
0L, 0L, 0L, 0L, 0L), Sebb = c(0L, 0L, 0L, 0L, 0L, 0L), Andrew.klochkov =
c(0L,
0L, 0L, 0L, 0L, 0L), Paul.Egan = c(0L, 0L, 0L, 0L, 0L, 0L), Hudson =
c(0L, 0L, 0L, 0L, 0L, 0L), Hadoop = c(0L, 0L,
0L, 0L, 0L, 0L), Aaron = c(0L, 0L, 0L, 0L, 0L, 0L), henry = c(0L, 0L,
0L, 0L, 0L, 0L), steve = c(0L, 0L, 0L, 0L, 0L, 0L), russel = c(0L,
0L, 0L, 0L, 0L, 0L)), .Names = c("Adrian.Cole",
"Alison.Wong", "Andrei.Savu", "Bruno.Dumon", "Edward.J..Yoon",
"Eugene.Koontz",
"Jakob.Homan", "Kelvin.Kakugawa", "Kirk.True", "Lars.George", "Soren.Macbeth",
"Stu.Hood", "Tibor.Kiss", "Tom.White", "Unassigned",
"David.Alves", "Patrick.Hunt", "Sebastian.Schoenherr",
"Roman.Valls", "Pavel.Yaskevich", "Karel.Vervaeke", "Shay.Banon",
"Hyunsik.Choi",
"Joey.Hung.", "Tommaso.Teofili", "Jeff.Hammerbacher.",
"Andrew.Purtell.", "Johan.Oskarsson", "Erik.Frey", "Sebb",
"Andrew.klochkov", "Paul.Egan",
"Hudson", "Hadoop", "Aaron", "henry", "steve", "russel"), row.names =
c("Adrian Cole", "Alison Wong", "Andrei Savu", "Bruno Dumon", "Edward J.
Yoon",
"Eugene Koontz"), class = "data.frame")

> dim(template)
[1] 38 38
> names(template)
 [1] "Adrian.Cole"  "Alison.Wong"  "Andrei.Savu"
 "Bruno.Dumon"
 [5] "Edward.J..Yoon"   "Eugene.Koontz""Jakob.Homan"
 "Kelvin.Kakugawa"
 [9] "Kirk.True""Lars.George"  "Soren.Macbeth"
 "Stu.Hood"
[13] "Tibor.Kiss"   "Tom.White""Unassigned"
"David.Alves"
[17] "Patrick.Hunt" "Sebastian.Schoenherr" "Roman.Valls"
 "Pavel.Yaskevich"
[21] "Karel.Vervaeke"   "Shay.Banon"   "Hyunsik.Choi"
"Joey.Hung."
[25] "Tommaso.Teofili"  "Jeff.Hammerbacher."   "Andrew.Purtell."
 "Johan.Oskarsson"
[29] "Erik.Frey""Sebb" "Andrew.klochkov"
 "Paul.Egan"
[33] "Hudson"   "Hadoop"   "Aaron"
 "henry"
[37] "steve""russel"

[[alternative HTML version deleted]]

__
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-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] chunk row to new table/file

2012-09-17 Thread s.s.m. fauzi
I have big .csv file. I would like to filter that file into a new table.


For example, I have .csv file as below:




   f1 f2  f3 f4  f5  f6 f7 f9  f10  f11
t1  1  0  1   0  1  0   0  0   01
t2  1  0  0   0  0  1   1  1   11
t3  0  0  0   0  0  0   0  0   00
t4  1  0  0   0  1  0   0  0   00
t5  0  0  0   0  0  0   0  0   00
t6  0  0  0   0  0  0   0  0   00

1. I have a table (as above)

2. What I want to do is, I want to chunk a new table for each row (meaning
that, I will have new table for row t1, new table for row t2, new table for
row t3 and etc)

3. To develop new table for each row, there is a condition that need to
meet.  The row should be grouped with other row which have the same value
in column
(as in my example, row t1,t2,t4 should be grouped together because value in
column f1 have the same value (which is 1) with the value in f1 for row t2
and t4, also value in f5 is equal with the value in f5 for row t4, and
value in f11 is equal with the value in f11 for row t2). Output for should
be like this:


   f1 f2  f3 f4  f5  f6 f7 f9  f10  f11
t1  1  0  1   0  1  0   0  0   01
t2  1  0  0   0  0  1   1  1   11
t4  1  0  0   0  1  0   0  0   00

4. Also as we can see from the above table, t2 also should have another
table because value in f1 in t1 and value f1 in t4 is equal. However, t2
should not consider t1. Output should be like this:

  f1 f2  f3 f4  f5  f6 f7 f9  f10  f11
t2  1  0  0   0  0  1   1  1   11
t4  1  0  0   0  1  0   0  0   00




New table(s) (with row and column header) should be then saved in a new .
csvfile.

Appreciate help from the expert!

[[alternative HTML version deleted]]

__
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-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to divide each column with its own value

2012-09-16 Thread s.s.m. fauzi
Hi,

I have a matrix as below:

mat=
 [,1]  [,2]  [,3]
[1,]147
[2,]258
[3,]369

What I want to do is, I would like to divide each column with its own
value, in order to get value 1.
Is there any simple script for that?

[[alternative HTML version deleted]]

__
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-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to filter information from a big .csv table into a new table

2012-09-16 Thread s.s.m. fauzi
Hi,

I have big .csv file. I would like to filter that file into a new table.



For example, I have .csv file as below:



 f1 f2  f3 f4  f5  f6 f7 f9  f10  f11

t1  1  0  1   0  1  0   0  0   01

t2  1  0  0   0  0  1   1  1   11

t3  0  0  0   0  0  0   0  0   00

t4  1  0  0   0  1  0   0  0   00

t5  0  0  0   0  0  0   0  0   00

t6  0  0  0   0  0  0   0  0   00



I want to filter the table above to another table as below. It will only show
an information which have a dependency.


As you can see below, t1 has a dependency with t2 and t4, because f1 has a same
value (value 1) with t2 and t4.

Also, f5 has a same value with f5 in t4.

Also, f10 has a same value with f10 in t2.



 f1 f2 f3 f4  f5 f6  f7  f9  f10 f11

t1  1  0  1  0  1  0   0   0   01

t2  1  0  0  0  0  1   1   1   11

t4  1  0  0  0  1  0   0   0   00



New table (with row and column header) should be then saved in a new .
csvfile.

[[alternative HTML version deleted]]

__
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-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] self defined distance matrix in NbClust

2012-09-16 Thread s.s.m. fauzi
Hi,

I have big .csv file. I would like to filter that file into a new table.



For example, I have .csv file as below:



 f1 f2  f3 f4  f5  f6 f7 f9  f10  f11

t1  1  0  1   0  1  0   0  0   01

t2  1  0  0   0  0  1   1  1   11

t3  0  0  0   0  0  0   0  0   00

t4  1  0  0   0  1  0   0  0   00

t5  0  0  0   0  0  0   0  0   00

t6  0  0  0   0  0  0   0  0   00



I want to filter the table above to another table as below. It will only
show an information which have a dependency.



As you can see below, t1 has a dependency with t2 and t4, because f1 has a
same value (value 1) with t2 and t4.

Also, f5 has a same value with f5 in t4.

Also, f10 has a same value with f10 in t2.



 f1 f2 f3 f4  f5 f6  f7  f9  f10 f11

t1  1  0  1  0  1  0   0   0   01

t2  1  0  0  0  0  1   1   1   11

t4  1  0  0  0  1  0   0   0   00



New table (with row and column header) should be then saved in a new .csvfile.

[[alternative HTML version deleted]]

__
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-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Error during matrix multiplication

2012-09-12 Thread s.s.m. fauzi
Yes,
I have a row and column header. I need to save the row and column header.
Here is the example of the data

*Whirr_127.csv*
WHIRR.127 WHIRR.128 WHIRR.129 WHIRR.137 WHIRR.139 WHIRR.140 WHIRR.141
WHIRR.145 WHIRR.146 WHIRR.147
Adrian Cole 0 0 1 0 0 0
0 0 0 0
Alison Wong 0 0 0 0 0 0
1 0 0 0
Jakob Homan 0 0 0 0 1 0
0 0 0 0
Tibor Kiss  0 1 0 0 0 0
0 0 1 0
Tom White   1 0 0 1 0 0
0 1 0 1
Unassigned  0 0 0 0 0 1
0 0 0 0

*Files_Whirr_127.csv*
*
pom.xml. ZooKeeperServiceTest.java HBaseServiceController.java
HadoopServiceController.java. BasicServerClusterActionHandler.java.
AbstractClusterSpecCommand.java.
WHIRR-1270 0   0
  0 0
 0
WHIRR-1281 0   0
  0 0
 0
WHIRR-1291 0   0
  0 0
 0
WHIRR-1370 0   0
  0 0
 0
WHIRR-1391 0   0
  0 0
 0
WHIRR-1400 0   0
  0 0
 0
WHIRR-1410 0   0
  0 0
 0
WHIRR-1450 0   0
  0 0
 0
WHIRR-1460 0   0
  0 0
 0
WHIRR-1470 0   0
  0 0
 0

(cut to save space)

*

On Thu, Sep 13, 2012 at 3:37 PM, Jeff Newmiller wrote:

> You need to learn to use the str() function to debug these kinds of
> problems. And you need to learn to provide data with your code (perhaps
> with the dput function) so others can reproduce your problem if you want
> help.
>
> I would guess that you have non-numeric data in your files.
> ---
> Jeff NewmillerThe .   .  Go Live...
> DCN:Basics: ##.#.   ##.#.  Live
> Go...
>   Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
> /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
> ---
> Sent from my phone. Please excuse my brevity.
>
> "s.s.m. fauzi"  wrote:
>
> >Hi,
> >I have two matrix from two different .csv files.
> >
> >#load .csv files
> >a <- as.matrix(read.table("Whirr_127.csv", header=T, sep=",",
> >row.names=1))
> >b <- as.matrix(read.table("Files_Whirr_127.csv", header=T, sep=",",
> >row.names=1))
> >a
> >b
> >
> >I managed to do transpose to 'b' without any error.
> >
> >transpose_task <- t(b)
> >transpose_task
> >
> >But, when I tried to do multiplication (a%*%transpose_task), an error
> >occured.
> >
> >td <- (a%*%transpose_task)
> >td
> >
> >Here is the error:
> >ERROR:  requires numeric/complex matrix/vector arguments
> >ERROR:  object 'td' not found
> >
> >Anybody can help me to solve this?
> >
> >Thank you
> >
> >   [[alternative HTML version deleted]]
> >
> >__
> >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-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

__
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-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Error during matrix multiplication

2012-09-12 Thread s.s.m. fauzi
Hi,
I have two matrix from two different .csv files.

#load .csv files
a <- as.matrix(read.table("Whirr_127.csv", header=T, sep=",", row.names=1))
b <- as.matrix(read.table("Files_Whirr_127.csv", header=T, sep=",",
row.names=1))
a
b

I managed to do transpose to 'b' without any error.

transpose_task <- t(b)
transpose_task

But, when I tried to do multiplication (a%*%transpose_task), an error
occured.

td <- (a%*%transpose_task)
td

Here is the error:
ERROR:  requires numeric/complex matrix/vector arguments
ERROR:  object 'td' not found

Anybody can help me to solve this?

Thank you

[[alternative HTML version deleted]]

__
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-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Read data from .csv file as a matrix and compare the different between two matrix

2012-09-04 Thread s.s.m. fauzi
Hi,
I have two table matrix, and I would like to compare the different between
two matrix.
For example:

Matrix 1:
A B C
A 0  1 0
B 0  0 1
C 0  0  0

Matrix 2:
   A B C
A 0  1  0
B 0  0  0
C 0  0  0

Each column which have value 1, should also return value 1. As in this
case/example, the result should appear like this (as below). The result of
this differentiation should also be in matrix table and should be write in .
csv file.

Result of the differences:
   A B C
A 0  1  0
B 0  0  0
C 0  0  0

At the mean time, I'm able to load the .csv file and convert it to matrix
matrix1 <-read.table("matrix1.csv", header=T, sep=",")
matrix1 <- as.matrix(matrix1)
matrix2 <- read.table("matrix2.csv", header=T, sep=",")
matrix2 <- as.matrix(matrix2)

But, I can't find a suitable script to compare the differences between the
matrix and write it to file.

Appreciate any help from the expert

[[alternative HTML version deleted]]

__
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-guide.html
and provide commented, minimal, self-contained, reproducible code.