[R] Problem with fitdistr function
Hello, I am using fitdistr function for parameter estimation. When I use fd-fitdistr(V2,gamma) I get following error: Error in optim(x = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, : initial value in 'vmmin' is not finite fd-fitdistr(V2,weibull) Error in optim(x = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, : non-finite value supplied by optim But if I use following I dont get any errors. fd-fitdistr(V2,exponential) I have included necessary libraries. How can i remove this error?Are there any restrictions in using fitdistr function?If yes is there any alternative approach for solving such problem? My aim is to get estimated value of parameters. Data is as follows: N V1 V2 1 32400 0 2 32460 0 3 32520 0 4 32580 0 5 32640 0 6 32700 0 7 32760 0 8 32820 0 9 32880 0 10 32940 0 11 33000 0 12 33060 0 13 33120 0 14 33180 0 15 33240 0 16 33300 0 17 33360 0 18 33420 0 19 33480 0 20 33540 0 21 33600 0 22 33660 0 23 33720 0 24 33780 0 25 33840 0 26 33900 0 27 33960 0 28 34020 0 29 34080 0 30 34140 0 31 34200 0 32 34260 0 33 34320 0 34 34380 0 35 34440 0 36 34500 0 37 34560 0 38 34620 0 39 34680 0 40 34740 0 41 34800 0 42 34860 0 43 34920 0 44 34980 0 45 35040 0 46 35100 0 47 35160 0 48 35220 32 49 35280 0 50 35340 0 51 35400 0 52 35460 0 53 35520 0 54 35580 0 55 35640 0 56 35700 0 57 35760 0 58 35820 0 59 35880 0 60 35940 0 61 36000 0 62 36060 0 63 36120 31 64 36180 32 65 36240 0 66 36300 0 67 36360 0 68 36420 0 69 36480 0 70 36540 0 71 36600 0 72 36660 0 73 36720 0 74 36780 0 75 36840 0 76 36900 0 77 36960 0 78 37020 0 79 37080 0 80 37140 0 81 37200 0 82 37260 0 83 37320 0 84 37380 0 85 37440 0 86 37500 0 87 37560 0 88 37620 0 89 37680 0 90 37740 0 91 37800 0 92 37860 0 93 37920 32 94 37980 0 95 38040 0 96 38100 0 97 38160 0 98 38220 0 99 38280 0 100 38340 0 101 38400 0 102 38460 0 103 38520 0 104 38580 0 105 38640 0 106 38700 0 107 38760 0 108 38820 32 109 38880 32 110 38940 32 111 39000 0 112 39060 0 113 39120 0 114 39180 0 115 39240 0 116 39300 0 117 39360 0 118 39420 0 119 39480 0 120 39540 0 121 39600 0 122 39660 0 123 39720 32 124 39780 32 125 39840 77 126 39900 0 127 39960 0 128 40020 0 129 40080 0 130 40140 0 131 40200 0 132 40260 0 133 40320 0 134 40380 0 135 40440 0 136 40500 0 137 40560 0 138 40620 32 139 40680 32 140 40740 109 141 40800 67 142 40860 92 143 40920 0 144 40980 0 145 41040 0 146 41100 0 147 41160 0 148 41220 0 149 41280 0 150 41340 0 151 41400 0 152 41460 0 153 41520 112 154 41580 0 155 41640 0 156 41700 0 157 41760 0 158 41820 0 159 41880 0 160 41940 0 161 42000 0 162 42060 0 163 42120 0 164 42180 0 165 42240 0 166 42300 0 167 42360 0 168 42420 0 169 42480 0 170 42540 66 171 42600 0 172 42660 93 173 42720 0 174 42780 0 175 42840 0 176 42900 0 177 42960 0 178 43020 0 179 43080 0 180 43140 0 181 43200 0 182 43260 0 183 43320 0 184 43380 0 185 43440 0 186 43500 0 187 43560 0 188 43620 0 189 43680 138 190 43740 0 191 43800 0 192 43860 0 193 43920 0 194 43980 0 195 44040 0 196 44100 0 197 44160 0 198 44220 0 199 44280 0 200 44340 0 201 44400 0 202 44460 0 203 44520 0 204 44580 0 205 44640 0 206 44700 0 207 44760 0 208 44820 0 209 44880 0 210 44940 0 211 45000 0 212 45060 0 213 45120 69 214 45180 90 215 45240 0 216 45300 0 217 45360 112 218 45420 0 219 45480 0 220 45540 0 221 45600 87 222 45660 0 223 45720 97 224 45780 0 225 45840 0 226 45900 0 227 45960 0 228 46020 0 229 46080 0 230 46140 0 231 46200 0 232 46260 0 233 46320 92 234 46380 0 235 46440 0 236 46500 0 237 46560 0 238 46620 0 239 46680 0 240 46740 0 241 46800 0 242 46860 0 243 46920 0 244 46980 0 245 47040 0 246 47100 0 247 47160 0 248 47220 0 249 47280 0 250 47340 0 251 47400 0 252 47460 0 253 47520 0 254 47580 0 255 47640 0 256 47700 0 257 47760 0 258 47820 0 259 47880 0 260 47940 0 261 48000 0 262 48060 0 263 48120 0 264 48180 0 265 48240 0 266 48300 0 267 48360 0 268 48420 0 269 48480 0 270 48540 0 271 48600 0 272 48660 0 273 48720 0 274 48780 0 275 48840 0 276 48900 0 277 48960 0 278 49020 0 279 49080 0 280 49140 0 281 49200 0 282 49260 0 283 49320 0 284 49380 0 285 49440 0 286 49500 0 287 49560 0 288 49620 32 289 49680 32 290 49740 0 291 49800 0 292 49860 0 293 49920 0 294 49980 33 295 50040 0 296 50100 0 297 50160 0 298 50220 0 299 50280 0 300 50340 0 301 50400 0 302 50460 0 303 50520 102 304 50580 0 305
Re: [R] Problem with fitdistr function
Aswad Gurjar wrote: Hello, I am using fitdistr function for parameter estimation. When I use fd-fitdistr(V2,gamma) I get following error: Error in optim(x = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, : initial value in 'vmmin' is not finite fd-fitdistr(V2,weibull) Error in optim(x = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, : non-finite value supplied by optim But if I use following I dont get any errors. fd-fitdistr(V2,exponential) I have included necessary libraries. How can i remove this error?Are there any restrictions in using fitdistr function?If yes is there any alternative approach for solving such problem? My aim is to get estimated value of parameters. The density of a gamma distribution can be infinite at zero, so fitting to data with exact zeros is asking for trouble. Probably the sanest way to handle this sort of data is to treat the zeroes as left-censored observations, i.e. for x=0 use pgamma(0.5,) instead of dgamma(0,). I think fitdistr() will do this if you set up the density appropriately. Data is as follows: N V1 V2 1 32400 0 2 32460 0 3 32520 0 4 32580 0 5 32640 0 6 32700 0 7 32760 0 8 32820 0 9 32880 0 10 32940 0 11 33000 0 12 33060 0 13 33120 0 14 33180 0 15 33240 0 16 33300 0 17 33360 0 18 33420 0 19 33480 0 20 33540 0 21 33600 0 22 33660 0 23 33720 0 24 33780 0 25 33840 0 26 33900 0 27 33960 0 28 34020 0 29 34080 0 30 34140 0 31 34200 0 32 34260 0 33 34320 0 34 34380 0 35 34440 0 36 34500 0 37 34560 0 38 34620 0 39 34680 0 40 34740 0 41 34800 0 42 34860 0 43 34920 0 44 34980 0 45 35040 0 46 35100 0 47 35160 0 48 35220 32 49 35280 0 50 35340 0 51 35400 0 52 35460 0 53 35520 0 54 35580 0 55 35640 0 56 35700 0 57 35760 0 58 35820 0 59 35880 0 60 35940 0 61 36000 0 62 36060 0 63 36120 31 64 36180 32 65 36240 0 66 36300 0 67 36360 0 68 36420 0 69 36480 0 70 36540 0 71 36600 0 72 36660 0 73 36720 0 74 36780 0 75 36840 0 76 36900 0 77 36960 0 78 37020 0 79 37080 0 80 37140 0 81 37200 0 82 37260 0 83 37320 0 84 37380 0 85 37440 0 86 37500 0 87 37560 0 88 37620 0 89 37680 0 90 37740 0 91 37800 0 92 37860 0 93 37920 32 94 37980 0 95 38040 0 96 38100 0 97 38160 0 98 38220 0 99 38280 0 100 38340 0 101 38400 0 102 38460 0 103 38520 0 104 38580 0 105 38640 0 106 38700 0 107 38760 0 108 38820 32 109 38880 32 110 38940 32 111 39000 0 112 39060 0 113 39120 0 114 39180 0 115 39240 0 116 39300 0 117 39360 0 118 39420 0 119 39480 0 120 39540 0 121 39600 0 122 39660 0 123 39720 32 124 39780 32 125 39840 77 126 39900 0 127 39960 0 128 40020 0 129 40080 0 130 40140 0 131 40200 0 132 40260 0 133 40320 0 134 40380 0 135 40440 0 136 40500 0 137 40560 0 138 40620 32 139 40680 32 140 40740 109 141 40800 67 142 40860 92 143 40920 0 144 40980 0 145 41040 0 146 41100 0 147 41160 0 148 41220 0 149 41280 0 150 41340 0 151 41400 0 152 41460 0 153 41520 112 154 41580 0 155 41640 0 156 41700 0 157 41760 0 158 41820 0 159 41880 0 160 41940 0 161 42000 0 162 42060 0 163 42120 0 164 42180 0 165 42240 0 166 42300 0 167 42360 0 168 42420 0 169 42480 0 170 42540 66 171 42600 0 172 42660 93 173 42720 0 174 42780 0 175 42840 0 176 42900 0 177 42960 0 178 43020 0 179 43080 0 180 43140 0 181 43200 0 182 43260 0 183 43320 0 184 43380 0 185 43440 0 186 43500 0 187 43560 0 188 43620 0 189 43680 138 190 43740 0 191 43800 0 192 43860 0 193 43920 0 194 43980 0 195 44040 0 196 44100 0 197 44160 0 198 44220 0 199 44280 0 200 44340 0 201 44400 0 202 44460 0 203 44520 0 204 44580 0 205 44640 0 206 44700 0 207 44760 0 208 44820 0 209 44880 0 210 44940 0 211 45000 0 212 45060 0 213 45120 69 214 45180 90 215 45240 0 216 45300 0 217 45360 112 218 45420 0 219 45480 0 220 45540 0 221 45600 87 222 45660 0 223 45720 97 224 45780 0 225 45840 0 226 45900 0 227 45960 0 228 46020 0 229 46080 0 230 46140 0 231 46200 0 232 46260 0 233 46320 92 234 46380 0 235 46440 0 236 46500 0 237 46560 0 238 46620 0 239 46680 0 240 46740 0 241 46800 0 242 46860 0 243 46920 0 244 46980 0 245 47040 0 246 47100 0 247 47160 0 248 47220 0 249 47280 0 250 47340 0 251 47400 0 252 47460 0 253 47520 0 254 47580 0 255 47640 0 256 47700 0 257 47760
[R] waning msg when R is launched
During startup - Warning message: In readChar(con, 5) : can only read in bytes in a non-UTF-8 MBCS locale I don't know what it comes from. It seems like a error thought not a fatal one. Thanks -- HUANG Ronggui Bachelor of Social Work, Fudan University, China Master of sociology, Fudan University, China Ph.D. Student , CityU of HK, http://www.cityu.edu.hk/sa/psa_web2006/students/rdegree/huangronggui.html __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] waning msg when R is launched
It is from R-2.6.2. On 2/9/08, ronggui [EMAIL PROTECTED] wrote: During startup - Warning message: In readChar(con, 5) : can only read in bytes in a non-UTF-8 MBCS locale I don't know what it comes from. It seems like a error thought not a fatal one. Thanks -- HUANG Ronggui Bachelor of Social Work, Fudan University, China Master of sociology, Fudan University, China Ph.D. Student , CityU of HK, http://www.cityu.edu.hk/sa/psa_web2006/students/rdegree/huangronggui.html -- HUANG Ronggui Bachelor of Social Work, Fudan University, China Master of sociology, Fudan University, China Ph.D. Student , CityU of HK, http://www.cityu.edu.hk/sa/psa_web2006/students/rdegree/huangronggui.html __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with fitdistr function
Can you please elaborate on this with eg if possible? I didn't get you. Thank You. On 2/9/08, Peter Dalgaard [EMAIL PROTECTED] wrote: Aswad Gurjar wrote: Hello, I am using fitdistr function for parameter estimation. When I use fd-fitdistr(V2,gamma) I get following error: Error in optim(x = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, : initial value in 'vmmin' is not finite fd-fitdistr(V2,weibull) Error in optim(x = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, : non-finite value supplied by optim But if I use following I dont get any errors. fd-fitdistr(V2,exponential) I have included necessary libraries. How can i remove this error?Are there any restrictions in using fitdistr function?If yes is there any alternative approach for solving such problem? My aim is to get estimated value of parameters. The density of a gamma distribution can be infinite at zero, so fitting to data with exact zeros is asking for trouble. Probably the sanest way to handle this sort of data is to treat the zeroes as left-censored observations, i.e. for x=0 use pgamma(0.5,) instead of dgamma(0,). I think fitdistr() will do this if you set up the density appropriately. Data is as follows: N V1 V2 1 32400 0 2 32460 0 3 32520 0 4 32580 0 5 32640 0 6 32700 0 7 32760 0 8 32820 0 9 32880 0 10 32940 0 11 33000 0 12 33060 0 13 33120 0 14 33180 0 15 33240 0 16 33300 0 17 33360 0 18 33420 0 19 33480 0 20 33540 0 21 33600 0 22 33660 0 23 33720 0 24 33780 0 25 33840 0 26 33900 0 27 33960 0 28 34020 0 29 34080 0 30 34140 0 31 34200 0 32 34260 0 33 34320 0 34 34380 0 35 34440 0 36 34500 0 37 34560 0 38 34620 0 39 34680 0 40 34740 0 41 34800 0 42 34860 0 43 34920 0 44 34980 0 45 35040 0 46 35100 0 47 35160 0 48 35220 32 49 35280 0 50 35340 0 51 35400 0 52 35460 0 53 35520 0 54 35580 0 55 35640 0 56 35700 0 57 35760 0 58 35820 0 59 35880 0 60 35940 0 61 36000 0 62 36060 0 63 36120 31 64 36180 32 65 36240 0 66 36300 0 67 36360 0 68 36420 0 69 36480 0 70 36540 0 71 36600 0 72 36660 0 73 36720 0 74 36780 0 75 36840 0 76 36900 0 77 36960 0 78 37020 0 79 37080 0 80 37140 0 81 37200 0 82 37260 0 83 37320 0 84 37380 0 85 37440 0 86 37500 0 87 37560 0 88 37620 0 89 37680 0 90 37740 0 91 37800 0 92 37860 0 93 37920 32 94 37980 0 95 38040 0 96 38100 0 97 38160 0 98 38220 0 99 38280 0 100 38340 0 101 38400 0 102 38460 0 103 38520 0 104 38580 0 105 38640 0 106 38700 0 107 38760 0 108 38820 32 109 38880 32 110 38940 32 111 39000 0 112 39060 0 113 39120 0 114 39180 0 115 39240 0 116 39300 0 117 39360 0 118 39420 0 119 39480 0 120 39540 0 121 39600 0 122 39660 0 123 39720 32 124 39780 32 125 39840 77 126 39900 0 127 39960 0 128 40020 0 129 40080 0 130 40140 0 131 40200 0 132 40260 0 133 40320 0 134 40380 0 135 40440 0 136 40500 0 137 40560 0 138 40620 32 139 40680 32 140 40740 109 141 40800 67 142 40860 92 143 40920 0 144 40980 0 145 41040 0 146 41100 0 147 41160 0 148 41220 0 149 41280 0 150 41340 0 151 41400 0 152 41460 0 153 41520 112 154 41580 0 155 41640 0 156 41700 0 157 41760 0 158 41820 0 159 41880 0 160 41940 0 161 42000 0 162 42060 0 163 42120 0 164 42180 0 165 42240 0 166 42300 0 167 42360 0 168 42420 0 169 42480 0 170 42540 66 171 42600 0 172 42660 93 173 42720 0 174 42780 0 175 42840 0 176 42900 0 177 42960 0 178 43020 0 179 43080 0 180 43140 0 181 43200 0 182 43260 0 183 43320 0 184 43380 0 185 43440 0 186 43500 0 187 43560 0 188 43620 0 189 43680 138 190 43740 0 191 43800 0 192 43860 0 193 43920 0 194 43980 0 195 44040 0 196 44100 0 197 44160 0 198 44220 0 199 44280 0 200 44340 0 201 44400 0 202 44460 0 203 44520 0 204 44580 0 205 44640 0 206 44700 0 207 44760 0 208 44820 0 209 44880 0 210 44940 0 211 45000 0 212 45060 0 213 45120 69 214 45180 90 215 45240 0 216 45300 0 217 45360 112 218 45420 0 219 45480 0 220 45540 0 221 45600 87 222 45660 0 223 45720 97 224 45780 0 225 45840 0 226 45900 0 227 45960 0 228 46020 0 229 46080 0 230 46140 0 231
Re: [R] Question
Alexander Ovodenko alexander.ovodenko at gmail.com writes: I have recently started learning R. I converted a Stata datafile into an R image file, but I am unable to do anything with the data. You probably forgot to read in the data; converting alone does not help. Try ls() to get a list of the available objects. Dieter __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] waning msg when R is launched
You haven't given us the 'minimal information' the posting guide asks for. Let's guess you are using a Chinese locale on Windows, in which case you cannot use readChar to read non-ASCII data (as the message says). If so, it looks like this occurs when loading a saved workspace, and is just a warning that will not be important if the workspace is properly saved. On Sat, 9 Feb 2008, ronggui wrote: It is from R-2.6.2. On 2/9/08, ronggui [EMAIL PROTECTED] wrote: During startup - Warning message: In readChar(con, 5) : can only read in bytes in a non-UTF-8 MBCS locale I don't know what it comes from. It seems like a error thought not a fatal one. Thanks -- HUANG Ronggui Bachelor of Social Work, Fudan University, China Master of sociology, Fudan University, China Ph.D. Student , CityU of HK, http://www.cityu.edu.hk/sa/psa_web2006/students/rdegree/huangronggui.html -- HUANG Ronggui Bachelor of Social Work, Fudan University, China Master of sociology, Fudan University, China Ph.D. Student , CityU of HK, http://www.cityu.edu.hk/sa/psa_web2006/students/rdegree/huangronggui.html __ 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 provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 provide commented, minimal, self-contained, reproducible code.
[R] scatterplot3d to display text
Dear all, I'm looking for a way to display text (label) in a scatterplot3d instead of the default dot. I mean someting like the text() function which can be associated with plot(). Do you think this is possible ? My second question is quite well covered by some threads but I haven't been able to find a definitive way of doing. Is there a way to enable rotation in a scatterplot3d ? Tank you in advance for your answers. -- View this message in context: http://www.nabble.com/scatterplot3d-to-display-text-tp15372042p15372042.html Sent from the R help mailing list archive at Nabble.com. __ 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 provide commented, minimal, self-contained, reproducible code.
[R] Reading data from a dataframe
Thanks for the replies to my prior question. My problem is that R always says object not found when I enter a variable name into a command. I converted a Stata file into an Rdata file by first loading the foreign package by entering require(foreign) Then I asked R to read the Stata file by entering pol572a1- read.dta(C:\\alex\\Graduate Coursework\\Pol 572\\pol572a1.dta) So now I can do a few things with the data, but I am only able to do so by entering with(pol572a1, before typing another command. So I enter the following for a scatter plot: with(pol572a1, plot(rgnpc, incmean)) When I run a simple linear regression, I enter the following: with(pol572a1, lm(incmean~rgnpc)) But when try to get a fitted line, I enter the following: with(pol572a1, lm( share.gnp)-lm(incmean~rgnpc)) But I get the following error message: Error in lm(share.gnp) - lm(incmean ~ rgnpc) : object share.gnp not found So what should I do to get R to read the dataframe in the ordinary way with the usual command? I am willing to scrap this dataframe and use the original Stata file to start over, as long as that resolves the problem. Thanks! Alex [[alternative HTML version deleted]] __ 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 provide commented, minimal, self-contained, reproducible code.
[R] R is not reading(?) my data properly
Thanks for the replies to my prior question. My problem is that R always says object not found when I enter a variable name into a command. I converted a Stata file into an Rdata file by first loading the foreign package by entering require(foreign) Then I asked R to read the Stata file by entering pol572a1- read.dta(C:\\alex\\Graduate Coursework\\Pol 572\\pol572a1.dta) So now I can do a few things with the data, but I am only able to do so by entering with(pol572a1, before typing another command. So I enter the following for a scatter plot: with(pol572a1, plot(rgnpc, incmean)) When I run a simple linear regression, I enter the following: with(pol572a1, lm(incmean~rgnpc)) But when try to get a fitted line, I enter the following: with(pol572a1, lm( share.gnp)-lm(incmean~rgnpc)) But I get the following error message: Error in lm(share.gnp) - lm(incmean ~ rgnpc) : object share.gnp not found So what should I do to get R to read the dataframe in the ordinary way with the usual command? I am willing to scrap this dataframe and use the original Stata file to start over, as long as that resolves the problem. Thanks! Alex [[alternative HTML version deleted]] __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] Loading Data to R
Have a look at the R Data Import/Export manual on the R website. My simple-minded approach is simply to save the data as a csv file and read it in using read.table or read.csv --- Christine Lynn [EMAIL PROTECTED] wrote: This is the most basic question ever...I haven't used R in a couple years since college so I forget and haven't been able to find what I'm looking for in any of the manuals. I just need to figure out how to load a dataset into the program from excel! Thanks! CL [[alternative HTML version deleted]] __ 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 provide commented, minimal, self-contained, reproducible code. __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] R ver 2.0.1 NA in Probability Vector Error Messages
Gabriella, First of all I would suggest that you upgrade to a recent R version (2.6.2). Without a reprodicible example of your code it is very hard to examine the problem. Use traceback() to identify were the problem occurs in your code. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Delle Donne, Gabriella Verzonden: vrijdag 8 februari 2008 20:41 Aan: r-help@r-project.org Onderwerp: [R] R ver 2.0.1 NA in Probability Vector Error Messages Hello, I am currently operating R version 2.0.1. I am running an analysis that uses previously written fuctions that I load into R 2.0.1 via the file menu (file--load workspace). There are other colleagues on my team that are operating the same version of R, using the same input datafile, the same workspace, and the same R code to run this analysis. Their analysis runs without any errors, yet mine does does not. The analysis that we are running attempts to create a sample of individuals that meets certain compositional demographic criteria. To achieve this we ask R to run though up to 10,000 iterations before producing a sample that BEST (i.e., with the smallest rate of error) conforms to the proportions of these demographic characteristics that we specify. When I run this analysis, R produces an output file that results from fewer interations with higher error rates than what my colleagues have achieved when running the same exact code on the same exact data. The error message that populates my R output window is as follows: Error in sample(length(x), size, replace, prob) : NA in probability vector. I do not understand why I receive this error message, whereas my colleages do not. Any guidance/advice would we extremely helpful! Thank You! Gabriella Delle Donne [[alternative HTML version deleted]] __ 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 provide commented, minimal, self-contained, reproducible code. __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] shortest distance between two point pattern
Dear Miltinho, there is also the function matchpt in the Biobase package (in Bioconductor) that seems to do what you want (in n dimensions). It's written in C, and the implementation is simple and of complexity n*m. (For larger problems, there are more efficient nearest neighbor search algorithms, but I am not aware whether or where in R.). This one works well for medium sized problem as in your example. Best wishes Wolfgang -- Wolfgang Huber EBI/EMBL Cambridge UK http://www.ebi.ac.uk/huber Milton Cezar Ribeiro scripsit: Hi R-experts. I am working in a R-code where I have two datasets with x and y coordinates on each dataset. I intent to identify the shortest distance between this two datasets. I wrote a short code to do that. But when I join the datasets to compute the distances, the merge function run so slowly. I need only to identify the index of rows from each dataset related to the shortest distance. x0-rnorm(n=500,mean=1,sd=runif(1)) y0-rnorm(n=500,mean=3,sd=runif(1)) x1-rnorm(n=700,mean=8,sd=runif(1)) y1-rnorm(n=700,mean=5,sd=runif(1)) df.0-cbind(x0,y0) df.1-cbind(x1,y1) plot(df.0,xlim=range(c(x0,x1)),ylim=range(c(y0,y1))) points(df.1,col=2) rm(x0,x1,y0,y1) #merge two data.frames of points IT SPEND many time df.merge-merge(df.0,df.1,all=T) #compute distances between each pair of points attach(df.merge) df.merge$distance-((x0-x1)^2+(y0-y1)^2)^0.5 detach(df.merge) #identify the minimum distance df.merge.distance.min-min(df.merge$distance) #select the pair of points (x0,y0,x1,y1) with shortest distance df.merge.distance.min.subset-subset(df.merge,df.merge$distance=df.merge.distance.min) #trace a arrow between the points with shortest distance arrows(df.merge.distance.min.subset[1,1],df.merge.distance.min.subset[1,2],df.merge.distance.min.subset[1,3],df.merge.distance.min.subset[1,4],code=0,col=3,lwd=2,lty=1) Any help are welcome Miltinho Brazil. __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] Subsetting a data.frame degenerates at one column?
I think I understand this. Try str(input) and you will see that input$disk2 in a vector. You can force a data.frame using data.frame(input(,targets)) --- Allen S. Rout [EMAIL PROTECTED] wrote: Greetings. At the moment, I'm applying R to some AIX 'nmon' output, trying to get a handle on some disk performance metrics. In case anyone's interested: http://docs.osg.ufl.edu/tsm/pdf/ some of them are more edifying than others. (ahem) I'm trying to develop a somewhat general framework for plotting these measures, in the hopes that it's of some use to people other than me. One obstacle I encounter is that, when I select one column out of a data.frame, the result is no longer a data.frame. So, say I've got, in data frame 'input' disk1 disk2 disk3 disk4 T 0 1 0 4 T0001 0 1 0 5 T0002 0 1 0 5 T0003 0 2 0 4 T0004 0 2 0 3 T0005 0 1 0 3 T0006 0 0 0 3 and somewhere I've noted a list targets - c('disk2','disk3') I can say input[,targets] disk2 disk3 T 1 0 T0001 1 0 T0002 1 0 T0003 2 0 T0004 2 0 T0005 1 0 T0006 0 0 but if targets - c('disk2') input[,targets] [1] 1 1 1 2 2 1 0 Ick. I've been reading through the indexing and data.frame docs, and remain unsatisfied so far. Where is my thinking going wrong? - Allen S. Rout __ 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 provide commented, minimal, self-contained, reproducible code. __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading data from a dataframe
On 09/02/2008 11:20 AM, Alexander Ovodenko wrote: Thanks for the replies to my prior question. My problem is that R always says object not found when I enter a variable name into a command. I converted a Stata file into an Rdata file by first loading the foreign package by entering require(foreign) Then I asked R to read the Stata file by entering pol572a1- read.dta(C:\\alex\\Graduate Coursework\\Pol 572\\pol572a1.dta) So now I can do a few things with the data, but I am only able to do so by entering with(pol572a1, before typing another command. So I enter the following for a scatter plot: with(pol572a1, plot(rgnpc, incmean)) When I run a simple linear regression, I enter the following: with(pol572a1, lm(incmean~rgnpc)) But when try to get a fitted line, I enter the following: with(pol572a1, lm( share.gnp)-lm(incmean~rgnpc)) But I get the following error message: Error in lm(share.gnp) - lm(incmean ~ rgnpc) : object share.gnp not found That line doesn't make sense. You want something like share.gnp - with(po1572a1, lm(incmean ~ rgnpc)) Duncan Murdoch So what should I do to get R to read the dataframe in the ordinary way with the usual command? I am willing to scrap this dataframe and use the original Stata file to start over, as long as that resolves the problem. Thanks! Alex [[alternative HTML version deleted]] __ 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 provide commented, minimal, self-contained, reproducible code. __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] R is not reading(?) my data properly
Alexander, Learn to use the data argument. E.g. plot(rgnpc, incmean, data = pol572a1) Model - lm(incmean ~ rgnpc, data = pol572a1) to get the fitted values: Model$fitted HTH, Thierry PS It seems to me that you might want to read a good introduction into R. ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Alexander Ovodenko Verzonden: zaterdag 9 februari 2008 17:23 Aan: r-help@r-project.org Onderwerp: [R] R is not reading(?) my data properly Thanks for the replies to my prior question. My problem is that R always says object not found when I enter a variable name into a command. I converted a Stata file into an Rdata file by first loading the foreign package by entering require(foreign) Then I asked R to read the Stata file by entering pol572a1- read.dta(C:\\alex\\Graduate Coursework\\Pol 572\\pol572a1.dta) So now I can do a few things with the data, but I am only able to do so by entering with(pol572a1, before typing another command. So I enter the following for a scatter plot: with(pol572a1, plot(rgnpc, incmean)) When I run a simple linear regression, I enter the following: with(pol572a1, lm(incmean~rgnpc)) But when try to get a fitted line, I enter the following: with(pol572a1, lm( share.gnp)-lm(incmean~rgnpc)) But I get the following error message: Error in lm(share.gnp) - lm(incmean ~ rgnpc) : object share.gnp not found So what should I do to get R to read the dataframe in the ordinary way with the usual command? I am willing to scrap this dataframe and use the original Stata file to start over, as long as that resolves the problem. Thanks! Alex [[alternative HTML version deleted]] __ 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 provide commented, minimal, self-contained, reproducible code. __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading data from a dataframe
Alexander Ovodenko [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Thanks for the replies to my prior question. My problem is that R always says object not found when I enter a variable name into a command. I converted a Stata file into an Rdata file by first loading the foreign package by entering require(foreign) Then I asked R to read the Stata file by entering pol572a1- read.dta(C:\\alex\\Graduate Coursework\\Pol 572\\pol572a1.dta) At this point you should type str(pol572a1) to make sure everything is the dataframe named pol572a1. So now I can do a few things with the data, but I am only able to do so by entering with(pol572a1, before typing another command. So I enter the following for a scatter plot: with(pol572a1, plot(rgnpc, incmean)) If you wanted to avoid the with() function (but why would you?) you could have used: plot(pol572a1$rgnpc, pol572a1$incmean) When I run a simple linear regression, I enter the following: with(pol572a1, lm(incmean~rgnpc)) Which creates the model and immediately discards it, because no durable object was given the values: But when try to get a fitted line, I enter the following: with(pol572a1, lm( share.gnp)-lm(incmean~rgnpc)) That does not look particular sensible. Assuming that the goal was to create a model object named share.gnp, then try instead: with(pol572a1, share.gnp.mdl -lm(incmean~rgnpc) ) (My practice is to label my models, but it is not necessary.) Then look at share.gnp.mdl with str() and you should see fitted.values. You could then plot() the fitted values and the observed values. But I get the following error message: Error in lm(share.gnp) - lm(incmean ~ rgnpc) : object share.gnp not found So what should I do to get R to read the dataframe in the ordinary way with the usual command? I cannot tell what you mean. It appears you already have the data in a dataframe. I am willing to scrap this dataframe and use the original Stata file to start over, as long as that resolves the problem. Thanks! Alex __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] scatterplot3d to display text
mauroyb0 wrote: Dear all, I'm looking for a way to display text (label) in a scatterplot3d instead of the default dot. I mean someting like the text() function which can be associated with plot(). Do you think this is possible ? Yes, it is, type: vignette(s3d, scatterplot3d) and take a look at example on pages 18-19 which is almost the same as page 14 of Ligges, U. and Mächler, M. (2003): Scatterplot3d - an R Package for Visualizing Multivariate Data. Journal of Statistical Software 8 (11), 1-20. It makes use of the function xyz.convert() that is included in the returned object from scatterplot3d(). My second question is quite well covered by some threads but I haven't been able to find a definitive way of doing. Is there a way to enable rotation in a scatterplot3d ? Well just some limited rotation by specifying the angle. If you want nice interactive rotation of things, I'd recommend package rgl. Best wishes, Uwe Ligges Tank you in advance for your answers. __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] shortest distance between two point pattern
PS: ...For larger problems, there are more efficient nearest neighbor search algorithms, but I am not aware whether or where in R. The 'but' subclause was wrong, one place to look at is the yaImpute package and also this thread: http://tolstoy.newcastle.edu.au/R/e4/devel/08/01/0158.html Best wishes Wolfgang -- Wolfgang Huber EBI/EMBL Cambridge UK http://www.ebi.ac.uk/huber __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading data from a dataframe
On 09/02/2008 11:38 AM, David Winsemius wrote: Alexander Ovodenko [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Thanks for the replies to my prior question. My problem is that R always says object not found when I enter a variable name into a command. I converted a Stata file into an Rdata file by first loading the foreign package by entering require(foreign) Then I asked R to read the Stata file by entering pol572a1- read.dta(C:\\alex\\Graduate Coursework\\Pol 572\\pol572a1.dta) At this point you should type str(pol572a1) to make sure everything is the dataframe named pol572a1. So now I can do a few things with the data, but I am only able to do so by entering with(pol572a1, before typing another command. So I enter the following for a scatter plot: with(pol572a1, plot(rgnpc, incmean)) If you wanted to avoid the with() function (but why would you?) you could have used: plot(pol572a1$rgnpc, pol572a1$incmean) When I run a simple linear regression, I enter the following: with(pol572a1, lm(incmean~rgnpc)) Which creates the model and immediately discards it, because no durable object was given the values: But when try to get a fitted line, I enter the following: with(pol572a1, lm( share.gnp)-lm(incmean~rgnpc)) That does not look particular sensible. Assuming that the goal was to create a model object named share.gnp, then try instead: with(pol572a1, share.gnp.mdl -lm(incmean~rgnpc) ) That won't work: share.gnp.mdl will be created in the local environment created by with(), and then discarded. You need to put it outside, i.e. share.gnp.mdl - with(pol572a1, lm(incmean~rgnpc) ) Duncan Murdoch (My practice is to label my models, but it is not necessary.) Then look at share.gnp.mdl with str() and you should see fitted.values. You could then plot() the fitted values and the observed values. But I get the following error message: Error in lm(share.gnp) - lm(incmean ~ rgnpc) : object share.gnp not found So what should I do to get R to read the dataframe in the ordinary way with the usual command? I cannot tell what you mean. It appears you already have the data in a dataframe. I am willing to scrap this dataframe and use the original Stata file to start over, as long as that resolves the problem. Thanks! Alex __ 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 provide commented, minimal, self-contained, reproducible code. __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] R is not reading(?) my data properly
On 09/02/2008 11:37 AM, ONKELINX, Thierry wrote: Alexander, Learn to use the data argument. E.g. plot(rgnpc, incmean, data = pol572a1) That won't work. The data arg to plot (and most other functions that have one) requires a formula, not a simple specification of x and y. You'd need plot(incmean ~ rgnpc, data = po1572a1) (The reason for this limitation is that plot needs to evaluate its first argument to know what method to call. It can evaluate the formula incmean ~ rgnpc, but can't evaluate the nonexistent rgnpc. Duncan Murdoch Model - lm(incmean ~ rgnpc, data = pol572a1) to get the fitted values: Model$fitted HTH, Thierry PS It seems to me that you might want to read a good introduction into R. ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Alexander Ovodenko Verzonden: zaterdag 9 februari 2008 17:23 Aan: r-help@r-project.org Onderwerp: [R] R is not reading(?) my data properly Thanks for the replies to my prior question. My problem is that R always says object not found when I enter a variable name into a command. I converted a Stata file into an Rdata file by first loading the foreign package by entering require(foreign) Then I asked R to read the Stata file by entering pol572a1- read.dta(C:\\alex\\Graduate Coursework\\Pol 572\\pol572a1.dta) So now I can do a few things with the data, but I am only able to do so by entering with(pol572a1, before typing another command. So I enter the following for a scatter plot: with(pol572a1, plot(rgnpc, incmean)) When I run a simple linear regression, I enter the following: with(pol572a1, lm(incmean~rgnpc)) But when try to get a fitted line, I enter the following: with(pol572a1, lm( share.gnp)-lm(incmean~rgnpc)) But I get the following error message: Error in lm(share.gnp) - lm(incmean ~ rgnpc) : object share.gnp not found So what should I do to get R to read the dataframe in the ordinary way with the usual command? I am willing to scrap this dataframe and use the original Stata file to start over, as long as that resolves the problem. Thanks! Alex [[alternative HTML version deleted]] __ 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 provide commented, minimal, self-contained, reproducible code. __ 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 provide commented, minimal, self-contained, reproducible code. __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading data from a dataframe
Duncan Murdoch [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: On 09/02/2008 11:38 AM, David Winsemius wrote: Alexander Ovodenko [EMAIL PROTECTED] wrote in snipped Which creates the model and immediately discards it, because no durable object was given the values: But when try to get a fitted line, I enter the following: with(pol572a1, lm( share.gnp)-lm(incmean~rgnpc)) That does not look particular sensible. Assuming that the goal was to create a model object named share.gnp, then try instead: with(pol572a1, share.gnp.mdl -lm(incmean~rgnpc) ) That won't work: share.gnp.mdl will be created in the local environment created by with(), and then discarded. You need to put it outside, i.e. share.gnp.mdl - with(pol572a1, lm(incmean~rgnpc) ) Thank you for the correction. I see that I was committing the same error I had described above it albeit in a different manner. I do hope he first saw your earlier post, or that of Onkelinx suggesting the data= approach before following me into a blind alley. -- David Winsemius __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] Loading Data to R
You need library(gdata) before On 08/02/2008, Wensui Liu [EMAIL PROTECTED] wrote: # READ DATA FROM XLS FILE # xls - read.xls(file = C:/projects/Rintro/Part01/export.xls, sheet = 3, type = data.frame, from = 1, colNames = TRUE) On Feb 8, 2008 3:49 PM, Christine Lynn [EMAIL PROTECTED] wrote: This is the most basic question ever...I haven't used R in a couple years since college so I forget and haven't been able to find what I'm looking for in any of the manuals. I just need to figure out how to load a dataset into the program from excel! Thanks! CL [[alternative HTML version deleted]] __ 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 provide commented, minimal, self-contained, reproducible code. -- === WenSui Liu ChoicePoint Precision Marketing Phone: 678-893-9457 Email : [EMAIL PROTECTED] Blog : statcompute.spaces.live.com __ 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 provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] Subsetting a data.frame degenerates at one column?
Try this also: input[targets] On 08/02/2008, Allen S. Rout [EMAIL PROTECTED] wrote: Greetings. At the moment, I'm applying R to some AIX 'nmon' output, trying to get a handle on some disk performance metrics. In case anyone's interested: http://docs.osg.ufl.edu/tsm/pdf/ some of them are more edifying than others. (ahem) I'm trying to develop a somewhat general framework for plotting these measures, in the hopes that it's of some use to people other than me. One obstacle I encounter is that, when I select one column out of a data.frame, the result is no longer a data.frame. So, say I've got, in data frame 'input' disk1 disk2 disk3 disk4 T 0 1 0 4 T0001 0 1 0 5 T0002 0 1 0 5 T0003 0 2 0 4 T0004 0 2 0 3 T0005 0 1 0 3 T0006 0 0 0 3 and somewhere I've noted a list targets - c('disk2','disk3') I can say input[,targets] disk2 disk3 T 1 0 T0001 1 0 T0002 1 0 T0003 2 0 T0004 2 0 T0005 1 0 T0006 0 0 but if targets - c('disk2') input[,targets] [1] 1 1 1 2 2 1 0 Ick. I've been reading through the indexing and data.frame docs, and remain unsatisfied so far. Where is my thinking going wrong? - Allen S. Rout __ 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 provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] When I cbind the POSIXct gets lost
Gabor - Thanks. I can recreate your example without any problem but I don't understand the relevance. Is turning the result of the cbind() into a dataframe what you're telling me? If so, I tried that and I'm still stuck with the loss of the POSIXct. (If not I'm afraid I missed the point.) Gabor Grothendieck wrote: Use data.frame: tt - ISOdate(2000, 1:3, 1) cbind(tt, tt) tttt [1,] 946728000 946728000 [2,] 949406400 949406400 [3,] 951912000 951912000 data.frame(tt, tt) tttt.1 1 2000-01-01 12:00:00 2000-01-01 12:00:00 2 2000-02-01 12:00:00 2000-02-01 12:00:00 3 2000-03-01 12:00:00 2000-03-01 12:00:00 On Feb 8, 2008 4:59 PM, Ken Spriggs [EMAIL PROTECTED] wrote: I would like to create a new dataframe from the DateTime column of an existing dataframe and a numeric vector. When I do cbind(x[,1], y) the result is: [1,] 1199370600 12.500 [2,] 1199371200 69.375 [3,] 1199371800 23.750 where the first column you see used to look like: 2008-01-03 08:30:00 Central Standard Time 2008-01-03 08:40:00 Central Standard Time 2008-01-03 08:50:00 Central Standard Time How do I keep the DateTime from getting converted? I've tried as.POSIXct() to convert it back (no luck). -- View this message in context: http://www.nabble.com/When-I-cbind-the-POSIXct-gets-lost-tp15364786p15364786.html Sent from the R help mailing list archive at Nabble.com. __ 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 provide commented, minimal, self-contained, reproducible code. __ 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 provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/When-I-cbind-the-POSIXct-gets-lost-tp15364786p15380762.html Sent from the R help mailing list archive at Nabble.com. __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] When I cbind the POSIXct gets lost
Ok, thanks guys! I see what you're sayin' now Gabor. :) mkeller wrote: Ken, not sure, but you might try data.frame(whatever1=x[,1],whatever2=y) this should maintain the classes of the vectors. I'm guessing that y and x are of different classes. From ?cbind: For the default method, a matrix combining the ... argument. The type of a matrix result determined from the highest type of any of the inputs in the hierarchy raw logical integer real complex character list Matt On Feb 8, 2008 2:59 PM, Ken Spriggs [EMAIL PROTECTED] wrote: I would like to create a new dataframe from the DateTime column of an existing dataframe and a numeric vector. When I do cbind(x[,1], y) the result is: [1,] 1199370600 12.500 [2,] 1199371200 69.375 [3,] 1199371800 23.750 where the first column you see used to look like: 2008-01-03 08:30:00 Central Standard Time 2008-01-03 08:40:00 Central Standard Time 2008-01-03 08:50:00 Central Standard Time How do I keep the DateTime from getting converted? I've tried as.POSIXct() to convert it back (no luck). -- View this message in context: http://www.nabble.com/When-I-cbind-the-POSIXct-gets-lost-tp15364786p15364786.html Sent from the R help mailing list archive at Nabble.com. __ 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 provide commented, minimal, self-contained, reproducible code. -- Matthew C Keller Asst. Professor of Psychology University of Colorado at Boulder www.matthewckeller.com __ 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 provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/When-I-cbind-the-POSIXct-gets-lost-tp15364786p15381200.html Sent from the R help mailing list archive at Nabble.com. __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] When I cbind the POSIXct gets lost
The point is don't use cbind -- use data.frame. On Feb 9, 2008 1:20 PM, Ken Spriggs [EMAIL PROTECTED] wrote: Gabor - Thanks. I can recreate your example without any problem but I don't understand the relevance. Is turning the result of the cbind() into a dataframe what you're telling me? If so, I tried that and I'm still stuck with the loss of the POSIXct. (If not I'm afraid I missed the point.) Gabor Grothendieck wrote: Use data.frame: tt - ISOdate(2000, 1:3, 1) cbind(tt, tt) tttt [1,] 946728000 946728000 [2,] 949406400 949406400 [3,] 951912000 951912000 data.frame(tt, tt) tttt.1 1 2000-01-01 12:00:00 2000-01-01 12:00:00 2 2000-02-01 12:00:00 2000-02-01 12:00:00 3 2000-03-01 12:00:00 2000-03-01 12:00:00 On Feb 8, 2008 4:59 PM, Ken Spriggs [EMAIL PROTECTED] wrote: I would like to create a new dataframe from the DateTime column of an existing dataframe and a numeric vector. When I do cbind(x[,1], y) the result is: [1,] 1199370600 12.500 [2,] 1199371200 69.375 [3,] 1199371800 23.750 where the first column you see used to look like: 2008-01-03 08:30:00 Central Standard Time 2008-01-03 08:40:00 Central Standard Time 2008-01-03 08:50:00 Central Standard Time How do I keep the DateTime from getting converted? I've tried as.POSIXct() to convert it back (no luck). -- View this message in context: http://www.nabble.com/When-I-cbind-the-POSIXct-gets-lost-tp15364786p15364786.html Sent from the R help mailing list archive at Nabble.com. __ 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 provide commented, minimal, self-contained, reproducible code. __ 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 provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/When-I-cbind-the-POSIXct-gets-lost-tp15364786p15380762.html Sent from the R help mailing list archive at Nabble.com. __ 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 provide commented, minimal, self-contained, reproducible code. __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] matrix loop
John Kane [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: You are trying to create a matrix in the loop Try creating the matrix before the loop m - 1:5 n-1:10 y - matrix(rep(NA, 50), nrow=m) # I think that this might actually work: y - matrix(rep(NA, 50), nrow=max(m)) for(i in 1:length(m)) { for(j in 1:length(n)) { y[i,j]=sum(i,j) } } #produced: Error in y[i, j] = sum(i, j) : subscript out of bounds -- David Winsemius However as Jim Holtman points out you can do this particular matrix by outer(1:5, 1:10, +) --- mohamed nur anisah [EMAIL PROTECTED] wrote: Dear list, I'm trying to make a loop of a (5x10) matrix and below are my codes. Could anybody help me figure out why my loop is not working. Thanks in advance!! m-1:5 n-1:10 for(i in 1:length(m)) { for(j in 1:length(n)) { y[i,j]=sum(i,j) y-as.matrix(y[i,j]) } } cheers, __ 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 provide commented, minimal, self-contained, reproducible code.
[R] Comparing spatial point patterns - Syrjala test
Dear Lists, At several stations distributed regularly in space[1], we sampled repeatedly (4 times) the abundance of organisms and measured environmental parameters. I now want to compare the spatial distribution of various species (and test wether they differ or not), or to compare the distribution of a particular organism with the distribution of some environmental variable. Syrjala's test[2] seems to be appropriate for such comparisons. The hamming distance is also used (but it is not associated with a test). However, as far as I understand it, Syrjala's test only compares the distribution gathered during one sampling event, while I have four successive repeats and: - I am interested in comparing if, on average, the distributions are the same - I would prefer to keep the information regarding the variability of the abundances in time, rather than just comparing the means, since the abundances are quite variable. Therefore I have two questions for all the knowledgeable R users on these lists: - Is there a package in which Syrjala's test is implemented for R? - Is there another way (a better way) to test for such differences? Thank you very much in advance for your help. [1] http://jo.irisson.free.fr/work/research_tetiaroa.html [2] http://findarticles.com/p/articles/mi_m2120/is_n1_v77/ai_18066337/pg_7 Jean-Olivier Irisson --- UMR 5244 CNRS-EPHE-UPVD, 52 av Paul Alduy, 66860 Perpignan Cedex, France +336 21 05 19 90 http://jo.irisson.free.fr/work/ __ 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 provide commented, minimal, self-contained, reproducible code.
[R] \ll and \gg in expression()
How do I enter 'much greater than' and 'much less than' symbols in an expression? _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] [R-sig-Geo] Comparing spatial point patterns - Syrjala test
Dear Jean, I have no idea of how to solve this issue, but I suggest you write to the authors of spatstat package. I think they could help you very much. Another thing is that there was a threhead on this many times ago. May be that Alan Swanson cold also help you. http://finzi.psych.upenn.edu/R/Rhelp02a/archive/51226.html Kind regards, miltinho On 2/9/08, jiho [EMAIL PROTECTED] wrote: Dear Lists, At several stations distributed regularly in space[1], we sampled repeatedly (4 times) the abundance of organisms and measured environmental parameters. I now want to compare the spatial distribution of various species (and test wether they differ or not), or to compare the distribution of a particular organism with the distribution of some environmental variable. Syrjala's test[2] seems to be appropriate for such comparisons. The hamming distance is also used (but it is not associated with a test). However, as far as I understand it, Syrjala's test only compares the distribution gathered during one sampling event, while I have four successive repeats and: - I am interested in comparing if, on average, the distributions are the same - I would prefer to keep the information regarding the variability of the abundances in time, rather than just comparing the means, since the abundances are quite variable. Therefore I have two questions for all the knowledgeable R users on these lists: - Is there a package in which Syrjala's test is implemented for R? - Is there another way (a better way) to test for such differences? Thank you very much in advance for your help. [1] http://jo.irisson.free.fr/work/research_tetiaroa.html [2] http://findarticles.com/p/articles/mi_m2120/is_n1_v77/ai_18066337/pg_7 Jean-Olivier Irisson --- UMR 5244 CNRS-EPHE-UPVD, 52 av Paul Alduy, 66860 Perpignan Cedex, France +336 21 05 19 90 http://jo.irisson.free.fr/work/ ___ R-sig-Geo mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-sig-geo [[alternative HTML version deleted]] __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] \ll and \gg in expression()
On Sat, 9 Feb 2008, Michael Kubovy wrote: How do I enter 'much greater than' and 'much less than' symbols in an expression? Those are not in the Adobe Symbol encoding used for plotmath. Since you have not told us your platform and locale as requested in the posting guide, I don't know if the following is relevant to you. If you have a suitable Unicode font and the means to use it (which most likely means a UTF-8 locale in R 2.7.0) they are the glyphs for \u226a and \u226b (see http://www.alanwood.net/unicode/mathematical_operators.html). A quick check suggests that not many fonts do. _ Professor Michael Kubovy University of Virginia Department of Psychology [...] 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 provide commented, minimal, self-contained, reproducible code. Yes, please do read it! -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] md5 hash is wrong for 2.6.2 (Windows)
On 09/02/2008 4:41 PM, Paul Lynch wrote: Hi, I've downloaded R-2.6.2-win32.exe (base) from two CRAN sites (http://mirrors.ibiblio.org/pub/mirrors/CRAN/ and http://lib.stat.cmu.edu/R/CRAN/) and for both of those sites the expected MD5 hash is reported to be: ed512872818707f27ca05f08be7363c2 *R-2.6.2-win32.exe (See, for example, http://lib.stat.cmu.edu/R/CRAN/bin/windows/base/md5sum.txt). However, when I compute the MD5 hash (using two different MD5 hash generators) I get 4acf8298a829c2787b8fe848f866999a *R-2.6.2-win32.exe Could someone check and confirm that the MD5 sums on the CRAN server are incorrect? (And fix it?) Thanks, --Paul p.s. Given that two CRAN servers have the bad value, I'm guessing it's safe to install. It installed okay is seems to be running fine. Thanks for noticing this. I don't know what happened, but the version that was uploaded was shorter than the real one, which should have 30750532 bytes. The md5sum.txt file is correct for the real one, but doesn't match the truncated one. I've redone the upload, and now the md5sum matches. It will take some time for CRAN to synchronize with the change; it won't be immediately visible. But I also changed the page to say Last change: 2008-02-09, so if you see that date, you should be getting the right download. I'll have to put some tests into the upload script. Duncan Murdoch __ 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 provide commented, minimal, self-contained, reproducible code.
[R] md5 hash is wrong for 2.6.2 (Windows)
Hi, I've downloaded R-2.6.2-win32.exe (base) from two CRAN sites (http://mirrors.ibiblio.org/pub/mirrors/CRAN/ and http://lib.stat.cmu.edu/R/CRAN/) and for both of those sites the expected MD5 hash is reported to be: ed512872818707f27ca05f08be7363c2 *R-2.6.2-win32.exe (See, for example, http://lib.stat.cmu.edu/R/CRAN/bin/windows/base/md5sum.txt). However, when I compute the MD5 hash (using two different MD5 hash generators) I get 4acf8298a829c2787b8fe848f866999a *R-2.6.2-win32.exe Could someone check and confirm that the MD5 sums on the CRAN server are incorrect? (And fix it?) Thanks, --Paul p.s. Given that two CRAN servers have the bad value, I'm guessing it's safe to install. It installed okay is seems to be running fine. -- Paul Lynch Aquilent, Inc. National Library of Medicine (Contractor) __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] md5 hash is wrong for 2.6.2 (Windows)
On 09/02/2008 4:41 PM, Paul Lynch wrote: Hi, I've downloaded R-2.6.2-win32.exe (base) from two CRAN sites (http://mirrors.ibiblio.org/pub/mirrors/CRAN/ and http://lib.stat.cmu.edu/R/CRAN/) and for both of those sites the expected MD5 hash is reported to be: ed512872818707f27ca05f08be7363c2 *R-2.6.2-win32.exe (See, for example, http://lib.stat.cmu.edu/R/CRAN/bin/windows/base/md5sum.txt). However, when I compute the MD5 hash (using two different MD5 hash generators) I get 4acf8298a829c2787b8fe848f866999a *R-2.6.2-win32.exe Could someone check and confirm that the MD5 sums on the CRAN server are incorrect? (And fix it?) Thanks, --Paul p.s. Given that two CRAN servers have the bad value, I'm guessing it's safe to install. It installed okay is seems to be running fine. I've worked out what happened: there was a build of R-patched which overwrote the release, because it happened before the VERSION file had been updated to include Patched. I don't upload md5sum.txt in the R-patched or R-devel scripts, so that's why you detected the difference. To confirm this, you could check the NEWS file: it contained entries for 2.6.2 Patched, as well as the 2.6.2 entries. As far as I know it's perfectly safe to use. Duncan Murdoch __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] Applying lm to data with combn
Thank you, can you suggest wht is the shortest way to store the combination with min residual error term? AliR wrote: http://www.nabble.com/file/p15359204/test.data.csv http://www.nabble.com/file/p15359204/test.data.csv test.data.csv Hi, I have used apply to have certian combinations, but when I try to use these combinations I get the error [Error in eval(expr, envir, enclos) : object X.GDAXI not found]. being a novice I donot understand that after applying combination to the data I cant access it and use lm on these combinations. The data frame either is no longer a matrix, how can I access the data and make it work for lm!! Any help please! fruit = read.csv(file=test.data.csv,head= TRUE, sep=,)# read it in matrix format #fruit =read.file(row.names=1)$data mD =head(fruit[, 1:5])# only first five used in combinations #X.SSMII = head(fruit[, 6])# Keep it for referebce nmax = NULL n = ncol(mD)# dont take the last column for reference purpose if(is.null(nmax)) nmax = n mDD = apply(combn(5, 1),1, FUN= function(y) mD[, y])# to fg = lm( X.SSMII ~ X.GDAXI + X.FTSE + X.FCHI + X.IBEX, data = mDD )# regress on combos s = cbind(s, Residuals = residuals(fg))# take residuals print(mD) -- View this message in context: http://www.nabble.com/Applying-lm-to-data-with-combn-tp15359204p15391159.html Sent from the R help mailing list archive at Nabble.com. __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] \ll and \gg in expression()
On Feb 9, 2008, at 4:41 PM, Prof Brian Ripley wrote: On Sat, 9 Feb 2008, Michael Kubovy wrote: How do I enter 'much greater than' and 'much less than' symbols in an expression? Those are not in the Adobe Symbol encoding used for plotmath. Since you have not told us your platform and locale as requested in the posting guide R version 2.7.0 Under development (unstable) (2008-02-05 r44340) i386-apple-darwin8.10.1 locale: C I don't know if the following is relevant to you. If you have a suitable Unicode font and the means to use it (which most likely means a UTF-8 locale in R 2.7.0) they are the glyphs for \u226a and \u226b (see http://www.alanwood.net/unicode/mathematical_operators.html) . A quick check suggests that not many fonts do. Thanks. The Mac character palette tells me that they correspond to Unicode 226A and B or UTF8 E2 89 AA and AB. My question now is, how do I tell expression() to use the glyphs for these? _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ 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 provide commented, minimal, self-contained, reproducible code.
[R] error in the function
Dear lists, i want to find the non-overlapping interval values with this code: mysetdiff=function(x,y){ m=length(x) n=length(y) bx = logical(m) by = logical(n) for(i in 1:m){ for(j in 1:n){ if(x[i]=y[j+1]){ bx[i] = T by[j] = T NA= NA } } } sx = x[!bx] sy = y[!by] s=c(sx,sy) return(s) } Below is my dataset. When i called back my function with the code;mysetdiff(f,e). An error had occur: Error in if (x[i] = y[j + 1]) { : missing value where TRUE/FALSE needed. How am i going to fix my function so that i can get the values of my non-overlapping interval. Any suggestion?? Thanks a bunch!! e [1] 17130612 17712302 21225764 25012714 33852816 36012944 36252300 [8] 36737468 43693832 44148616 45318876 45852632 53258208 58530988 [15] 60437872 72516480 79673224 93128744 94269896 95868704 99651504 [22] 113688560 131101008 132955984 135891280 141318144 148257888 156158176 [29] 157797616 162055856 168221296 173125232 176267104 182826240 183742528 [36] 184401728 190671888 196639616 17587118 18221688 21387314 30748348 [43] 34480192 36209144 36280276 36971144 43878548 44496056 45740012 [50] 46752088 53700056 58603536 60691012 72757696 80077728 93181480 [57] 94474624 97418088 106596368 120128352 132462320 132980744 135998880 [64] 142259520 151591840 156920960 157838176 162743136 168466848 173167936 [71] 176338384 182930096 184149776 185735712 190910576 f [1] 17712302 21203780 25012714 33852816 34794536 36012944 37891284 [8] 43693832 44148616 45852632 53289188 61573112 63664928 72516480 [15] 79673224 94474624 95868704 99651504 113688560 125159688 127388568 [22] 131101008 154599216 176267104 181504912 182562720 182826240 183742528 [29] 196841904 18100404 21387314 30748348 34384588 35996440 36252300 [36] 37942556 43878548 44496056 46752088 53700056 62637560 63969952 [43] 72757696 80077728 94617360 97144032 106596368 120128352 127220456 [50] 127504536 132462320 154717312 176338384 181836032 182687824 182930096 [57] 184149776 - [[alternative HTML version deleted]] __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] error in the function
a quick look at it shows you would be trying to access y[n+1] in the last part of that loop and that is greater than the number of entries in 'y' so you will get an NA and this is not legal for comparisons. On Feb 9, 2008 6:07 PM, mohamed nur anisah [EMAIL PROTECTED] wrote: Dear lists, i want to find the non-overlapping interval values with this code: mysetdiff=function(x,y){ m=length(x) n=length(y) bx = logical(m) by = logical(n) for(i in 1:m){ for(j in 1:n){ if(x[i]=y[j+1]){ bx[i] = T by[j] = T NA= NA } } } sx = x[!bx] sy = y[!by] s=c(sx,sy) return(s) } Below is my dataset. When i called back my function with the code;mysetdiff(f,e). An error had occur: Error in if (x[i] = y[j + 1]) { : missing value where TRUE/FALSE needed. How am i going to fix my function so that i can get the values of my non-overlapping interval. Any suggestion?? Thanks a bunch!! e [1] 17130612 17712302 21225764 25012714 33852816 36012944 36252300 [8] 36737468 43693832 44148616 45318876 45852632 53258208 58530988 [15] 60437872 72516480 79673224 93128744 94269896 95868704 99651504 [22] 113688560 131101008 132955984 135891280 141318144 148257888 156158176 [29] 157797616 162055856 168221296 173125232 176267104 182826240 183742528 [36] 184401728 190671888 196639616 17587118 18221688 21387314 30748348 [43] 34480192 36209144 36280276 36971144 43878548 44496056 45740012 [50] 46752088 53700056 58603536 60691012 72757696 80077728 93181480 [57] 94474624 97418088 106596368 120128352 132462320 132980744 135998880 [64] 142259520 151591840 156920960 157838176 162743136 168466848 173167936 [71] 176338384 182930096 184149776 185735712 190910576 f [1] 17712302 21203780 25012714 33852816 34794536 36012944 37891284 [8] 43693832 44148616 45852632 53289188 61573112 63664928 72516480 [15] 79673224 94474624 95868704 99651504 113688560 125159688 127388568 [22] 131101008 154599216 176267104 181504912 182562720 182826240 183742528 [29] 196841904 18100404 21387314 30748348 34384588 35996440 36252300 [36] 37942556 43878548 44496056 46752088 53700056 62637560 63969952 [43] 72757696 80077728 94617360 97144032 106596368 120128352 127220456 [50] 127504536 132462320 154717312 176338384 181836032 182687824 182930096 [57] 184149776 - [[alternative HTML version deleted]] __ 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 provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ 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 provide commented, minimal, self-contained, reproducible code.
[R] R on Mac PRO does anyone have experience with R on such a platform ?
I saw there exists an R version for Mac/OS. I'd like to hear from someone who is running R on a Mac/OS before venturing on getting the following computer system. I am in the process of choosing a powerful laptop 17 MB PRO 2.6GHZ(dual-core) 4GBRAM Thank you so much, -- Maura E.M [[alternative HTML version deleted]] __ 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 provide commented, minimal, self-contained, reproducible code.
[R] Which package should I use if I estimate a recursive model?
Dear All: I want to estimate a simple recursive mode in R. Which package should I use? Thank you very much in advance. Yongfu He _ [[alternative HTML version deleted]] __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] R on Mac PRO does anyone have experience with R on such a platform ?
I have R on all sorts of Macs, including one's a lot whimpier than the one you are describing and it works great on all of them. gary mcclelland colorado On Sat, Feb 9, 2008 at 6:29 PM, Maura E Monville [EMAIL PROTECTED] wrote: I saw there exists an R version for Mac/OS. I'd like to hear from someone who is running R on a Mac/OS before venturing on getting the following computer system. I am in the process of choosing a powerful laptop 17 MB PRO 2.6GHZ(dual-core) 4GBRAM Thank you so much, -- Maura E.M [[alternative HTML version deleted]] __ 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 provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ 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 provide commented, minimal, self-contained, reproducible code.
[R] Error in optim while using fitdistr() function
Hello, I am trying to fit distribution for data consisting of 421 readings.It is basically no of requests arrived per minute.It contains many 0 entries as no of requests.When i use fd-fitdistr(V2,gamma) I get following error: Error in optim(x = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, : initial value in 'vmmin' is not finite What should I do ? I need this function because I want to get value of estimated parameters. Is there any other function to perform such calculations? Please help me. Thank You. Code is as follows: x-data.frame() N-data.frame((read.table(cs2ip.txt))) attach(N) m-min(V1) k-floor(1 + log2(length(V1))) f-(max(V1)-min(V1))/k i-1 j-1 while(i=(length(V1))) { fc-0 while(V1[i]=(m+f)) { fc-fc+V2[i] i-i+1 if(ilength(V1)) break } x[j,1]-fc m-m+f j-j+1 } library(MASS) fd-fitdistr(V2,gamma) Input data is: TIME NO (SEC) OF REQUESTS 32400 0 32460 0 32520 0 32580 0 32640 0 32700 0 32760 0 32820 0 32880 0 32940 0 33000 0 33060 0 33120 0 33180 0 33240 0 33300 0 33360 0 33420 0 33480 0 33540 0 33600 0 33660 0 33720 0 33780 0 33840 0 33900 0 33960 0 34020 0 34080 0 34140 0 34200 0 34260 0 34320 0 34380 0 34440 0 34500 0 34560 0 34620 0 34680 0 34740 0 34800 0 34860 0 34920 0 34980 0 35040 0 35100 0 35160 0 35220 32 35280 0 35340 0 35400 0 35460 0 35520 0 35580 0 35640 0 35700 0 35760 0 35820 0 35880 0 35940 0 36000 0 36060 0 36120 31 36180 32 36240 0 36300 0 36360 0 36420 0 36480 0 36540 0 36600 0 36660 0 36720 0 36780 0 36840 0 36900 0 36960 0 37020 0 37080 0 37140 0 37200 0 37260 0 37320 0 37380 0 37440 0 37500 0 37560 0 37620 0 37680 0 37740 0 37800 0 37860 0 37920 32 37980 0 38040 0 38100 0 38160 0 38220 0 38280 0 38340 0 38400 0 38460 0 38520 0 38580 0 38640 0 38700 0 38760 0 38820 32 38880 32 38940 32 39000 0 39060 0 39120 0 39180 0 39240 0 39300 0 39360 0 39420 0 39480 0 39540 0 39600 0 39660 0 39720 32 39780 32 39840 77 39900 0 39960 0 40020 0 40080 0 40140 0 40200 0 40260 0 40320 0 40380 0 40440 0 40500 0 40560 0 40620 32 40680 32 40740 109 40800 67 40860 92 40920 0 40980 0 41040 0 41100 0 41160 0 41220 0 41280 0 41340 0 41400 0 41460 0 41520 112 41580 0 41640 0 41700 0 41760 0 41820 0 41880 0 41940 0 42000 0 42060 0 42120 0 42180 0 42240 0 42300 0 42360 0 42420 0 42480 0 42540 66 42600 0 42660 93 42720 0 42780 0 42840 0 42900 0 42960 0 43020 0 43080 0 43140 0 43200 0 43260 0 43320 0 43380 0 43440 0 43500 0 43560 0 43620 0 43680 138 43740 0 43800 0 43860 0 43920 0 43980 0 44040 0 44100 0 44160 0 44220 0 44280 0 44340 0 44400 0 44460 0 44520 0 44580 0 44640 0 44700 0 44760 0 44820 0 44880 0 44940 0 45000 0 45060 0 45120 69 45180 90 45240 0 45300 0 45360 112 45420 0 45480 0 45540 0 45600 87 45660 0 45720 97 45780 0 45840 0 45900 0 45960 0 46020 0 46080 0 46140 0 46200 0 46260 0 46320 92 46380 0 46440 0 46500 0 46560 0 46620 0 46680 0 46740 0 46800 0 46860 0 46920 0 46980 0 47040 0 47100 0 47160 0 47220 0 47280 0 47340 0 47400 0 47460 0 47520 0 47580 0 47640 0 47700 0 47760 0 47820 0 47880 0 47940 0 48000 0 48060 0 48120 0 48180 0 48240 0 48300 0 48360 0 48420 0 48480 0 48540 0 48600 0 48660 0 48720 0 48780 0 48840 0 48900 0 48960 0 49020 0 49080 0 49140 0 49200 0 49260 0 49320 0 49380 0 49440 0 49500 0 49560 0 49620 32 49680 32 49740 0 49800 0 49860 0 49920 0 49980 33 50040 0 50100 0 50160 0 50220 0 50280 0 50340 0 50400 0 50460 0 50520 102 50580 0 50640 0 50700 0 50760 100 50820 0 50880 0 50940 0 51000 0 51060 0 51120 0 51180 0 51240 0 51300 0 51360 0 51420 32 51480 32 51540 0 51600 0 51660 0 51720 0 51780 0 51840 0 51900 0 51960 0 52020 0 52080 0 52140 0 52200 0 52260 0 52320 0 52380 0 52440 0 52500 0 52560 0 52620 0 52680 0 52740 0 52800 0 52860 0 52920 0 52980 0 53040 0 53100 0 53160 0 53220 0 53280 0 53340 0 53400 0 53460 0 53520 0 53580 0 53640 0 53700 0 53760 0 53820 0 53880 0 53940 0 54000 0 54060 0 54120 0 54180 0 54240 0 54300 0 54360 0 54420 0 54480 0 54540 0 54600 0 54660 0 54720 0 54780 0 54840 0 54900 0 54960 0 55020 0 55080 0 55140 0 55200 0 55260 0 55320 0 55380 0 55440 0 55500 0 55560 0 55620 0 55680 0 55740 0 55800 0 55860 0 55920 0 55980 0 56040 0 56100 0 56160 0 56220 0 56280 0 56340 0 56400 0 56460 0 56520 0 56580 0 56640 0 56700 0 56760 0 56820 0 56880 0 56940 0 57000 0 57060 0 57120 0 57180 0 57240 0 57300 0 57360 0 57420 0 57480 0 57540 0 57600 0 Aswad [[alternative HTML version deleted]] __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] Error in optim while using fitdistr() function
Hello, I am trying to fit distribution for data consisting of 421 readings.It is basically no of requests arrived per minute.It contains many 0 entries as no of requests.When i use fd-fitdistr(V2,gamma) I get following error: Error in optim(x = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, : initial value in 'vmmin' is not finite What should I do ? I need this function because I want to get value of estimated parameters. Is there any other function to perform such calculations? Please help me. Thank You. Code is as follows: x-data.frame() N-data.frame((read.table(cs2ip.txt))) attach(N) library(MASS) fd-fitdistr(V2,gamma) Input data is: V2 contains : (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 32,0,0,0,0,0,0,0,0,0,0,0,0,31,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,32,32,77,0,0,0,0,0,0,0,0,0,0,0,0, 32,32,109,67,92,0,0,0,0,0,0,0,0,0,0,112,0,0,0,0,0,0,0,0,0,0,0,0,0,0,66,0,93,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,138,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,69,90,0, 0,112,0,0,0,87,0,97,0,0,0,0,0,0,0,0,0,92,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,33,0,0,0,0,0,0,0, 0,102,0,0,0,100,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) Aswad [[alternative HTML version deleted]] __ 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 provide commented, minimal, self-contained, reproducible code.
[R] Error in optim while using fitdistr() function for estimation of parameters
Hello, I am trying to fit distribution for data consisting of 421 readings.It is basically no of requests arrived per minute.It contains many 0 entries as no of requests.When i use fd-fitdistr(V2,gamma) I get following error: Error in optim(x = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, : initial value in 'vmmin' is not finite What should I do ? I need this function because I want to get value of estimated parameters. Is there any other function to perform such calculations? Please help me. Thank You. Code is as follows: x-data.frame() N-data.frame((read.table(cs2ip.txt))) attach(N) library(MASS) fd-fitdistr(V2,gamma) Aswad [[alternative HTML version deleted]] __ 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 provide commented, minimal, self-contained, reproducible code.
[R] PCA + Hotelling's T^2
Dear R users; Is there any function to plot the confidence ellipse (Hotelling's T^2) in an score plot from a PCA? I have the scores off course , say scores for PC1 and PC2, and the value of the Hotelling's T^2 statistic. Thanks for any hint PM __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] [R-sig-Geo] Comparing spatial point patterns - Syrjala test
On Feb 9, 2008 10:39 PM, milton ruser [EMAIL PROTECTED] wrote: I have no idea of how to solve this issue, but I suggest you write to the authors of spatstat package. I think they could help you very much. Another thing is that there was a threhead on this many times ago. May be that Alan Swanson cold also help you. http://finzi.psych.upenn.edu/R/Rhelp02a/archive/51226.html Thank you for your answer. Indeed I saw this email during my research before posting my message. Unfortunately nobody answered it. I just hoped that things may have improved in this area of R since then and that potential authors, such as authors of the spatstat package, would be reading these lists. I will contact those people personally indeed. Thanks again. At several stations distributed regularly in space[1], we sampled repeatedly (4 times) the abundance of organisms and measured environmental parameters. I now want to compare the spatial distribution of various species (and test wether they differ or not), or to compare the distribution of a particular organism with the distribution of some environmental variable. Syrjala's test[2] seems to be appropriate for such comparisons. The hamming distance is also used (but it is not associated with a test). However, as far as I understand it, Syrjala's test only compares the distribution gathered during one sampling event, while I have four successive repeats and: - I am interested in comparing if, on average, the distributions are the same - I would prefer to keep the information regarding the variability of the abundances in time, rather than just comparing the means, since the abundances are quite variable. Therefore I have two questions for all the knowledgeable R users on these lists: - Is there a package in which Syrjala's test is implemented for R? - Is there another way (a better way) to test for such differences? Thank you very much in advance for your help. [1] http://jo.irisson.free.fr/work/research_tetiaroa.html [2] http://findarticles.com/p/articles/mi_m2120/is_n1_v77/ai_18066337/pg_7 -- Jean-Olivier Irisson UMR 5244 CNRS-EPHE-UPVD, 52 av Paul Alduy, 66860 Perpignan Cedex, France +336 21 05 19 90 http://jo.irisson.free.fr/work/ __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] Error in optim while using fitdistr() function for estimationof parameters
Hello, Thank You for response.Yes,It is discrete data.I have tried discrete model using goodfit() test.But that too is not working.Is there any other test for discrete data? When I try goodfit() test for discrete distribution: gf-goodfit(x[[1]],type= nbinomial,method= MinChisq) where x[[1]] is my data with 9 bins. x contains following data and interval is of 2800 seconds: V1 1 0 2 127 3 477 4 363 5 685 6 0 7 363 8 0 9 0 I get following errors: Warning messages: 1: NaNs produced in: pnbinom(q, size, prob, lower.tail, log.p) 2: NaNs produced in: pnbinom(q, size, prob, lower.tail, log.p) 3: NaNs produced in: pnbinom(q, size, prob, lower.tail, log.p) 4: NaNs produced in: pnbinom(q, size, prob, lower.tail, log.p) 5: NaNs produced in: pnbinom(q, size, prob, lower.tail, log.p) 6: NaNs produced in: pnbinom(q, size, prob, lower.tail, log.p) 7: NaNs produced in: pnbinom(q, size, prob, lower.tail, log.p) summary(gf) Goodness-of-fit test for nbinomial distribution X^2 df P( X^2) Pearson 5.539024 2 0.06269258 Warning message: Chi-squared approximation may be incorrect in: summary.goodfit(gf) When i use poisson distribution : gf-goodfit(x[[1]],type= poisson,method= MinChisq) I get following errors: Warning messages: 1: NA/Inf replaced by maximum positive value in: optimize(chi2, range(count)) 2: NA/Inf replaced by maximum positive value in: optimize(chi2, range(count)) 3: NA/Inf replaced by maximum positive value in: optimize(chi2, range(count)) 4: NA/Inf replaced by maximum positive value in: optimize(chi2, range(count)) 5: NA/Inf replaced by maximum positive value in: optimize(chi2, range(count)) 6: NA/Inf replaced by maximum positive value in: optimize(chi2, range(count)) 7: NA/Inf replaced by maximum positive value in: optimize(chi2, range(count)) 8: NA/Inf replaced by maximum positive value in: optimize(chi2, range(count)) 9: NA/Inf replaced by maximum positive value in: optimize(chi2, range(count)) 10: NA/Inf replaced by maximum positive value in: optimize(chi2, range(count)) summary(gf) Goodness-of-fit test for poisson distribution X^2 df P( X^2) Pearson 4.137318e+138 30 Warning message: Chi-squared approximation may be incorrect in: summary.goodfit(gf) What should i do now?How can I remove these warnings and errors? Thank You. Aswad On 2/10/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Chenge your model, most likely. You are telling us a) the response is discrete and b) there is a substantial probability that the value is zero. The gamma distributon is a model for a continuous response, your response is integer valued. Perhaps you should consider something the Poisson or Negative Binomial. Evem from the little you give us, the problem seems more statistical than computational to me. Bill Venables CSIRO Laboratories PO Box 120, Cleveland, 4163 AUSTRALIA Office Phone (email preferred): +61 7 3826 7251 Fax (if absolutely necessary): +61 7 3826 7304 Mobile: +61 4 8819 4402 Home Phone: +61 7 3286 7700 mailto:[EMAIL PROTECTED] http://www.cmis.csiro.au/bill.venables/ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Aswad Gurjar Sent: Sunday, 10 February 2008 4:17 PM To: r-help@r-project.org Subject: [R] Error in optim while using fitdistr() function for estimationof parameters Hello, I am trying to fit distribution for data consisting of 421 readings.It is basically no of requests arrived per minute.It contains many 0 entries as no of requests.When i use fd-fitdistr(V2,gamma) I get following error: Error in optim(x = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, : initial value in 'vmmin' is not finite What should I do ? I need this function because I want to get value of estimated parameters. Is there any other function to perform such calculations? Please help me. Thank You. Code is as follows: x-data.frame() N-data.frame((read.table(cs2ip.txt))) attach(N) library(MASS) fd-fitdistr(V2,gamma) Aswad [[alternative HTML version deleted]] __ 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 provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] Error in optim while using fitdistr() function for estimationof parameters
Chenge your model, most likely. You are telling us a) the response is discrete and b) there is a substantial probability that the value is zero. The gamma distributon is a model for a continuous response, your response is integer valued. Perhaps you should consider something the Poisson or Negative Binomial. Evem from the little you give us, the problem seems more statistical than computational to me. Bill Venables CSIRO Laboratories PO Box 120, Cleveland, 4163 AUSTRALIA Office Phone (email preferred): +61 7 3826 7251 Fax (if absolutely necessary): +61 7 3826 7304 Mobile: +61 4 8819 4402 Home Phone: +61 7 3286 7700 mailto:[EMAIL PROTECTED] http://www.cmis.csiro.au/bill.venables/ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Aswad Gurjar Sent: Sunday, 10 February 2008 4:17 PM To: r-help@r-project.org Subject: [R] Error in optim while using fitdistr() function for estimationof parameters Hello, I am trying to fit distribution for data consisting of 421 readings.It is basically no of requests arrived per minute.It contains many 0 entries as no of requests.When i use fd-fitdistr(V2,gamma) I get following error: Error in optim(x = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, : initial value in 'vmmin' is not finite What should I do ? I need this function because I want to get value of estimated parameters. Is there any other function to perform such calculations? Please help me. Thank You. Code is as follows: x-data.frame() N-data.frame((read.table(cs2ip.txt))) attach(N) library(MASS) fd-fitdistr(V2,gamma) Aswad [[alternative HTML version deleted]] __ 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 provide commented, minimal, self-contained, reproducible code. __ 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 provide commented, minimal, self-contained, reproducible code.