由买买提看人间百态

topics

全部话题 - 话题: colname
1 (共1页)
c***z
发帖数: 6348
1
It took me a whole day. Either I am retarded or SQL is. Why it is so
complicated just to loop over all columns!
I am posting here to help people facing similar problems. If you have a
better solution, please do share! Thanks!
Below is the SQL code:
DECLARE @ColName VARCHAR(150)
DECLARE @sqlStatement VARCHAR(MAX)
SET @sqlStatement = 'initial part of you query, for example select, insert
update etc. '
DECLARE myCursor CURSOR STATIC FOR
SELECT name FROM syscolumns WHERE id = (SELECT id FRO... 阅读全帖
O*****y
发帖数: 222
2
a <- read.csv("A.csv", header=TRUE)
b <- read.csv("B.csv", header=TRUE)
new1 <- cbind(a, b[, setdiff(colnames(b), colnames(a))])
new2 <- b[, setdiff(colnames(b), colnames(a))]
l**********l
发帖数: 361
3
来自主题: Biology版 - 求文章三篇
Title: Non-invasive genetic identification of the red fox Vulpes vulpes in
the Shiretoko National Park, eastern Hokkaido, Japan
Source: Mammal study [1343-4152] Oishi yr:2010 vol:35 iss:3 pg:201 -207
http://apps.isiknowledge.com/full_record.do?product=UA&colname=
Title: Sex Determination and Individual Identification of American Minks (
Neovison vison) on Hokkaido, Northern Japan, by Fecal DNA Analysis
Source: Zoological science [0289-0003] Shimatani yr:2010 vol:27 iss:3 pg:243
-247
http://apps... 阅读全帖
l*******d
发帖数: 101
4
来自主题: Statistics版 - 【R】保留matrix中某些值
跟DaShagen写的大同小异。把找出来的值加进去。
> n = 4
> threshhold = 5
> X = matrix (1:16, byrow=TRUE, ncol=n, dimnames=list(1:4, c("A", "B", "C",
"D")))
> X
A B C D
1 1 2 3 4
2 5 6 7 8
3 9 10 11 12
4 13 14 15 16
> ind = which (X>threshhold, arr.ind=TRUE)
> findNames = data.frame (ind, rowName=rownames(X)[ind[,1]], colName=
colnames(X)[ind[,2]], value=as.vector(X)[(ind[,2]-1)*n+ind[,1]], row.names=
NULL)
> findNames
row col rowName colName value
1 3 1 3 A 9
2 4 1 4
r****5
发帖数: 618
5
来自主题: DataSciences版 - R 问题请教
f0008非常感谢,我用了
t(apply(subhw,2,FUN=function(x) c(Missing=sum(is.na(x)),Mean=mean(x),Median
=median(x), sdev=sd(x), Min=min(x), Max=max(x))))

如果col没有排序要求,你的更简单。原来summary里可以再加其他function, 象sd等
,我还以为仅仅能用原有的6个呢。
还有个问题,就是这个显示print 后再屏幕上有row names,就是原来的col names。但
是write。table后就没有了。这样我要再加一个col才行。我在上面的function里加了
mycols=colnames(x)。但是执行后没有显示出来
summary<-t(apply(subhw,2,FUN=function(x) c(mycols=colnames(x),Missing=sum(is
.na(x)),Mean=mean(x),Median=median(x), sdev=sd(x), Min=min(x), Max=max(x))))
print... 阅读全帖
i*****w
发帖数: 75
6
建议一种方法:
1) UNPIVOT TableA, You will get:
ID1, COL1, CONTENT1
ID2, COL2, CONTENT2
ID3, COL3, CONTENT3
2) Join TableA and TableB by LIKE.
EXAMPLE:
-- Prepare Source Table
DECLARE @tblA Table (ID int identity, col1 varchar(100), col2 varchar(100),
col3 varchar(100))
INSERT INTO @tblA (col1, col2, col3)
SELECT 'this is a test', 'I am not sure', 'Give it a try.'
UNION ALL
SELECT 'who cares', 'No one knows', 'Why not'
UNION ALL
SELECT 'it is impossible', 'please let me know', 'be honest'
-- ... 阅读全帖
l**********1
发帖数: 5204
7
big aunt or uncle
BTW, including LX some post then by Matrix machine learning
LZ pls refer one E-Book
by NAOMI ALTMAN
its title is 'R lecture'
its pp9
>We will use the grep command to find the columns from the same biological
>replicate. Note that hexbin >resets the number of plots per gure
>back to one. If you want to use a loop to plot several pairs, you need to
>use par(ask=T) to page through
>the plots. Here we do only the rst 6 plots. The grayscale of the plot
>indicates the number of ... 阅读全帖
q**j
发帖数: 10612
8
来自主题: Statistics版 - 两个有关于R的小问题?
That is very good. I am not aware of the assign tool.
Another issue is:
Result = matrix(0,nrow=2,ncol=3)
for (j in 1:3)
{
colnames(Result)[j] = paste("item",j,sep="")
}
can you see why it always gives error message? but
colnames(Result) = c("Good","Better","Best")
will work as expected. I am quite puzzled here.
o******6
发帖数: 538
9
☆─────────────────────────────────────☆
qqzj (小车车) 于 (Thu Feb 26 15:48:04 2009) 提到:
好奇心强,同一个工作用R和python各搞了一次。数据文件是709 by 88的.csv文件。如
下是R code: (code 写的不好,希望拍砖帮我改进。)
************************************************************************
Data = read.csv("D:/VP_BAP.csv")
NoRow = dim(Data)[1]
NoCol = dim(Data)[2]
RowName = Data[,1]
ColName = colnames(Data)
Output = c("","")
for (i in 1:NoRow){
for (j in 1:NoCol){
if (Data[i,j]==c("N")){
Temp = c(as.character(RowName[i]
a***r
发帖数: 420
10
来自主题: Statistics版 - 【R】保留matrix中某些值
有个n*n的matrix(result),有col和row name,我想保留这个matrix中大于5的值,
并且保留这些值对应的colname和rowname,因为这个是这些值的来源信息。
不知道有没有专门的语句,发挥主观能动性写了一个:
threshold<-matrix(,ncol=4,nrow=n*n)
for (i in 1:(n-1)){
for (j in (i+1):n) {
if (result[i,j]>5)
threshold[((i-1)*n+j),1] <-rownames(result)[i]
threshold[((i-1)*n+j),2] <-colnames(result)[j]
threshold[((i-1)*n+j),3] <-as.numeric(result[i,j])
}
}
threshold <- threshold[complete.cases(threshold),]
总觉得有点笨哪,有没有语句直接能实现的呢?
谢谢大家!
S********a
发帖数: 359
11
来自主题: Statistics版 - 【包子】从excel读取数据到R的问题
我怎么找出我的perl是多少呢,我目前的理解是不止一个方法读取XLS,哪个最方便使
用呢?
或者我用
library(xlsReadWrite)
mydata<-read.xls("c:\L\NJ\Study\copy.xls", colNames=TRUE)
出下面错误信息
Error in .Call("ReadXls", file, colNames, sheet, type, from, rowNames, :
Incorrect number of arguments (11), expecting 10 for ReadXls
怎么改呢?
s*****a
发帖数: 2735
12
来自主题: Statistics版 - SAS 中 proc iml 怎么生成data file?
PROC IML;
X={2 3,
4 5};
CREATE test2 FROM x[colname={'a' 'b'}];
APPEND FROM x;
Quit;
上边这个可以生成 test2;
PROC IML;
a=1;
b=2;
x={a b};
CREATE test2 FROM x[colname={'a' 'b'}];
APPEND FROM x;
Quit;
上面这个就不行了
只给出
a b
A B
请提示。
n*******y
发帖数: 437
13
来自主题: Statistics版 - 求助 R density plot 出现波纹。。。
hello大家好 我R用了一阵也不是太熟 请问,当数据点少的时候density plot出
现波纹怎么解决? 谢谢!
code:
# show fringes
test = as.data.frame( sample(0:5,10000,replace=T) )
colnames(test) = c('mon')
ggplot(test, aes(x=mon)) + geom_density(binwidth=1, size=1)
# normal
test = as.data.frame( sample(0:20,10000,replace=T) )
colnames(test) = c('mon')
ggplot(test, aes(x=mon)) + geom_density(binwidth=1, size=1)
c***z
发帖数: 6348
14
来自主题: DataSciences版 - generating percentile-percentage charts
老板又有新花样,这次要cumulative的percentages
patient_percentiles_cum <- patient_percentiles_fin[, c(1,102)]
colnames(patient_percentiles_cum)[2] <- "top.0"
for (k in 1:100) {
# k <- 1

temp <- patient_percentiles_fin[, c(102:(102-k))]

top <- apply(temp,
1,
FUN = sum)
top <- data.frame(top)

patient_percentiles_cum <- cbind(patient_percentiles_cum,
top)

colnames(patient_percentiles_cum)[2+k] <- paste("top",
... 阅读全帖
h******3
发帖数: 351
15
来自主题: JobHunting版 - 贡献两个题
Palo Alto小公司, 不错的start up.
一上来半个小时, 三个题, 一张纸. 我开始没重视(字迹廖草), 最后就载在上面.
code, code, code强, 才有机会啊.
1. 给你一个整数数组 int[] arr, size较小. 请写出一个sort method.
comments: 我写的是selection sort. 题目里边数据量没有具体数据, 也无人可以问,
发题目的是recruiter. 如果你面世, 写那个啊? quick sort
2. step by step, explain what does server do when execute
select max(colname) from t1;
3. 一张表, 写with statement
b******o
发帖数: 545
16
Error in .Call("WriteXls", x, file, colNames, sheet, from - 1, rowNames, :
Incorrect number of arguments (7), expecting 6 for WriteXls
================================================================
what's that means?
c*****d
发帖数: 6045
17
来自主题: Database版 - a simple question on Oracle
你是问如何格式化输出吗
set linesize 120
set pagesize 500
format [colname] a20
c***c
发帖数: 6234
18
来自主题: Database版 - 关于not closed cursor的请教
我写java。使用了大量的Stored Procedure。很多是open cursor,return java一个
list。
同组另一个人只会一般query,也只用一般statement。现在测试发现,每个session 有
30-40个 held unclosed cursor。
我们都是确保在使用cursor fetch data 后,都close resultset 和statement的
会不会cursor从一般query来的?
难道不能使用SP的 out parameter 是cursor?我这么用了10年了,一直没问题。很疑惑
code类似
stmPersonMaster.registerOutParameter(5, OracleTypes.CURSOR);
stmPersonMaster.execute();
rs = (ResultSet) stmPersonMaster.getObject(5);
while(rs.next()){
rs.getString(colName)
}
rs.close
stmPersonMaster.close
谢谢
B********r
发帖数: 397
19
来自主题: Programming版 - Cassandra 里的 partition

table,
是啊,还有一个大问题,就是用CQL3怎么动态的加column, 比如我定义了一个table只有
两个colum,那就不能直接
set keySpace[colFamily][colName] = value
而必须先add column 然后再 insert? 这样不是多了一个round trip么.
还有如果我要 select top 10 * from table order by id
貌似只能把所有的都返回,我在client side自己sort?
l**********1
发帖数: 5204
20
Continue:
第四乐章 Finale
找有关的PhD dissertation 里边的 R source code program
while U can debug it or even rewrite it for another task,
then you already masted NGS coding skills.
比如
http://www.dspace.cam.ac.uk/handle/1810/218542
DSpace at Cambridge
title: Genome-wide analyses using bead-based microarrays
Authors: Dunning, Mark J
Issue Date: 4-Sep-2008
Files in This Item:
File Description Size Format
dunning_thesis_.pdf 10.47 MB Adobe PDF
its Appendix B
R source Code f... 阅读全帖
F********E
发帖数: 1025
F********E
发帖数: 1025
s*****n
发帖数: 2174
23
来自主题: Statistics版 - 两个有关于R的小问题?
你定义矩阵的时候, 默认的dimnames是NULL, 也就是不存在.
下面你对一个不存在的东西取[j]指标, 显然会报错. 但是你
做colnames(Result) = c("Good","Better","Best")的时候,
是等于正常赋值, 这个是可以的. 问题出在取[j]指标上.
这个就好像下面这个例子
> a[3] <- 1
Error: object "a" not found
在没有的定义a的情况下, 你就取a[3]是不行的.
> a <- c(NA, NA, 1)
你对a整体赋值, 这是可以的.
解决办法:
1. (推荐)使用data.frame. data frame 是R里面专门定义的一种特殊类型的矩阵, 比
矩阵的信息要稍微丰富一些. 能用data frame, 就不要用matrix.
Result <- data.frame(matrix(0,nrow=2,ncol=3))
for (j in 1:3){
names(Result)[j] = paste("item",j,sep="")
}
2. 如果非要用matrix, 那么就事先把dimnames的位置
b********y
发帖数: 63
24
来自主题: Statistics版 - 今天又“R”了 -- 感想和请教。
Not sure how SAS is more convenient on those issues, but they should not be a
problem for R at all.
同一个事情先用SAS干了,然后用R干了。有些感想,有些问题。跑来跟大家交流一下啊。
1. R里面改个变量名这么这么难?
需要一个reshape pacakge
data.frame = rename(data.frame, c(oldname = "newname"))
不用这个package就更麻烦了。
you can just change the name: colnames(x)[1] = newName1.
2. 控制时间,日期怎么这么难?
以前“告别棒球场”说了,最好不要用日期,全部用字符。临到用的时候才换。就算这
样还是问题多多。比如 “1990-12-04”,怎么样轻松的把它变成 “1990-12-01”(月
初),“1990-12-31”(月末)。往前,往后移动几个月?我写了一个function来干这
个。但是非常慢(yes, I know it.)而且不能往以前移动。我
q**j
发帖数: 10612
25
多谢帮助!
1. 如果一个data frame 有 (key1, key2, var1),另外一个有(key1, key2, var2)。
我希望找出在第一个data frame里面,但是不在第二个里面的所有行。请问是否必须要
像SAS那样建立in1, in2然后经过merge()以后挑选?有没有简单的办法?(var1 var2
可能是missing)。
2.
> data
x y z
1 apple 1996 1
2 orange 1997 2
3 orange 1996 3
4 apple 1998 4
5 apple 1997 5
> new
[,1] [,2] [,3]
[1,] NA NA NA
[2,] NA NA NA
> rownames(new) = unique(x)
> colnames(new) = unique(y)
> new
1996 1997 1998
apple NA NA NA
orange NA NA NA
> Row.Index = match(data$x,rownames(new))
f***a
发帖数: 329
26
来自主题: Statistics版 - R question about apply() and outer()
Anyone has any idea? I have been facing such problems. Thanks! :)
#data set
dat <- matrix(1:10,,2)
colnames(dat) <- letters[1:2]
F <- function(a,b){a+b}
outer(1:2,4:6,F) #wokring
apply(dat,1,F) #not working. how to fix?
x <- 1:5
FF <- function(a,b){ sum(a*x+b) }
outer(1:2,4:6,FF)#not working. why? how to fix?
s*****n
发帖数: 2174
27
来自主题: Statistics版 - R question about apply() and outer()
第一个问题, 可以用apply实现. 但你要确定F的参数只有一个, 这个参数在实际操作中就是矩阵的每一行. 比如下面这个例子
dat <- matrix(1:10,,2)
colnames(dat) <- letters[1:2]
F <- function(t){t[1] + t[2]}
apply(dat,1,F)
注意定义的是 F(t), 而不是 F(t[1], t[2]).
seq(along=a) 在这里不是1, 而是6. 如果你觉得是1, 说明你没有理解outer的工作原理. outer(a, b, FUN) 的执行原理, 是先把a, b 做成相应的矩阵(本质还是向量)A, B, 然后一起传给FUN. FUN要对A和B的对应元素进行操作. 这里
a 是 (1,2), b是(4,5,6). 传递给FUN的分别是(1,2,1,2,1,2)和(4,4,5,5,6,6)
你定义的FF, 是把A和B看作向量来和x进行操作的, R会认为需要把一个长度为6的向量和一个长度为5的向量相乘, 然后再和一个长度为6的向量相加, 所以报错.
下面的例子可能能对你的理解有帮助:
x <- 1:5
f**********e
发帖数: 48
28
#R code, simple implementation, your data frame is df
cl<-colnames(df)
rw<-rownames(df)
cl_len<-length(cl)
rw_len<-length(rw)
new_rname<-character(cl_len*rw_len)
new_data<-numeric(cl_len*rw_len)
index<-0
for (i in 1:cl_len){
for (j in 1:rw_len){
index<-index+1
new_rname[index]<-paste(rw[j],cl[i])
new_data[index]<-df[i,j]
}
}
data.frame(new_rname,new_data)
y****2
发帖数: 34
29
来自主题: Statistics版 - 再问R的问题 - 关于matrix 的operation
data <- matrix(c(1 ,1 ,2, 2, 1, 3, 4, 2,1, 5, 6, 3,2, 7, 8, 3,2, 9, 10, 4),
ncol=4, byrow=T)
colnames(data) <- c("id", "x1", "x2", "e")
### step1:
data[,2:3] <- data[,2:3]*data[,4]
data1 <- data[,1:3]
### step2:
data2 <- aggregate(data1[,2:3], list(id=data1[,1]), sum)
### step3:
data3 <- split(data2[,2:3], f=list(data2[,1]))
data3 <- lapply(data3, as.vector, "numeric")
mprod <- function(x){x %*% t(x)}
data4 <- lapply(data3, mprod)
### step4:
data5 <- 0
for(i in 1:length(data4)){
data5 <- data5 +
f******9
发帖数: 267
30
来自主题: Statistics版 - 请教一个关于R的问题
谢谢了,但是有个问题因为我的colnames有数字,这样的话,虽然两个表格相同的
column在一起了,但是column的顺序
全打乱了,都按照从小到大排列了。
i********f
发帖数: 206
31
来自主题: Statistics版 - 请教一个关于R的问题
可能需要改一下colnames
s*****n
发帖数: 2174
32
来自主题: Statistics版 - 【R】保留matrix中某些值
给你写个example, 抛砖引玉吧
假设你的矩阵叫做 A, 目标data frame叫做 result.
result <- data.frame(
RowName = rep(dimnames(A)[[1]], dim(A)[2]),
ColName = rep(dimnames(A)[[2]], each = dim(A)[1]),
Value = as.vector(A))
result <- result[result$Value > 5, ]
在R里面, 要尽量避免循环啦.
a***r
发帖数: 420
33
来自主题: Statistics版 - 怎样用R定位变量的位置
抛砖引玉
#original matrix: A
#new matrix: X
#number of obs:n
#number of var:nvar
> A
var1 var2 var3 var4 var5
1 1 2 3 4 5
2 6 7 8 9 10
3 11 12 13 14 15
4 16 17 18 19 20
>n=4
>nvar=5
>value <-as.vector(t(A))
>varname <-rep(colnames(A),n)
>ID <-sort(rep((1:n),nvar))
>X <-data.frame(cbind(ID,varname,value))
ID var value
1 1 var1 1
2 1 var2 2
3 1 var3 3
4 1 var4 4
5 1 var5 5
6 2 var1 6
7 2 var2 7
8 2 var3
p***r
发帖数: 920
34
来自主题: Statistics版 - 怎样用R定位变量的位置
data<-data.frame(matrix(101:106,2,3))
> data
X1 X2 X3
1 101 103 105
2 102 104 106
> newdata<-
data.frame(id=rep(rownames(data),dim(data)[2]),varname=rep(colnames(data
),dim(data)[1]),value=c(t(as.matrix(data))))
> newdata
id varname value
1 1 X1 101
2 2 X2 103
3 1 X3 105
4 2 X1 102
5 1 X2 104
6 2 X3 106
f******9
发帖数: 267
35
来自主题: Statistics版 - R:matrix
How to find the numbers which are more than 0.5 in a matrix (and with their
rownames and colnames)?
for example, in this matrix:
[,1] [,2] [,3] [,4] [,5]

[1,] 1.0000000000 0.0320075758 0.1183712121 0.0293040293 0.0083333333
[2,] 0.0320075758 1.0000000000 0.0571428571 0.1668650794 0.0004662005
[3,] 0.1183712121 0.0571428571 1.0000000000 0.0053418803 0.0028846154
[4,] 0.0293040293 0.1668650794 0.0053418803 1.0000000000 0.0426767677
[5,] 0.008333
S******y
发帖数: 1123
36
最近在研究R - biglm.
R document 里说 - "biglm creates a linear model object that uses only p^2
memory for p variables. It can be updated with more data using update. This
allows linear regression on data sets larger than memory."
读了下面的 source code, 还是没搞懂update具体是怎么实现的。。。
> biglm::biglm
function (formula, data, weights = NULL, sandwich = FALSE)
{
tt <- terms(formula)
if (!is.null(weights)) {
if (!inherits(weights, "formula"))
stop("`weights' must be a formula")
w <- ... 阅读全帖
z**********i
发帖数: 88
37
来自主题: Statistics版 - a R question
Using SAS to subset data, I can get N=48, but using R, I can not, I don't
know anything about. Would anybody check my R code and see where is the
problem? Below is the SAS code and R code. Thanks.
data x;
set ALL_12222010;
where tau>93 & abeta142<192 & PTAU181P>23;run; **n=48;
#R code;
sizing <- function(variable.name,dx.group){
cut.sample <- function(variable.name,dx.group){
attach(variable.name)
variable.name$enrich=as.numeric(tau>93 & abeta142<192 & PTAU181P>23);
... 阅读全帖
J****n
发帖数: 54
38
来自主题: Statistics版 - R xlsReadWrite package
> aaa <- read.xls(rfile)
Error in .Call("ReadXls", file, colNames, sheet, type, from, rowNames, :
Incorrect number of arguments (11), expecting 10 for ReadXls
大家遇到过这个错么?怎么改?(Windows OS)
Thanks.
q**j
发帖数: 10612
39
来自主题: Statistics版 - 用R出现怪问题。
好像是rownames和column names不一样造成的。这个也太不合理了吧。
> colnames(S)=1:12
> rownames(S)=1:12
> all.equal(S, t(S))
[1] TRUE
请问有没有简单的办法让R不这么变态。明明是个矩阵么。

V
-0
-0
-0
-0
b*****n
发帖数: 685
40
来自主题: Statistics版 - 用R出现怪问题。
colnames()=NULL
rownames()=NULL
t****a
发帖数: 1212
41
You can use fisher exactly test to tell if the overlapping is random. Before
doing this you need to now that the size of the background (the DaShagen's
questions: How many genes are there?). In the following code I just assumed
the background size is 20000, both A and B are sampled from the background.
# R code here.
bg <- 20000; a <- 3000; b <- 4000; ab <- 500
your.data <- matrix(c(ab, a-ab, b-ab, bg-a-b+ab), 2, 2)
colnames(your.data) <- rownames(your.data) <- c('In Group', 'Not In Group')
name... 阅读全帖
a********a
发帖数: 346
42
来自主题: Statistics版 - R help
挺简单的一个R code, 下边的error是为什么呢?
> data=matrix(1:4,2,2)
> data
[,1] [,2]
[1,] 1 3
[2,] 2 4
> colnames(data)=c("x","y")
> data
x y
[1,] 1 3
[2,] 2 4
> data$x
Error in data$x : $ operator is invalid for atomic vectors
b********y
发帖数: 63
43
来自主题: Statistics版 - R help
> data = as.data.frame(matrix(1:4,2,2))
> colnames(data)=c("x","y")
> data$x
d*********k
发帖数: 1239
44
用了dataframe啊,然后 dim() 给我的是3*4矩阵,我可以改colnames和rownames,这
个没有问题
但是怎么给最开始的一列(暂且叫0列,也就是rownames)加个名字呢?就是rownames
()表示的是年份1990,1991,1992,我想在最左上角加个名字
不知道我解释清楚我想干嘛了没有~~ 谢谢啦
t****a
发帖数: 1212
45
it is possible.
assuming that your matrix is m
them you can define names(dimnames(m)) = c(rownames.title, colnames.title)
t****a
发帖数: 1212
46
it is possible.
assuming that your matrix is m
them you can define names(dimnames(m)) = c(rownames.title, colnames.title)
s********1
发帖数: 54
47
来自主题: Statistics版 - SAS里缺失observation补全的问题
data hh1;
input ID year;
cards;
1 1998
1 2001
2 1994
2 1995
2 1999
2 2001
3 1997
3 1999
3 2000
;
run;
proc univariate data=hh1;
var year;
by ID;
output out=dout max=dmax min=dmin;
run;
proc iml;
use dout;
read all into X;
do i = 1 to 3;
n=X[i,2]-X[i,3]+1;
xx_temp=repeat(i,n,1)||(X[i,3]:X[i,2])`;
xx=xx//xx_temp;
end;
print xx;
create hh1fix from xx[colname={ID year}];
append from xx;
quit;
t*****w
发帖数: 254
48
来自主题: Statistics版 - 怎样来选这些dyads
answer is the following;
your final result is the following:
student teacher senior
2732 3465 1
3347 3837 1
1179 1693 1
3875 1711 1
3875 2059 1
2032 1784 1
2848 3921 1
2148 1416 1
3038 1434 1
3530 2037 1
2585 3811 1
1481 3954 1
... 阅读全帖
c***z
发帖数: 6348
49
## build data frame
work <- c(12, 14, 4, 16, 12, 20, 25, 8, 24, 28, 4, 15)
edu <- c(6,3,8,8,4,4,1,3,12,9,11,4)
income <- c(34.7, 17.9, 22.7, 63.1, 33.0, 41.4, 20.7, 14.6, 97.3, 72.1, 49.1
, 52.0)
studay.df <- data.frame(cbind(work, edu, income))
## linear model
model_3 <- lm(income ~ ., data = studay.df) # OLS
summary_table <- data.frame(summary(model_3)$coefficients)
colnames(summary_table) <- c("coef", "std.error", "t_value", "p_value")
summary_table$regressor <- row.names(summary_table)
s... 阅读全帖
t*****w
发帖数: 254
50
来自主题: Statistics版 - 请问面试 R 应该怎么准备?
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... 阅读全帖
1 (共1页)