Displaying 20 results from an estimated 20000 matches similar to: "Help with indexing"
2009 May 13
5
Help with reshape/reShape and indexing
Dear R Helpers,
I have trouble applying reShape and reshape although I read the documentation and several posts, so I would very much appreciate your help on the two points below.
I have a dataframe
df = data.frame(Name=c("a", "a", "a", "b", "b", "c"), X1=c("12", "13", "14", "20", "25",
2008 Nov 08
2
Data Manipulation, add frequency index
Hi, there,
I have a simple data manipulation question for you. Thank you for your help!
Suppose that I have this data about people appearing in a class
Mary
Mary
Mary
Sam
Sam
John
John
John
John
Then I want to find out what exact time(s) the student appears at the
moment such as
Mary 1
Mary 2
Mary 3
Sam 1
Sam 2
John 1
John 2
John 3
John 4
the fifth row shows tha Sam show the second times
2011 Jun 01
4
subsetting with condition
Dear R Team,
I am a new R user and I am currently trying to subset my data under a
special condition. I have went through several pages of the subsetting
section here on the forum, but I was not able to find an answer.
My data is as follows:
ID NAME MS Pol. Party
1 John x F
2 Mary s S
2009 Apr 07
2
Frequency table to histogram
I have read a frequency table in to R called "temp." I now want to create a histogram table from it, but I obviously first have to expand the data - to the sample size of 100. I want to use the command rep(), but I'm not sure how to go about it..I tried using the code:
temp1<-rep(temp$Chest,100)
hist(temp1)
But this creates a v. odd histogram so I know it must be wrong!
2011 Oct 01
2
Help with cast/reshape
I realize that this is terribly basic, but I just don't seem to see it at this moment, so I would very much appreciate your help.
How shall I transform this dataframe:
> df1
? Name Index Value
1??? a???? 1?? 0.1
2??? a???? 2?? 0.2
3??? a???? 3?? 0.3
4??? a???? 4?? 0.4
5??? b???? 1?? 2.1
6??? b???? 2?? 2.2
7??? b???? 3?? 2.3
8??? b???? 4?? 2.4
into this dataframe:
> df2
??? Index?
2010 Oct 06
3
tapply output
Hello, I am having trouble getting the output from the tapply function
formatted so that it can be made into a nice table. Below is my question
written in R code. Does anyone have any suggestions? Thank you. Geoff
#Input the data;
name <- c('Tom', 'Tom', 'Jane', 'Jane', 'Enzo', 'Enzo', 'Mary', 'Mary');
year <- c(2008, 2009,
2010 Apr 26
4
concise syntax for selecting multiple rows
I would like to select rows if a row contains any one of several values. I can do the selection as follows:
result[,"Subject"]=="JEFF" | result[,"Subject"]=="BG"
But this is very unwieldily if one wishes to select many, many rows as one has to continuously repeat the source:
result[,"Subject"]=="JEFF" |
2019 May 16
3
print.<strorageMode>() not called when autoprinting
In R-3.6.0 autoprinting was changed so that print methods for the storage
modes are not called when there is no explicit class attribute. E.g.,
% R-3.6.0 --vanilla --quiet
> print.function <- function(x, ...) { cat("Function with argument list ");
cat(sep="\n ", head(deparse(args(x)), -1)); invisible(x) }
> f <- function(x, ...) { sum( x * seq_along(x) ) }
2019 May 21
2
print.<strorageMode>() not called when autoprinting
It also is a problem with storage.modes "integer" and "complex":
3.6.0> print.integer <- function(x,...) "integer vector"
3.6.0> 1:10
[1] 1 2 3 4 5 6 7 8 9 10
3.6.0> print(1:10)
[1] "integer vector"
3.6.0>
3.6.0> print.complex <- function(x, ...) "complex vector"
3.6.0> 1+2i
[1] 1+2i
3.6.0>
2008 Nov 24
4
Calculating sum of letter values
Hi all
If I have a string, say "ABCDA", and I want to convert this to the sum of the letter values, e.g.
A -> 1
B -> 2
etc, so "ABCDA" = 1+2+3+4+1 = 11
Is there an elegant way to do this? Trying something like
which(LETTERS %in% unlist(strsplit("ABCDA", "")))
is not quite correct, as it does not count repeated characters. I guess what I need is
2013 Feb 05
2
adjacency list to non-symmetric matrix
Dear R community,
is there an easy way to convert an adjacency list (or a data-frame) to a non-symmetric matrix?
The adjacency list has the following form:
person group
1 Sam a
2 Sam b
3 Sam c
4 Greg a
5 Tom b
6 Tom c
7 Tom d
8 Mary b
9 Mary d
I need the data in a matrix with persons as rows and groups as columns:
a b c d
Sam 1 1 1 0
Greg 1 0 0 0
Tom 0 1 1 1
Mary 0 1 0 1
I know that there
2018 Jan 04
3
silent recycling in logical indexing
Hmm.
Chuck: I don't see how this example represents
incomplete/incommensurate recycling. Doesn't TRUE replicate from
length-1 to length-3 in this case (mat[c(TRUE,FALSE),2] would be an
example of incomplete recycling)?
William: clever, but maybe too clever unless you really need the
speed? (The clever way is 8 times faster in the following case ...)
x <- rep(1,1e6)
2019 May 21
3
print.<strorageMode>() not called when autoprinting
Letting a user supply the autoprint function would be nice also. In a way
you can already do that, using addTaskCallback(), but that doesn't let you
suppress the standard autoprinting.
Having the default autoprinting do its own style of method dispatch doesn't
seem right.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, May 21, 2019 at 10:50 AM Lionel Henry <lionel at
2013 Mar 19
2
Cumulative Frequency Graph
Hi,
I am trying to create a Cumulative Frequency graph and I am using the
following example:
http://www.r-tutor.com/elementary-statistics/quantitative-data/cumulative-frequency-graph
When I plot this data, how do I put in "real values" on the x-axis, rather
than the values that
are used for the breaks
Thanks
--
Shane
[[alternative HTML version deleted]]
2010 Feb 25
3
behavior of seq_along
I'm trying to understand the behavior of seq_along in the following example:
x <- 1:5; sum(x)
y <- 6:10; sum(y)
data <- c(x,y)
S <- sum( data[seq_along(x)] )
S
T <- sum( data[seq_along(y)] )
T
Why is T != sum(y) ?
2009 Dec 18
2
Vectorized switch
What is the 'idiomatic' way of writing a vectorized switch statement?
That is, I would like to write, e.g.,
vswitch( c('a','x','b','a'),
a= 1:4,
b=11:14,
100 )
=> c(1, 100, 13, 4 )
equivalent to
ifelse( c('a','x','b','a') ==
2007 Apr 03
1
Behavior of seq_along (was: Create a new var reflecting the order of subjects in existing var)
I am moving this from r-help to r-devel. Based on offline communications
with Jim, suppose dat is defined as follows:
set.seed(123)
dat <- data.frame(ID= c(rep(1,2),rep(2,3), rep(3,3), rep(4,4),
rep(5,5)), var1 =rnorm(17, 35,2), var2=runif(17,0,1))
# Then this ave call works as expected:
ave(dat$ID, dat$ID, FUN = function(x) seq_along(x))
# but this apparently identical calculation
2012 Feb 21
3
[LLVMdev] How To Pass An Command Line Option To The Pass
Hi all,
I have a problem with passing multiple option(-flag=aaa/bbb) from clang to llvm,
I don't know how to parse it, should I parse it in clang and pass it
to llvm or should I parse it in llvm pass where I use it,
could you help me.
Thanks in advance,
Sevak.
2009 Jul 09
1
bug in seq_along
Using the IRanges package from Bioconductor and somewhat recent R-2.9.1.
ov = IRanges(1:3, 4:6)
length(ov) # 3
seq(along = ov) # 1 2 3 as wanted
seq_along(ov) # 1!
I had expected that the last line would yield 1:3. My guess is that
somehow seq_along don't utilize that ov is an S4 class with a length
method.
The last line of the *Details* section of ?seq has a typeo. Currently
it is
2007 Mar 26
1
data-frame adding/deleting column
Hallo,
I have got an existing data frame and want to add a new column. The
existing data frame was created like this:
> df <- rbind( c("Fred", "Mary", 4), c("Fred", "Mary", 7),
+ c("Fred", "Mary", 9), c("Barney", "Liz", 3),
+ c("Barney", "Liz", 5) )
> df