Dear all,
I have a data frame in which the columns need to be ordered. The first column X
is at the right position, but the remaining columns X1-Xn should be ordered
like this: X1, X2, X3 etc instead of like below.
colnames(pos1)
[1] X X1 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19
X2 X20
It does not work when using more variables, and my data frames usually
contains about thousand columns...
Best,
Joel
fakedata - data.frame(A=c(0,0,0), X1=c(1,1,1), X6=c(6,6,6),
X7=c(7,7,7), X3=c(3,3,3), X4=c(4,4,4), X9=c(9,9,9), X2=c(2,2,2),
X8=c(8,8,8), X5=c(5,5,5))
fakedata
A X1 X6 X7
@Alfredo
The X is removed, but the reordering does not work:
colnames(df)[1] - Mass
columnNames - colnames(df)
colnames(df)
[1] Mass X1 X10 X11 X12 X13 X14 X15 X16
X17 X18 X19 X2 X20 X3 X4 X5 X6 X7
X8 X9
colnames(df) - gsub(X,,colnames(df))
colnames(df)
@ Jim
That would work for just a few columns, but I will have around 1000 of
them so I need something more generic.
best,
Joel
jim holtman jholt...@gmail.com 17-02-2012 14:44
pos2 - pos1[, c(X, X1, X2, X3, X4, X5, X6, X7, X8,
X9, X10, X11, X12,
X13, X14, X15, X16, X17, X18, X19,
Thank you Sarah, now it works!!
Sarah Goslee sarah.gos...@gmail.com 17-02-2012 15:13
Sorry, it should be:
fakedata[, order(pos)]
A X1 X2 X3 X4 X5 X6 X7 X8 X9
1 0 1 2 3 4 5 6 7 8 9
2 0 1 2 3 4 5 6 7 8 9
3 0 1 2 3 4 5 6 7 8 9
Using order also ensures that
Hi Dennis,
Thanks for your prompt response.
Best,
Joel
Dennis Murphy djmu...@gmail.com 30-10-2011 21:11
Hi:
Here are a few ways (untested, so caveat emptor):
# plyr package
library('plyr')
ddply(df, .(Plant, Tissue, Gene), summarise, ntest =
shapiro.test(ExpressionLevel))
# data.table
Dear R users,
I have a data frame in the form below, on which I would like to make normality
tests on the values in the ExpressionLevel column.
head(df)
ID Plant Tissue Gene ExpressionLevel
1 1 p1 t1 g1 366.53
2 2 p1 t1 g2 0.57
3 3 p1 t1 g311.81
4 4
Hi all,
I need to replace missing values in a matrix by 10 % of the lowest available
value in the matrix. I've got a function I've used earlier to replace negative
values by the lowest value, in a data frame, but I'm not sure how to modify
it...
nonNeg = as.data.frame(apply(orig.df, 2,
Thanks a lot Paul!!
Best,
Joel
Date: Thu, 28 Jan 2010 10:48:37 +0100
From: p.hiems...@geo.uu.nl
To: joel_furstenberg_h...@hotmail.com
CC: r-help@r-project.org
Subject: Re: [R] NA Replacement by lowest value?
Joel Fürstenberg-Hägg wrote:
Hi all,
I need to replace
Fürstenberg-Hägg wrote:
Hi all,
I need to replace missing values in a matrix by 10 % of the lowest
available value in the matrix. I've got a function I've used earlier to
replace negative values by the lowest value, in a data frame, but I'm not
sure how to modify it...
nonNeg
Hi all,
I have two question. First, I wonder how to remove a part of the column names
in a matrix? I would like to remove the _ACCX or _NAX part below. Is there
a method where the _ as well as all characters after i can be removed?
dim(exprdata)
[1] 88 512
Hi all,
I would like to remove rows from a matrix, based on the frequency of missing
values. If there are more than 10 % missing values, the row should be deleted.
I use the following to calculate the frequencies, thereby getting a new matrix
with the frequencies:
Hi all,
I want to calculate the row wise mean of groups of columns in a matrix M. All
columns belonging to the same group have the same column name. My idea is to
create a new vector V containing these column names, but after first removing
the duplicates. Then I would calculate the means
Hi all,
I'm have a matrix (X) with observations as rows and parameters as columns. I'm
trying to exchange all missing values in a column by the column mean using the
code below, but so far, nothing happens with the NAs... Can anyone see where
the problem is?
N-nrow(X) # Calculate
Hi all,
I'm having a problem when putting the four plots (Residuals vs Fitted, Normal
Q-Q, Scale - Location, and Residuals vs Leverage) from an Anova using
plot(aov()) into a pdf. A string aov(df[,i] ~ cat)) is added as the main
title, so when I use mtext() the two titles are overlapping.
Hi all,
I'm doing Multiple linear regression for a data set. However, it takes a lot of
time, as I would like to check every possible combination of factors, evalute
the results based for instance on their p values, and then choose the best
regression model.
So, I wonder if anyone might have
Hi all,
Does any of you know how to make a decision tree when the data set contains
factors and numericals?
I've got a data frame with 3 columns, where y and x1 are numerical and x2
contains factors. Is it possible to use the rpart package, and in that case
how? Otherwise, is there
Hi all,
Anyone experienced in the LaTeX format?
I'm trying to use the xtable package to create nice anova tables, but how do I
do to produce a pdf from the resulting LaTeX table? I've tried WinShell and
MiKTeX, but I couldn't get any of them working...
Here's an example of the
Hi all,
I've tried to make a decision tree for the following data set:
Level X Response
279 C 2.4728646 -9.445
341 B 0.5986398 -9.413
343 B 1.1786271 -9.413
384 D 1.4797870 -9.413
390 C 2.0364569 -9.133
391 D
Hi all,
I've tried to make a 3D plot, but have run into some problems.
I'd like to have a plot that I can rotate interactively using the mouse, which
is possible using the plots3d {R.basic}. However, I would like to change the
symbols used as the points, but there's no pch in plot3d().
Hi all,
I've got some problems when changing the trellis settings for the lattice
plots. The plots look exactly as I want them to when calling show.settings() as
well as when plotting them in the graphical window. But when printing to a pdf
file, none of the settings are used!? Does anyone
?
-- Tony Plate
Joel Fürstenberg-Hägg wrote:
Hi all,
Does anyone know how to get the independent components and loadings from an
Independent Component Analysis (ICA), as well as principal components and
loadings from a Pricipal Component analysis (PCA) using the fastICA
Hi all,
I wonder what the difference is between the functions prcomp and the PCA
plotting method used in example 3 from the fastICA package. They give totally
different plots. The reason for asking is that I've earlier used prcomp, but
now I should do an ICA, and I guess I cannot compare
Hi all,
Does anyone know how to get the independent components and loadings from an
Independent Component Analysis (ICA), as well as principal components and
loadings from a Pricipal Component analysis (PCA) using the fastICA package? Or
perhaps if there's another way to do ICAs in R?
Hi all,
I'm new to PCA in R, so this might be a basical thing, but I cannot find
anything on the net about it.
I need to make a PCA plot with two response variables (df$resp1 and df$resp2)
against eight metabolites (df$met1, df$met2, ...) and I don't have a clue how
to do... and I've only
Hi all,
I'm trying to write a script that changes all negative values in a data frame
column to a small positive value, based on the the minimum value of the column.
However, I get the following error:
Error in if (x[i] 0) { : argument is of length zero
As well, I would minimum
Hi all,
I'm searching for a way to exclude outliers from my dataset while making
xyplots. While plotting using pairs(), I exclude specific row in my data frame
and save the settings as a variable which I later include as an argument:
# Discard outliers and save settings as idx
Hello everybody,
I'm using the lattice package and the xyplot to make several graphs like below.
However, I can just print the three grouped plots onto one page as I'm putting
them into a pdf-file, which gives me a huge amount of pages... Is it possible
to put them all, or at least more than
Hi all,
Probably a simple question, but I just can't find a simple answear in the older
threads or anywhere else.
I've added some new vectors as columns in a data frame using cbind(). As
they're all put as the last columns inte the data frame, I would like to move
them to specific positions.
Hi everybody,
I'm using the method described here to make a linear regression:
http://www.apsnet.org/education/advancedplantpath/topics/Rmodules/Doc1/05_Nonlinear_regression.html
## Input the data that include the variables time, plant ID, and severity
time -
Hi all,
I guess this might be an easy question, but I've searched multiple help pages
without finding any answear... so now I put my trust in you!
I have a data frame (36 variables and 556 observations). One column contains
three factors, and I would like to divide the data frame into three
Hi,
I've got a data frame (556 rows and 36 columns) from which I need to create
several xy plots and print to pdf, in order to detect outliers and trends in
the data. 16 of the columns contains numerical values, and I would like to
create graphs for all combinations. It can be done manually,
32 matches
Mail list logo