[R] aggregate output to data frame

2019-03-27 Thread cir p via R-help
Dear users,
i am trying to summarize data using "aggregate" with the following command:

aggregate(pcr$Ct,c(pcr["Gene"],pcr["Type"],pcr["Rep"]),FUN=function(x){c(mean(x),
 sd(x), sd(x)/sqrt(sd(x)))})

and the structure of the resulting data frame is 

'data.frame':66 obs. of  4 variables:
$ Gene: Factor w/ 22 levels "14-3-3e","Act5C",..: 1 2 3 4 5 6 7 8 9 10 ...
$ Type: Factor w/ 2 levels "Std","Unkn": 2 2 2 2 2 2 2 2 2 2 ...
$ Rep : int  1 1 1 1 1 1 1 1 1 1 ...
 $ x   : num [1:66, 1:3] 16.3 16.7 18.2 17.1 18.6 ...

The actual data is "bundled" in a matrix $x of the data frame. I would like to 
have the columns of this matrix as individual numeric columns in the same data 
frame instead of a matrix, but cant really figure it out how to do this in an 
efficient way. Could someone help me with the construction of this?

Thanks a lot,

Cyrus

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] memory usage upon web-query using try function

2011-06-26 Thread cir p
Dear Community,
my program below runs quite slow and I'm not sure whether the http-requests are 
to blame for this. Also, when running it gradually increases the memory usage 
enormously. After the program finishes, the memory is not freed. Can someone 
point out a problem in the code? Sorry my basic question, but I am totally new 
to R programming...

Many thans for your time,
Cyrus

require(XML)
row=0
URL="http://de.finance.yahoo.com/lookup?s=";
df <- matrix(ncol=6,nrow=10)
for (Ticker in 10:20)
{
URLTicker=paste(URL,Ticker,sep="")
query=try(readHTMLTable(
URLTicker,
which=2,
header=T,
colClasses = c("character","character","character",
   "character","character","character"),
stringsAsFactors=F,)[1,],silent=T)

if (class(query)=="data.frame")
{
row=row+1
df[row,]=as.character(query)
}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] dynamic network analysis

2009-07-30 Thread cir p

Dear group,
I am browsing the web to find suitable software for dynamic network analysis. I 
came across the sna-package under R, but this seems to do static analysis only. 
Is this right? Or is there a separate package for dynamic network analysis?
Thanks

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Multiplication of data frame with vector

2009-07-07 Thread cir p

Dear group:
sorry for my beginners question, but I'm rather new to R and was searching high 
and low without success:

I have a data frame (df) with variables in the rows and observations in the 
columns like (the actual data frame has 15 columns and 1789 rows):

  early1 early2 early3 early4 early5
M386T1000  57056  55372  58012  55546  57309
M336T9011063  10312  10674  10840  11208
M427T9112064  11956  12692  12340  11924
M429T91 4594   3890   4096   4019   4204
M447T9026553  27647  26889  26751  26929

Now I'm trying to transform each value column-wise to make columns to all have 
the same mean with:

df * mean(mean(df)) / mean(df).

I just can't get my head around this: mean(df) gives me the correct column 
means vector, and mean(mean(df)) gives me the correct total mean. The above 
operation works correctly for individual rows, i.e. if I do
 df[1,]*mean(mean(df))/mean(df)

Can someone tell me what I am doing wrong??
Thanks!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.