Displaying 20 results from an estimated 7000 matches similar to: "Reading a txt file from internet"
2024 Sep 07
1
Reading a txt file from internet
That looks like a UTF-16LE byte order mark. Simply open the connection
with the proper encoding:
read.delim(
'https://online.stat.psu.edu/onlinecourses/sites/stat501/files/ch15/employee.txt',
fileEncoding = "UTF-16LE"
)
On Sat, Sep 7, 2024 at 3:57?PM Christofer Bogaso
<bogaso.christofer at gmail.com> wrote:
>
> Hi,
>
> I am trying to the data from
>
2024 Sep 07
1
Reading a txt file from internet
When you specify LE in the encoding type, you are logically telling the decoder that you know the two-byte pairs are in little-endian order... which could override whatever the byte-order-mark was indicating. If the BOM indicated big-endian then the file decoding would break. If there is a BOM, don't override it unless you have to (e.g. for a wrong BOM)... leave off the LE unless you really
2024 Sep 07
1
Reading a txt file from internet
On 2024-09-07 4:52 p.m., Jeff Newmiller via R-help wrote:
> When you specify LE in the encoding type, you are logically telling the decoder that you know the two-byte pairs are in little-endian order... which could override whatever the byte-order-mark was indicating. If the BOM indicated big-endian then the file decoding would break. If there is a BOM, don't override it unless you have to
2024 Sep 07
1
Reading a txt file from internet
On Sun, 08 Sep 2024, Christofer Bogaso writes:
> Hi,
>
> I am trying to the data from
> https://online.stat.psu.edu/onlinecourses/sites/stat501/files/ch15/employee.txt
> without any success. Below is the error I am getting:
>
>> read.delim('https://online.stat.psu.edu/onlinecourses/sites/stat501/files/ch15/employee.txt')
>
> Error in make.names(col.names,
2024 Sep 07
1
Reading a txt file from internet
I tried it on R 4.4.1 on Linux Mint 21.3 just before I posted it, and I just tried it on R 3.4.2 on Ubuntu 16.04 and R 4.3.2 on Windows 11 just now and it works on all of them.
I don't have a big-endian machine to test on, but the Unicode spec says to honor the BOM and if there isn't one to assume that it is big-endian data. But in this case there is a BOM so your machine has a buggy
2024 Sep 08
1
Reading a txt file from internet
On 2024-09-07 7:37 p.m., Jeff Newmiller wrote:
> I tried it on R 4.4.1 on Linux Mint 21.3 just before I posted it, and I just tried it on R 3.4.2 on Ubuntu 16.04 and R 4.3.2 on Windows 11 just now and it works on all of them.
>
> I don't have a big-endian machine to test on, but the Unicode spec says to honor the BOM and if there isn't one to assume that it is big-endian data.
2012 Apr 02
2
linear-by-linear association model in R?
Dear all, can somebody give me some pointer how I can fit a
"linear-by-linear association model" (i.e. loglinear model for the
ordinal variables) in R? A brief description can be found here
'https://onlinecourses.science.psu.edu/stat504/node/141'.
Thanks for your help
2012 Dec 01
4
Getting all possible contingency tables
Hello all,
Let say I have 2-way contingency table:
Tab <- matrix(c(8, 10, 12, 6), nr = 2)
and the Chi-squared test could not reject the independence:
> chisq.test(Tab)
Pearson's Chi-squared test with Yates' continuity correction
data: Tab
X-squared = 1.0125, df = 1, p-value = 0.3143
However I want to get all possible contingency tables under this
independence
2012 Dec 19
2
Copy data from Excel
Hello again,
I my day to day calculation, I need to take lot of data from Excel and
forth and generally I use 'clipboard' option with read.delim() function.
However many time, the data in Excel are like '(111,000)' instead of
'-111000'. Generally I convert data in the 2nd form in Excel itself and
then copy to clipboard.
Is there any option in R, so that I can
2012 Mar 14
1
Questing on fitting Baseline category Logit model
Dear all,
I am facing some problem with how to fit a "Baseline category Logit
model" with R. Basically I am considering famous "Alligator" data as
discussed by Agresti. This data can also be found here:
https://onlinecourses.science.psu.edu/stat504/node/174
(there is also an accompanying R file, however the underlying R code
could not load the data properly!!!)
Below are
2010 Mar 22
2
Why "\\" instead of simple "/" to specify a file path
Hi all,
I have saved my workplace in a .RData format. However if I want to open
that, I need to use following code :
load("C:\\......")
Here my question is why "\\". In all the time generally we use "/" like when
we use read.delim() function etc. Is there any possibility to have some
consistency there? Is there any other way to re-open the .RData file?
Thanks,
--
2018 Mar 04
3
Change Function based on ifelse() condtion
Below is my full implementation (tried to make it simple as for demonstration)
Lapply_me = function(X = X, FUN = FUN, Apply_MC = FALSE, ...) {
if (Apply_MC) {
return(mclapply(X, FUN, ...))
} else {
if (any(names(list(...)) == 'mc.cores')) {
myList = list(...)[!names(list(...)) %in% 'mc.cores']
}
return(lapply(X, FUN, myList))
}
}
Lapply_me(as.list(1:4), function(xx) {
if (xx ==
2010 Jul 10
7
Need help on date calculation
Hi all, please see my code:
> library(zoo)
> a <- as.yearmon("March-2010", "%B-%Y")
> b <- as.yearmon("May-2010", "%B-%Y")
>
> nn <- (b-a)*12 # number of months in between them
> nn
[1] 2
> as.integer(nn)
[1] 1
What is the correct way to find the number of months between "a" and "b",
still
2018 Mar 04
0
Change Function based on ifelse() condtion
The reason that it works for Apply_MC=TRUE is that in that case you call
mclapply(X,FUN,...) and
the mclapply() function strips off the mc.cores argument from the "..."
list before calling FUN, so FUN is being called with zero arguments,
exactly as it is declared.
A quick workaround is to change the line
Lapply_me(as.list(1:4), function(xx) {
to
Lapply_me(as.list(1:4),
2018 Mar 04
2
Change Function based on ifelse() condtion
My modified function looks below :
Lapply_me = function(X = X, FUN = FUN, Apply_MC = FALSE, ...) {
if (Apply_MC) {
return(mclapply(X, FUN, ...))
} else {
if (any(names(list(...)) == 'mc.cores')) {
myList = list(...)[!names(list(...)) %in% 'mc.cores']
}
return(lapply(X, FUN, myList))
}
}
Here, I am not passing ... anymore rather passing myList
On Sun, Mar 4, 2018 at 10:37 PM,
2018 Mar 04
2
Change Function based on ifelse() condtion
@Eric - with this approach I am getting below error :
Error in FUN(X[[i]], ...) : unused argument (list())
On Sun, Mar 4, 2018 at 10:18 PM, Eric Berger <ericjberger at gmail.com> wrote:
> Hi Christofer,
> You cannot assign to list(...). You can do the following
>
> myList <- list(...)[!names(list(...)) %in% 'mc.cores']
>
> HTH,
> Eric
>
> On Sun, Mar
2012 Dec 14
5
A question on list and lapply
Dear all, let say I have following list:
Dat <- vector("list", length = 26)
names(Dat) <- LETTERS
My_Function <- function(x) return(rnorm(5))
Dat1 <- lapply(Dat, My_Function)
However I want to apply my function 'My_Function' for all elements of
'Dat' except the elements having 'names(Dat) == "P"'. Here I have
specified the name
2017 Aug 02
4
Extracting numeric part from a string
Hi again,
I am struggling to extract the number part from below string :
"\"cm_ffm\":\"563.77\""
Basically, I need to extract 563.77 from above. The underlying number
can be a whole number, and there could be comma separator as well.
So far I tried below :
> library(stringr)
> str_extract("\"cm_ffm\":\"563.77\"",
2012 Mar 16
4
How to start R in maximized size???
Dear all, when I start R, I want that the console window should be in
the Maximized size automatically. Can somebody help me how to achieve
that?
Thanks and regards,
2013 Mar 28
4
How to replace '$' sign?
Hello again,
I want to remove "$" sign and replace with nothing in my text.
Therefore I used following code:
> gsub("$|,", "", "$232,685.35436")
[1] "$232685.35436"
However I could not remove '$' sign.
Can somebody help me why is it so?
Thanks and regards