Displaying 20 results from an estimated 57 matches for "column2".
Did you mean:
column
2004 Aug 17
2
levels of factor
R-help,
I have a data frame wich I subset like :
a <- subset(df,df$"column2" %in% c("factor1","factor2") & df$"column2"==1)
But when I type levels(a$"column2") I still get the same levels as in df (my original data frame)
Why is that?
Is it right?
Luis
Luis Ridao Cruz
Fiskiranns??knarstovan
N??at??n 1
P.O. Box 3051
FR-1...
2010 Oct 04
1
Splitting a DF into rows according to a column
...eros. Curabitur fringilla dui ac dui
rutrum pretium. Donec sed magna adipiscing nisi accumsan congue sed ac est.
Vivamus lorem urna, tristique quis accumsan quis, ullamcorper aliquet
velit."
> tmpDF <- data.frame(Column1=rep(unlist(strsplit(loremIpsum,"
")),length.out=510),Column2=runif(510,min=0,max=1e8))
is to be split into DFs with 50 entries in an ordered manner according to
column2 (first DF ist o contain the rows with the 50 largest numbers, ...).
Here is what I have been doing:
> binSize <- 50
> splitMembership <-
pmin(ceiling(order(tmpDF[["Colum...
2010 May 31
2
accessing a data frame with row names
Readers,
I have entered a file into r:
,column1,column2
row1,0.1,0.2
row2,0.3,0.4
using the command:
dataframe<-read.table("/path/to/file.csv",header=T,row.names=1)
When I try the command:
dataframe[,2]
I receive the response:
NULL
I was expecting:
row1 0.2
row2 0.4
What is my error with the syntax please?
Yours,
r251
mandriva200...
2004 Nov 23
5
number of pairwise present data in matrix with missings
is there a smart way of determining the number of pairwise present data
in a data matrix with missings (maybe as a by-product of some
statistical function?)
so far, i used several loops like:
for (column1 in 1:99) {
for (column2 in 2:100) {
for (row in 1:500) {
if (!is.na(matrix[row,column1]) & !is.na(matrix[row,column2])) {
pairs[col1,col2] <- pairs[col1,col2]+1
}
}
}
}
but this seems neither the most elegant nor an utterly fast solution.
thanks for suggestions.
andreas wolf
2008 Feb 26
1
Split data.frames depeding values of a column
Hello to all
is there a function wich splits a data.frame (column1,column2,column3,....)
into
data1 <-(column1,column3....) #column2 = 1
data2 <-(column1,column3....) #column2 = 2
data3 <-(column1,column3....) #column2 = 3
...
Regards Knut
2009 May 14
2
Function to read a string as the variables as opposed to taking the string name as the variable
I am writing a custom function that uses an R-function from the
reshape package: cast. However, my question could be applicable to
any R function.
Normally one writes the arguments directly into a function, e.g.:
result=cast(table1, column1 + column2 + column3 ~ column4,
mean) (1)
I need to be able to write this statement as follows:
result=cast(table1, string_with_columns ~ column4, mean) (2)
string_with_columns = group of functions that ultimately outputs:
"column1 + column2 + column3"
Statement 1 outputs th...
2009 Jun 13
3
How Can I insert another column data into the CSV file when I use FasterCSV?
Hi, All,
Suppose I have a CSV file, there is data in it.
* Column 1 Column2 Column 3 Column 4
Row1 a b c
Row2 a2 b2 c2*
You know, the column 4 is no data
Now, I would like to insert data to Column 4, after save, the CSV file will
be:
* Colu...
2006 Jan 04
3
matrix math
...rame has 20 variables (“cocolumns") and 525 observations (“rows”). All variables are numeric.
I want to create a new dataframe that also has 20 columns and 525 rows. The values in this dataframe should be the sum of the 2 other dataframe.
(i.e. temp1$column 1+temp2$column1, temp1$column2+temp2$column2, etc)
What is the best/easiest way to accomplish this?
Is I wish to "multiply" (instead of sum) the columns, how do I?
I tried:
temp3<-as.matrix(temp1)+as.matrix(temp2)
I get the following error message: “Error in as.matrix(temp1) + as.matrix...
2009 Jun 17
6
script help
Hi
?
I have a file. list.txt (two columns)
?
column1??? column2
name??????? address
?
?
I need to put in the letter file letter.txt eg:
?
Dear: Chloe
Address: CA
?
Can I use this
?
for i `cat list.txt` | sed 's/Chloe/$i.1; /CA/$i.2/g' $i.letter.txt
?
Thank you for your help
?
?
?
?
?
_____________________________________________________________...
2010 Feb 27
1
New Variable from Several Existing Variables
...;Yes", however if any one of the three existing variables is
a "No", then then new variable should be a "No". I would then use that new
variable as an exclusion for data in a new or existing dataset (i.e., if
NewVariable = "No" then delete):
Take this:
Column1, Column2, Column3
Yes, Yes, Yes
Yes, No, Yes
No, No, No
No, Yes, No
Yes, Yes, No
Generate this:
Column1, Column2, Column3, NewVariable1
Yes, Yes, Yes, Yes
Yes, No, Yes, No
No, No, No, No
No, Yes, No, No
Yes, Yes, No, No
And end up with this:
Column1, Column2, Column3, NewVariable1
Yes, Yes, Yes, Yes
Any...
2009 Jun 15
2
Help with syntax error
Hi,
I have written boxplot commands of this form before, but I don''t quite understand why the function call is reporting a syntax error in this instance. All parameters passed to the function are strings.
Thanks in advance.
Payam
> simplevar <- function(wframe,column1,column2) {
+ tframe <- get(wframe)
+ x1 <- which(names(wframe)==column1)
+ x2 <- which(names(wframe)==column2)
+ print(tframe[x1])
+ print(tframe[x2])
+ gtitle <- paste(names(tframe[x2])," vs. ", names(tframe[x1])
+ quartz(width=7,height=5,dpi=200)
Error: s...
2013 Mar 21
2
Displaying median value over the horizontal(median)line in the boxplot
...52 but I only want it to be displayed as 7.6.
Thank you so much for your help. I am very sorry for troubling you but I am very very new to this programming and to R as you can see.
<quote author='arun kirshna'>
Hi,
Lines1<-readLines(textConnection("Column1 -1,2,3,4,5,6,6,7
COlumn2- 3,4,5,6,7,8,8
Column3-- 45,66,7,8,89,
COlumn4-5,6,7,7,8,9
Column5 -5,6,7,8,8"))
vec1<-unlist(strsplit(Lines1,"-"))
dat1<-as.data.frame(t(read.table(text=vec1[grepl(",",vec1)],sep=",",fill=TRUE)))
row.names(dat1)<-NULL
colnames(dat1)<-tolower(gsub(&q...
2004 Oct 25
2
Reading sections of data files based on pattern matching
...I want
to analyze plot etc.
Since this will be used many people at the department I wanted to make
sure that will do this in the best way.
For instance I want to read a snippets of data from a text that look
like this.
-------------------------------
Lots of stuff
...
@@Start Values@@
Column1 Column2 Column3 ...
Row1 1 2 3 ...
...
@@End Values@@
More stuff
...
@@Start OtherValues@@
Column1 Column2 Column3 ...
Row1 1 2 3 ...
...
@@End OtherValues@@
I looked in the help files and found grep which operates on character
strings, do I have to like this then?
1. Read file with readLines("f...
2006 Apr 06
1
reshape question
Hi,
I have a data fram like this:
date column1 column2 column3 value1 value2 value3
1-1 A B C 10 5 2
2-1 A B D 5 2 0
3-1 A B E 17 10 7
How can I reshape it to:
date column1 column2 column3 v x
1-1 A B C value1 10
1-1 A B C value2 5
1-1 A B C value3 2
2-1 A B D value1 5
2-1 A B D value2 2
2-1 A B D value3 0
3-1 A B E value1 17
3-1 A B E value2 10
3-1...
2009 Dec 03
2
Dataframe help
Hi there
I have two dataframes
Dataframe_1
column_1 colum_2
121 12345
145 1675
167 2765
Dataframe_2
column_1 column2
121 abc
345 lmn
167 efg
I want a resulting dataframe
121 12345 abc
167 2765 efg
how do i go abt it
Ramya
--
View this message in context: http://n4.nabble.com/Dataframe-help-tp947934p947934.html
Sent from the R help mailing list archive at Nabble.co...
2009 Aug 12
2
Symbolic references - passing variable names into functions
Hello All,
I am trying to write a function which would operate on columns of a
dataframe specified in parameters passed to that function.
f = function(dataf, col1 = "column1", col2 = "column2") {
dataf$col1 = dataf$col2 # just as an example
}
The above, of course, does not work as intended. In some languages one
can force evaluation of a variable, and then use that evaluation as the
variable name. Thus,
> a = "myvar"
> (operator)a = 1
>...
2005 Dec 31
3
Semi-Dynamic table sorting (without AJAX)
...s strategy, I have come
across several refinements that I would like to share.
First...
your table view should look like this...
...
<table>
<tr>
<th><%= link_to ''Column1'', :sort=>''column1'' %>
<th><%= link_to ''Column2'', :sort=>''column2'' %>
</tr>
.....
</table>
...
your ''model'' controller ''list'' action should look like this....
def list
sorthash = {"column1"=>"column1, updated_at", "column2"=&...
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 need a function like read.table. But it seems that read.table only can handle files, not vectors...
2018 May 10
2
using for loop with data frames.
...ad.csv("test3.csv",header =TRUE)
How could I would implement a code loop that , for instance, would select
two coluns of interest in a fashion of the code below ?
# selecting only 2 columns of interest
for (1, 1:3) {
df_selected [i] <- df_bs_id[i] [ , c("column1", "column2")] }
Tks
MMS
[[alternative HTML version deleted]]
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 that's not what I want.