Displaying 20 results from an estimated 5000 matches similar to: "splitting a long dataframe"
2013 Jun 10
4
Combining CSV data
Hello R community,
I am trying to combine two CSV files that look like this:
File A
Row_ID_CR, Data1, Data2, Data3
1, aa, bb, cc
2, dd, ee, ff
File B
Row_ID_N, Src_Row_ID, DataN1
1a, 1, This is comment 1
2a, 1, This is comment 2
3a,
2011 May 19
3
problem with optim()
Dear R-users,
I would like to maximize the function g above which depends on 4 parameters (2 vectors, 1 real number, and 1 matrix) using optim() and BFGS method. Here is my code:
# fonction to maximize
g=function(x)
{
x1 = x[1:ncol(X)]
x2 = x[(ncol(X)+1)]
x3 = matrix(x[(ncol(X)+2):(ncol(X)+1+ncol(X)*ncol(Y))],nrow=ncol(X),ncol=ncol(Y))
x4 = x[(ncol(X)+1+ncol(X)*ncol(Y)+1):length(x)]
2013 Feb 01
29
cumulative sum by group and under some criteria
Thank you very much for your reply. Your code work well with this example.
I modified a little to fit my real data, I got an error massage.
Error in split.default(x = seq_len(nrow(x)), f = f, drop = drop, ...) :
Group length is 0 but data length > 0
On Thu, Jan 31, 2013 at 12:21 PM, arun kirshna [via R] <
ml-node+s789695n4657196h87@n4.nabble.com> wrote:
> Hi,
> Try this:
>
2010 Jul 20
1
p-values pvclust maximum distance measure
Hi,
I am new to clustering and was wondering why pvclust using "maximum"
as distance measure nearly always results in p-values above 95%.
I wrote an example programme which demonstrates this effect. I
uploaded a PDF showing the results
Here is the code which produces the PDF file:
-------------------------------------------------------------------------------------
s <-
2013 Aug 26
4
transform variables
Dear all!
I have a data frame composed by 13 columns (year, and 12 months). I want to
transform this data base in another like this
year month values
1901 1
1901 2
1901 3
.....
1901 12
1902 1
1902 2
....
1902 12
Is there a possibility to succeed that in R?
Thank you!
best regards!
CR
--
---
Catalin-Constantin ROIBU
Lecturer PhD, Forestry engineer
Forestry Faculty of Suceava
Str.
2011 Feb 24
2
MCMCpack combining chains
Deal all, as MCMClogit does not allow for the specification of several chains, I have run my model 3 times with different random number seeds and differently dispersed multivariate normal priors.
For example:
res1 = MCMClogit(y~x,b0=0,B0=0.001,data=mydat, burnin=500, mcmc=5500, seed=1234, thin=5)
res2 = MCMClogit(y~x,b0=1,B0=0.01,data=mydat, burnin=500, mcmc=5500, seed=5678, thin=5)
res3 =
2005 Jul 19
1
initial points for arms in package HI
Dear R-users
I have a problem choosing initial points for the function arms()
in the package HI
I intend to implement a Gibbs sampler and one of my conditional
distributions is nonstandard and not logconcave.
Therefore I'd like to use arms.
But there seem to be a strong influence of the initial point
y.start. To show the effect I constructed a demonstration
example. It is reproducible
2013 Nov 21
1
how can I import a number of datsets in a folder in my working directory to a list in R
Hi,
Suppose, if I create 15 files in my working directory.
set.seed(48)
lapply(1:15,function(i) {m1 <- matrix(sample(1:20,1686*2,replace=TRUE),nrow=1686,ncol=2); write.table(m1,paste0("file_",i,".txt"),row.names=FALSE,quote=FALSE)})
?D <-dir()
D1 <- D[order(as.numeric(gsub("\\D+","",D)))]
D1
?res <- t(sapply(D1,function(x) {x1<-
2013 Oct 04
3
Trying to avoid nested loop
Dear R users.
I'm trying to avoid using nested loops in the following code but I'm not sure how to proceed. Any help would be greatly appreciated.
With regards,Phil
X = matrix(rnorm(100), 10, 10)
## Version with nested loopsresult = 0
for(m in 1:nrow(X)){ for(n in 1:ncol(X)){ if(X[m,n] != 0){ result = result + (X[m,n] / (1 + abs(m - n))) } }}
## No loop-sum(ifelse(M
2012 Nov 08
5
map two names into one
Thanks.
Yes. Your approach can identify:
Glaxy ace S 5830 and
S 5830 Glaxy ace
But you can not identify using same program:
Iphone 4S 16 G
Iphone 4S 16G
How should I solve both in same time.
Kind regards,Tammy
[[alternative HTML version deleted]]
2012 Aug 06
1
cannot find function "simpleRDA2"
Hi,
I am trying to run the command "forward.sel.par," however I receive
the error message: "Error: could not find function 'simpleRDA2'." I
have the vegan library loaded. The documentation on "varpart" has not
helped me to understand why I cannot call this function. Maybe I am
missing something obvious because I am still an 'R' novice.
Below is a
2011 Aug 04
1
How to get the test statistic corresponding to the p-value in mtable?
Dear R-Users,
I want to use mtable from package "memisc" to produce Latex-style estimation
output. However, mtable() only gives me a p-value and not the corresponding
test-statistic. Does anyone know how to extract it, either from a glm/anova
object or mtable? Here is a short example:
# Run this ####################
install.packages("memisc")
library(memisc)
set.seed(1)
2009 Feb 02
1
Assigning colnames in loop
Dear R-listers,
I am trying to assign colnames to a data frame within a loop, but I keep
getting a "target of assignment expands to non-language object"-error. I
need to split up a large dataset into about 20 smaller ones, and I would
like to assign colnames within the loop, so I won't have to type the
same thing 20 times over.
I have concocted this really goofy example which
2009 Jul 31
1
[PATCH] [memdisk] Additional EDD Device Parameter Table fields
Some additional fields from the EDD-4 spec. draft for the Device
Parameter
Table have been added into the structure in setup.c and memdisk.inc.
These
were added in the hopes of resolving a FreeDOS MEMDISK bug on IBM
ThinkPads.
---
memdisk/memdisk.inc | 11 +++++++++++
memdisk/setup.c | 10 ++++++++++
2 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/memdisk/memdisk.inc
2012 Jun 20
1
prcomp: where do sdev values come from?
In the manual page for prcomp(), it says that sdev is "the standard
deviations of the principal components (i.e., the square roots of the
eigenvalues of the covariance/correlation matrix, though the
calculation is actually done with the singular values of the data
matrix)." ?However, this is not what I'm finding. ?The values appear
to be the standard deviations of a reprojection of
2013 Feb 15
10
reading data
Hi,
#working directory data1 #changed name data to data1.? Added some files in each of sub directories a1, a2, etc.
?indx1<- indx[indx!=""]
lapply(indx1,function(x) list.files(x))
#[[1]]
#[1] "a1.txt"??????? "mmmmm11kk.txt"
#[[2]]
#[1] "a2.txt"??????? "mmmmm11kk.txt"
#[[3]]
#[1] "a3.txt"??????? "mmmmm11kk.txt"
#[[4]]
#[1]
2013 Apr 05
2
How to perform a grouped shapiro wilk test on dataframe
Hello,
I was wandering if it is possible to perform on a dataframe called 'all' a
shapiro wilk normality test for COUNTS by variable Group
ACTIVITY? Could it be done using plyer? I saw an eg that applies to an
array but not to a dataframe:
lapply(split(dataset1$Height,dataset1$Group),shapiro.test)
Any thoughts would be much appreciated.
My dataframe is in shape:
dat ACTIVIT
2012 Dec 27
4
Finding (swapped) repetitions of numbers pairs across two columns
Hi,
I've had this problem for a while and tackled it is a quite dirty way
so I'm wondering is a better solution exists:
If we have two vectors:
v1 = c(0,1,2,3,4)
v2 = c(5,3,2,1,0)
How to remove one instance of the "3,1" / "1,3" double?
At the moment I'm using the following solution, which is quite horrible:
v1 = c(0,1,2,3,4)
v2 = c(5,3,2,1,0)
ft <-
2013 Feb 17
3
Select components of a list
Hi Gustav,
Try this:
lapply(1:length(models),function(i) lapply(models[[i]],function(x) summary(x)$coef[2,]))[[1]] #1st list component
[[1]]
#??? Estimate?? Std. Error????? z value???? Pr(>|z|) # pm10
#5.999185e-04 1.486195e-04 4.036606e+00 5.423004e-05
#[[2]]
#??? Estimate?? Std. Error????? z value???? Pr(>|z|) #ozone
#0.0010117294 0.0003792739 2.6675428048 0.0076408155
#[[3]]
#???
2013 Jun 18
1
transform 3 numeric vectors empty of 0/1
Dear all,
Without a loop, I would like transform 3 numeric vectors empty of 0/1 of
same length
Vec1 : transform 1 to A and 0 to ""
Vec2 : transform 1 to B and 0 to ""
Vec3 : transform 1 to C and 0 to ""
to obtain only 1 vector Vec who is the paste of the 3 vectors (Ex : ABC,
BC, AC, AB,...)
Any idea ?
Thank you for your help
--
Michel ARNAUD