楼主: 耕耘使者
24293 16

[问答] 怎样显示R软件中某个程序包中的一个数据集? [推广有奖]

贵宾

已卖:5006份资源

学术权威

39%

还不是VIP/贵宾

-

威望
4
论坛币
1811021 个
通用积分
171.7911
学术水平
109 点
热心指数
173 点
信用等级
87 点
经验
93428 点
帖子
4549
精华
0
在线时间
2848 小时
注册时间
2006-4-6
最后登录
2025-7-12

楼主
耕耘使者 发表于 2012-1-17 00:50:49 |AI写论文
20论坛币
我知道在ggplot2程序包中有diamonds这个数据集,我也安装了ggplot2这个程序包,并且,我使用 data(package = .packages(all.available = TRUE))这个命令也成功地显示:
Data sets in package ‘ggplot2’:
diamonds               Prices of 50,000 round cut diamonds
economics              US economic time series
midwest                Demographic information of midwest counties
movies                 Movie information and user ratings from
可是,是该如何查看或者调用diamonds这个数据集呢?
我曾尝试在R提示符下直接输入diamonds,但提示:“错误: 找不到对象'diamonds'


最佳答案

mathfan 查看完整内容

I think the following codes works: library(ggplot2) data(diamonds) summary(diamonds)
关键词:r软件 数据集 程序包 information Time Series 软件 怎样 程序

沙发
mathfan 发表于 2012-1-17 00:50:50
I think the following codes works:

library(ggplot2)
data(diamonds)
summary(diamonds)
已有 1 人评分学术水平 热心指数 收起 理由
耕耘使者 + 1 + 1 热心帮助其他会员

总评分: 学术水平 + 1  热心指数 + 1   查看全部评分

藤椅
mathfan 发表于 2012-1-17 01:10:19
To see the first 5 rows of the data:

diamonds[1:5,]
已有 1 人评分学术水平 热心指数 收起 理由
耕耘使者 + 1 + 1 热心帮助其他会员

总评分: 学术水平 + 1  热心指数 + 1   查看全部评分

板凳
qoiqpwqr 发表于 2012-1-17 01:29:47
我的没有问题,是不是你的ggplot2没装好


> library(ggplot2)
Loading required package: reshape
Loading required package: plyr

Attaching package: ‘reshape’

The following object(s) are masked from ‘package:plyr’:

    rename, round_any

Loading required package: grid
Loading required package: proto
> head(diamonds)
  carat       cut color clarity depth table price    x    y    z
1  0.23     Ideal     E     SI2  61.5    55   326 3.95 3.98 2.43
2  0.21   Premium     E     SI1  59.8    61   326 3.89 3.84 2.31
3  0.23      Good     E     VS1  56.9    65   327 4.05 4.07 2.31
4  0.29   Premium     I     VS2  62.4    58   334 4.20 4.23 2.63
5  0.31      Good     J     SI2  63.3    58   335 4.34 4.35 2.75
6  0.24 Very Good     J    VVS2  62.8    57   336 3.94 3.96 2.48
已有 1 人评分学术水平 热心指数 收起 理由
耕耘使者 + 1 + 1 热心帮助其他会员

总评分: 学术水平 + 1  热心指数 + 1   查看全部评分

报纸
dyh325 发表于 2012-1-17 01:41:05
Hi~
data("diamonds",package="ggplot2")  
may also works~
hope that will help you~
已有 2 人评分学术水平 热心指数 收起 理由
松石空月 + 5 好的意见建议
耕耘使者 + 1 + 1 热心帮助其他会员

总评分: 学术水平 + 6  热心指数 + 1   查看全部评分

地板
吉林小王子 在职认证  发表于 2012-1-17 07:33:19
library(ggplot2)
data(diamonds)
diamonds
已有 1 人评分学术水平 热心指数 收起 理由
耕耘使者 + 1 + 1 热心帮助其他会员

总评分: 学术水平 + 1  热心指数 + 1   查看全部评分

7
耕耘使者 发表于 2012-1-17 09:54:31
mathfan 发表于 2012-1-17 01:08
I think the following codes works:

library(ggplot2)
Thank you,it really works!
Great!

8
耕耘使者 发表于 2012-1-17 10:09:20
mathfan 发表于 2012-1-17 01:10
To see the first 5 rows of the data:

diamonds[1:5,]
Succeed!
Thanks again!

9
耕耘使者 发表于 2012-1-17 10:10:50
qoiqpwqr 发表于 2012-1-17 01:29
我的没有问题,是不是你的ggplot2没装好
确实没装好。我是用菜单安装的,改做library命令安装后,成功。
多谢版主!

10
耕耘使者 发表于 2012-1-17 10:11:59
dyh325 发表于 2012-1-17 01:41
Hi~
data("diamonds",package="ggplot2")  
may also works~
It really helped me,thank you!

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-30 22:11