Jump to content
  • entries
    6
  • comments
    0
  • views
    3.461

Επανακωδικοποίηση μεταβλητών που περιέχουν κείμενο στο R


bromptonista

3.838 views

To R έχει ισχυρές συναρτήσεις  για την επανακωδικοποίηση μεταβλητών που περιέχουν κείμενο, συχνό πρόβλημα στις ιατρικές έρευνες.

Για παράδειγμα, έχουμε μια βάση δεδομένων retrospective.cohort με ιστολογικά (στη μεταβλητή TNM7) από καρκίνους με το σύστημα ΤΝΜ (σε μορφή pT1a pN1) και θέλουμε να δημιουργήσουμε άλλες μεταβλητές για χωριστά T/N και ομαδοποίηση όλες τις κατηγορίες. Αυτό γίνεται με τη συνάρτηση grepl ως εξής:

attach(retrospective.cohort)
retrospective.cohort$sizecat[grepl("T1", TNM7) ] <- "T1"
retrospective.cohort$sizecat[grepl("T2", TNM7) ] <- "T2"
retrospective.cohort$sizecat[grepl("T3", TNM7)  ] <- "T3"
retrospective.cohort$sizecat[grepl("T4", TNM7)  ] <- "T4"

retrospective.cohort$lncat[grepl("N0", TNM7) ] <- "0"
retrospective.cohort$lncat[grepl("N1", TNM7) ] <- "1"
retrospective.cohort$lncat[grepl("N2", TNM7) ] <- "1"
retrospective.cohort$lncat[grepl("N3", TNM7) ] <- "1"
detach(retrospective.cohort)

emtoilet

0 Comments


Recommended Comments

There are no comments to display.

Επισκέπτης
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Δημιουργία νέας...

Important Information

By using this site, you agree to our Terms of Use.