Displaying 20 results from an estimated 10000 matches similar to: "factor issue"
2009 Feb 19
2
counting strings in a column
Dear All,
I have a query : what is the command to count number of repeated words in a
column.
for ex:
a =
oranges
oranges
apples
apples
grape
oranges
apple
pine
the result should be
oranges 3
apples 3
grape 1
pine 1
is there an easy way for this.
Thanks,
Nataraju
GM R & D
Bangalore
--
"No relationship is Static .. You either Step up or Step down"
[[alternative HTML
2009 Apr 29
2
reading csv file : blanks
Hi,
I have a comma seperated data file which has blanks in it. I am trinying to
import it to R using
data1<-read.csv("oa_2006.csv", header = TRUE, sep = ",", quote="\"",
dec=".")
I want the missing values to be "NA". instead R reads them as "U". Any idea
why this happens ?
Thanks in advance.
Regards,
Nataraju
GM
2009 Apr 24
2
displaying percentage in bar plot
Hi,
I have a query regarding barplot
I have a following data
AIS LEvel
1 2 3
body region A 10 15 20
B 15 25 15
Now I want to plot a barplot and in each bar (corresponding a body region),
I need a percentage of AIS level 1 displayed in the plot. Is there an
2005 Apr 02
4
factor to numeric in data.frame
Dear All,
Assume I have a data.frame that contains also factors and I would like to
get another data.frame containing the factors as numeric vectors, to apply
functions like sapply(..., median) on them.
I read the warning concerning as.numeric or unclass, but in my case this
makes sense, because the factor levels are properly ordered.
I can do it, if I write for each single column
2010 Aug 17
2
Matrix
How do I completely remove the first column?
(x <- matrix(c(1, 44, 124, 80, 254, 70, 190, 0, 2, 35, 110, 70, 240, 73, 216, 0, 3, 41, 114, 80, 279, 68, 178, 0, 4, 31, 100, 80, 284, 68, 149, 0, 5, 61, 190, 110, 315, 68, 182, 1, 6, 61, 130, 88, 250, 70, 185, 0, 7, 44, 130, 94, 298, 68, 161, 0, 8, 58, 110, 74, 384, 67, 175, 0, 9, 52, 120, 80, 310, 66, 144, 0, 10, 52, 120, 80, 337, 67, 130, 0, 11,
2006 Dec 15
1
Switching labels on a factor
Hi All,
I'm perplexed by the way the unclass function displays a factor whose
labels have been swapped with the relevel function. I realize it won't
affect any results and that the relevel did nothing useful in this
particular case. I'm just doing it to learn ways to manipulate factors.
The display of unclass leaves me feeling that the relevel had failed.
I've checked three books
2012 Nov 05
1
Another code to drop factor levels
I apologize if this is not appropriate for this mailing list.
In R, there is already functionality to drop unused factor levels. However, I am proposing the code below that I wrote. In some occasions, it was faster than applying function 'factor'. In any case, there is no restriction for anyone to use the code below.
droplevels2 <- function(x) {
if (is.null(levels(x)))
stop("no
2004 Feb 17
1
deprecated 'codes' function in 'factor' docs (PR#6590)
Full_Name: Andrew Stryker
Version: 1.8.1
OS: Linux/Win XP
Submission from: (NULL) (65.124.252.58)
>From ?factor:
See Also:
'[.factor' for subsetting of factors.
'gl' for construction of "balanced" factors and 'C' for factors
with specified contrasts. 'levels' and 'nlevels' for accessing the
levels, and
2007 Oct 03
1
Reimplement order somehow
Hello,
I have a script in R language that makes sorting using the order() method of
R language. What I need is to reimplement this method in any other language
(PHP, Perl, Python, Java maybe).
First I tried to reimplement it in php, here is some numbers that i need to
sort:
1,2,3,4,5,6,7,8,9,10,300,231,11,12,0,1
R language:
n = c(1,2,3,4,5,6,7,8,9,10,300,231,11,12,0,1)
n
[1] 1 2 3 4 5
2008 Jul 31
2
dput vs unclass to see what a factor really is composed of
I used read.dta() to read in a Stata 9 dataset to R. The "Sex01" variable
takes on two values in Stata: 0 and 1, and it is labeled "M" and "F"
respectively, analogous to an R factor. Thus, read.dta reads it in as a
factor.
Now, I wanted to see what this variable *really* is, in R. For instance,
sometimes R converts a 0/1 variable into a 1/2 variable when it considers
2007 Mar 21
1
rbind.data.frame reacts on levels without factor (PR#9578)
Full_Name: Lutz Prechelt
Version: 2.4.1
OS: Windows XP
Submission from: (NULL) (160.45.111.67)
I stack a number of data.frames using rbind.
Each of these dataframes has a column 'authorname', which is a factor
and a column author = unclass(authorname) as piecewise pseudonyms.
When using rbind to stack these dataframes, R warns about invalid factor levels
and inserts all NAs in the author
2007 Aug 09
2
Systematically biased count data regression model
Dear all,
I am attempting to explain patterns of arthropod family richness
(count data) using a regression model. It seems to be able to do a
pretty good job as an explanatory model (i.e. demonstrating
relationships between dependent and independent variables), but it has
systematic problems as a predictive model: It is biased high at low
observed values of family richness and biased low at
2009 Oct 20
2
descriptive statistics qn
This is day one on R for me, I am trying to figure out how to do simple
computations. For example I have a data set with 200 observations. I am
trying to compute the mean and variance in r for 1:25 (first 25
observations); 1:50 (first 50 obs) ; 1:100th observation etc. Here is the
dataset:
Id value
1 2.2338
2 3.13597
3 1.98685
4 4.35593
5 2.43963
6 4.20262
7 3.12131
8 4.79583
9 3.13937
10
1997 May 21
2
R-alpha: factors ...
Perhaps someone can enlighten me here:
R> x <- factor(LETTERS[1:3])
R> x
[1] A B C
R> mode(x)
[1] "factor"
R> class(x)
[1] "factor"
R> mode(unclass(x))
[1] "factor"
S-PLUS has
> x <- factor(LETTERS[1:3])
> mode(x)
[1] "numeric"
> class(x)
[1] "factor"
> mode(unclass(x))
[1] "numeric"
???
2009 Jan 24
1
Environment change?
So i have a simple question that doesnt require sample code, not sure if that
violates posting rules or not.
Is this:
[1] "111" "112" "113" "114" "115" "116" "118" "119" "120" "123" "125" "126"
[13] "127" "128" "132" "137"
2008 Feb 16
3
Arithmetic bug? (found when use POSIXct) (PR#10776)
Full_Name: Bo Zhou
Version: 2.6.1 (2007-11-26)
OS: Windows XP
Submission from: (NULL) (207.237.54.242)
Hi,
I found an arithmetic problem when I'm doing something with POSIXct
The code to reproduce it is as follows (This is the recommended way of finding
out time zone difference on R News 2004-1 Page 32 URL
http://cran.r-project.org/doc/Rnews/Rnews_2004-1.pdf)
a=Sys.time()
2012 Dec 21
2
Why can't I "unclass" an array?
In a real example I was trying to remove the class from the result of table, just because
it was to be used as a building block for other things and a simple integer vector seemed
likely to be most efficient.
I'm puzzled as to why unclass doesn't work.
> zed <- table(1:5)
> class(zed)
[1] "table"
> class(unclass(zed))
[1] "array"
>
2012 Dec 21
2
Why can't I "unclass" an array?
In a real example I was trying to remove the class from the result of table, just because
it was to be used as a building block for other things and a simple integer vector seemed
likely to be most efficient.
I'm puzzled as to why unclass doesn't work.
> zed <- table(1:5)
> class(zed)
[1] "table"
> class(unclass(zed))
[1] "array"
>
2011 Apr 04
0
Multithreading of Geneland
Hi all,
I would like to multithread that script, to detect structure from multilocus genetic data :
>library(Geneland)
>
>geno = read.table("cot966gen_test.txt") #the file is show after
>MCMC(geno.dip.codom = geno, varnpop=T, npopmax=20, spatial = F, nit=100000, thinnin=100, path.mcmc="./")
>PostProcessChain(path.mcmc="./", nxdom=100, nydom=100,
2005 Apr 20
1
make check failure -- R 2.1.0 Windows XP SP2
I compiled R 2.1.0 under Windows XP SP2 as a preliminary to rebuilding a
custom package for use with R 2.1.0. The compile completed successfully,
and I was able to run demo(graphics) successfully. But make check and
make check-recommended fail.
> version
_
platform i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status
major 2
minor 1.0
year 2005