楼主: cbw1243
44321 504

[问答] 接受各种R语言难题   [推广有奖]

461
cbw1243 发表于 2016-12-17 00:19:05
linshengqiao 发表于 2016-12-15 23:43
用R做一个模型
因变量Y是定序的,1到5分的量表
自变量,最主要的是A,A影响B和C,对因变量起作用
Use system of equations.

462
迦落无痕 发表于 2016-12-18 12:40:00 来自手机
cbw1243 发表于 2016-6-26 09:15
暑假漫长,生活没有挑战。在此征集各类R语言疑难杂症,欢迎各位骚扰。
提出给力问题的,将予以100论坛币奖 ...
R语言编写函数寻找向量X(a,b,c)的中间值和其下标,怎么做?

463
夏天和夏天 发表于 2016-12-19 23:45:31 来自手机
请问我有很多txt 文件,变量名一样,要计算某个值,怎样实现批量读入,计算,读出呢?拜求大神了!

464
tudou2015 发表于 2016-12-20 00:08:16 来自手机
cbw1243 发表于 2016-6-26 09:15
暑假漫长,生活没有挑战。在此征集各类R语言疑难杂症,欢迎各位骚扰。
提出给力问题的,将予以100论坛币奖 ...
请问大神,做分段线性回归,如何找出breakpoints啊,有什么好的方法或者包推荐吗?

465
yjy1002 发表于 2016-12-20 10:15:43

In this problem, you will perform K-means clustering manually, with K = 2, on a small example with n = 6 observations and p = 2 features. The observations are as follows.

(b) Randomly assign a cluster label to each observation. You can use the sample() command in R to do this. Report the cluster labels for each observation.

(c) Compute the centroid for each cluster.

(d) Assign each observation to the centroid to which it is closest, in terms of Euclidean distance. Report the cluster labels for each observation.

(e) Repeat (c) and (d) until the answers obtained stop changing

(f) In your plot from (a), color the observations according to the


图片1.png (4.55 KB)

图片1.png

466
fjz92419 发表于 2016-12-20 15:51:00
最近用ggplot2作任何图的时候都会弹出这样的错误Error in valid.units(units) : object 'validUnits' not found,楼主知道该如何解决吗?

467
fjz92419 发表于 2016-12-20 17:50:21
最近使用ggplot作图的时候加入theme_classic()会出现没有坐标轴的情况,使用panel.grid.major = element_blank()又会出现图的四周都有框线。
之前是没有这个情况的,使用theme_classic()可以做到没有背景只有坐标轴,而现在在theme里加入axis.ticks=element_line(color="black", size=50),也无法设置出连续的坐标轴了。
请问这个问题有解决方法吗?

468
cbw1243 发表于 2016-12-23 12:52:36
夏天和夏天 发表于 2016-12-19 23:45
请问我有很多txt 文件,变量名一样,要计算某个值,怎样实现批量读入,计算,读出呢?拜求大神了!
把所有文件放在一个文件夹
filenames <- list.files("..", pattern="*.txt",all.files=TRUE, full.names=TRUE) # ..中指定路径
dat <- lapply(filenames, read.table) #批量读到R里

469
cbw1243 发表于 2016-12-23 12:53:24
tudou2015 发表于 2016-12-20 00:08
请问大神,做分段线性回归,如何找出breakpoints啊,有什么好的方法或者包推荐吗?
strucchange

470
jamest1982 发表于 2016-12-23 15:16:19
cbw1243 发表于 2016-12-17 00:05
for 是loop,在R里 save就是一个函数。循环运行一个函数很正常
如何将结果保存到不同文件或相同文件中?如何避免操作过程出现的数据覆盖问题?非常感谢!

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

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