To create this plot, we're going to pass in our variables
to gg plot as usual. We'll set x equal to age,
and y equal to median friend count. And we'll set
data equal to the data frame that we just created. So
pf.fc by age, gender. Now I just need to add
gm line and pass up the color parameter inside the unaesthetic
wrapper. This time the color will take on the value
of gender. This will give me one line for males and
one line for females. Running this code, we get the same
exact plot. Hopefully you're feeling like a data guru at this point.
لإنشاء هذا المخطط، سنمرر المتغيرات الخاصة بنا
إلى رسم gg كالعادة. سنعيّن x تساوي العمر
وy تساوي وسيط عدد الأصدقاء. وسنعيّن البيانات بحيث تساوي
إطار البيانات الذي تم إنشاؤه حالاً. لذا
سيصبح pf.fc حسب العمر والنوع. أحتاج فقط الآن إلى إضافة
سطر gm وتمرير معلمة اللون داخل
برنامج تضمين الشكل الجمالي. سيأخذ اللون في هذه المرة قيمة
النوع. سيعطيني ذلك سطرًا واحدًا للذكور
وسطرًا واحدًا للإناث. بتشغيل هذه التعليمة البرمجية
.نحصل على المخطط ذاته بالضبط. نأمل أن تشعر كأنك مدير البيانات في هذه النقطة
To create this plot, we're going to pass in our variables
to ggplot as usual. We'll set x equal to age,
and y equal to median friend count. And we'll set
data equal to the data frame that we just created. So
pf.fc by age, gender. Now I just need to add
gm line and pass up the color parameter inside the unaesthetic
wrapper. This time the color will take on the value
of gender. This will give me one line for males and
one line for females. Running this code, we get the same
exact plot. Hopefully you're feeling like a data guru at this point.
この図の作成には変数をggplotにつなげます
xを年齢にし
yを友達数の中央値にします
dataは今作成したデータフレームに設定します
なのでpf.fc_by_age_genderとなります
あとはgeom_lineを足しaesラッパの中に
カラーパラメータを入れ性別で色を変えます
これで男性を示す線と女性を示す線ができます
コードを実行すると同じ図が完成します
皆さんうまくできたでしょうか
Para criar este gráfico, vamos passar nossas variáveis
ao gráfico GG como de costume. Definiremos x igual à idade
e y igual à contagem média de amigos. E definiremos
data igual à estrutura de dados que acabamos de criar. Portanto,
pf.fc por idade e sexo. Agora precisamos apenas adicionar
geom_line e passar o parâmetro color dentro de um
wrapper não estético. Desta vez, color terá o valor
de gender. Isso fornecerá uma linha para homens
e uma linha para mulheres. Ao executar esse código, obtemos este
mesmo gráfico. Espero que você esteja se sentindo um guru em dados a esta altura.
为了创建此图 我们照常要将变量传递给 ggplot
我们将 x 设置为等于年龄
并将 y 设置为等于中位好友数
我们将数据设置为等于我们刚创建的数据帧
因此按年龄和性别分类 pf.fc
现在我只需要添加几何线 并将其传递给不美观包装内的颜色参数
这次颜色将呈现性别值
这将为我提供一条男性线
和一条女性线 运行此代码
我们可以得到相同的精确图 希望你在这一点上感觉像数据大师