Re: [R] wildcard symbol or character
Jorge Ivan Velez wrote: Dear John, Assuming that your information is in the list x, does substr(x,1,2) work for you? HTH, Jorge Jorge, i tried split(rtt, substr(rtt,1,3)) and that worked also. (i didn't think to nest it when you first suggested it.) i just have to clean up the levels thing. thanks!! now, i look into regex some... john __ 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] wildcard symbol or character
Bill Venables responded and got me what i wanted with this: [EMAIL PROTECTED] wrote: >> cv <- scan( >> > textConnection("CW-W730 CW-W720 CW-W710 CW-W700 CW-W690 CW-W680 > CW-W670 CW-W660 CE-W997 CE-W987 CE-W977 CE-W967 > CE-W956 CE-W944 CE-W934 CE-W924 7W-W760 > 7W-W750 > 7W-967W-941 7W-932 7W-923 7W-914 > 7W-905 > 7E-W565 7E-W555 7E-W545 7E-W535 7E-W525 > 7E-906 > 7E-850 7E-840"), what = "") > Read 32 items > >> cv >> > [1] "CW-W730" "CW-W720" "CW-W710" "CW-W700" "CW-W690" > [6] "CW-W680" "CW-W670" "CW-W660" "CE-W997" "CE-W987" > [11] "CE-W977" "CE-W967" "CE-W956" "CE-W944" "CE-W934" > [16] "CE-W924" "7W-W760" "7W-W750" "7W-96" "7W-941" > [21] "7W-932" "7W-923" "7W-914" "7W-905" "7E-W565" > [26] "7E-W555" "7E-W545" "7E-W535" "7E-W525" "7E-906" > [31] "7E-850" "7E-840" > >> split(cv, substring(cv, 0, 2)) >> > $`7E` > [1] "7E-W565" "7E-W555" "7E-W545" "7E-W535" "7E-W525" "7E-906" > [7] "7E-850" "7E-840" > > $`7W` > [1] "7W-W760" "7W-W750" "7W-96" "7W-941" "7W-932" "7W-923" > [7] "7W-914" "7W-905" > > $CE > [1] "CE-W997" "CE-W987" "CE-W977" "CE-W967" "CE-W956" "CE-W944" > [7] "CE-W934" "CE-W924" > > $CW > [1] "CW-W730" "CW-W720" "CW-W710" "CW-W700" "CW-W690" "CW-W680" > [7] "CW-W670" "CW-W660" john.polo wrote: hello all, i want to split a list into smaller lists. the list looks like this: CW-W730 CW-W720 CW-W710 CW-W700 CW-W690 CW-W680 CW-W670 CW-W660 CE-W997 CE-W987 CE-W977 CE-W967 CE-W956 CE-W944 CE-W934 CE-W924 7W-W760 7W-W750 7W-967W-941 7W-932 7W-923 7W-914 7W-905 7E-W565 7E-W555 7E-W545 7E-W535 7E-W525 7E-906 7E-850 7E-840 ... i want the smaller lists to be based on the first two characters, like CW or 7E. i tried split() where the f variable = c("1E-*","1W-*","2E-*","2W-*","5E-*","5W-*","7E-*","7W-*","CE-*","CW-*"), but * doesn't work as a wildcard as i had hoped. can someone tell me the appropriate wildcard character/symbol to use, please? john __ 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] wildcard symbol or character
Jorge Ivan Velez wrote: Dear John, Assuming that your information is in the list x, does substr(x,1,2) work for you? HTH, Jorge thanks for your reply Jorge. i will try substr(). john __ 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] wildcard symbol or character
Michael Dewey wrote: split() where the f variable = c("1E-*","1W-*","2E-*","2W-*","5E-*","5W-*","7E-*","7W-*","CE-*","CW-*"), but * doesn't work as a wildcard as i had hoped. can someone tell me the appropriate wildcard character/symbol to use, please Did you really use split()? yes, i did. the output looked like this: > split(rtt,RTT) $`1E-.` [1] CW-W739 CW-W729 CW-W719 CW-W709 CW-W699 CW-W689B CW-W679 CW-W669 ... $`1W-.` [1] CW-W738 CW-W728 CW-W718 CW-W708 CW-W698 CW-W688 CW-W678 CW-W668 ... I suspect that ?strsplit might help you and you can follow the link to regular expressions or do ?regexp for enlightenment on the wonders of regular expressions. As another poster has mentioned you can of course use substr() in this case but regular expressions enable you to do far more. i haven't tried any of other solution suggested in other posts yet. thanks for your reply. john __ 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] wildcard symbol or character
At 03:07 03/06/2008, john.polo wrote: hello all, i want to split a list into smaller lists. the list looks like this: CW-W730 CW-W720 CW-W710 CW-W700 CW-W690 CW-W680 CW-W670 CW-W660 CE-W997 CE-W987 CE-W977 CE-W967 CE-W956 CE-W944 CE-W934 CE-W924 7W-W760 7W-W750 7W-967W-941 7W-932 7W-923 7W-914 7W-905 7E-W565 7E-W555 7E-W545 7E-W535 7E-W525 7E-906 7E-850 7E-840 ... i want the smaller lists to be based on the first two characters, like CW or 7E. i tried split() where the f variable = c("1E-*","1W-*","2E-*","2W-*","5E-*","5W-*","7E-*","7W-*","CE-*","CW-*"), but * doesn't work as a wildcard as i had hoped. can someone tell me the appropriate wildcard character/symbol to use, please? Did you really use split()? I suspect that ?strsplit might help you and you can follow the link to regular expressions or do ?regexp for enlightenment on the wonders of regular expressions. As another poster has mentioned you can of course use substr() in this case but regular expressions enable you to do far more. john Michael Dewey http://www.aghmed.fsnet.co.uk __ 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] wildcard symbol or character
Dear John, Assuming that your information is in the list x, does substr(x,1,2) work for you? HTH, Jorge On Mon, Jun 2, 2008 at 10:07 PM, john.polo <[EMAIL PROTECTED]> wrote: > hello all, > > i want to split a list into smaller lists. the list looks like this: > CW-W730 CW-W720 CW-W710 CW-W700 CW-W690 CW-W680 CW-W670 CW-W660 > CE-W997 CE-W987 CE-W977 CE-W967 CE-W956 CE-W944 CE-W934 CE-W924 > 7W-W760 7W-W750 7W-967W-941 7W-932 7W-923 7W-914 7W-905 > 7E-W565 7E-W555 7E-W545 7E-W535 7E-W525 7E-906 7E-850 7E-840 ... > > > i want the smaller lists to be based on the first two characters, like CW > or 7E. i tried split() where the f variable = > c("1E-*","1W-*","2E-*","2W-*","5E-*","5W-*","7E-*","7W-*","CE-*","CW-*"), > but * doesn't work as a wildcard as i had hoped. can someone tell me the > appropriate wildcard character/symbol to use, please? > > john > > __ > 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] wildcard symbol or character
hello all, i want to split a list into smaller lists. the list looks like this: CW-W730 CW-W720 CW-W710 CW-W700 CW-W690 CW-W680 CW-W670 CW-W660 CE-W997 CE-W987 CE-W977 CE-W967 CE-W956 CE-W944 CE-W934 CE-W924 7W-W760 7W-W750 7W-967W-941 7W-932 7W-923 7W-914 7W-905 7E-W565 7E-W555 7E-W545 7E-W535 7E-W525 7E-906 7E-850 7E-840 ... i want the smaller lists to be based on the first two characters, like CW or 7E. i tried split() where the f variable = c("1E-*","1W-*","2E-*","2W-*","5E-*","5W-*","7E-*","7W-*","CE-*","CW-*"), but * doesn't work as a wildcard as i had hoped. can someone tell me the appropriate wildcard character/symbol to use, please? john __ 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.