similar to: how to create data.frames from vectors with duplicates

Displaying 20 results from an estimated 30000 matches similar to: "how to create data.frames from vectors with duplicates"

2011 Aug 31
1
counting the duplicates in an object of list
Hi all, I have a list x: ?> x=list(a=c('1','2'),b=c('2','3'),c=c('1','2'),d=c('2','3')) I can get the unique elements with unique(), but how can I get the number of duplicates for each unique elements? > unique(x) [[1]] [1] "1" "2" [[2]] [1] "2" "3" Thanks -- Best, Zhenjiang
2011 Mar 15
3
how to reshape the data.frame from long to wide in a specific order
Hi, For example, the data.frame like: origdata.long <- read.table(header=T, con <- textConnection(' subject sex condition measurement 1 M control 7.9 1 M first 12.3 1 M second 10.7 2 F control 6.3 2 F first 10.6 2 F second 11.1 3 F control 9.5 3
2011 Apr 15
1
how to add two data.frame with the same column but different row numbers
Hi all, Suppose I have 2 data.frame , a and b, how can I add them together to get c? Thanks > a A a 1 b 2 c 3 > b A a 6 c 1 > c A a 7 b 2 c 4 -- Best, Zhenjiang [[alternative HTML version deleted]]
2011 Aug 05
4
a question on list manipulation
Hi R users, I have a list: > x $A [1] "a" "b" "c" $B [1] "b" "c" $C [1] "c" I want to convert it to a lowercase-to-uppercase list like this: > y $a [1] "A" $b [1] "A" "B" $c [1] "A" "B" "C" In a word, I want to reverse the list names and the elements under each
2011 Aug 02
2
how to control to save plots to which dev
Hi, I have a for loop to make 2 types of plots and I'd like to save one type of plots to a pdf file and the other to another pdf file. How can I control which plot will be saved to which pdf? Thanks -- Best, Zhenjiang
2010 Aug 10
4
matrix problem
Hi, I have a file like this: 1 2 0.1 2 3 0.2 3 1 0.3 And I want to read it to create a matrix like this: [,1] [,2] [,3] [1,] 0 0.1 0 [2,] 0 0 0.2 [3,] 0.3 0 0 How can I do it efficiently? Thanks. -- Best, Zhenjiang [[alternative HTML version deleted]]
2011 Aug 29
1
sum of two lists
Hi R users, Suppose I have two lists and the names of list 'm' are a subset of those of 'n', how can I sum the two lists with corresponding elements added together to get list 'o'? > n = list("a"=1,"b"=3,"c"=5) > m = list('b'=4) > o $a [1] 1 $b [1] 7 $c [1] 5 Thanks -- Best, Zhenjiang [[alternative HTML version
2010 Nov 10
1
ggplot2 problem in interacting mode
Hi all, When running R interactively, I have the problem as following: > library(ggplot2) Loading required package: reshape Loading required package: plyr Attaching package: 'reshape' The following object(s) are masked from 'package:plyr': round_any Loading required package: grid Loading required package: proto > data(VADeaths) > pg <- ggplot(melt(VADeaths),
2011 Aug 24
1
read.table truncated data?
Hi R users, I was using read.table to read a file. The data.fame looked alright, but I found not all rows are read by the read.table. What's wrong with it? It didn't give me any warning or error messages. Why the data are truncated? Thanks. $ wc -l all/isoform_exp.diff 42847 all/isoform_exp.diff > a=read.table('all/isoform_exp.diff', header=T, sep='\t') > nrow(a)
2010 Apr 20
1
the bar width of barchart plot in lattice package
Dear R users, I am trying to use the following code to make a barchar plot. The bars in the plot turn out to be a little narrow. Is there any way to modify the width of the bars? Thank you! library(lattice) scores = gl(2, 5, label=c('Sensitivity', 'PPV'), length = 100) sequences = gl(5, 1, label=c('Lemna minor', 'Dugesia japonica A', 'Gymnosporangium
2010 Apr 29
1
a question on autocorrelation acf
Hi R users, where can I find the equations used by acf function to calculate autocorrelation? I think I misunderstand acf. Doesn't acf use following equation to calculate autocorrelation? [image: R(\tau) = \frac{\operatorname{E}[(X_t - \mu)(X_{t+\tau} - \mu)]}{\sigma^2}\, ,] If it does, then the autocorrelation of a sine function should give a cosine; however, the following code gives a
2010 Apr 22
1
how to reorder of groups and specify ylim for each row in lattice barchart
R experts, Is there anyway to reorder inside each group? In the following example, the bar of year 1932 is always plotted before the bar of year 1931, may I change the order inside each groups of bars? library(lattice) barchart(yield ~ variety | site,data=barley, groups = year, layout = c(1,6),auto.key = list(points = FALSE, rectangles = TRUE, space = "right"),ylab = "Barley Yield
2009 Jul 24
3
Duplicated date values aren't duplicates
Dear list, I just had a function (as.ltraj in Adehabitat) give me the following error: "Error in as.ltraj(xy, id, date = da) : non unique dates for a given burst" I checked my dates and got the following: > dupes<-mydata$DateTime[duplicated(mydata$DateTime)] > dupes [1] (07/30/02 00:00:00) (08/06/03 17:45:00) Is there a reason different dates would come up as duplicate
2010 Nov 08
4
Create Matrix of 2 Dim from two vectors
Hello, I have two data. x<-c(1, 2, 3) y<-c(4,5,6) How do i create matrix of 3 by 3 from this two, such that (1,4) (1,5) (1,6) (2,4) (2,5) (2,6) (3,4) (3,5) (3,6) I tried some thing like this: xy <- as.data.frame(c(0,0,0), dim=c(3,3)) for(i in 1:3) for(j in 1:3) xy[i][j]<-c(x[i],y[j]) but i got errors..!!!! any help would appreciate -- View this message in
2010 Mar 09
1
Help with adding points to allEffects plot
Thanks in advance for any help. I am attempting to add points to a plot using the allEffects command in the effects package. When I try to add the points I get the following error message: Error in plot.xy(xy.coords(x, y), type = type, ...) : plot.new has not been called yet Strangely, using the code I've pasted below this has worked for me in the past however figuring out what has
2006 Feb 26
2
how to change my data to "point data set" in package "SPLANCE"?
Hi! I want to use the package "SPLANCE" to do Ripley's K analysis I have a basic question about the package. I try to find how to do it, but I cannot. I hope you can help me. I donot know how to change my data form to "point data set". my data form is: > qumo[1:5,] code species dbh x y tag status branch 223 10312 QUMO 54.5 7.83 44.80 10306 alive
2012 Jun 12
4
How to index a matrix with different row-number for each column?
here's my question: suppose I have a matrix: mt<-matrix(1:12,ncol=6) now I have a vector vt<-c(1,2,2,2,1,2) which means I want to get: the 1st row for column1; the 2nd row for column2; the 2nd row for column3; the 2nd row for column4; ... that what I want is this vector: 1,4,6,8,9,12 Does anyone know how to do this fast? I know I can use for-loop to travel all columns,but
2010 May 06
2
splitting character strings and converting to numeric vectors
This seemingly should be quite simple but I can't solve it: I have a long character vector of geographic data (data frame column named "XY") whose elements vary in length (from 11 to 14 chars). Each element is structured as a set of digits, then an underscore, then more digits, e.g: > data.frame(head(as.character(XY))) head.as.character.XY.. 1 -448623_854854 2
2010 Feb 09
3
split strings in a vector and convert it to a data.frame
hi, I have a vector full of strings like; xy_100_ab xy_101_ab xy_102_ab xy_103_ab I want to seperate each string in three pieces and the separator should be the "_" at the end I want a data.frame like: column1 column2 column3 xy 100 ab xy 101 ab xy 102 ab xy 103 ab I tried strsplit but I couldn't figure out how to convert the list I get into a data.frame. I just
2011 Feb 06
2
Multiplying elements of vectors
Hi guys: Sorry if this question is very basic. I?m learning basic matrix and vectors multiplication to develop a population matrix model for plants. I?m trying to multiply the elements of two vectors (each of the ?x? values by each of the ?y? values) to obtain a square matrix of xy values. f.e. x<-seq(5,205) y<-seq(5,20,5) stages<-c(?Sdl?, ?Juv?, ?Ad1?, ?Ad2?) If I just multiply xy as