g*******y 发帖数: 380 | 1 I used following code to plot time series:
new1x=out$res
new1x=ts(new1x, start=c(1600,1),frequency=1)
plot(new1x, xlab='Year AD', main="Time series")
New1x has six columns which called y1, y2, y3,..., y6.
How can I revise the above code to change the label of each ylab? such as y1
<-Tommy, y2<-Johnny,..., y6<-Terry.
Thank you in advance! |
|
f******9 发帖数: 267 | 2 How to make a plot in R with horizontal ylab? Thanks! |
|
t*****w 发帖数: 254 | 3 When I had my job interview, they always tested my SAS skill.However I use R
all the time. To help your preparation, read my R codes to see how much you
can understand it.
%in%
?keyword
a<-matrix(0,nrow=3,ncol=3,byrow=T)
a1 <- a1/(t(a1)%*%spooled%*%a1)^.5 #standadization in discrim
a1<- a>=2; a[a1]
abline(h = -1:5, v = -2:3, col = "lightgray", lty=3)
abline(h=0, v=0, col = "gray60")
abs(r2[i])>r0
aggregate(iris[,1:4], list(iris$Species), mean)
AND: &; OR: |; NOT: !
anova(lm(data1[,3]~data1[,1... 阅读全帖 |
|
b*****e 发帖数: 223 | 4 左边那个,用 plot,大概是
read.csv ("path", header=T)
pdf(file='c:/temp/leftplot.pdf')
plot (x, y, lty=2, pch=22 col='red', main="My Plot Title", xlab="My x axis label", ylab='My y axis label')
dev.off ()
右边那个,用 plot 加 lines
read.csv ("path", header=T)
pdf(file='c:/temp/rightplot.pdf')
plot (x, y, lty=2, pch=22 col='red', main="My Plot Title", xlab="My x axis label", ylab='My y axis label') - 用第一条线的 x,y 画
lines (x, y, lty=3, pch=23, col='blue') - 用第二条线的 x,y 画
lines (x, y, lty=4, pch=24, col='purple... 阅读全帖 |
|
Y****a 发帖数: 243 | 5 呵呵,不会用google 或 bing 的吗?
http://www.astrostatistics.psu.edu/datasets/R/html/stats/html/q
Usage section, last example:
qqplot(x, y, plot.it = TRUE, xlab = deparse(substitute(x)),
ylab = deparse(substitute(y)), ...)
如果你的问题是怎么把数据读到R里面,查看 read.csv, read.table, etc..
个人觉得比较方便的是把数据存在 .csv 格式,直接调用 read.csv
my.data <- read.csv(file="myData.csv")
qqplot(my.data,xlab="X name",ylab="Y name") |
|
b****5 发帖数: 449 | 6 给想要学习R 做简单统计的朋友们,放进去自己改改应该能跑了。这个是新手练习向的。
应该是我发的最后一个主贴了,股版还是吵架的多,讨论技术的确实少。马上回国工作
了也不能看了。
最后可以看出某些股票最多连跌多少天。希望给大家帮助。
这个娱乐性质比较强,真正的model远比这个复杂。
library(quantmod)
library(PerformanceAnalytics)
#library(plyr)
source("calc_return.R")
ticker = "IWM"
bench = "SPY"
start_t = '2010-12-30'
end_t = '2016-01-20'
raw_bench = getSymbols(Symbols=bench,auto.assign = F, from= start_t,to= end_
t)
raw_prices = getSymbols(Symbols=ticker,auto.assign = F, from= start_t,to=
end_t)
dates = index(raw_prices)
l_dates = le... 阅读全帖 |
|
c*******e 发帖数: 1828 | 7 借微风的脚本用用
setwd("DIRECTORY")
data = read.csv("DATA.csv")
Y=data[,1]
X=data[,2]
correlation=cor(Y,X)
summary(correlation)
pdf('graph.pdf', width=5, height=5) #图的长宽看情况自己改吧
plot(X, Y, xlab='power', ylab='package loss rate')
dev.off()
这样就连算数带画图都搞定了
你搞个输入输出重定向就可以批处理了:)
写bash脚本啥的你肯定比我们都在行 |
|
q******r 发帖数: 6542 | 8 ☆─────────────────────────────────────☆
handsomex (潇潇细雨) 于 (Thu Mar 24 23:05:47 2011, 美东) 提到:
有什么好的度量吗?
☆─────────────────────────────────────☆
benbenma (猪猪) 于 (Thu Mar 24 23:34:13 2011, 美东) 提到:
regression?就是那个啥r2的东东?
☆─────────────────────────────────────☆
handsomex (潇潇细雨) 于 (Thu Mar 24 23:40:23 2011, 美东) 提到:
这是什么啊?
☆─────────────────────────────────────☆
benbenma (猪猪) 于 (Thu Mar 24 23:42:47 2011, 美东) 提到:
统计分析啊?
☆─────────────────────────────────────☆
handsomex (潇潇细雨) 于 ... 阅读全帖 |
|
l**********1 发帖数: 5204 | 9 pls refer
> posted on FRIDAY, JULY 6, 2012
Fix Overplotting with Colored Contour Lines
I saw this plot in the supplement of a recent paper comparing microarray
results to RNA-seq results. Nothing earth-shattering in the paper - you've
probably seen a similar comparison many times before - but I liked how they
solved the overplotting problem using heat-colored contour lines to indicate
density. I asked how to reproduce this figure using R on Stack Exchange,
and my question was quickly answered b... 阅读全帖 |
|
F*******h 发帖数: 136 | 10 vect_r<-c(1:10)
theta<-c(0:999)/999*2*pi
c_theta<-cos(theta)
s_theta<-sin(theta)
cir.scatter<-function(r){
f<-array(0,c(1000,2))
f[,1]<-r*c_theta
f[,2]<-r*s_theta
return(f)
}
n<-length(vect_r)
sort_r<-sort(vect_r,decreasing=T)
plot(cir.scatter(sort_r[1]),type="l",xlab="x",ylab="y")
for(i in 2:n){
lines(cir.scatter(sort_r[i]))
} |
|
h*******1 发帖数: 9 | 11 > qqplot(u, rchi, ylab="Data Quantiles", xlab=expression(paste(chi^2, (1), "
", plain(Quantiles)))) |
|
b*******g 发帖数: 513 | 12 搞清楚了,用这句话
plot(z,y,type="l", main="Diagnostics for beta",ylab="beta",xlab="iteration",
axes = FALSE)
axis(1,at=c(20000,40000,60000,80000,100000),lab=c("20000", "40000", "60000",
"80000","100000"))
box()
04 |
|
|
f******9 发帖数: 267 | 14
谢谢,但这个只能保证y轴上的每个数字是水平的,我想要y轴的名称水平,比如plot
heart disease vs snoring,我想要
heart disease这几个单词水平的,而不是和y axis平行 |
|
j******4 发帖数: 6090 | 15 There is a "par" function that can set up the forms of your output, you can
type in ?par in R to look up those parameters.
Here is an MA plot example(Bioinformatics/Microarray):
par(mfrow=c(8,8), mar=c(0.1, 0.1, 0.1, 0.1), xaxt="n", yaxt="n")
for(i in 1:length(rma)){for(j in 1:length(rma)){
Ai<-((rma[,i])+(rma[,j]))/2
Mj<-((rma[,i])-(rma[,j]))
plot( c(min(Ai), max(Ai)), c(-3,3), type="n", xlab="A", ylab="M")
points(Ai, Mj, pch=".")
lines(c(0, 13), c(0,0), col=2)
}} |
|
g**c 发帖数: 84 | 16 有一个数据文件,假如有20000行,我要随机选其中的1000行,要选100次,然后把选的
这100组数据作在一张图里。
我写的程序。怎么加循环语句呢。谢谢!
readtable<-read.table(" ",header = F, sep=",")
n <- nrow(readtable)
print(n)
readtable.sub <- readtable[sample(1:n,1000, replace=FALSE),]
names(readtable.sub)
hist(readtable.sub$V4)
hist(readtable.sub$V4, ,xlab="x",ylab="y", main="xy", freq=FALSE, xlim=c(300
,6000))
lines(density(readtable$V4),col="red") |
|
g**c 发帖数: 84 | 17 for (i in 1:100) {readtable.sub <- readtable[sample(1:n,1000, replace=FALSE
),]
names(readtable.sub)
hist(readtable.sub$V4)
hist(readtable.sub$V4, ,xlab="x",ylab="y", main="xy", freq=FALSE, xlim=c(300
,6000))
lines(density(readtable$V4),col="red")}
这样不行,最后显示的图是第100个,前面的保存不到这张图上,前面的被后面的代替
了。
我错那里了? |
|
w*******e 发帖数: 666 | 18 刚开始学习R,主要是想用survivalROC package。想请教下面的问题,非常感谢!
我做10年和1年的time dependt ROC得到的AUC 一样。我用的是survial ROC guide上的
code。做十年的时候只是把cutoff改成了3650还有year改成了10。不知道是不是还有什
么需要改的,为什么结果完全没有区别?
code 如下:
library(survivalROC)
nobs <- NROW(ggtno)
cutoff <- 365
score1= survivalROC(Stime=ggtno$time,
status=ggtno$censor,
marker = ggtno$score,
predict.time = cutoff,span = 0.25*nobs^(-0.20) )
plot(score1$FP, score1$TP, type="l", xlim=c(0,1), ylim=c(0,1),
xlab=paste( "FP", "\n", "AUC = ",round(score1$AUC,3))... 阅读全帖 |
|
l*********a 发帖数: 42 | 19 How can I improve my R plot (see code below) to publishing quality level (i.
e. as good as Tableau graphs or Excel/PPT graphs)?
Thanks!
#----------------total sales amt --------------------
par(bg="white")
plot(t$tot_sales_amt, type="n", axes=FALSE, ann=FALSE, ylim=c(0,1000000))
lines(t$tot_sales_amt, col="blue")
points(t$tot_sales_amt, pch=21, bg="lightcyan", cex=1.5)
axis(2, col.axis="dark blue")
axis(1, at=1:dim(t)[1],lab=paste(substring(t$dt,5,6), '-', substring(t$dt,7,
8), sep=''), col.a... 阅读全帖 |
|
g******2 发帖数: 234 | 20 suppose your data is a data frame with 2 columns: x and y.
data$group <- 1
data$group[data$x < - log(2)] <- 2
data$group[data$x > log(2)] <- 3
plot(data$x[data$group == 1], data$y[data$group == 1], xlab = "x", ylab = "y
", xlim = range(data$x), ylim = range(data$y))
points(data$x[data$group == 2], data$x[data$group == 2], col = "blue")
points(data$x[data$group == 3], data$x[data$group == 3], col = "red") |
|
l******o 发帖数: 3764 | 21 怎么能弄出个legend来,显示红线和蓝线都是什么?
查了半天也没查到
my code
====================
pl <- ggplot (tab.dat) +
geom_point(data=tab.dat, aes(TAD, DV), colour="#444444", size=3, shape=1
) + #default shape is closed circle
geom_line(data=vpc.dat, aes( (vpc.dat$upper+vpc.dat$lower)/2, vpc.dat[["
X50.sim"]]), size=1.5, colour="#882222") +
geom_line(data=vpc.dat, aes( (vpc.dat$upper+vpc.dat$lower)/2, vpc.dat[["
X5.sim"]]), size=1.5, linetype="dashed", colour="#222288") +
geom_line(data=vpc.dat, aes( (vpc.d... 阅读全帖 |
|
Z*******n 发帖数: 694 | 22 Three people suggested survival model.
I am willing to learn and try.
I used the cox proportional hazard model long long time ago, and now I
forgot how to use it.
Some old R code is below (NOT for this problem at hand, but for some
exercise problem). Am I in the right track? Any tips/hint/R code snippets?
library(survival)
?coxph
coxph.m <- coxph(Surv(lifetime,notcensored1) ~ x1+x2, data=mydata)
summary(coxph.m)
plot(survfit(coxph.m),xlab='time',ylab='1-CDF')
predict(coxph.m, newdata=ldkfakdfj... 阅读全帖 |
|