Plotting andrews curves of subsets of a data frame on the same plot

Posted by user2976477 on Stack Overflow See other posts from Stack Overflow or by user2976477
Published on 2013-11-10T15:52:12Z Indexed on 2013/11/10 21:55 UTC
Read the original article Hit count: 332

Filed under:
|
|

I have a data frame of 12 columns and I want to plot andrews curves in R of this data, basing the color of the curves on the 12th columns. Below are a few samples from the data (sorry the columns are not aligned with the numbers)

Teacher_explaining  Teacher_enthusiastic    Teacher_material_interesting    Material_stimulating    Material_useful Clear_marking   Marking_fair    Feedback_prompt Feedback_clarifies  Detailed_comments   Notes   Year
80  80  80  80  85  85  80  80  80  80  70  3
70  60  30  40  70  60  30  40  70  0   30  3
100 90  90  80  80  100 100 90  100 100 100 MSc
85  85  85  90  90  70  90  50  70  80  100 MSc
90  50  90  90  90  70  100 50  80  100 100 4
100 80  80  75  90  80  80  50  80  80  90  3

From this data I tried to plot andrews curves using the code below:

install.packages("andrews")
library(andrews)

 col <- as.numeric(factor(course[,12]))
    andrews(course[,1:12], clr = 12)

However, the 12th column has three groups (3 types of responses) and I want to group two of them and then plot the andrews curve of the data, without editing my data frame in Excel.

x <- subset(course, Year == "MSc" & "4")
y <- subset(course, Year == "3")

I tried the above code, but my argument for x don't work. "MSc", "3" and "4" are the groups in the 12th column, and I want to group MSc and 4 so that their Andrews curves have the same color.

If you have any idea how to do this, please let me know.

© Stack Overflow or respective owner

Related posts about r

    Related posts about subset