On Feb 8, 2012, at 12:23 AM, Sebastián Daza wrote:
Hi everyone,
I would like to have a function to compute some values in a dataset.
First, I have to define a value for the lx variable in row 1 (e.g.,
100,000), npx is a given proportion. lx of row 2 is equal to lx of row
1 times npx of row 1. I
On 08-02-2012, at 06:23, Sebastián Daza wrote:
> Hi everyone,
> I would like to have a function to compute some values in a dataset.
> First, I have to define a value for the lx variable in row 1 (e.g.,
> 100,000), npx is a given proportion. lx of row 2 is equal to lx of row
> 1 times npx of row
Hi everyone,
I would like to have a function to compute some values in a dataset.
First, I have to define a value for the lx variable in row 1 (e.g.,
100,000), npx is a given proportion. lx of row 2 is equal to lx of row
1 times npx of row 1. I can do this row by row...
data[1,"lx"] <- 10
dat
-Any- was my fix... Appreciate it.
//M
On 3. juni 2010, at 21.33, Phil Spector wrote:
> ?any
>
> Not really a reproducible answer, but I think you're looking
> for
>
> apply(tes[,sam],1,function(x)any(is.na(x)))
>
>
> - Phil Spector
>
you probably want to use the apply function:
d=sample(1000,500);
d[sample(500,50)]<-NA; #put 50 NAs into the data
d=data.frame(matrix(d,ncol=50));
names(d)=paste('var',1:50,sep='.')
d
apply(d,1,sum) #are any of the row values NA ?
apply(d,2,function(x)sum(is.na(x))) #how many values for each of
On Jun 3, 2010, at 2:20 PM, moleps wrote:
> Dear R´ers..
>
> In this mock dataset how can I generate a logical variable based on whether
> just tes or tes3 are NA in each row??
>
> test<-sample(c("A",NA,"B"),100,replace=T)
> test2<-sample(c("A",NA,"B"),100,replace=T)
> test3<-sample(c("A",NA,"
Hi there,
One option would be
apply(tes, 1, function(.row) any(is.na(.row[c(1,3)])))
See ?any, ?is.na and ?apply for more information.
HTH,
Jorge
On Thu, Jun 3, 2010 at 3:20 PM, moleps <> wrote:
> Dear R´ers..
>
> In this mock dataset how can I generate a logical variable based on whether
>
?any
Not really a reproducible answer, but I think you're looking
for
apply(tes[,sam],1,function(x)any(is.na(x)))
- Phil Spector
Statistical Computing Facility
Department o
Dear R´ers..
In this mock dataset how can I generate a logical variable based on whether
just tes or tes3 are NA in each row??
test<-sample(c("A",NA,"B"),100,replace=T)
test2<-sample(c("A",NA,"B"),100,replace=T)
test3<-sample(c("A",NA,"B"),100,replace=T)
tes<-cbind(test,test2,test3)
sam<-c("t
Although the message is rather unreadable, I guess you want to look at
?reshape.
Uwe Ligges
oscar linares wrote:
Dear Rxperts,
I would like to convert the following:
StudyStudy.NameParameterDestSrcFormValueMin
MaxFSD
1NT_1-0BFK(03)03A0.
Dear Rxperts,
I would like to convert the following:
StudyStudy.NameParameterDestSrcFormValueMin
MaxFSD
1NT_1-0BFK(03)03A0.128510.0E+001.
0.41670E-01
1NT_1-0BFL(00,03)0003D0.36577
1NT_1-0BFL(00
? gsub
>
> gsub("\\(|\\)", "", var)
You can then read.table on a textConnection.
> read.table(textConnection(gsub("\\(|\\)", "", var) ))
V1 V2
1 p1 10
2 p1 3
3 p1 4
4 p2 20
5 p2 30
6 p2 40
7 p3 4
8 p3 1
9 p1 2
On Jan 18, 2009, at 12:13 PM, oscar linares wrote:
Dear Rxperts,
I have a
Does this give you what you want:
> x <- read.table(textConnection("p(1) 10
+ p(1) 3
+ p(1) 4
+ p(2) 20
+ p(2) 30
+ p(2) 40
+ p(3) 4
+ p(3) 1
+ p(1) 2"), as.is=TRUE)
> # remove parenthesis
> x$V1 <- gsub("[()]", "", x$V1)
>
>
> x
V1 V2
1 p1 10
2 p1 3
3 p1 4
4 p2 20
5 p2 30
6 p2 40
7 p3 4
8 p3
Dear Rxperts,
I have a varaibles data file that looks like this
p(1) 10
p(1) 3
p(1) 4
p(2) 20
p(2) 30
p(2) 40
p(3) 4
p(3) 1
p(1) 2
I cannot process these data with R because it does not like the parentheses.
How can I get these to look like:
p1 10
p1 3
p1 4
p2 20
p2 30
p2 40
p3 4
p3 1
p3 2
The
> I want to draw a subset of "ex" by selecting only the A and B units:
>
> > ex1 <- subset(ex[which(ex$id=="A"|ex$id=="B"),])
or a bit simpler:
ex1 <- subset(ex, ex$id %in% c('A','B'))
In your expresion you don't need the subset function, as you are already
using indexing to extract the desired
Hi all,
I have a data management question. I am using an panel dataset read into
R as a dataframe, call it "ex". The variables in "ex" are: id year x
id: a character string which identifies the unit
year: identifies the time period
x: the variable of interest (which might contain NAs).
Here
s.d <- structure(list(RiverMile = c(202L, 198L, 190L, 185L, 179L, 148L,
119L, 61L)), .Names = "RiverMile", row.names = c(NA, -8L), class =
"data.frame")
#s.d is all of the river miles that can occur in all of the data frames that
I want to put together
feb06 <- structure(list(RiverMile = c(202L, 1
This is an example of two months of data from a twenty four month data set
that I would like to apply this too. These data are subsets of the same
stations throught time, but differing ones were included on different
sampling dates. I would like to subset these data and then put them
together as
18 matches
Mail list logo