[R] ddply/tapply and set function

2021-02-17 Thread A. Mani
I want a data frame (derived from another data frame) of the form

Type   Set
1 {1,5, 7}
2 {3,8)
..

tapply(Id,Type, set) works, but does not yield a data frame.
'set' is from package set/set6/etc
ddply does not seem to work with the function.
How should I proceed with this optimally?


Thanks and Best

A Mani

Prof.Dr.(Miss) A Mani
ASL, AMS, ISRS, CLC, CMS, MTA
Senior Member, International Rough Set Society
Research Scientist, Indian Statistical Institute, Kolkata
Formerly HBCSE, TIFR, CU.
Homepage: https://www.logicamani.in
Blog: https://logicamani.blogspot.in/
Research Gate: https://www.researchgate.net/profile/Mani_A
sip:girlprofes...@ekiga.net
Pronouns: She/Her/Hers

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] ddply/tapply and set function

2021-02-17 Thread A. Mani
The original data frame can be like
Type   Id
1 1
1 5
1 7
2 3
2 8
..

tapply(Id,Type,set) will yield the sets correctly (assuming the data
frame is attached) but not a data frame of the form mentioned.

A similar ddply command does not work at all with the function 'set'
(while 'mean' etc work fine)

Thanks and Best

A Mani

Prof.Dr.(Miss) A Mani
ASL, AMS, ISRS, CLC, CMS, MTA
Senior Member, International Rough Set Society
Research Scientist, Indian Statistical Institute, Kolkata
Formerly HBCSE, TIFR, CU.
Homepage: https://www.logicamani.in
Blog: https://logicamani.blogspot.in/
Research Gate: https://www.researchgate.net/profile/Mani_A
sip:girlprofes...@ekiga.net
Pronouns: She/Her/Hers

On Wed, Feb 17, 2021 at 4:24 PM Jim Lemon  wrote:
>
> Hi  A,
> I'm unable to work out what you are using as input. Maybe:
>
> id<-data.frame(Type=c(1,2,1,1,2),set=c(1,3,5,7,8))
>
> but that doesn't work with your
>
> tapply(id,Type,set)
>
> command. Perhaps a bit more detail?
>
> Jim
>
>
>
> On Wed, Feb 17, 2021 at 7:48 PM A. Mani  wrote:
> >
> > I want a data frame (derived from another data frame) of the form
> >
> > Type   Set
> > 1 {1,5, 7}
> > 2 {3,8)
> > ..
> >
> > tapply(Id,Type, set) works, but does not yield a data frame.
> > 'set' is from package set/set6/etc
> > ddply does not seem to work with the function.
> > How should I proceed with this optimally?
> >
> >
> > Thanks and Best
> >
> > A Mani
> >
> > Prof.Dr.(Miss) A Mani
> > ASL, AMS, ISRS, CLC, CMS, MTA
> > Senior Member, International Rough Set Society
> > Research Scientist, Indian Statistical Institute, Kolkata
> > Formerly HBCSE, TIFR, CU.
> > Homepage: https://www.logicamani.in
> > Blog: https://logicamani.blogspot.in/
> > Research Gate: https://www.researchgate.net/profile/Mani_A
> > sip:girlprofes...@ekiga.net
> > Pronouns: She/Her/Hers
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] ddply/tapply and set function

2021-02-17 Thread A. Mani
Update:
The whole problem was due to set() from library sets.
'sets' is not a very consistent package, and users should be warned.

Set$new() and as.Set() from set6 work in a predictable, object-oriented way.

Thanks and Best

A Mani

Prof.Dr.(Miss) A Mani
ASL, AMS, ISRS, CLC, CMS, MTA
Senior Member, International Rough Set Society
Research Scientist, Indian Statistical Institute, Kolkata
Formerly HBCSE, TIFR, CU.
Homepage: https://www.logicamani.in
Blog: https://logicamani.blogspot.in/
Research Gate: https://www.researchgate.net/profile/Mani_A
sip:girlprofes...@ekiga.net
Pronouns: She/Her/Hers

On Wed, Feb 17, 2021 at 9:50 PM Bert Gunter  wrote:
>
> df <- data.frame(X1 = c(1,1,1,2,2), X2 = c(1,5,7,3,8))
> > df
>   X1 X2
> 1  1  1
> 2  1  5
> 3  1  7
> 4  2  3
> 5  2  8
> > v <- with(df, tapply(X2, X1, c))
> ## v is a list, and I would work directly with this rather than converting to 
> a data.frame. But if you insist:
>
> > df2 <- data.frame(v, row.names = names(v))
> > df2[1,1] ## produces a **list** with a single component containing the 
> > vector c(1,5,7)
> [[1]]
> [1] 1 5 7
>
> > df2[[1,1]] ## produces a vector -- note doubled brackets
> [1] 1 5 7
>
>
> Cheers,
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and 
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Wed, Feb 17, 2021 at 6:50 AM A. Mani  wrote:
>>
>> The original data frame can be like
>> Type   Id
>> 1 1
>> 1 5
>> 1 7
>> 2 3
>> 2 8
>> ..
>>
>> tapply(Id,Type,set) will yield the sets correctly (assuming the data
>> frame is attached) but not a data frame of the form mentioned.
>>
>> A similar ddply command does not work at all with the function 'set'
>> (while 'mean' etc work fine)
>>
>> Thanks and Best
>>
>> A Mani
>>
>> Prof.Dr.(Miss) A Mani
>> ASL, AMS, ISRS, CLC, CMS, MTA
>> Senior Member, International Rough Set Society
>> Research Scientist, Indian Statistical Institute, Kolkata
>> Formerly HBCSE, TIFR, CU.
>> Homepage: https://www.logicamani.in
>> Blog: https://logicamani.blogspot.in/
>> Research Gate: https://www.researchgate.net/profile/Mani_A
>> sip:girlprofes...@ekiga.net
>> Pronouns: She/Her/Hers
>>
>> On Wed, Feb 17, 2021 at 4:24 PM Jim Lemon  wrote:
>> >
>> > Hi  A,
>> > I'm unable to work out what you are using as input. Maybe:
>> >
>> > id<-data.frame(Type=c(1,2,1,1,2),set=c(1,3,5,7,8))
>> >
>> > but that doesn't work with your
>> >
>> > tapply(id,Type,set)
>> >
>> > command. Perhaps a bit more detail?
>> >
>> > Jim
>> >
>> >
>> >
>> > On Wed, Feb 17, 2021 at 7:48 PM A. Mani  wrote:
>> > >
>> > > I want a data frame (derived from another data frame) of the form
>> > >
>> > > Type   Set
>> > > 1 {1,5, 7}
>> > > 2 {3,8)
>> > > ..
>> > >
>> > > tapply(Id,Type, set) works, but does not yield a data frame.
>> > > 'set' is from package set/set6/etc
>> > > ddply does not seem to work with the function.
>> > > How should I proceed with this optimally?
>> > >
>> > >
>> > > Thanks and Best
>> > >
>> > > A Mani
>> > >
>> > > Prof.Dr.(Miss) A Mani
>> > > ASL, AMS, ISRS, CLC, CMS, MTA
>> > > Senior Member, International Rough Set Society
>> > > Research Scientist, Indian Statistical Institute, Kolkata
>> > > Formerly HBCSE, TIFR, CU.
>> > > Homepage: https://www.logicamani.in
>> > > Blog: https://logicamani.blogspot.in/
>> > > Research Gate: https://www.researchgate.net/profile/Mani_A
>> > > sip:girlprofes...@ekiga.net
>> > > Pronouns: She/Her/Hers
>> > >
>> > > __
>> > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > > 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-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Irregular Time Series Issue

2008-03-07 Thread A Mani
Hello,
   I have an irregular time series of the form :

Time Data Time1 Data1 
1   b1 e
7  g 4i
NA  NA   5 k
NA  NA  NA  NA ...

(the columns have varying length of NAs after a certain point)
Converting this to regular time series with Pastecs does not seem to
work, when I see the
entire data as a single series. So I remove the NAs and deal with one
series at a time in a loop.

Any suggestions ?


Thanks

A. Mani


-- 
A. Mani
Member, Cal. Math. Soc

__
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.