Displaying 20 results from an estimated 30000 matches similar to: "How to convert a matrix to a dataframe and makes its first row be the column name"
2008 Sep 23
1
How to draw arrows or segment lines in 3 dimensional graph
Hi
I have a dataset which is like this:
ID X1 Y1 Z1 X2 Y2 Z2
1 32 127 85 31.7 121 85
2 37.9 153 88 34.6 137 90
3 36.8 134 88 36.1 155 97
4 31.4 136 87 29 113 70
I would like draw the arrow or segment line for each ID from (x1, y1, z1) to
(x2, y2, z2)
Is there a way to do this kind of 3-D graph.
Thank you
--
View this message in context:
2009 Aug 06
2
Convert dataframe to table with counts where column names become row names
Can anyone explain how best to go from a dataframe to a table (or better yet
a new dataframe) of counts, where the row names in the new table (or
dataframe) are the column names of the original df.
start w/
DF1 =
Pos1 Pos2 Pos3 ....
oligo1 G C A
oligo2 U U A
oligo3 G C C
oligo4 C G U
oligo5 A A G
.....
End with
DF2 =
2006 Feb 24
2
converting character matrix to a dataframe
Dear R-Help,
Suppose I have a character matrix, e.g.,
(ch.mat <- matrix(c('a','s','*','f','w','*','k','*','*','f','i','o'),
ncol=3))
When I convert 'ch.mat' to a dataframe, the columns are converted to
factors:
(d1 <- data.frame(ch.mat))
mode(d1[,1])
is.factor(d1[,1])
To prevent
2009 Feb 06
3
how to delete specific rows in a data frame where the first column matches any string from a list
Hi,
I'm new in the mailing list but I would appreciate if you could help
me with this:
I have a big matrix from where I need to delete specific rows. The
second entry on these rows to delete should match any string within a
list (other file with just one column).
Thank you so much!
Laura
2008 Apr 27
1
parallel max, min, and median of dataframe columns
Hello, all,
I have a dataframe of three rows and umpteen columns. I want to show the
maximum, minimum, and median with a vertical line and a central dot (I'd
use a boxplot, but with only three data points, that's overkill; I can't
just use points, because of overlap and some of the other data plotted on
the graph).
This works:
> boxplot(data_frame,
2009 Apr 13
3
tapply output as a dataframe
i use tapply and by often, but i always end up banging my head against
the wall with the output.
is there a simpler way to convert the output of the following tapply to
a dataframe or matrix than what i have here:
# setup data for tapply
dt = data.frame(bucket=rep(1:4,25),val=rnorm(100))
fn = function(x) {
ret =
c(unname(quantile(x,probs=seq(.25,.75,.25),na.rm=T)),mean(x,na.rm=T))
}
a =
2011 May 27
1
How to convert an ftable object to a matrix including the row names?
Dear expeRts,
What's the easiest way to convert an ftable object to a matrix such that the
row names of the ftable object are shown in the first couple of columns of the
matrix? This is (typically) required, for example, when the final goal is to print
the matrix via xtable.
Below is a rather complicated example of how to do it...
Cheers,
Marius
## Goal: convert an ftable() to a
2008 Jun 22
5
Re move row.names column in dataframe
Hello,
aa<-c(1,1,2,2,3,3,4,4,5,5,6,6)
bb<-c(56,56,33,33,53,53,20,20,63,63,9,9)
cc<-data.frame(aa,bb)
uniquedf <- unique(cc)
View(uniquedf)
Why does the column "row.names" appear in the new dataframe and how do I get
rid of it.
"uniquedf$row.names <- NULL" does not seem to work.
For what I'm doing this is a useless column and can cause confusion and/or
2008 Oct 20
2
convert matrix to dataframe with repeating row names
Hi R,
I have a matrix x with repeating row names.
> dim(x)
[1] 862 19
zz<-matrix(0,4,4)
rownames(zz)=c("a","a","b","b")
data.frame(zz) (?)
I need to use x in a linear regression
lm(as.formula(paste("final_dat[,5]~",paste(colnames(x),collapse="+"))),x
)
this gives me a error
Error in
2007 Apr 16
2
Dealing with data frame column names beginning with a numeric
I wish to set up a simple function using boxplot so that it will be
available to someone using R for Windows. (I myself use Linux.)
The way the data is organised makes it convenient to use the boxplot
function in a manner similar to this example given in the help.
> mat <- cbind(Uni05 = (1:100)/21, Norm = rnorm(100),
+ T5 = rt(100, df = 5), Gam2 = rgamma(100, shape
2010 Feb 26
7
How to add a variable to a dataframe whose values are conditional upon the values of an existing variable
Hi everyone,
I am at my wits end with what I believe would be considered simple by a more experienced R user. I want to know how to add a variable to a dataframe whose values?are conditional?on the values of an existing?variable.?I can't seem to make an ifelse statement work?for my situation.?The existing variable?in my dataframe is?a character variable named DOW which contains abbreviated
2009 Jan 07
1
Re moving Numeric,0 from dataframe
I realize i am breaking the posting rules by not posting sample code but i
tried building some sample test code for this problem based on my working
code and it wasnt producing what i wanted so hopefully a brief explanation
and my result will allow you guys enough information to offer some advice.
My result:
allTAZprobs TAZS
[1,] Numeric,0 640
[2,] 0.4385542 641
[3,] 0.2876207 642
[4,]
2013 Mar 07
2
Copying a dataframe
Hi, I am trying to create a data frame using the dimensions of another data
frame that I have input. This is the code I am using:
tab is the data frame that is input.
c.leng<-length(tab[,1]); r.leng<-length(tab[1,]);
opdf<-data.frame(ncol=c.leng, nrow=r.leng);
a<-1;
while(a<=c.leng)
{
opdf[[1]][a]<-tab[[1]][a];
a<-a+1;
}
This is the error message I am getting:
Error in
2009 Mar 11
3
Converting a dataframe to a matrix
If I have a dataframe which is organized like this:
name color likes?
1 sally red 0
2 sally blue 1
3 sally green 1
4 jake red 0
5 jake blue 1
6 jake green 1
7 tom red 1
8 tom blue 0
9 tom green 0
And I want to create a matrix in the form:
red blue green
sally 0 1 1
jake 0 1 1
tom 1 0 0
Are there any built-in
2018 May 22
0
remove rows of a matrix by part of its row name
Hello,
Use grep to get the row indices and then subset with a *negative* index
to remove those rows.
rn <- scan(what = character(), text = "
70/556
71.1/280
72.1/556
72.1/343
73.1/390
73.1/556
")
mat <- matrix(rnorm(6*6), nrow = 6)
row.names(mat) <- rn
inx <- grep("73\\.", row.names(mat))
new_mat <- mat[-inx, ]
new_mat
Hope this helps,
Rui Barradas
On
2018 May 22
4
remove rows of a matrix by part of its row name
Dear R-experts,
How can I remove a certain feature or observation by a part of its name. To be clear, I have a matrix with 766 observations as a rows. The row names are like this
70/556
71.1/280
72.1/556
72.1/343
73.1/390
73.1/556
Now I would like to remove all the rows that contain the text 73.1
Any ideas or suggestion please ?
Regards
**********************
Ahmed Serag
Analytical
2007 Mar 10
2
read a irregular text file data into dataframe()
I am using R2.4.1 calling a text file contains the following data structure:
when i call the file into R using
tData<-read.table("c:\\test.txt")
it gave me Error saying, irregular column in the data set
however i need to use the below type of data
Is there any alternative in R?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0010 0028 0061 0088
0010 0042 0084
0004 0010 0055
0010 0018 0040 0042
2006 Aug 14
3
column to row
Dear mailing list
I have a data in two columns and how can i convert it to one row . thank you
in advance
inpute
1 2
3 4
5 6
7 8
9 1
out put
1 2 3 4 5 6 7 8 9 1
[[alternative HTML version deleted]]
2006 Sep 17
2
Excluding columns from dataframe and selecting row records
Dear R-friends,
I have to simple questions. First I would like to exclude some columns from a dataframe and after I need select rows that satisfy some conditions.
My data frame looks like
Region Species Bodysize Weigth Age
Africa Sp1 10.2 20 2
Africa Sp2 12.2 12 2
Africa Sp3 15.3 18 3
Africa Sp4 11.5 40 4
Brazil Sp1 10.2 40 3
Brazil Sp2 22.2 32 2
Brazil Sp3 12.3
2012 Sep 17
2
How to divide each column with its own value
Hi,
I have a matrix as below:
mat=
[,1] [,2] [,3]
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9
What I want to do is, I would like to divide each column with its own
value, in order to get value 1.
Is there any simple script for that?
[[alternative HTML version deleted]]