Displaying 20 results from an estimated 10000 matches similar to: "for loop over dataframe without indices"
2011 Feb 23
2
list multiplied by a factor / mapply
Dear list,
this works fine:
x <- split(iris, iris$Species)
x1 <- lapply(x, function(L) transform(L, g = L[,1:4] * 3))
but I would like to multiply each Species with another factor:
setosa by 2, versicolor by 3 and virginica by 4. I've tried mapply but
without success.
Any thoughts? Thanks for any idea!
Patrick
2005 Jul 08
5
Help with Mahalanobis
Dear R list,
I'm trying to calculate Mahalanobis distances for 'Species' of 'iris' data
as obtained below:
Squared Distance to Species From Species:
Setosa Versicolor Virginica
Setosa 0 89.86419 179.38471
Versicolor 89.86419 0 17.20107
Virginica 179.38471 17.20107 0
These distances were obtained with proc 'CANDISC'
2007 Jan 26
2
Why do return or visible don´t return my objekt?
Dear RRRRRrrrrrrrrlist!
I?ve got two lists which contain sets of DNA-sequences. They look
something like this:
List of 33
$ Cunonia_atrorubens : chr [1:247] "t" "t" "n" "t" ...
$ Cunonia_balansae : chr [1:254] "t" "c" "c" "c" ...
$ Cunonia_capensis : chr
2003 Nov 05
1
save(iris,file=
I tried it using file and it seems to work for saving:
> data(iris)
> con <- file("clipboard","w")
> save(iris,ascii=T,file=con)
> close(con)
> readLines("clipboard")
... lengthy output follows which seems correct ...
but not for loading:
> con <- file("clipboard","r")
> load(con)
Error in load(con) : loading from
2008 Aug 07
6
multiple tapply
Hi folk,
I tried this and it works just perfectly
tapply(iris[,1],iris[5],mean)
but, how to obtain a single table from multiple variables?
In tapply x is an atomic object so this code doesn't work
tapply(iris[,1:4],iris[5],mean)
Thanx and great summer holidays
Gianandrea
--
View this message in context: http://www.nabble.com/multiple-tapply-tp18868063p18868063.html
Sent from the R help
2010 Dec 15
3
Applying function to a TABLE and also "apply, tapply, sapply etc"
Dear R-help forum members,
Suppose I have a data-frame having two variables and single data for each of them, as described below.
variable_1 variable_2
10 20
I have written a function, say, 'fun' which uses input 10 and 20 and gives me desired result.
fun = function(X, Y)
{
X + Y #( I am just giving an example of
2005 Jul 06
1
Help: Mahalanobis distances between 'Species' from iris
Dear R list,
I'm trying to calculate Mahalanobis distances for 'Species' of 'iris' data
as obtained below:
Squared Distance to Species From Species:
Setosa Versicolor Virginica
Setosa 0 89.86419 179.38471
Versicolor 89.86419 0 17.20107
Virginica 179.38471 17.20107 0
This distances above were obtained with proc
2010 Jul 29
1
where did the column names go to?
I've just tried to merge 2 data sets thinking they would only keep the common
columns, but noticed the column count was not adding up. I've then
replicated a simple example and got the same thing happening.
q1. why doesn't 'b' have a column name?
q2. when I merge, why does the new column 'y' have all values as 5.1?
Thanks in advance,
Mr. confused
> a <-
2012 Dec 10
3
splitting dataset based on variable and re-combining
I have a dataset and I wish to use two different models to predict. Both models are SVM. The reason for two different models is based
on the sex of the observation. I wish to be able to make predictions and have the results be in the same order as my original dataset. To
illustrate I will use iris:
# Take Iris and create a dataframe of just two Species, setosa and versicolor, shuffle them
2005 Aug 26
2
problem with certain data sets when using randomForest
Hi,
Since I've had no replies on my previous post about my
problem I am posting it again in the hope someone
notice it. The problem is that the randomForest
function doesn't take datasets which has instances
only containing a subset of all the classes. So the
dataset with instances that either belong to class "a"
or "b" from the levels "a", "b" and
2012 Oct 10
2
Summary using by() returns character arrays in a list
I use by() to generate a summary statistics like so:
Lbys <- by(dat[Nidx], dat$LipTest, summary)
where Nidx is an index vector with names picking out the columns in the
data frame dat.
This returns a list of character arrays (see below for str() output) where
the columns are named correctly but the rownames are empty strings and the
values are strings prepended with the summary
2010 Jun 09
4
question about "mean"
Hi there:
I have a question about generating mean value of a data.frame. Take
iris data for example, if I have a data.frame looking like the following:
---------------------
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4
0.2 setosa
2 4.9 3.0 1.4
0.2
2006 Dec 18
5
Replacing values
Hi all,
I have to recode some values in a dataset. for example changing all zeros to
"." or 999 would be also ok. does anybody know how to do this? thanks in
advance. lars
--
View this message in context: http://www.nabble.com/-R--Replacing-values-tf2841687.html#a7934402
Sent from the R help mailing list archive at Nabble.com.
2009 Oct 17
1
Easy way to `iris[,-"Petal.Length"]' subsetting?
Dear all
What is the easy way to drop a variable by using its name (and not its
number)? Example:
> data(iris)
> head(iris)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4 0.2 setosa
2 4.9 3.0 1.4 0.2 setosa
3 4.7 3.2 1.3 0.2 setosa
4 4.6 3.1
2003 Nov 05
1
save(iris,file="clipboard",ascii=TRUE)
Is this a bug? I thought that "clipboard" could always be substituted
for a filename when dealing with ASCII files.
> data(iris)
> save(iris,ascii=TRUE,file="clipboard")
Error in file(file, "wb") : `mode' for the clipboard must be `r' or `w'
Also this (where gclip is a utility found at unxutils.sourceforge.net
that copies its standard input to the
2005 Apr 27
4
How to add some of data in the first place dataset
Dear R-help,
First I apologize if my question is quite simple.
I need add some of data in the first place my dataset, how can I do that.
I have tried with rbind, but I did not succes.
0.1 3.6 0.4 0.9 rose
4.1 4.0 1.2 1.2 rose
4.4 3.2 1.9 0.5 rose
4.6 1.1 1.1 0.2 rose
For example,
2017 Oct 25
2
How to create a table structure in Java code?
Hi all,
Using RConsole, it's easy to get data from the database that you can use in an R Command. Like this:
(Reference case)
irisQuery <- dbGetQuery(conn, "select * from iris")
boxM(irisQuery [,-5], irisQuery[,5])
----
(Actual case this posting is about)
Yet, if I'm getting that same (sample IRIS) data, say, in a web service possibly POSTED from a SQL command, that same
2017 Oct 26
3
How to create a table structure in Java code?
That's amazing! Thank you!!!
One follow up question, if that's OK?
If, instead of using hard-coded CSV, I read the CSV into a variable first, then it fails again with a parse error.
Code below.
So, if I read the CSV into a variable, do I need an additional wrapper method?
Seems like it should still work.
Thanks in advance for your reply.
-M
String inputIris =
2007 Apr 29
1
randomForest gives different results for formula call v. x, y methods. Why?
Just out of curiosity, I took the default "iris" example in the RF
helpfile...
but seeing the admonition against using the formula interface for large data
sets, I wanted to play around a bit to see how the various options affected
the output. Found something interesting I couldn't find documentation for...
Just like the example...
> set.seed(12) # to be sure I have
2013 Jan 16
4
Get a percent variable based on group
Dear all, I'd like to get a percentage variable based on a group, but without creating a new data frame.
For example:
data(iris)
iris$percent <-unlist(tapply(iris$Sepal.Length,iris$Species,function(x) x/sum(x, na.rm=TRUE)))
This does not work, I should have only three standard values, respectively for setosa, versicolor, and virginica. How can I do this?
MANY THANKS,
Karine