Displaying 20 results from an estimated 20000 matches similar to: "how to read in multiple files with unequal number of columns"
2008 Apr 08
1
how to check if a variable is preferentially present in a sample
Dear All,
I do apologise if this question is out of place for this list but I've
tried searching mailing lists and read "Introductory Statistics with
R" by Peter Dalgaard, but couldn't find any hints on solving my
question below:
I have a data frame (d) of values which I will rank in decreasing
order of "val". Each value belongs to a group, either 'A',
2008 Oct 03
2
suggestions for plotting 5000 data points
Dear all,
I have a collection of 5000 entries which represent the evolutionary
rates of 3 animals.
I would like to show the differences between the rates of all 3
animals and have tried using the function parallel (from the lattice
package) and pairs() function.
The parallel function would have been perfect save for the large
number of data (5000). The pairs() function doesn't show
2006 Sep 06
2
how to loop through 2 lists with different indexes
Dear all,
I am a newbie in R and need some help please. (I do apologise if my
email is not as informative as it should be, I've tried to include
the relevant details without overcrowding it with the rest of the code)
I would like to sample (without replacement) Y objects based on the
number of objects in X in 5 different bins. I'm having trouble
because the list object in which
2008 Apr 14
3
Is this an artifact of using "which"?
Dear all,
I used "which" to obtain a subset of values from my data.frame.
however, I find that there is a "trace" of the values I have removed.
Any suggestions would be greatly appreciate.
Below is my data:
d <- data.frame( val = 1:10,
group = sample(LETTERS[1:5], 10, repl=TRUE) )
>d
val group
1 1 B
2 2 E
3 3 B
4 4
2012 Jun 07
3
conditional statement to replace values in dataframe with NA
Hello and thanks for helping.
#some data
L3 <- LETTERS[1:3]
dat1 <- data.frame(cbind(x=1, y=rep(1:3,2), fac=sample(L3, 6, replace=TRUE)))
#When x==1 and y==1 I want to replace the 1 values with NA
#I can select the rows I want:
dat2<-subset(dat1,x==1 & y==1)
#replace the 1 with NA
dat2$x<-rep(NA,nrow(dat2)
dat2$y<-rep(NA,nrow(dat2)
#select the other rows and rbind
2010 Nov 08
7
How to rbind list of vectors with unequal vector lengths?
Hi,
How to rbind these vectors from a list?:
> l <- list(a = c(1, 2), b = c(1, 2, 3))
> l
$a
[1] 1 2
$b
[1] 1 2 3
> do.call(rbind, l)
[,1] [,2] [,3]
a 1 2 1
b 1 2 3
Warning message:
In function (..., deparse.level = 1) :
number of columns of result is not a multiple of vector length (arg 1)
>
-J
2006 Jan 23
1
Sample rows in data frame by subsets
Hi,
I need to resample rows in a data frame by subsets
L3 <- LETTERS[1:3]
d <- data.frame(cbind(x=1, y=1:10), fac=sample(L3, 10, repl=TRUE))
x y fac
1 1 1 A
2 1 2 A
3 1 3 A
4 1 4 A
5 1 5 C
6 1 6 C
7 1 7 B
8 1 8 A
9 1 9 C
10 1 10 A
I have seen this used to sample rows with replacement
d[sample(nrow(d), replace=T), ]
x y fac
7 1 7 B
2
2010 Oct 26
1
S4 methods for rbind()
Hello.
I am trying to write an S4 method for rbind(). I have a class of objects
called 'mdm', and I want to be able to rbind() them to one another.
I do not want the method for rbind() to coerce anything to an mdm object.
I want rbind(x1,x2,x1,x2) to work as expected [ie rbind() should take any
number of arguments].
This is what I have so far:
setGeneric(".rbind_pair",
2005 Jun 10
4
data.frame to character
Hi,
Excuse me for this simple question.
How to convert as.data.frame to as.character?
?data.frame
> L3 <- LETTERS[1:3]
> L10 <- LETTERS[1:10]
> d <- data.frame(cbind(x=c("XYZ"), y=L10), fac=sample(L3, 10, repl=TRUE))
> d
x y fac
1 XYZ A A
2 XYZ B A
3 XYZ C A
4 XYZ D A
5 XYZ E B
6 XYZ F C
7 XYZ G A
8 XYZ H C
9 XYZ I B
10 XYZ
2013 Dec 14
2
Change factor levels
Suppose I have a dataframe 'd' defined as
L3 <- LETTERS[1:3]
d0 <- data.frame(cbind(x = 1, y = 1:10), fac = sample(L3, 10, replace
= TRUE))
(d <- d0[d0$fac %in% c('A', 'B'),])
x y fac
2 1 2 B
3 1 3 A
4 1 4 A
5 1 5 A
6 1 6 B
8 1 8 A
Even though factor 'fac' in 'd' only has 2 levels, but it seems to bear the
birthmark
2009 Jan 06
2
Converting data frame to symmetric matrix
Dear Sir or Madam,
I have the following data frame (which is just a toy example of my
larger dataset)
L3 <- LETTERS[1:3]
x=c(1,1,2,2,3,3,4,4,5,5)
y=1:10
d <- data.frame(cbind(x,y), fac=sample(L3, 10, replace=TRUE))
This data frame produces the following output
x y fac
1 1 1 C
2 1 2 C
3 2 3 B
4 2 4 B
5 3 5 C
6 3 6 B
7 4 7 B
8 4 8 C
9 5 9 B
10 5
2006 Apr 06
3
convert a data frame to matrix - changed column name
I have a question, which very easy to solve, but I can't find a solution.
I want to convert a data frame to matrix. Here my toy example:
> L3 <- c(1:3)
> L10 <- c(1:6)
> d <- data.frame(cbind(x=c(10,20), y=L10), fac=sample(L3, + 6, repl=TRUE))
> d
x y fac
1 10 1 1
2 20 2 1
3 10 3 1
4 20 4 3
5 10 5 2
6 20 6 2
> is.data.frame(d)
[1] TRUE
> sapply(d,
2008 Nov 09
1
Help on performing multiple chi-square tests
Hi,
I am new to R and I need to perform multiple chi-square tests. I
manage to perform one at a time, but is there a specific command
to do multiple tests?
For example, I have a table that looks like this:
Marker Treatment Genotype1 Genotype2 Genotype3
1 A 23 57 32
1 B 43 59 12
...
...
n A ## ## ##
n
2006 Sep 27
1
Impossible to merge with a zero rows data frame?
I'm trying to merge two data frames. One of them is a zero rows data
frame.
I'm using the merge parameter 'all.x = TRUE' so I'd expect to obtain all
the rows of x. In fact the merge help says:
all.x: logical; if 'TRUE', then extra rows will be added to the
output, one for each row in 'x' that has no matching row in
'y'. These rows
2011 Jan 06
5
How to join matrices of different row length from a list
Hi,
I have several matrix in a list, for example:
e
[[1]]
[,1] [,2]
[1,] 1 3
[2,] 2 4
[[2]]
[,1] [,2]
[1,] 1 4
[2,] 2 5
[3,] 3 6
[[3]]
[,1] [,2]
[1,] 2 1
I would like to join them by column i.e.
[,1] [,2] [,3] [,4][,5] [,6]
[1,] 1 3 1 4 2 1
[2,] 2 4 2 5 NA NA
[3,] NA NA 3 6 NA NA
I have tried
2005 Oct 20
1
Windows 2000 crash while using rbind (PR#8225)
Windows 2000 reports that "Rgui.exe has generated errors and will be =
closed by Windows. You will need to restart the program." when using =
rbind.=20
df1 <- data.frame(cbind(x=3D1, y=3D1:1000), fac=3Dsample(LETTERS[1:3], =
1000, repl=3DTRUE))
df2 <- data.frame(cbind(x=3D1, y=3D1:10), fac=3Dsample(LETTERS[4:6], =
10, repl=3DTRUE))
df3 <- data.frame(cbind(x=3D1,
2008 Nov 25
2
dots methods: dispatch issues
There seems to be a bug arising when using multiple S4 generics with "..."
as the signature.
The following code works as expected:
##############################################################
> setGeneric("rbind", function(..., deparse.level=1)
standardGeneric("rbind"),
+ signature = "...")
Creating a generic for "rbind" in
2004 Mar 30
1
classification with nnet: handling unequal class sizes
I hope this question is adequate for this list
I use the nnet code from V&R p. 348: The very nice and general function
CVnn2() to choose the number of hidden units and the amount of weight
decay by an inner cross-validation- with a slight modification to use it
for classification (see below).
My data has 2 classes with unequal size: 45 observations for classI and
116 obs. for classII
With
2009 Oct 07
1
merging dataframes with an unequal number of variables
Hallo Everyone
I have the kind of problem that one should never have because one must
always plan well and communicate with your team. But now I haven't so here
is my problem.
I have data coming in on a daily basis from surveys in 10 towns. The
questionnaire has 62 variables but some of the regions have used older
versions of the questionnaire that have a few variables less. I want to
combine
2010 Oct 26
4
divide column in a dataframe based on a character
Hello,
If I have a dataframe:
example(data.frame)
zz<-c("aa_bb","bb_cc","cc_dd","dd_ee","ee_ff","ff_gg","gg_hh","ii_jj","jj_kk","kk_ll")
ddd <- cbind(dd, group = zz)
and I want to divide the column named group by the "_", how would I do this?
so instead of the first row being
x