首页 > > 详细

讲解留学生Matlab、Matlab程序调试、讲解Python程序、Python设计讲解

mean(vector1)
vector1 * 4
summary(vector1)
length(vector1)

vector2 <- c(3,4,2,6,9)
vector1 * vector2
vector1 / vector2
cor(vector1,vector2)
vector3 <- vector1 * vector2
str(vector1)
You can also plot data in various ways. For example, the simple commands ‘boxplot([vector name]’ and
‘hist[vector name]’ create boxplot and histograms respectively.
You can also plot two variables together。
Question 3: using the help for the function ‘plot’, produce a plot of the variables vector1 and vector2
together, and copy and paste it into your results.
There are some datasets you can play around with, built into R. To see what they are, type the command
below and hit enter/return.
data()

data(iris)
You can view the beginning of the dataset (i.e, the first few rows) using the ‘head’ function, and the end of
the dataset using the ‘tail function’. To view only a single column, you could use iris$[columnName]. You
can also combine these, to view the beginning or end of a single variable in a dataset.

head(iris$Sepal.Length)
Now work with this dataset to complete answer the remaining questions/complete the remaining tasks.

Question 4: Inspect the structure of the iris dataset. What variable is recognized by R as a Factor variable?
Bonus Question: Can you figure out what categories exist for this factor variable?
Question 5: Make a histogram for Sepal Length, and paste it into your results. Here’s a hint: to call on a
single column of a dataset, you need to type ‘datasetName$columnName’ 5:
etName$ColumnName’

Question 6: Use the ‘subset’ command to create a subset of the data, where the only species represented
is ‘setosa’ (you can use ‘head’ and ‘tail’ to inspect the beginning and end of the resulting dataset, or view
the entire result by simply typing the new name of the resulting dataset)
Question 7: For the entire iris dataset, calculate the correlation coefficient between Sepal Length and
Petal Length.
Question 8: Plot the relationship between Sepal Length and Petal Length for the entire dataset. As an
extra challenge, see if you can use symbols other than the default
Question 9: What is the maximum value for Petal Length across the entire dataset?
Question 10: For the subset of data that you took earlier (Question 6), create a boxplot of Sepal Width.

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!