Thank you, that helps.
-Original Message-
From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us]
Sent: Monday, March 5, 2018 3:36 PM
To: Sariya, Sanjeev
Cc: r-help@r-project.org; R Help
Subject: RE: [R] Help with apply and new column?
Comments interspersed, and some code at the end
t;:" ) # gets the whole column splits at once
# wildly guessing here
rs_chrmatrix <- do.call( rbind, temp )
rs_DF <- as.data.frame( rs_chrmatrix, stringsAsFactors = FALSE )
names( rs_DF ) <- c( "CHR", "P", "X1", "X2" )
rs_DF$P <- as.integer( rs_DF$P )
str( rs_DF )
##
data)<-c("SNP","P","CHR","BP")
-Original Message-
From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us]
Sent: Monday, March 5, 2018 1:48 PM
To: r-help@r-project.org; Sariya, Sanjeev ; R Help
Read the Posting Guide... (see message footer) ... some relevant things you can
find there:
a) Yes, this appears to be about how to use an R base function so it is on topic
b) Post a reproducible example (include some sample data, preferably using the
dput function)
c) Post using plain text so t
Hello members,
Can I ask question for apply, adding new column to data frame on this e-mail
list?
Thanks!
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman
Dear All,
please provide insights into the following problem;
this part is the reproducible example:
library(nleqslv)
S1 <-0.5
S2 <-0.5
Z <-7.2598
M1 <--5.7831
M2 <-24.597
mk501 <-1.2827
mk502 <-4.7964
AL <--0.5623
f <- function(H1){
1 -
(S1/(mk501*((H1/(Z-H1))^(1/M1)))+S2/(mk502*((H1/(Z-
ith it.
Regards
Petr
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Robert Lynch
> Sent: Friday, July 26, 2013 2:46 AM
> To: r-help@r-project.org
> Subject: [R] help with apply (lapply or sapply not sure)
>
I am reading in a bunch of files and then processing them all in the same
way.
I am sure there as a better way then to copy and past the code for each
file. Here is what I've done so far
InputFiles<-
as.character(list.files("~/ISLE/RWork/DataWarehouseMining/byCourse/"))
#Path to the Course data f
Dear R users, I am trying to use apply function on a 3D array (get rid of any
loop) but wasn't successfull. Below is a toy example of what I am trying to do:
refID_remNoCat = 1:30;
s_remNoCat = sample(1:length(refID_remNoCat),size=length(refID_remNoCat));
s.sort_remNoCat = sort(s_remNoCat,ind
M.Ribeiro wrote:
>
> Ok, I am sorry, I was building a reproducible example to post here and I
> made a mistake. Th second loop (in the variable k) updates ycorr.
> Therefore, it would be
>
> ycorr <- rnorm(10)
> Nindiv <- 10
> x <-matrix(sample(c(0:2),50,re = T),10)
> gtemp <- rnorm(10)
> for (i
Ok, I am sorry, I was building a reproducible example to post here and I made
a mistake. Th second loop (in the variable k) updates ycorr.
Therefore, it would be
ycorr <- rnorm(10)
Nindiv <- 10
x <-matrix(sample(c(0:2),50,re = T),10)
gtemp <- rnorm(10)
for (i in 1:Nindiv) {
for (k in 1:nco
Hi:
Are you *sure* that's what you want to do?
> y - x[,5] * gtemp[5]
[1] 0.10116205 2.46220119 3.04966544 0.56074569 -1.14872521 -0.89275228
[7] 3.52161381 0.64880894 0.70167063 -0.06120996
> identical(as.vector(ycorr), y - x[,5] * gtemp[5])
[1] TRUE
Perhaps you ought to explain what y
Hello R gurus,
I have a simple routine using for loops that i was just trying to make it
faster
y <- rnorm(10)
Nindiv <- 10
x <-matrix(sample(c(0:2),50,re = T),10)
gtemp <- rnorm(10)
ycorr <- array(0,c(Nindiv,1))
for (i in 1:Nindiv) {
for (k in 1:ncol(x)) {
ycorr[i] <- y[i
keley.edu]
> Sent: Monday, October 04, 2010 2:20 PM
> To: Doran, Harold
> Cc: Gabriela Cendoya; R-help
> Subject: Re: [R] Help with apply
>
> Harold -
> The first way that comes to mind is
>
> doit = function(i,j)exp(sum(log((exp(tmp[i,]*(qq$nodes[j]-b))) /
>
ld
Cc: Gabriela Cendoya; R-help
Subject: Re: [R] Help with apply
Harold -
The first way that comes to mind is
doit = function(i,j)exp(sum(log((exp(tmp[i,]*(qq$nodes[j]-b))) /
(factorial(tmp[i,]) * exp(exp(qq$nodes[j]-b)) *
((1/(s*sqrt(2*pi))) * exp(-((qq$nodes[j]-0)^2/(
PM
To: Doran, Harold
Cc: R-help
Subject: Re: [R] Help with apply
You are missing "s" in your definitions so I can't reproduce your code.
tmp <- data.frame(var1 = sample(c(0:10), 3, replace = TRUE), var2 =
sample(c(0:10), 3, replace = TRUE), var3 = sample(c(0:10), 3, repl
On Mon, Oct 4, 2010 at 10:44 AM, Gabriela Cendoya
wrote:
> You are missing "s" in your definitions so I can't reproduce your code.
When he uses apply(), he sets s = 1.
>
>> tmp <- data.frame(var1 = sample(c(0:10), 3, replace = TRUE), var2 =
>> sample(c(0:10), 3, replace = TRUE), var3 = sample(c
Sorry about that; s <- 1
-Original Message-
From: Gabriela Cendoya [mailto:gabrielacendoya.rl...@gmail.com]
Sent: Monday, October 04, 2010 1:44 PM
To: Doran, Harold
Cc: R-help
Subject: Re: [R] Help with apply
You are missing "s" in your definitions so I can't reproduce
You are missing "s" in your definitions so I can't reproduce your code.
> tmp <- data.frame(var1 = sample(c(0:10), 3, replace = TRUE), var2 =
> sample(c(0:10), 3, replace = TRUE), var3 = sample(c(0:10), 3, replace = TRUE))
>
> str(tmp)
'data.frame': 3 obs. of 3 variables:
$ var1: int 9 3 9
Suppose I have the following data:
tmp <- data.frame(var1 = sample(c(0:10), 3, replace = TRUE), var2 =
sample(c(0:10), 3, replace = TRUE), var3 = sample(c(0:10), 3, replace = TRUE))
I can run the following double loop and yield what I want in the end (rr1) as:
library(statmod)
Q <- 2
b <- runif
On 8/02/2010 4:33 PM, Jim Lemon wrote:
On 02/08/2010 12:26 PM, Nathan S. Watson-Haigh wrote:
I have a 2 column data.frame:
> d[1:5,]
a b
1 80015 C
2 80016 B
3 80023 C
4 80062 B
5 80069 B
I want to apply a function across each row:
> for(i in 1:nrow(d)) {
+ myFun(con, d[i,]$a, d[i,]
On 8/02/2010 2:08 PM, David Winsemius wrote:
On Feb 7, 2010, at 8:26 PM, Nathan S. Watson-Haigh wrote:
I have a 2 column data.frame:
d[1:5,]
a b
180015 C
280016 B
380023 C
480062 B
580069 B
I want to apply a function across each r
On 02/08/2010 12:26 PM, Nathan S. Watson-Haigh wrote:
I have a 2 column data.frame:
> d[1:5,]
a b
1 80015 C
2 80016 B
3 80023 C
4 80062 B
5 80069 B
I want to apply a function across each row:
> for(i in 1:nrow(d)) {
+ myFun(con, d[i,]$a, d[i,]$b)
+ }
How do I do this using apply()? I'm unsu
On Feb 7, 2010, at 8:26 PM, Nathan S. Watson-Haigh wrote:
I have a 2 column data.frame:
> d[1:5,]
a b
180015 C
280016 B
380023 C
480062 B
580069 B
I want to apply a function across each row:
> for(i in 1:nrow(d)) {
+myFun(con, d[i,]$a, d[i,]$b)
+
I have a 2 column data.frame:
> d[1:5,]
a b
180015 C
280016 B
380023 C
480062 B
580069 B
I want to apply a function across each row:
> for(i in 1:nrow(d)) {
+myFun(con, d[i,]$a, d[i,]$b)
+ }
How do I do this using apply()? I'm unsure how to tell ap
> datg=t(sapply(split(datgic, datgic$NPERMNO, drop=TRUE),
function(x){return(
> x[nrow(x),] )}))
>
>
> I get something like this...
>
> GVKEY NPERMNO GIC year
> 10001 12994 10001 55102010 2007
> 10002 19049 10002 40101015 2007
> 10009 16739 10009 40101010 1999
>
> Has this
What you are seeing are the row numbers of the original locations. If
datgic is really a data frame, this is probably what you want using
lapply and do.call:
> x <- data.frame(a=letters, b=sample(1:4, 26, TRUE))
> y <- lapply(split(x, x$b), tail, 1)
> do.call(rbind, y)
a b
1 z 1
2 y 2
3 w 3
4 x
I'm trying to drop all rows except for the ones with the most recent year.
So I split the data frame by NPERMNO and keep just the last record of all
groups.
datg=t(sapply(split(datgic, datgic$NPERMNO, drop=TRUE), function(x){return(
x[nrow(x),] )}))
I get something like this...
GVKEY NPE
28 matches
Mail list logo