On Thu, Dec 3, 2009 at 3:52 PM, John Filben johnfil...@yahoo.com wrote:
Can R support data manipulation programming that is available in the SAS
datastep? Specifically, can R support the following:
- Read multiple dataset one record at a time and compare values from
each; then base
Please refrain from posting HTML. The results can be incomprehensible:
On 2009.12.03 13:52:09, John Filben wrote:
Can R support data manipulation programming that is available in the SAS
datastep??? Specifically, can R support the following:
-?? Read multiple dataset one
The data import/export manual can elaborate on a lot of these; this is
all straightforward, although many people would prefer to use a
relational database for some of the things you mentioned. I'm not
aware of a goto command in R, though (although I could be wrong).
--Gray
On Thu, Dec 3, 2009 at
On Dec 3, 2009, at 10:52 PM, Gray Calhoun wrote:
The data import/export manual can elaborate on a lot of these; this is
all straightforward, although many people would prefer to use a
relational database for some of the things you mentioned.
See Wickham's pithy response to this.
I'm not
Try this:
as.data.frame.table(xtabs(area ~ habitat + sq, DF), responseName =
area.sum)[c(2:3, 1)]
sq area.sum habitat
1 10 field
2 13 garden
3 13pond
4 10 river
5 21 field
6 22 garden
7 20pond
8 2
Is this what you are looking for:
x
X Y Z
1 123 3 1
2 234 3 1
3 345 4 2
4 456 3 2
new.x - x[rep(seq(nrow(x)), times=x$Y),]
new.x
X Y Z
1 123 3 1
1.1 123 3 1
1.2 123 3 1
2 234 3 1
2.1 234 3 1
2.2 234 3 1
3 345 4 2
3.1 345 4 2
3.2 345 4 2
3.3 345 4 2
4 456 3 2
4.1 456 3 2
4.2
Here is a suggestion. Let your data frame be 'dat':
dat
X YZ
123 31
234 31
345 42
456 32
Try this:
bigData - data.frame(with(dat,
rbind(cbind(X = rep(X, Z), Y = rep(Y,Y), Z = 1),
cbind(X = rep(X, Y-Z), Y = rep(Y,
See ?ave and ?seq_along
DF - data.frame(Name = c(Mary, Mary, Mary, Sam, Sam,
John, John, John, John), stringsAsFactors = FALSE)
DF$index - ave(1:nrow(DF), DF$Name, FUN = seq_along)
On Sat, Nov 8, 2008 at 5:43 AM, jie feng [EMAIL PROTECTED] wrote:
Hi, there,
I have a simple data
one way is with ave(), e.g.,
dat - data.frame(name = rep(c(Mary, Sam, John), c(3,2,4)))
dat$freq - ave(seq_along(dat$name), dat$name, FUN = seq_along)
dat
I hope it helps.
Best,
Dimitris
jie feng wrote:
Hi, there,
I have a simple data manipulation question for you. Thank you for your
How about:
id - c(rep(a,4),rep(b,2), rep(c,5), rep(d,1))
start - c(c(0,6,17,20),c(0,1),c(0,5,10,11,50),c(0))
stop - c(c(6,12,20,30),c(1,10),c(3,10,11,30,55),c(6))
data - data.frame(id,start,stop)
f - function(data){
m - match(data$start,data$stop) + 1
if (length(m)==1
On Thu, Nov 6, 2008 at 4:23 PM, Peter Jepsen [EMAIL PROTECTED] wrote:
Here is an example:
id - c(rep(a,4),rep(b,2), rep(c,5), rep(d,1))
start - c(c(0,6,17,20),c(0,1),c(0,5,10,11,50),c(0))
stop - c(c(6,12,20,30),c(1,10),c(3,10,11,30,55),c(6))
data - as.data.frame(cbind(id,start,stop))
data
special cases outside my small example dataset.
Thank you again!
Peter.
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of bartjoosen
Sent: 6. november 2008 11:31
To: r-help@r-project.org
Subject: Re: [R] Data manipulation question
How about:
id - c(rep(a,4
Giovanni Petris GPetris at uark.edu writes:
## Example: Ratings of prime minister (Agresti, Table 12.1, p.494)
rating - matrix(c(794, 86, 150, 570), 2, 2)
dimnames(rating) - list(First = c(approve, disapprove),
+ Second = c(approve, disapprove))
rating
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ben Bolker
Sent: Friday, May 02, 2008 7:36 AM
To: [EMAIL PROTECTED]
Subject: Re: [R] Data manipulation for random intercept GLMM
Giovanni Petris GPetris at uark.edu writes:
## Example: Ratings of prime
On Fri, 2008-02-29 at 15:01 +, Luis Ridao Cruz wrote:
R-help,
I have a data frame in which I compute maximum by rows
and I wish to find out the column name at which this maximun occurs.
Does anyone know how to do it?
Thanks in advance
Do you mean compute the maximum value in a row
[EMAIL PROTECTED] wrote:
Hi,
i'd like to plot some data that I have with the value on the x axis and
freq
on the y axis.
So, I need to calculate the freq a value is seen within my data vector
for example, say i have a vector of data
data=c(1,1,1,4,5,5,6)
I
On Thu, 2008-02-14 at 14:35 +, [EMAIL PROTECTED] wrote:
Hi,
i'd like to plot some data that I have with the value on the x axis and
freq
on the y axis.
So, I need to calculate the freq a value is seen within my data vector
for example, say i have a vector of data
Hi rich,
data - c(1,1,1,4,5,5,6)
table(data)
data
1 4 5 6
3 1 2 1
hope it helps
josephine
[EMAIL PROTECTED] wrote:
Hi,
i'd like to plot some data that I have with the value on the x axis and
freq
on the y axis.
So, I need to calculate the freq a value is seen within my data
Here are a couple of ways depending on what you want.
data1=c(1,1,1,4,5,5,6)
plot(table(data1))
---
plotvec - as.vector(aa)
nns - names(aa)
plot(plotvec, xaxt=n)
mtext(nns, at=1:4, side=1)
---
--- [EMAIL PROTECTED]
[EMAIL
Try this:
values - c(1,1,1,4,5,5,6)
with(rle(values), plot(values, lengths))
But I think that you can use barplot:
barplot(table(values))
On 14/02/2008, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
Hi,
i'd like to plot some data that I have with the value on the x axis and
freq
Michael Denslow [EMAIL PROTECTED] wrote in
news:[EMAIL PROTECTED]:
Dear R users,
I am a new user (probably obvious by my question) and
have really learned a lot from reading this list.
Thank you all very much. My main struggles with R are
with data manipulation.
So here is my
2007/10/15, Petr PIKAL [EMAIL PROTECTED]:
Hi
Well, let us put it another way. Do you want for each unique combination
of Hole and Feature to subtract a value from one data frame, let us call
it nom from another data frame, let us call it raw? If yes I assume you
have exactly same number of
Hi
Klaus Friis Østergaard [EMAIL PROTECTED] napsal dne 16.10.2007
10:34:15:
2007/10/15, Petr PIKAL [EMAIL PROTECTED]:
Hi
Well, let us put it another way. Do you want for each unique combination
of Hole and Feature to subtract a value from one data frame, let us call
it nom from
Hi Klaus,
I am not exactly sure what you are asking for, but something like this? This
would be option (2) from your list - I don't know that it would be too
difficult in R that you would want to use another tool.
filt - function(x)
with(x,which(Hole 1))
normalize - function(x,y)
{
2007/10/15, Stephen Tucker [EMAIL PROTECTED]:
Hi Klaus,
I am not exactly sure what you are asking for, but something like this?
This
would be option (2) from your list - I don't know that it would be too
difficult in R that you would want to use another tool.
filt - function(x)
Hi
[EMAIL PROTECTED] napsal dne 15.10.2007 14:36:59:
2007/10/15, Stephen Tucker [EMAIL PROTECTED]:
Hi Klaus,
I am not exactly sure what you are asking for, but something like
this?
This
would be option (2) from your list - I don't know that it would be too
difficult in R that you
Try this:
transform(d, z = y[match(x, id)])
On 10/10/07, Julien Barnier [EMAIL PROTECTED] wrote:
Hi all,
Suppose I have the following data.frame, with an id column and two
variables columns :
idX Y
0001 NA 21
0002 NA 13
0003 000145
0004
use something like the following (untested)
files - paste(C:/d, 1:3, .txt, sep = )
dats - vector(list, 3)
for (i in 1:3) {
dats[[i]] - read.table(files[i], header = TRUE)
}
dats
do.call(rbind, dat)
I hope it helps.
Best,
Dimitris
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
Dimitris Rizopoulos wrote:
use something like the following (untested)
files - paste(C:/d, 1:3, .txt, sep = )
dats - vector(list, 3)
for (i in 1:3) {
dats[[i]] - read.table(files[i], header = TRUE)
}
dats
do.call(rbind, dat)
..or even
files - paste(C:/d, 1:3, .txt, sep = )
101 - 129 of 129 matches
Mail list logo