[BlindRUG] [EXTERNAL EMAIL] Re: BlindRUG Digest, Vol 63, Issue 1

Jonathan Godfrey A.J.Godfrey at massey.ac.nz
Sat Feb 12 09:13:22 UTC 2022


Hello Amy,

I was pleased to see that while I was over-committed since your last email, several other people have responded to your specific issues.

There have been multiple ways to do a lot of tasks in R for a long time, and the variety of solutions to the same problems is always on the rise.

The use of apply() offered by Robin is a great example. Another person might recommend tapply() instead, while someone whose life revolves around the tidyverse would offer an entirely different solution. The solution that might serve you best is probably going to be the one that is being used by your classmates, so I recommend checking in with the teaching staff on which style they're expecting you to use. I'm not going to start discussing the merits of one way or another here as it really isn't going to help you. 

I think that calculating the standard deviation of a row stands out for me. While we do sometimes store data in a two-way table with rows representing one way of grouping results and columns being another, it is increasingly common to have data arranged in a "tidy" fashion, with each row being an observation and each column being a variable. A two-way table of data (sometimes called wide format) isn't tidy, but it might make for a nice table for the purposes of displaying data. To make it tidy, we'd put the data in one column, and have other columns for each grouping variable. That two-way table (wide format) then gets turned into a three column (long format) with the results, the row grouping, and the column grouping for analysis. For example, a 4 row 5 column of plant heights might be compact, but for most statistical work, we want those 20 heights in a single column, have a second column to tell which row they all came from originally, and a third column for the original column, so a 4x5 table in wide format becomes a 20x3 data frame in long format.

If you had a data frame for one set of results, and another data frame for a second set of results, you wouldn't combine them side by side. To keep them tidy, you'd put one above the other so that each observation stays as a unique row of the combined result. As well as sticking them together this way, we'd normally also add a new column to say which set each observation came from. For example, imagine you have heights for 15 girls and 12 boys. We'd usually be better off combining them into a 27 row data frame with one column for height and a second column for gender.


In contrast, the suggestion about improved use of `write.csv()` is  what everyone would suggest to correct the problem you've highlighted. I'd ask why you need to keep loading and then writing a file over and over though. You shouldn't need to repeatedly replace your data files unless you are doing something new to them each time.

Keeping track of commands you've issued and the output that is generated is important. I'd ask what your classmates are doing and try to stick as closely to the way they are working as is possible. We might not be able to use RStudio, but we can use script files (commands only) or R markdown files (commands and regular text). The .Rhistory file Robin referred to can be difficult to open if you're using Windows. The same set of commands can be saved as a plain text file using the savehistory() command. We normally save them with a .R extension not .txt so you might need to tell Windows to open .R files in notepad or your preferred text file editor.

The beauty of using a file with your commands is that you don't actually have to share your full session with anyone to show them your problems. If you've got the commands you used, you can share that set of commands and your data file with the person helping,  and they can re-run your code and share in your suffering with the errors. They can then fix and test the errors with you.  If you're interacting online, you should be able to share your screen with your sighted teacher. 

Even if I'm in the same room, I ask my students to send me their data and script or markdown files by email, and talk them through what I needed to do to fix things. Doing practical sessions entirely online this coming semester is going to present a fresh challenge for me; I've often been able to just spot the problem and tell them verbally what to do next because we're in the same room. The online space is so less private and I can already see people being less willing to expose themselves to scrutiny by other students.

HTH,
J





-----Original Message-----
From: BlindRUG <blindrug-bounces at nfbnet.org> On Behalf Of Robin Williams via BlindRUG
Sent: Friday, 11 February 2022 11:01 PM
To: Blind R Users Group <blindrug at nfbnet.org>
Cc: Robin Williams <Robin.Williams at atass-sports.co.uk>
Subject: Re: [BlindRUG] [EXTERNAL EMAIL] Re: BlindRUG Digest, Vol 63, Issue 1

Apologies, I accidentally hit send in my previous message.
--------
Hi Amy,

Here are a few answers to some of your difficulties.

When exporting data, set row.names=FALSE when calling write.csv or write.table. The dataframes you're writing out have a rownames component, which are being written to file. Then when you read that file back in, they're being added as an extra column in your new dataframe.

If you have a matrix for which you want to get the row standard deviations, you should be able to do apply(x,1,sd)

In terms of your difficulties in combining multiple dataframes, I can only assume they have different numbers of columns, or perhaps mismatching column names?

You might like to learn about .Rhistory files to save and load the history of your session. My advice though would be to have all your commands in a script, so you can run your session with someone else and debug.

In general it's a good idea to familiarise yourself with the R help system. It is certainly a learning curve, but a worthwhile one if you're planning to do a lot of work in R.

HTH,
R
-----Original Message-----
From: BlindRUG <blindrug-bounces at nfbnet.org> On Behalf Of Amy Albin via BlindRUG
Sent: 10 February 2022 17:25
To: blindrug at nfbnet.org
Cc: Amy Albin <amyralbin at gmail.com>
Subject: [EXTERNAL EMAIL] Re: [BlindRUG] BlindRUG Digest, Vol 63, Issue 1

Okay I've been having lots of problems with classes. Like when I turn a variable into numeric it will still stay a list. When trying to combine 4 data.frames into one, it won't let me because they have different numbers of rows. I don't think it should matter. Like it doesn't matter if not all the same number of people were in each condition, so why can't I combine them?

Another problem is every time I export to .csv and then reimport into R, it adds an extra column. Every time. So the first day I'm working in columns 2:13, second day it migrates to columns 3:14, third day it's 4:15.

Also I can't figure out how to get row standard deviations.

As far as problem solving, what I mean is that many times just Googling won't work. I try to apply what the code says from a website and it doesn't work because maybe something's different about my data.
Like one example was that the website didn't say you had to remove missing data in order for it to work, so I spent like an hour not knowing what to do with "incorrect number of dimensions" error.

My final question is: Is there a way to log the entire R history including error messages into a text file? This would help me a lot when I'm working with others and need to tell them what went wrong.
Again, I found a website that claimed to explain how to do it but it didn't work for me.

Thanks.

Best,

Amy
Pronouns: she/her/hersOn 2/10/22, blindrug-request at nfbnet.org <blindrug-request at nfbnet.org> wrote:
> Send BlindRUG mailing list submissions to
> 	blindrug at nfbnet.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> 	
> https://apc01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fnfbne
> t.org%2Fmailman%2Flistinfo%2Fblindrug_nfbnet.org&data=04%7C01%7CA.
> J.Godfrey%40massey.ac.nz%7C1733dd22570147fbaf5308d9ed45ae20%7C388728e1
> bbd0437898dcf8682e644300%7C1%7C0%7C637801705815948264%7CUnknown%7CTWFp
> bGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn
> 0%3D%7C3000&sdata=zOEqBvjfe8J3oE9uCeOripbf5THQxMasudFosVzEUTg%3D&a
> mp;reserved=0 or, via email, send a message with subject or body 
> 'help' to
> 	blindrug-request at nfbnet.org
>
> You can reach the person managing the list at
> 	blindrug-owner at nfbnet.org
>
> When replying, please edit your Subject line so it is more specific 
> than "Re: Contents of BlindRUG digest..."
>

_______________________________________________
BlindRUG mailing list
BlindRUG at nfbnet.org
https://apc01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fnfbnet.org%2Fmailman%2Flistinfo%2Fblindrug_nfbnet.org&data=04%7C01%7CA.J.Godfrey%40massey.ac.nz%7C1733dd22570147fbaf5308d9ed45ae20%7C388728e1bbd0437898dcf8682e644300%7C1%7C0%7C637801705815948264%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=zOEqBvjfe8J3oE9uCeOripbf5THQxMasudFosVzEUTg%3D&reserved=0
To unsubscribe, change your list options or get your account info for BlindRUG:
https://apc01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fnfbnet.org%2Fmailman%2Foptions%2Fblindrug_nfbnet.org%2Frobin.williams%2540atass-sports.co.uk&data=04%7C01%7CA.J.Godfrey%40massey.ac.nz%7C1733dd22570147fbaf5308d9ed45ae20%7C388728e1bbd0437898dcf8682e644300%7C1%7C0%7C637801705815948264%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=zXJc2b43pCyhkKROOIRj%2BJZT0mdNFwAvogwSD6hsLtA%3D&reserved=0
The list archive can be viewed at:
https://apc01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.nfbnet.org%2Fpipermail%2Fblindrug_nfbnet.org&data=04%7C01%7CA.J.Godfrey%40massey.ac.nz%7C1733dd22570147fbaf5308d9ed45ae20%7C388728e1bbd0437898dcf8682e644300%7C1%7C0%7C637801705815948264%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=zRt5K%2FH4M%2F3GEqisIAYzjorXMoPk8Z%2FQfwxerDkCEHY%3D&reserved=0
More information and useful links about using R as a blind person can be obtained at:
http://R-Resources.massey.ac.nz

Look for help using R commands by reading the accessible e-book "Let's Use R Now" compiled by Jonathan Godfrey at:
http://R-Resources.massey.ac.nz/lurn/front.html


_______________________________________________
BlindRUG mailing list
BlindRUG at nfbnet.org
https://apc01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fnfbnet.org%2Fmailman%2Flistinfo%2Fblindrug_nfbnet.org&data=04%7C01%7CA.J.Godfrey%40massey.ac.nz%7C1733dd22570147fbaf5308d9ed45ae20%7C388728e1bbd0437898dcf8682e644300%7C1%7C0%7C637801705815948264%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=zOEqBvjfe8J3oE9uCeOripbf5THQxMasudFosVzEUTg%3D&reserved=0
To unsubscribe, change your list options or get your account info for BlindRUG:
https://apc01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fnfbnet.org%2Fmailman%2Foptions%2Fblindrug_nfbnet.org%2Fa.j.godfrey%2540massey.ac.nz&data=04%7C01%7CA.J.Godfrey%40massey.ac.nz%7C1733dd22570147fbaf5308d9ed45ae20%7C388728e1bbd0437898dcf8682e644300%7C1%7C0%7C637801705815948264%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=ishLcdyBwnK%2FfR%2Bt5yWTR333zynLzN6XX3LegD%2FtjZs%3D&reserved=0
The list archive can be viewed at:
https://apc01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.nfbnet.org%2Fpipermail%2Fblindrug_nfbnet.org&data=04%7C01%7CA.J.Godfrey%40massey.ac.nz%7C1733dd22570147fbaf5308d9ed45ae20%7C388728e1bbd0437898dcf8682e644300%7C1%7C0%7C637801705815948264%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=zRt5K%2FH4M%2F3GEqisIAYzjorXMoPk8Z%2FQfwxerDkCEHY%3D&reserved=0
More information and useful links about using R as a blind person can be obtained at:
http://R-Resources.massey.ac.nz

Look for help using R commands by reading the accessible e-book "Let's Use R Now" compiled by Jonathan Godfrey at:
http://R-Resources.massey.ac.nz/lurn/front.html



More information about the BlindRUG mailing list