选取数据框中的元素

# 选取数据框中的元素 ---------------------------------------------------------------

patientdata[c('diabetes','status')]
patientdata[1:2]
patientdata[,1:2]
patientdata$age

table(patientdata$diabetes,patientdata$status)

summary(mtcars$mpg)
plot(mtcars$mpg,mtcars$wt)

attach(mtcars)
summary(mpg)
plot(mpg,wt)
detach(mtcars)

mpg = c(25,36,47)
attach(mtcars)
plot(mpg,wt)

with(mtcars,{
  print(summary(mpg))
  plot(mpg,disp)
 # plot(mpg,wt)
})

with(mtcars,{
  local_var <- summary(mpg)
  global_var <<- summary(mpg)
  
})
local_var
global_var


patientdata
patientdata<- data.frame(patientID,age,diabetes,status,row.names = patientID)
patientdata
View(patientdata)

  

posted @ 2019-09-11 14:09  dogfaraway  阅读(253)  评论(0编辑  收藏  举报