[R] Extract data in word pad
David Winsemius
dwinsemius at comcast.net
Sun Jan 13 04:22:04 CET 2013
Note: I usually reply to posters as well as the list, but after having
my email address sent to this poster forwarded to a spamming photo
site which refuses to honor its unsubscribe links, I am deleting her
address from the response.
On Jan 12, 2013, at 6:23 PM, Roslina Zakaria wrote:
> Dear r-users,
>
> I have saved data in word pad. I would like to extract certain part
> of data only, for example
>
> 19710629 080000(PARTIAL) 39.3 at interval beginning 19701126
> 010326
> 19720629 080000(PARTIAL) 33.8 at interval beginning 19720517
> 144507
> 19730629 080000(PARTIAL) 32.2 at interval beginning 19720910
> 135747
Lines <- readLines( textConnection(" Year Ending Maximum
Value (Rain mm)
Gap from 19710509 090000 to 19710607 080000 of 28.96 Days
19710629 080000(PARTIAL) 39.3 at interval beginning 19701126
010326
Gap from 19710809 110221 to 19710816 080000 of 6.87 Days
Gap from 19720207 070000 to 19720303 080000 of 25.04 Days
Gap from 19720424 070000 to 19720504 080000 of 10.04 Days
19720629 080000(PARTIAL) 33.8 at interval beginning 19720517
144507
Gap from 19720913 090000 to 19720918 080000 of 4.96 Days
Gap from 19720929 150000 to 19721006 080000 of 6.71 Days
Gap from 19730129 070000 to 19730226 080000 of 28.04 Days
Gap from 19730531 030203 to 19730607 080000 of 7.21 Days
19730629 080000(PARTIAL) 32.2 at interval beginning 19720910
135747
Gap from 19731031 154200 to 19731205 080000 of 34.68 Days
Gap from 19740301 121500 to 19740425 080000 of 54.82 Days
19740629 080000(PARTIAL) 38.9 at interval beginning 19731003
124849
19750629 080000 43.3 at interval beginning 19750105
173500
Gap from 19750809 114901 to 19750828 080000 of 18.84 Days
Gap from 19760326 144900 to 19760424 080000 of 28.72 Days
19760629 080000(PARTIAL) 101.5 at interval beginning 19750809
111800
Gap from 19770121 111500 to 19770330 080000 of 67.86 Days
19770629 080000(PARTIAL) 39.4 at interval beginning 19760917
141200
19780629 080000 38.5 at interval beginning 19780508
195400")
)
Lines[ grep("PARTIAL", Lines) ]
There were 6 matches. If a smaller number were desired then some sort
of description of the criteria for selection should have been
described in natural language.
--
David.
Per
>
> and so on...
>
> The original data set are given below:
>
> Year Ending Maximum Value (Rain mm)
> Gap from 19710509 090000 to 19710607 080000 of 28.96 Days
> 19710629 080000(PARTIAL) 39.3 at interval beginning 19701126
> 010326
> Gap from 19710809 110221 to 19710816 080000 of 6.87 Days
> Gap from 19720207 070000 to 19720303 080000 of 25.04 Days
> Gap from 19720424 070000 to 19720504 080000 of 10.04 Days
> 19720629 080000(PARTIAL) 33.8 at interval beginning 19720517
> 144507
> Gap from 19720913 090000 to 19720918 080000 of 4.96 Days
> Gap from 19720929 150000 to 19721006 080000 of 6.71 Days
> Gap from 19730129 070000 to 19730226 080000 of 28.04 Days
> Gap from 19730531 030203 to 19730607 080000 of 7.21 Days
> 19730629 080000(PARTIAL) 32.2 at interval beginning 19720910
> 135747
> Gap from 19731031 154200 to 19731205 080000 of 34.68 Days
> Gap from 19740301 121500 to 19740425 080000 of 54.82 Days
> 19740629 080000(PARTIAL) 38.9 at interval beginning 19731003
> 124849
> 19750629 080000 43.3 at interval beginning 19750105
> 173500
> Gap from 19750809 114901 to 19750828 080000 of 18.84 Days
> Gap from 19760326 144900 to 19760424 080000 of 28.72 Days
> 19760629 080000(PARTIAL) 101.5 at interval beginning 19750809
> 111800
> Gap from 19770121 111500 to 19770330 080000 of 67.86 Days
> 19770629 080000(PARTIAL) 39.4 at interval beginning 19760917
> 141200
> 19780629 080000 38.5 at interval beginning 19780508
> 195400
>
> I hope somebody can help me with this. I tried to save
> in ,csv.excel but quite difficult since it has numbers and words.
>
> Thank you so much for any help given.
>
> Regards,
>
> Roslina
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
David Winsemius, MD
Alameda, CA, USA
More information about the R-help
mailing list