Re: [R] how to delete all classes variables in current previously saved history?

2012-02-19 Thread Alfredo Alessandrini
rm(list=ls()) 2012/2/19 sagarnikam123 sagarnikam...@gmail.com i have variables stored in previous history,next time i log in, load previous history,i want to use same variable name for using other values, i don't know exactly how many are they ? their names also.. How to delete all

Re: [R] How to change the order of columns in a data frame?

2012-02-17 Thread Alfredo Alessandrini
Hi Joel, to replace the colnames: colnames(dataframe - )gsub(X,,colnames(dataframe)) to order by colnames: dataframe - dataframe[,colnames(dataframe)] Alfredo 2012/2/17 Joel Fürstenberg-Hägg jo...@life.ku.dk Dear all, I have a data frame in which the columns need to be ordered. The

Re: [R] Writing output into a file

2012-02-12 Thread Alfredo Alessandrini
Hi, could you paste the results? Alfredo 2012/2/12 Suranga Kasthurirathne suranga...@gmail.com: Hi everyone, I'm an R newbie working with the poLCA module. I achieved my target without having to bother anyone, but It seems that I've got stuck at the last minute. My problem is simple. I

[R] cluster by unique value

2011-07-18 Thread Alfredo Alessandrini
Hi, I need to make a cluster classification by the unique values of the data frame. I explain the problem. I need to classify this table, and assign to the same cluster each row that has the same combination of value: data1 layer_1 layer_2 layer_3 [1,] 0.246000 2

[R] coefficients lm of data.frame

2011-07-07 Thread Alfredo Alessandrini
Hi, I've a data frame like this: as.data.frame(cbind(rnorm(1:12),rnorm(1:12))) V1 V2 1 -1.30849402 -0.52094136 2 0.96157302 0.76217871 3 -0.44223351 -1.72630871 4 -0.10432438 -1.04732942 5 -1.38748914 0.95877311 6 -0.63965975 0.65494811 7 -0.24058318 0.19496830

[R] extract element from list by rownames

2011-04-12 Thread Alfredo Alessandrini
Hi, I've a list of list. I want to extract an element by the rownames. I can extract it by: data[[1]][[1]][[4]][1] But I want to exctract it by a command like this: data[[1]][[B0]][[smac]][[cont]][1] It's possible? Thanks, Alfredo str(data) List of 1 $ :List of 4 ..$ :List of 4

Re: [R] Very simple question

2011-04-08 Thread Alfredo Alessandrini
Exist any function to associated with paste make this result more automatically. you can try with gsub. Alfredo 2011/4/8 Ronaldo Reis Junior chrys...@gmail.com: Hi, I have a very simple doubt. Look: teste - c(A,B,C) teste2 - paste(teste[1],teste[2],teste[3],sep=+) teste2 [1]

[R] round number

2011-03-26 Thread Alfredo Alessandrini
Hi, a - 4 a*0.2 [1] 0.8 ok!! Is there a method to obtain this: a*0.2 [1] 0.80 I need to round the number also with the zero. Thanks in advance, Alfredo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE

[R] best model cp mallow

2010-09-22 Thread Alfredo Alessandrini
Hi, I'm using the Cp and Radj method for the selection of variable, with the library leaps. I need to save the best model in a file. If I use the adjr2 method it's work, but I've a problem with Cp method: adjr - leaps(x,y,method=adjr2) maxadjr(adjr) 12312 0.713 0.56 ok... but whit Cp

[R] compare three values

2010-08-30 Thread Alfredo Alessandrini
Hi, I've three values. What is the best method to choice the lowest values with an if function? example: a = 3 b = 1 c = 5 if (lowest(a,b,c) is a) {} if (lowest(a,b,c) is b) {} if (lowest(a,b,c) is c) {} Thanks, Alfredo

[R] gsub

2010-08-06 Thread Alfredo Alessandrini
Hi, I'm using gsub, but I've a problem. print(i) [1] piante_venere.csv gsub(\\.csv$, , i) [1] piante_venere gsub(^piante_, , i) [1] venere.csv Can I combine the two expressions? Like this: gsub(.) [1] venere Thanks, Alfredo -- View this message in context:

[R] aggregate by column names

2010-02-18 Thread Alfredo Alessandrini
Hi, I've this dataframe: V1 V5 V6 1 MOD13Q1_249 0.1723 A1 2 MOD13Q1_249 0.1824 B1 3 MOD13Q1_249 0.1824 C1 4 MOD13Q1_249 0.1774 A2 5 MOD13Q1_249 0.1953 B2 6 MOD13Q1_249 0.1824 C2 7 MOD13Q1_265 0.1921 A1 8 MOD13Q1_265 0.1938 B1 9

Re: [R] sum column by colnames

2010-01-21 Thread Alfredo Alessandrini
, sort = FALSE) sapply(unique(union(names(data1), names(data2))), function(n)Reduce('+', m[grep(n, names(m))])) On Wed, Jan 20, 2010 at 10:59 AM, Alfredo Alessandrini alfreal...@gmail.com wrote: Hi, I've this dataframes: data1             1        2 3         4             5                6

[R] sum column by colnames

2010-01-20 Thread Alfredo Alessandrini
Hi, I've this dataframes: data1 12 3 4 56 50.4963017 0 0 0.2481509 1.9852069 0.4963017 10 0.000 0 0 0.000 0.6317266 0.000 15 0.000 0 0 0.000 0.000 0.000 20 0.000 0 0 3.3955301 0.000

[R] problem with unmatched quotes

2009-12-14 Thread Alfredo Alessandrini
Hi, I've a problem with unmatched quotes with a bash script within a R script: system(awk 'NR2 {FS= ;print$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12;}' phenology.txt) Errore: unexpected string constant in system(awk 'NR2 {FS= ;print$1 Alfredo __

[R] time series - month value

2009-12-01 Thread Alfredo Alessandrini
Hi, I've this time series: ts_evi Time Series: Start = c(2000, 4) End = c(2002, 7) Frequency = 23 [1] 0.1948306 0.1930461 0.1905792 0.1848909 0.1893624 0.1811400 0.1678140 [8] 0.1750714 0.3100132 0.3495946 0.4103353 0.4973740 0.4937490 0.4031435 [15] 0.3503787 0.2755022 0.2304617 0.2284854

[R] aggregate data.frame

2009-11-09 Thread Alfredo Alessandrini
Hi, I've two data.frame: ind_comp and dati_area ind_comp INDEXindice 1 1 0.3081856 2 2 0.1368007 3 3 0.1290952 4 4 0.2905484 5 5 0.2686706 6 6 0.1122784 7 7 0.4493264 8 8 0.1932665 9 9 0.1982783 1011 0.3724666 dati_area X_COORD

[R] sum two columns with same value

2009-10-17 Thread Alfredo Alessandrini
Hi, I've two dataframe: snag_totale AREA snag_ha 12 1.628128 23 10.274249 34 2.778503 45 73.764307 57 12.015985 log_totale AREAlog_ha 11 22.29846 22 17.16889 33 48.80377 44 144.18996 55 70.30962 66 61.81850 77 13.24876 How can

[R] vector and NA

2009-06-23 Thread Alfredo Alessandrini
Hi, I've a vector like this: -- inc[,5] [1]NANANANANANANA [8]NANANANANANANA [15]NANANANA

[R] first value...

2009-06-23 Thread Alfredo Alessandrini
Hi, I've a vector like this: inc [1]NANANANANANANA [8]NANANANANANANA [15]NANANANANANANA [22]NANA

Re: [R] first value...

2009-06-23 Thread Alfredo Alessandrini
Now is ok...thanks. Alfredo 2009/6/23 Alfredo Alessandrini alfreal...@gmail.com: I've the NA value also between the value of the vector: inc  [1]        NA        NA        NA        NA        NA        NA        NA  [8]        NA        NA        NA        NA        NA        NA        NA

Re: [R] first value...

2009-06-23 Thread Alfredo Alessandrini
only the first value, in this case: inc[82]. Regards, Alfredo 2009/6/23 Henrique Dallazuanna www...@gmail.com Try this:  which(diff(is.na(inc)) 0) On Tue, Jun 23, 2009 at 11:00 AM, Alfredo Alessandrini alfreal...@gmail.com wrote: Hi, I've a vector like this: inc  [1

[R] r script

2008-11-06 Thread Alfredo Alessandrini
A simple question :-) I'm writing a R scritp(#!/usr/bin/Rscript) How can execute a bash command inside the script, like the command for change the directory (cd)? Thanks in advance, Alfredo __ R-help@r-project.org mailing list

[R] count value

2008-09-11 Thread Alfredo Alessandrini
Hi, I've this data.frame: dia X1006109F X1006110F X1006111F X1006112F X1006113F X1006114F X1006115F 1NANANANANA45NA X1006116F X1006117F X1006118F X1006119F X1006120F X1006122F X1006123F 145NANANA

[R] add string

2008-07-31 Thread Alfredo Alessandrini
Hi, How can I join two string? frequency = 15 I want join the number frequency with a string. Alfredo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

[R] NA value

2008-06-27 Thread Alfredo Alessandrini
I'm trying to replace NA with 0 value... I've write a loop, but don't work... Where's the problem? cimfasy_rwl 1991 0.92 0.72 0.50 1.29 0.54 1.22 1992 2.15 1.28 1.23 2.26 1.22 3.17 1993 1.50 0.87 1.68 1.97 0.83 2.55 1994

Re: [R] NA value

2008-06-27 Thread Alfredo Alessandrini
Don't use a loop for this. Do this. I need to use a loop... I've many data. Alfredo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and

Re: [R] NA value

2008-06-27 Thread Alfredo Alessandrini
for (i in files_rwl) { thisfile - get(i) thisfile[is.na(thisfile)] - 0 assign(i, thisfile) } It's likely that you could condense it, but using the long form makes it clear what's happening. ..it's work Thanks... Alfredo

Re: [R] a loop....

2008-06-25 Thread Alfredo Alessandrini
I recommend avoid loop in this case I'm working with many files... I must utilise a loop necessarily. And you shall know that R is pretty smart in handling missing values. How do you know after change NA - 0 that 0 is from NA and not like in 1994 row and second column. This isn't a

[R] loop with files

2008-06-24 Thread Alfredo Alessandrini
I'm trying to make a loop with many files... library(dplR) files - system(ls *.rwl, intern=TRUE) files [1] cimfasy.rwl rocquce.rwl for (i in files) {a - read.rwl(i,header=0)} There are 70 series There are 21 series class(a) [1] data.frame This loop import all the files rwl in a single

Re: [R] colnames of a column

2008-06-20 Thread Alfredo Alessandrini
have you read the docs? Yes, I'm reading the manual An Introduction to R.. start with ?`[` Ok...I haven't read it. Thanks. Alfredo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

[R] colnames of a column

2008-06-19 Thread Alfredo Alessandrini
Hi, With this data.frame: class(rwl) [1] data.frame rwl 0028002F 0028013F 0028032F 1833 3.39 NA NA 1834 3.09 NA NA 1835 3.05 NA NA 1836 3.31 NA NA 1837 2.26 NA NA colnames(rwl) [1] 0028002F 0028013F 0028032F

[R] inverse cumsum

2008-06-18 Thread Alfredo Alessandrini
I've a matrix like this: 1985 1.38 1.27 1.84 2.10 0.59 3.47 1986 1.05 1.13 1.21 1.54 0.21 2.14 1987 1.33 1.21 1.77 1.44 0.27 2.85 1988 1.86 1.06 2.33 2.14 0.55 1.40 1989 2.10 0.65 2.74

Re: [R] inverse cumsum

2008-06-18 Thread Alfredo Alessandrini
2008/6/18 Alfredo Alessandrini [EMAIL PROTECTED]: I've a matrix like this: 1985 1.38 1.27 1.84 2.10 0.59 3.47 1986 1.05 1.13 1.21 1.54 0.21 2.14 1987 1.33 1.21 1.77 1.44 0.27 2.85 1988 1.86 1.06 2.33 2.14

Re: [R] inverse cumsum

2008-06-18 Thread Alfredo Alessandrini
i guess you mean columnwise cumsums computed starting from the bottom up? yes then this should do (given that your data is in matrix m, and years are row labels, not data): rc = nrow(m) cumsums = apply(m[rc:1,], 2, cumsum)[rc:1,] ok...work very well.. data 1987 1.33 1.21

[R] add a row to a data frame

2007-09-27 Thread Alfredo Alessandrini
Hi everybody, I've a data.frame d like this: 0 2468 10 12 14 16 X0 X2 X4 1945 350 NA NA NA NA NA NA NA NA 0.3848451 0.000 0.000 1946 408 NA NA NA NA NA NA NA NA 1.4202009 0.000 0.000 1947 511 NA NA NA NA

Re: [R] add a row to a data frame

2007-09-27 Thread Alfredo Alessandrini
# set X's colnames to match d's colnames(X) - colnames(d) # Now rbind() rbind(d, X) thanks, it's work... Alfredo [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

[R] data frame

2007-09-17 Thread Alfredo Alessandrini
Hi everybody, If I've a data frame like this: dataframe a X0 X2 X4 X6 X8 X10 X12 X14 X16 1957 0 0 0 0 0 0 0 0 0 1958 0 0 0 0 0 0 0 0 0 1959 831 0 0 0 0 0 0 0 0 1960 544 282 0 0 0 0 0 0 0 1961 446 365 0 0 0 0 0

[R] replace NA value with 0

2007-09-14 Thread Alfredo Alessandrini
Hi, how can I replace NA value with 0: 1991 217 119 103 109 137 202 283 240 146 NA 1992 270 174 149 144 166 239 278 237 275 NA 1993 146 111 104 89 98 131 153 148 175 NA 1994 177 123 146 124 121 200 266 191 240 106 1995 145 98 95 89 95 130 183 161 164 129 1996 145 98 89 90 93

[R] loop function

2007-09-13 Thread Alfredo Alessandrini
Hi, If I have this values: 21 23 14 58 26 How can I sum the values by a progression like this: (21) (21 + 23) (21 + 23 + 14) (21 + 23 + 14 + 58) (21 + 23 + 14 + 58 + 26) (21 + 23 + 14 + 58 + 26) I've try with the function loop Best Wishes, Alfredo [[alternative HTML